:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #f43f5e;
    --glass-blur: blur(12px);
    --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
    --input-bg: transparent;
    --select-bg: #1e293b;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --ipa-font: 'Noto Sans', 'Doulos SIL', 'Charis SIL', 'Gentium Plus', 'DejaVu Sans', 'Segoe UI', 'Lucida Sans Unicode', sans-serif;
}

body.light-theme {
    --bg-gradient: #f5f5f7;
    --card-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(0, 0, 0, 0.1);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --accent: #e11d48;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --input-bg: rgba(255, 255, 255, 0.5);
    --select-bg: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 10px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header h1 .accent {
    color: var(--accent);
    -webkit-text-fill-color: var(--accent);
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
}

main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Glassmorphism Sections */
.input-section,
.output-section,
.settings-panel {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
}

textarea {
    width: 100%;
    min-height: 150px;
    background: var(--input-bg);
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1.1rem;
    resize: vertical;
    outline: none;
    padding: 10px;
    border-radius: 10px;
}

textarea::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.settings-header {
    display: flex;
    justify-content: flex-end;
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.settings-panel {
    margin-top: 10px;
    animation: slideDown 0.3s ease-out;
}

.settings-panel.hidden {
    display: none;
}

.setting-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-width: 150px;
}

.setting-group.full-width {
    flex: 1 1 100%;
    min-width: 100%;
}

.setting-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--card-border);
    border-radius: 3px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

input[type="range"]::-moz-range-thumb:hover {
    background: var(--primary-hover);
    transform: scale(1.1);
}

select {
    background: var(--select-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    font-family: inherit;
    outline: none;
}

.output-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 15px;
}

.output-container {
    min-height: 200px;
    word-wrap: break-word;
}

.placeholder {
    color: var(--text-muted);
    text-align: center;
    padding-top: 80px;
    font-style: italic;
    opacity: 0.5;
}

/* Transcription Styles */
.paragraph-block {
    margin-bottom: 2rem;
}

.text-line {
    font-size: 1em;
    margin-bottom: 0.25rem;
}

.ipa-line {
    font-family: var(--ipa-font);
    color: var(--accent);
    font-size: 0.85em;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.word-pair {
    display: inline-flex;
    margin: 0 0.45rem 1rem 0;
    text-align: center;
    vertical-align: bottom;
    align-items: center;
}

.word-orig {
    display: block;
    font-size: 1em;
}

.word-ipa {
    display: block;
    font-size: 0.75em;
    color: var(--accent);
    font-family: var(--ipa-font);
    line-height: 1.2;
}

.ipa-above {
    flex-direction: column;
}

.ipa-below {
    flex-direction: column-reverse;
}

.ipa-text-only {
    font-size: 1em;
    color: var(--accent);
    font-family: var(--ipa-font);
    line-height: 1.8;
}

.line-block {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
}

.line-block.ipa-above {
    flex-direction: column;
}

.line-block.ipa-under {
    flex-direction: column-reverse;
}

.paragraph-block.display-flex {
    display: flex;
    flex-direction: column;
}

.paragraph-block.ipa-above {
    flex-direction: column;
}

.paragraph-block.ipa-under {
    flex-direction: column-reverse;
}

.line-block .ipa-line,
.paragraph-block .ipa-line {
    margin-bottom: 0.2rem;
}

.line-block .text-line,
.paragraph-block .text-line {
    margin-bottom: 0;
}

a {
    text-decoration: none;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    opacity: 0.6;
}

@media (max-width: 600px) {
    header h1 {
        font-size: 2.2rem;
    }

    .container {
        padding: 20px 15px;
    }
}