/* ---------- Reset & Base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0b0e14;
    color: #e8edf5;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
    line-height: 1.6;
}

.container {
    max-width: 820px;
    width: 100%;
}

/* ---------- Header ---------- */
header h1 {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #6dd5fa, #2980b9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: #8899b0;
    font-size: 0.95rem;
    margin-top: 0.25rem;
    border-bottom: 1px solid #1e2a3a;
    padding-bottom: 1.2rem;
    margin-bottom: 2rem;
}

/* ---------- Translator Section ---------- */
.translator {
    background: #141c28;
    border-radius: 20px;
    padding: 1.8rem 2rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7);
    border: 1px solid #24303e;
}

/* Mode selector */
.mode-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.8rem;
    flex-wrap: wrap;
}

.mode-btn {
    background: transparent;
    border: 1px solid #31465a;
    color: #b0c4db;
    padding: 0.6rem 1.4rem;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    flex: 1 1 auto;
}

.mode-btn:hover {
    background: #1e2d3d;
    border-color: #4a6a85;
    color: #fff;
}

.mode-btn.active {
    background: #1f6f9e;
    border-color: #1f6f9e;
    color: #fff;
    box-shadow: 0 0 12px rgba(31, 111, 158, 0.3);
}

/* Input / Output groups */
.input-group,
.output-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #a0b8d0;
    margin-bottom: 0.4rem;
    letter-spacing: 0.3px;
}

textarea {
    width: 100%;
    background: #0d141c;
    border: 1px solid #283746;
    border-radius: 14px;
    padding: 1rem;
    font-size: 1rem;
    font-family: 'Fira Code', 'Consolas', monospace;
    color: #e4edf5;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: #3a7ca5;
    box-shadow: 0 0 0 3px rgba(31, 111, 158, 0.2);
}

textarea::placeholder {
    color: #4a5f72;
    font-family: 'Segoe UI', sans-serif;
}

#outputText {
    background: #0a1017;
    color: #b8d4f0;
}

/* Action buttons */
.action-bar {
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin: 1.2rem 0 1.5rem;
}

.action-btn {
    background: #1b2838;
    border: none;
    color: #cfdef5;
    padding: 0.6rem 1.3rem;
    border-radius: 40px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #2a3d52;
    flex: 1 1 auto;
    justify-content: center;
}

.action-btn:hover {
    background: #263b4f;
    border-color: #407090;
    color: #fff;
    transform: translateY(-1px);
}

.action-btn:active {
    transform: scale(0.97);
}

#playBtn {
    background: #1a5f7a;
    border-color: #1a5f7a;
    color: #fff;
}

#playBtn:hover {
    background: #217a9c;
    border-color: #217a9c;
}

#clearBtn {
    background: #3d2a2a;
    border-color: #5a3a3a;
    color: #f0baba;
}

#clearBtn:hover {
    background: #5a3a3a;
    border-color: #7a4a4a;
}

/* Settings sliders */
.settings {
    display: flex;
    flex-wrap: wrap;
    gap: 1.8rem;
    margin-top: 0.8rem;
    padding-top: 1.2rem;
    border-top: 1px solid #1f2d3d;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1 1 180px;
}

.setting-item label {
    margin-bottom: 0;
    font-size: 0.8rem;
    min-width: 70px;
    color: #8aa3bc;
}

.setting-item input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #2a3f55;
    border-radius: 4px;
    outline: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3a8fc9;
    cursor: pointer;
    border: 2px solid #0b141e;
    box-shadow: 0 0 6px rgba(58, 143, 201, 0.4);
}

.setting-item input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3a8fc9;
    cursor: pointer;
    border: 2px solid #0b141e;
}

.setting-item span {
    min-width: 32px;
    text-align: center;
    font-weight: 600;
    color: #b8d4f0;
    font-size: 0.9rem;
}

/* ---------- Reference Table ---------- */
.reference {
    margin-top: 3rem;
}

.reference h2 {
    font-size: 1.3rem;
    font-weight: 500;
    color: #bfd6ed;
    margin-bottom: 1rem;
    letter-spacing: 0.5px;
}

.morse-table {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 0.6rem;
    background: #101a24;
    padding: 1.2rem;
    border-radius: 18px;
    border: 1px solid #1f2d3d;
}

.morse-item {
    background: #19232f;
    border-radius: 12px;
    padding: 0.5rem 0.3rem;
    text-align: center;
    font-size: 0.85rem;
    transition: background 0.15s;
    border: 1px solid #253544;
    cursor: default;
}

.morse-item:hover {
    background: #233a4e;
    border-color: #3a6a8a;
}

.morse-item .char {
    font-size: 1.3rem;
    font-weight: 700;
    color: #eef6ff;
    display: block;
}

.morse-item .code {
    font-family: 'Fira Code', monospace;
    color: #90b8d8;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* ---------- Footer ---------- */
footer {
    margin-top: 3rem;
    text-align: center;
    font-size: 0.8rem;
    color: #4a6178;
    border-top: 1px solid #18222e;
    padding-top: 1.5rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    .translator {
        padding: 1.2rem;
    }
    header h1 {
        font-size: 1.8rem;
    }
    .mode-btn {
        font-size: 0.8rem;
        padding: 0.5rem 1rem;
    }
    .action-btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.9rem;
    }
    .settings {
        flex-direction: column;
        gap: 0.8rem;
    }
    .morse-table {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        padding: 0.8rem;
    }
}