:root {
    --bg: #ffffff;
    --text: #000000;
    --accents-1: #fafafa;
    --accents-2: #eaeaea;
    --accents-3: #999999;
    --accents-4: #888888;
    --accents-5: #666666;
    --accents-7: #333333;
    --accents-8: #111111;
    --border: #eaeaea;
    --shadow: 0 5px 10px rgba(0, 0, 0, 0.12);
    --radius: 5px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
}

body.dark {
    --bg: #000000;
    --text: #ffffff;
    --accents-1: #111111;
    --accents-2: #333333;
    --accents-3: #444444;
    --accents-4: #666666;
    --accents-5: #888888;
    --accents-7: #eaeaea;
    --accents-8: #fafafa;
    --border: #333333;
    --shadow: 0 0 0 1px #333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.5;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Sound Toggle */
#sound-toggle .sound-on,
#sound-toggle .sound-off {
    transition: opacity 0.2s;
}

#sound-toggle .hidden {
    display: none;
}

/* Navbar */
.navbar {
    height: 64px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.logo {
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.05em;
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
    border: 1px solid var(--text);
    padding: 0 1.25rem;
    height: 40px;
}

.btn-primary:hover {
    background: transparent;
    color: var(--text);
}

.btn-secondary {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0 1.25rem;
    height: 40px;
}

.btn-secondary:hover {
    border-color: var(--text);
}

.btn-ghost {
    background: transparent;
    color: var(--accents-5);
    border: none;
    padding: 0 0.75rem;
    height: 40px;
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--accents-1);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    color: var(--accents-5);
}

.btn-icon:hover {
    color: var(--text);
    border-color: var(--text);
}

/* Header & Stats */
.dashboard-header {
    margin: 3rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-card {
    display: flex;
    flex-direction: column;
}

.stats-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accents-5);
    letter-spacing: 0.05em;
}

.stats-value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.actions {
    display: flex;
    gap: 0.75rem;
}

/* Search */
.search-section {
    margin-bottom: 2rem;
}

.input-minimal {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.input-minimal:focus {
    border-color: var(--text);
}

/* Grid & Cards */
.words-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-bottom: 4rem;
}

/* Word Card */
.word-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all 0.2s ease;
}

.word-card:hover {
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.card-word-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-word {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.btn-speaker {
    background: transparent;
    border: none;
    color: var(--accents-4);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-speaker:hover {
    color: var(--text);
    background: var(--accents-2);
}

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

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.card-translation {
    color: var(--accents-5);
    margin-bottom: 1rem;
}

.card-meta {
    font-size: 0.75rem;
    color: var(--accents-4);
    display: flex;
    gap: 1rem;
}

.card-footer {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg);
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accents-5);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
}

.form-group textarea {
    height: 80px;
    resize: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background-color: var(--bg);
    min-width: 160px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    z-index: 100;
    border-radius: var(--radius);
    margin-top: 5px;
}

.dropdown-content.show {
    display: block;
}

.dropdown-content a {
    color: var(--text);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 0.875rem;
}

.dropdown-content a:hover {
    background-color: var(--accents-1);
}

/* Training Overlay */
.training-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

.training-container {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.training-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4rem;
}

.card-controls {
    margin-top: 3rem;
    display: flex;
    gap: 2rem;
}

.card-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Refined Flashcard Flip */
.flashcard {
    width: 100%;
    height: 350px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    background: var(--bg);
    box-shadow: var(--shadow);
}

.flashcard-back {
    transform: rotateY(180deg);
}

.flashcard-back h2 {
    margin-bottom: 1rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.75rem 0;
    color: var(--accents-5);
    font-weight: 500;
    position: relative;
    border-radius: 0;
}

.tab-btn.active {
    color: var(--text);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--text);
}

.tab-content.hidden {
    display: none;
}

/* Analytics */
.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.analytics-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    background: var(--bg);
}

.analytics-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--accents-5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

/* Badge */
.badge {
    background: #0070f3;
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

#due-badge:empty {
    display: none;
}

@media (max-width: 768px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

/* Quiz */
.quiz-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.quiz-container h1 {
    margin-bottom: 2rem;
    text-align: center;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.option-btn {
    padding: 1.5rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    border-radius: var(--radius);
    text-align: left;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: var(--text);
}

.option-btn.correct {
    border-color: #0070f3;
    background: rgba(0, 112, 243, 0.1);
}

.option-btn.incorrect {
    border-color: #ff0000;
    background: rgba(255, 0, 0, 0.1);
}

.feedback {
    margin-top: 2rem;
    text-align: center;
    font-weight: 500;
}

/* Result View - Premium Card Look */
.result-view {
    text-align: center;
    margin: auto;
    padding: 3rem;
    max-width: 400px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--accents-1);
    box-shadow: var(--shadow);
}

.result-view h2 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin-bottom: 2rem;
}

.result-stats {
    margin: 2.5rem 0;
    display: flex;
    justify-content: center;
    gap: 3rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--accents-5);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
}

.stat-value.success {
    color: #0070f3;
}

.stat-value.error {
    color: #ff0000;
}

#finish-training {
    width: 100%;
    margin-top: 1rem;
}

/* Theme Icons */
.sun {
    display: block;
}

.moon {
    display: none;
}

body.dark .sun {
    display: none;
}

body.dark .moon {
    display: block;
}

.italic {
    font-style: italic;
    color: var(--accents-5);
    margin-top: 0.5rem;
}

.input-with-action {
    display: flex;
    gap: 0.5rem;
}

.input-with-action input {
    flex: 1;
}

.btn-ai {
    padding: 0 1rem;
    height: 48px;
    border-radius: var(--radius);
    border: 1px solid #7c3aed;
    background: rgba(124, 58, 237, 0.1);
    color: #7c3aed;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-ai:hover {
    background: #7c3aed;
    color: white;
}

.btn-ai.loading {
    animation: pulse-ai 1.5s infinite;
}

@keyframes pulse-ai {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* AI Chat Partner Styles */
.chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 500px;
    background: var(--accents-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    line-height: 1.4;
}

.message.ai {
    align-self: flex-start;
    background: var(--accents-2);
    color: var(--text);
    border-bottom-left-radius: 2px;
}

.message.user {
    align-self: flex-end;
    background: #0070f3;
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    display: flex;
    padding: 1rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    gap: 0.5rem;
}

.chat-input-area input {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    outline: none;
}

.chat-input-area input:focus {
    border-color: var(--accents-5);
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--accents-2);
    border-radius: 10px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 1rem;
    background: var(--accents-2);
    border-radius: var(--radius);
    border-bottom-left-radius: 2px;
    align-self: flex-start;
    width: fit-content;
    margin-bottom: 1rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--accents-5);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1.0);
    }
}


/* Listening Quiz Styles */
.btn-audio-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--accents-1);
    border: 2px solid var(--border);
    color: var(--accents-5);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.btn-audio-large:hover {
    background: var(--accents-2);
    color: var(--text);
    transform: scale(1.05);
    border-color: var(--accents-5);
}

.btn-audio-large:active {
    transform: scale(0.95);
}

.audio-quiz-area {
    text-align: center;
    padding: 2rem 0;
}

.input-minimal:focus {
    border-color: #0070f3;
    box-shadow: 0 0 0 2px rgba(0, 112, 243, 0.2);
}

/* Auth Styles */
.auth-tabs {
    display: flex;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem;
    color: var(--accents-5);
    font-weight: 500;
    cursor: pointer;
    position: relative;
    border-radius: 0;
}

.auth-tab.active {
    color: var(--text);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--text);
}

.auth-message {
    transition: all 0.3s ease;
}

.auth-message.success {
    background: rgba(0, 112, 243, 0.1);
    color: #0070f3;
    border: 1px solid rgba(0, 112, 243, 0.2);
}

.auth-message.error {
    background: rgba(255, 0, 0, 0.1);
    color: #ff0000;
    border: 1px solid rgba(255, 0, 0, 0.2);
}

/* or-divider — flex layout (no absolute positioning) */
.or-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accents-4);
    font-size: 0.8rem;
    margin: 0 0 1.5rem 0;
}

.or-divider::before,
.or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Mobile responsive for auth screen */
@media (max-width: 480px) {

    #auth-screen .auth-container,
    .auth-container {
        margin: 1rem;
        padding: 1.5rem 1.25rem;
        max-width: 100%;
        border-radius: 10px;
    }
}

/* ===== ONBOARDING ===== */
#onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 1rem;
    animation: ob-fade-in 0.4s ease;
}

@keyframes ob-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.ob-card {
    background: var(--accents-1);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    position: relative;
    animation: ob-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ob-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

/* Step dots */
.ob-steps {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 2rem;
}

.ob-step {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s ease;
}

.ob-step.active {
    background: var(--text);
    width: 20px;
    border-radius: 3px;
}

/* Slides */
.ob-slide {
    display: none;
    text-align: center;
    animation: ob-slide-in 0.3s ease;
}

.ob-slide.active {
    display: block;
}

@keyframes ob-slide-in {
    from {
        opacity: 0;
        transform: translateX(15px);
    }

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

.ob-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

.ob-slide h2 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.ob-slide>p {
    color: var(--accents-4);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* Features grid (step 0) */
.ob-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 2rem;
    text-align: left;
}

.ob-feature {
    background: var(--accents-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.85rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Steps list (step 1) */
.ob-steps-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    text-align: left;
}

.ob-step-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.ob-step-num {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: var(--text);
    color: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.ob-step-item strong {
    display: block;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 2px;
}

.ob-step-item span {
    font-size: 0.8rem;
    color: var(--accents-5);
}

/* Sample words (step 2) */
.ob-sample-words {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.ob-tag {
    background: var(--accents-1);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
    color: var(--text);
}

.ob-choice {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Tip (step 3) */
.ob-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: var(--accents-1);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    text-align: left;
    font-size: 0.85rem;
    color: var(--accents-4);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.ob-tip strong {
    color: var(--text);
}

/* Navigation */
.ob-nav {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    margin-top: 0.5rem;
}

/* Buttons */
.ob-btn-primary {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ob-btn-primary:hover {
    opacity: 0.85;
}

.ob-btn-ghost {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    color: var(--accents-5);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.ob-btn-ghost:hover {
    color: var(--text);
    border-color: var(--text);
}

@media (max-width: 480px) {
    .ob-card {
        padding: 1.75rem 1.25rem;
        border-radius: 12px;
    }

    .ob-features {
        grid-template-columns: 1fr 1fr;
    }
}