.morse-tool {
    --morse-panel: #ffffff;
    --morse-panel-soft: #fcfcfd;
    --morse-text: #101418;
    --morse-muted: #687385;
    --morse-border: #d8dbe0;
    --morse-border-strong: #c9ced6;
    --morse-blue: #dbe7f5;
    --morse-blue-2: #b8c6da;
    --morse-green: #eef8ef;
    --morse-green-2: #cfe2d1;
    --morse-amber: #fff5e3;
    --morse-amber-2: #ecd8ab;
    --morse-shadow: 0 12px 30px rgba(19, 28, 40, 0.08);
    color: var(--morse-text);
    font-family: "Inter", var(--font-sans);
    padding-top: 0;
}

html[data-theme="dark"] .morse-tool {
    --morse-panel: #181b1f;
    --morse-panel-soft: #20242a;
    --morse-text: #f1f3f5;
    --morse-muted: #9aa2ab;
    --morse-border: #2a3037;
    --morse-border-strong: #3a414a;
    --morse-blue: rgba(110, 168, 255, 0.14);
    --morse-blue-2: rgba(110, 168, 255, 0.28);
    --morse-green: rgba(64, 124, 74, 0.22);
    --morse-green-2: rgba(154, 220, 165, 0.22);
    --morse-amber: rgba(138, 99, 31, 0.18);
    --morse-amber-2: rgba(243, 209, 139, 0.28);
}

.morse-tool * {
    box-sizing: border-box;
}

.morse-tool .morse-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
}

.morse-tool .morse-button {
    min-width: 0;
}

.morse-tool [data-morse-play].cipher-btn {
    background: #eef8ef;
    border-color: #cfe2d1;
    color: #245e2d;
}

.morse-tool [data-morse-play].cipher-btn:hover:not([disabled]) {
    background: #e2f3e4;
    border-color: #b8d6bc;
}

.morse-tool [data-morse-stop].cipher-btn {
    background: #f6e8e8;
    border-color: #e7cbcb;
    color: #8d3a3a;
}

.morse-tool [data-morse-stop].cipher-btn:hover:not([disabled]) {
    background: #f0dede;
    border-color: #ddb8b8;
}

.morse-panel,
.morse-monitor-grid {
    display: grid;
    gap: 12px;
}

.morse-mini {
    margin: 0;
    color: var(--morse-muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.morse-mini strong,
.morse-pill strong,
.morse-note strong {
    color: var(--morse-text);
}

.morse-inline,
.morse-note code {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--morse-border);
    background: var(--morse-panel);
    color: var(--morse-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.84em;
    font-weight: 700;
    white-space: nowrap;
}

.morse-tool .cipher-option-row.is-disabled,
.morse-tool .cipher-stepper.is-disabled {
    opacity: 0.56;
}

.morse-field,
.morse-monitor {
    border: 1px solid var(--morse-border);
    background: var(--morse-panel);
    border-radius: 18px;
    padding: 12px;
}

.morse-monitor {
    overflow-anchor: none;
}

.morse-textarea-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.morse-textarea {
    width: 100%;
    min-height: 188px;
    resize: vertical;
    border-radius: 16px;
    border: 1px solid var(--morse-border-strong);
    background: var(--morse-panel);
    padding: 14px;
    color: var(--morse-text);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 1rem;
    line-height: 1.45;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.morse-output {
    min-height: 170px;
    background: var(--morse-panel-soft);
}

.morse-textarea::placeholder {
    color: var(--morse-muted);
}

.morse-textarea:focus,
.morse-button:focus-visible {
    border-color: rgba(11, 132, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(11, 132, 255, 0.1);
    outline: none;
}

.morse-copy-inline.done {
    color: #245e2d;
    border-color: var(--morse-green-2);
    background: var(--morse-green);
}

.morse-copy-inline.error {
    color: #7b5c1c;
    border-color: var(--morse-amber-2);
    background: var(--morse-amber);
}

.morse-copy-inline:disabled {
    cursor: not-allowed;
    opacity: 0.62;
}

.morse-now-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
}

.morse-signal-lamp {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid var(--morse-border-strong);
    background: radial-gradient(circle at 35% 35%, #fff, #f1f3f6 62%, #d8dde4 100%);
    box-shadow: inset 0 2px 8px rgba(255, 255, 255, 0.9);
    position: relative;
    transition: transform 0.08s ease, box-shadow 0.08s ease, border-color 0.08s ease;
}

.morse-signal-lamp::after {
    content: "";
    position: absolute;
    inset: 11px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #dfe8f7, #b7c8e0 70%, #9db0cd 100%);
    opacity: 0.62;
    transition: opacity 0.08s ease, transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease;
}

.morse-signal-lamp.is-on {
    border-color: var(--morse-blue-2);
    transform: scale(1.02);
    box-shadow: 0 0 0 5px rgba(78, 127, 210, 0.08), inset 0 2px 8px rgba(255, 255, 255, 0.9);
}

.morse-signal-lamp.is-on::after {
    opacity: 1;
    transform: scale(1.04);
    background: radial-gradient(circle at 35% 35%, #ffffff, #dce9fb 32%, #94b3df 78%, #6f95ca 100%);
    box-shadow: 0 0 28px rgba(83, 130, 206, 0.34);
}

.morse-now-copy {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.morse-now-label,
.morse-monitor-label {
    margin: 0;
    color: #566173;
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

html[data-theme="dark"] .morse-now-label,
html[data-theme="dark"] .morse-monitor-label {
    color: #c3ccd8;
}

html[data-theme="dark"] .morse-tool [data-morse-play].cipher-btn {
    background: rgba(64, 124, 74, 0.22);
    border-color: rgba(154, 220, 165, 0.28);
    color: #d8f3dc;
}

html[data-theme="dark"] .morse-tool [data-morse-play].cipher-btn:hover:not([disabled]) {
    background: rgba(77, 142, 88, 0.28);
    border-color: rgba(174, 231, 183, 0.34);
}

html[data-theme="dark"] .morse-tool [data-morse-stop].cipher-btn {
    background: rgba(122, 52, 52, 0.22);
    border-color: rgba(199, 132, 132, 0.3);
    color: #f1d0d0;
}

html[data-theme="dark"] .morse-tool [data-morse-stop].cipher-btn:hover:not([disabled]) {
    background: rgba(142, 63, 63, 0.28);
    border-color: rgba(214, 153, 153, 0.36);
}

.morse-now-main {
    margin: 0;
    color: #1f2a42;
    font-size: 1.04rem;
    line-height: 1.35;
    font-weight: 800;
    word-break: break-word;
}

html[data-theme="dark"] .morse-now-main {
    color: #f2f5f8;
}

.morse-now-sub {
    margin: 0;
    color: var(--morse-muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.morse-track-wrap,
.morse-symbol-wrap,
.morse-build-wrap {
    display: grid;
    gap: 8px;
}

.morse-track {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-top: 8px;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.morse-track-chip,
.morse-symbol-pill {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.morse-track-chip {
    flex: 0 0 auto;
    min-width: 44px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--morse-border);
    background: var(--morse-panel);
    color: #354055;
    font-size: 0.92rem;
    font-weight: 800;
    line-height: 1;
    text-align: center;
}

.morse-track-chip.done,
.morse-symbol-pill.done {
    background: var(--morse-green);
    border-color: var(--morse-green-2);
    color: #214d28;
}

.morse-track-chip.active,
.morse-symbol-pill.active {
    background: var(--morse-blue);
    border-color: var(--morse-blue-2);
    color: #182640;
    transform: translateY(-1px);
}

.morse-symbols {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.morse-symbol-pill {
    min-width: 40px;
    text-align: center;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid var(--morse-border);
    background: var(--morse-panel);
    color: #435067;
    font-size: 0.96rem;
    font-weight: 800;
    line-height: 1;
}

.morse-build-box {
    min-height: 76px;
    max-height: 126px;
    border-radius: 16px;
    border: 1px solid var(--morse-border-strong);
    background: var(--morse-panel-soft);
    padding: 14px;
    overflow-y: auto;
    scrollbar-width: thin;
    color: #23304a;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 1rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.morse-build-box-empty {
    color: var(--morse-muted);
}

@media (min-width: 1024px) {
    .morse-tool .morse-actions {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .morse-field,
    .morse-monitor {
        padding: 10px;
        border-radius: 16px;
    }

    .morse-field {
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
        min-height: 0;
    }

    .morse-textarea {
        min-height: 0;
        height: 100%;
        resize: none;
        padding: 12px;
        border-radius: 14px;
        font-size: 0.96rem;
        line-height: 1.42;
    }

    .morse-output {
        min-height: 0;
    }

    .morse-build-box {
        min-height: 68px;
        max-height: 116px;
        font-size: 0.96rem;
    }
}

@media (min-width: 700px) and (max-width: 1023px) {
    .morse-tool .morse-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .morse-tool *,
    .morse-tool *::before,
    .morse-tool *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
