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

body {
    font-family: Arial, sans-serif;
    background: var(--surface);
    color: var(--ink);
    min-height: 100vh;
}

/* MAIN APP */

.app-container {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 30px 40px;
}

/* HEADER */

header {
    margin-bottom: 30px;
    text-align: left;
}

header h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

header p {
    color: var(--muted);
}

/* TWO-COLUMN LAYOUT */

.main-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 25px;
    align-items: start;
}

/* LEFT SIDEBAR */

.controls-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 25px;
    text-align: center;
}

#status {
    color: var(--muted);
    margin-bottom: 25px;
    font-size: 16px;
}

#mic-button {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: var(--on-color);
    font-size: 40px;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 0 35px rgba(18, 124, 181, 0.3);
}

#mic-button:hover {
    transform: scale(1.06);
}

#mic-button.active {
    background: var(--danger);
    box-shadow: 0 0 40px rgba(229, 72, 77, 0.5);
}

#mic-instructions {
    margin-top: 18px;
    margin-bottom: 30px;
    color: var(--muted);
    font-size: 13px;
}

/* AVATAR SELECTION */

.avatar-selection {
    margin-bottom: 30px;
}

.avatar-selection > p {
    margin-bottom: 15px;
}

.avatar {
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.avatar svg {
    display: block;
    color: var(--ink);
}

.avatar-options {
    display: flex;
    justify-content: center;
    gap: 35px;
}

.avatar-option {
    width: 75px;
    padding: 8px 4px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--faint);
    cursor: pointer;
    transition: 0.2s;
}

.avatar-option.active {
    border-color: var(--primary);
    background-color: var(--primary-tint);
    color: var(--ink);
}

/* LANGUAGE CONTROLS */

.language-controls {
    display: flex;
    flex-direction: column;
    gap: 25px;
    margin: 25px 0 0;
}

.language-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.language-group p {
    margin-bottom: 5px;
    font-size: 14px;
    text-align: left;
}

.language-group button {
    padding: 10px 15px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background-color: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-size: 14px;
    text-align: left;
}

.language-group button:hover {
    background-color: var(--line-strong);
}

.language-group button.active {
    background-color: var(--primary-tint);
    border-color: var(--primary);
}

.flag {
    width: 20px;
    height: auto;
    vertical-align: middle;
    margin-right: 8px;
}

/* RIGHT CONVERSATION PANEL */

.conversation-panel {
    background: var(--surface);
    border-radius: 16px;
    padding: 25px;
    min-height: 650px;
}

.conversation-panel h2 {
    font-size: 22px;
    margin-bottom: 20px;
}

#conversation {
    text-align: left;
    background: var(--surface);
    border-radius: 12px;
    padding: 25px;
    min-height: 550px;
}

#transcripts p {
    margin-bottom: 15px;
    line-height: 1.6;
}

/* MOBILE LAYOUT */

@media (max-width: 800px) {
    .app-container {
        padding: 20px;
    }

    .main-layout {
        grid-template-columns: 1fr;
    }

    .controls-panel {
        width: 100%;
    }

    .conversation-panel {
        min-height: 400px;
    }

    #conversation {
        min-height: 350px;
    }

    header {
        text-align: center;
    }
}

/* FIT THE APP TO THE SCREEN */

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 30px;
}

header {
    margin-bottom: 15px;
    flex-shrink: 0;
}

.main-layout {
    flex: 1;
    min-height: 0;
}

.controls-panel {
    padding: 18px;
    min-height: 0;
    overflow-y: auto;
}

#status {
    margin-bottom: 15px;
}

#mic-button {
    width: 90px;
    height: 90px;
}

#mic-instructions {
    margin-top: 12px;
    margin-bottom: 18px;
}

.avatar-selection {
    margin-bottom: 18px;
}

.language-controls {
    gap: 15px;
    margin-top: 15px;
}

.language-group {
    gap: 6px;
}

.language-group button {
    padding: 8px 12px;
}

.conversation-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 18px;
}

.conversation-panel h2 {
    margin-bottom: 12px;
}

#conversation {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* MOBILE DEVICES */

@media (max-width: 800px) {
    .app-container {
        height: auto;
        min-height: 100vh;
    }

    .main-layout {
        display: grid;
        grid-template-columns: 1fr;
    }

    .conversation-panel {
        min-height: 400px;
    }

    /* A long conversation scrolls inside its box instead of
       stretching the page */
    #conversation {
        min-height: 350px;
        max-height: 60vh;
        max-height: 60dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

/* FINAL DESKTOP SCREEN LAYOUT */

@media (min-width: 801px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }

    .app-container {
        height: 100vh;
        height: 100dvh;
        padding: 15px 30px;
    }

    header {
        margin-bottom: 12px;
    }

    .main-layout {
        grid-template-columns: 320px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        flex: 1;
        min-height: 0;
    }

    .controls-panel {
        min-height: 0;
        overflow-y: auto;
        padding: 15px;
    }

    .conversation-panel {
        height: 100%;
        min-height: 0;
    }

    #conversation {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    /* Compact tutor selection */
    #mic-button {
        width: 85px;
        height: 85px;
    }

    .avatar-selection {
        margin-bottom: 15px;
    }

    .avatar-options {
        gap: 20px;
    }

    /* Put language choices side by side */
    .language-controls {
        gap: 14px;
        margin-top: 12px;
    }

    .language-group {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .language-group p {
        grid-column: 1 / -1;
        margin-bottom: 2px;
    }

    .language-group button {
        padding: 9px 4px;
        font-size: 12px;
        text-align: center;
        white-space: nowrap;
    }

    .flag {
        width: 16px;
        margin-right: 2px;
    }
}

/* TOP NAVIGATION BAR */

.app-container {
    max-width: none;
    height: 100vh;
    height: 100dvh;
    padding: 0 30px 15px;
    display: flex;
    flex-direction: column;
}

/* NAVBAR */

.top-navbar {
    height: 75px;
    min-height: 75px;
    width: calc(100% + 60px);
    margin-left: -30px;
    margin-right: -30px;
    margin-bottom: 18px;
    padding: 0 40px;
    background: var(--surface);

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand h1 {
    font-size: 25px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 35px;
}

.nav-links a {
    color: var(--muted);
    text-decoration: none;
    font-size: 15px;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--ink);
}

/* PANELS UNDER NAVBAR */

.main-layout {
    flex: 1;
    min-height: 0;
}

/* MOBILE NAVBAR */

@media (max-width: 800px) {
    .app-container {
        height: auto;
        min-height: 100vh;
        padding: 0 15px 15px;
    }

    .top-navbar {
        width: calc(100% + 30px);
        margin-left: -15px;
        margin-right: -15px;
        padding: 15px;
        height: auto;
        min-height: 75px;
        flex-direction: column;
        gap: 15px;
    }

    .nav-links {
        gap: 18px;
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* FIX EMPTY SPACE */

@media (min-width: 801px) {

    /* Make the left and right panels equal in height */
    .main-layout {
        align-items: stretch;
    }

    .controls-panel {
        height: 100%;
        box-sizing: border-box;
    }

    /* Bring navbar links closer to the title */
    .top-navbar {
        justify-content: flex-start;
        gap: 90px;
    }

}

/* DISTRIBUTE CONTROLS THROUGH LEFT PANEL */

@media (min-width: 801px) {
    .main-layout {
        align-items: stretch;
    }

    .controls-panel {
        height: 100%;
        align-self: stretch;
        box-sizing: border-box;

        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
    }
}

@media (min-width: 801px) {
    #mic-button {
        align-self: center;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ENGLISH TRANSLATION */
.translation-text {
    display: block;
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 400;
    line-height: 1.4;
}

.translation-hidden .translation-text {
    display: none;
}

/* TRANSLATION TOGGLE BUTTON */

.translation-controls {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 12px;
}

#translation-toggle {
    padding: 8px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background-color: var(--surface);
    color: var(--ink);
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

#translation-toggle:hover {
    background-color: var(--line-strong);
}

#translation-toggle.active {
    background-color: var(--primary-tint);
    border-color: var(--primary);
}

#translation-toggle.active:hover {
    background-color: var(--primary);
}

/* PAGE VIEWS (Practice, Progress, Settings, About) */

.is-hidden {
    display: none !important;
}

.page-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--surface);
    border-radius: 16px;
    padding: 30px;
}

.page-view h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.page-intro {
    color: var(--muted);
    line-height: 1.6;
    max-width: 700px;
    margin-bottom: 25px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
}

.info-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px;
}

.info-card h3 {
    font-size: 17px;
    margin-bottom: 8px;
}

.info-card p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.stat-card span {
    display: block;
    font-size: 40px;
    font-weight: bold;
    color: var(--success-ink);
    margin-bottom: 4px;
}

/* PRACTICE MODE BUTTONS */

.practice-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
}

.practice-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 22px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--ink);
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.practice-btn:hover {
    background: var(--surface-3);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.practice-btn.active {
    background: var(--primary-tint);
    border-color: var(--primary);
}

.practice-icon {
    font-size: 30px;
}

.practice-title {
    font-size: 16px;
    font-weight: bold;
}

.practice-desc {
    font-size: 12px;
    color: var(--muted);
}

.practice-btn.active .practice-desc {
    color: var(--success-ink);
}

/* Fewer columns on smaller screens */
@media (max-width: 1100px) {
    .practice-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .practice-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* CLEAR BUTTON */

.translation-controls {
    gap: 10px;
}

#clear-button {
    padding: 8px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background-color: var(--surface);
    color: var(--ink);
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

#clear-button:hover {
    background-color: var(--danger);
    border-color: var(--danger);
}

/* SETTINGS PAGE */

.settings-group {
    margin-bottom: 30px;
    max-width: 800px;
}

.settings-group h3 {
    font-size: 17px;
    margin-bottom: 6px;
}

.settings-help {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 14px;
}

.settings-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.setting-btn {
    padding: 12px 20px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background-color: var(--surface);
    color: var(--ink);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.setting-btn:hover {
    background-color: var(--line-strong);
}

.setting-btn.active {
    background-color: var(--primary-tint);
    border-color: var(--primary);
}

.level-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 200px;
    text-align: left;
}

/* Ten levels in two rows of five; two columns when there isn't room */
.settings-group:has(> .level-scale) {
    container-type: inline-size;
}

.settings-options.level-scale {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.level-scale .level-btn {
    min-width: 0;
    padding: 12px 14px;
}

@container (max-width: 680px) {
    .settings-options.level-scale {
        grid-template-columns: repeat(2, 1fr);
    }
}

.level-title {
    font-weight: bold;
}

.level-desc {
    font-size: 12px;
    color: var(--muted);
}

.setting-btn.active .level-desc {
    color: var(--success-ink);
}

/* PROGRESS PAGE */

.progress-panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
    margin-bottom: 24px;
}

.progress-panels h3 {
    margin-bottom: 16px;
}

/* Last 7 days chart */
.week-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    height: 180px;
}

.week-column {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.week-track {
    flex: 1;
    width: 100%;
    max-width: 38px;
    display: flex;
    align-items: flex-end;
    background: var(--surface);
    border-radius: 6px;
    overflow: hidden;
}

.week-bar {
    width: 100%;
    background: var(--success);
    border-radius: 6px 6px 0 0;
    min-height: 2px;
    transition: height 0.3s;
}

.week-value {
    font-size: 12px;
    color: var(--muted);
}

.week-label {
    font-size: 12px;
    color: var(--muted);
}

/* Practice mode list */
.mode-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mode-row {
    display: grid;
    grid-template-columns: 110px 1fr 28px;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.mode-name {
    color: var(--ink);
}

.mode-track {
    height: 10px;
    background: var(--surface);
    border-radius: 5px;
    overflow: hidden;
}

.mode-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 5px;
    transition: width 0.3s;
}

.mode-count {
    text-align: right;
    color: var(--muted);
}

.mode-empty {
    color: var(--muted);
    font-size: 14px;
}

/* Reset button */
.reset-btn:hover {
    background-color: var(--danger);
    border-color: var(--danger);
}

@media (max-width: 800px) {
    .progress-panels {
        grid-template-columns: 1fr;
    }
}

/* SPOKEN / WRITTEN SWITCH */

.channel-toggle {
    display: inline-flex;
    margin-bottom: 20px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}

.channel-btn {
    padding: 10px 22px;
    border: none;
    background: var(--surface);
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.channel-btn:hover {
    color: var(--ink);
}

.channel-btn.active {
    background: var(--primary-tint);
    color: var(--ink);
}

.practice-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.practice-btn:disabled:hover {
    background: var(--surface-3);
    border-color: var(--line);
    transform: none;
}

/* WRITTEN PRACTICE PAGE */

#view-write {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.write-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.write-header .page-intro {
    margin-bottom: 0;
}

.write-actions {
    display: flex;
    gap: 10px;
}

.write-back {
    display: inline-block;
    text-decoration: none;
}

.write-log {
    flex: 1;
    min-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
    background: var(--surface);
    border-radius: 12px;
}

.write-message {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.write-user {
    align-self: flex-end;
    align-items: flex-end;
}

.write-tutor {
    align-self: flex-start;
    align-items: flex-start;
}

.write-text {
    padding: 12px 16px;
    border-radius: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.write-user .write-text {
    background: var(--primary);
}

.write-tutor .write-text {
    background: var(--surface);
}

.write-translate {
    padding: 0 4px;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
}

.write-translate:hover {
    color: var(--ink);
}

.write-translation {
    padding: 0 4px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}

.write-translation[hidden] {
    display: none;
}

.write-status {
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
}

.write-error {
    color: var(--danger-ink);
    font-style: normal;
}

.write-input-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

#write-input {
    flex: 1;
    resize: none;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
}

#write-input:focus {
    outline: none;
    border-color: var(--primary);
}

#write-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 800px) {
    .write-message {
        max-width: 90%;
    }
}

/* LOGIN / SIGN-UP SCREEN */

.auth-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    background: var(--surface);
}

.auth-loading {
    color: var(--muted);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 32px 28px;
    background: var(--surface);
    border-radius: 16px;
}

.auth-card h1 {
    margin-bottom: 6px;
    font-size: 26px;
}

.auth-sub {
    margin-bottom: 20px;
    color: var(--muted);
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    width: 100%;
}

.auth-tabs .channel-btn {
    flex: 1;
    margin-bottom: 0;
}

#auth-form {
    margin-top: 20px;
}

#auth-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--muted);
}

#auth-form input,
.delete-form input {
    width: 100%;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
}

#auth-form input:focus,
.delete-form input:focus,
#custom-input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-error {
    min-height: 18px;
    margin-bottom: 10px;
    color: var(--danger-ink);
    font-size: 13px;
}

.auth-submit {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: var(--on-color);
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.auth-submit:hover {
    background: var(--primary-hover);
}

.auth-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.auth-note {
    margin-top: 16px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

/* NAVBAR: signed-in user */

.nav-user {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-left: auto;
    color: var(--muted);
    font-size: 14px;
}

.nav-logout {
    padding: 7px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    cursor: pointer;
}

.nav-logout:hover {
    background: var(--line-strong);
}

/* CUSTOM PRACTICE PANEL */

.custom-panel {
    max-width: 700px;
    margin-top: 24px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.custom-panel h3 {
    margin-bottom: 8px;
}

#custom-input {
    width: 100%;
    margin: 12px 0 10px;
    padding: 12px 14px;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
}

#focus-custom-input {
    width: 100%;
    margin-top: 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
}

.custom-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-actions .settings-help {
    margin-bottom: 0;
}

/* ACCOUNT (in Settings) */

.delete-form {
    max-width: 360px;
    margin-top: 16px;
}

.delete-form .settings-help {
    margin-bottom: 10px;
}

/* ABOUT PAGE */

.about-grid {
    max-width: 1000px;
}

/* WEAK SPOTS AND CORRECTIONS (Progress page) */

.weak-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.weak-item {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.weak-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.weak-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 4px;
}

.weak-topic {
    font-size: 14px;
    font-weight: bold;
    text-transform: capitalize;
}

.weak-count {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
}

.weak-example {
    margin-bottom: 2px;
    font-size: 14px;
    line-height: 1.5;
}

.weak-wrong {
    color: var(--danger-ink);
    text-decoration: line-through;
}

.weak-arrow {
    color: var(--muted);
}

.weak-right {
    color: var(--success-ink);
}

.weak-why {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

/* AUTH: email row, forgot and reset screens */

#auth-email-row label {
    display: block;
}

#forgot-form,
#reset-form {
    margin-top: 20px;
}

#forgot-form label,
#reset-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--muted);
}

#forgot-form input,
#reset-form input {
    width: 100%;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
}

#forgot-form input:focus,
#reset-form input:focus {
    outline: none;
    border-color: var(--primary);
}

.auth-error.ok {
    color: var(--success-ink);
}

.auth-link {
    display: block;
    margin: 14px auto 0;
    padding: 4px;
    border: none;
    background: none;
    color: var(--primary-ink);
    font-size: 13px;
    cursor: pointer;
}

.auth-link:hover {
    text-decoration: underline;
}

#email-form {
    margin: 0 0 18px;
}

#email-form .setting-btn {
    margin-bottom: 8px;
}

/* QUIZ SETUP (Practice page) */

.quiz-panel {
    max-width: 800px;
}

.quiz-option-group {
    margin-top: 16px;
}

.quiz-option-title {
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: bold;
}

.quiz-panel .setting-btn {
    padding: 10px 16px;
}

.quiz-panel .level-btn {
    min-width: 170px;
}

.quiz-topic {
    width: 100%;
    max-width: 420px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
}

.quiz-topic:focus {
    outline: none;
    border-color: var(--primary);
}

.quiz-panel .custom-actions {
    margin-top: 22px;
    gap: 12px;
    flex-wrap: wrap;
}

/* QUIZ PLAY PAGE */

#view-quiz {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.quiz-loading {
    padding: 40px 0;
    color: var(--muted);
    font-style: italic;
}

.quiz-play,
.quiz-results {
    width: 100%;
    max-width: 760px;
}

.quiz-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
}

.quiz-timer {
    font-weight: bold;
    font-size: 18px;
    color: var(--ink);
}

.quiz-timer.urgent {
    color: var(--danger-ink);
}

.quiz-progress {
    height: 8px;
    margin-bottom: 18px;
    background: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.quiz-progress-bar {
    height: 100%;
    width: 0;
    background: var(--success);
    transition: width 0.3s;
}

.quiz-card {
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.quiz-kind {
    margin-bottom: 8px;
    color: var(--success-ink);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.quiz-prompt {
    font-size: 21px;
    line-height: 1.5;
    margin-bottom: 8px;
}

.quiz-hint {
    min-height: 18px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 13px;
}

.quiz-answer-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-choice {
    padding: 13px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.quiz-choice:hover:not(:disabled) {
    background: var(--surface-3);
    border-color: var(--primary);
}

.quiz-choice.selected {
    border-color: var(--primary);
    background: var(--surface-2);
}

.quiz-choice.correct {
    border-color: var(--success);
    background: var(--success-tint);
}

.quiz-choice.wrong {
    border-color: var(--danger);
    background: var(--danger-tint);
}

.quiz-choice:disabled {
    cursor: default;
}

.quiz-tf-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.quiz-tf-row .quiz-choice {
    text-align: center;
    font-weight: bold;
}

.quiz-input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 16px;
}

.quiz-input:focus {
    outline: none;
    border-color: var(--primary);
}

.quiz-input:disabled {
    opacity: 0.8;
}

.quiz-sentence-line {
    min-height: 54px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
}

.quiz-word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.quiz-chip {
    padding: 9px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font-size: 15px;
    cursor: pointer;
}

.quiz-chip:hover:not(:disabled) {
    border-color: var(--primary);
}

.quiz-chip:disabled {
    cursor: default;
}

.quiz-chip.used {
    visibility: hidden;
}

.quiz-feedback {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
}

.quiz-feedback.good {
    background: rgba(34, 168, 102, 0.15);
    border: 1px solid var(--success);
}

.quiz-feedback.bad {
    background: rgba(229, 72, 77, 0.12);
    border: 1px solid var(--danger);
}

.quiz-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.quiz-submit {
    width: auto;
    padding: 12px 28px;
}

/* QUIZ RESULTS */

.quiz-results h3 {
    font-size: 22px;
    margin-bottom: 6px;
}

.quiz-result-score {
    margin-bottom: 18px;
    color: var(--success-ink);
    font-size: 36px;
    font-weight: bold;
}

.quiz-review {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
}

.quiz-review-item {
    padding: 12px 14px;
    background: var(--surface);
    border-left: 4px solid var(--success);
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
}

.quiz-review-item.missed {
    border-left-color: var(--danger);
}

.quiz-review-item .weak-why {
    margin-top: 4px;
}

@media (max-width: 800px) {
    .quiz-card {
        padding: 18px;
    }

    .quiz-prompt {
        font-size: 18px;
    }
}
/* SPEAK PAGE SIDEBAR: FIT WITHOUT SCROLLING
   The panel is as tall as the window and spreads its items out evenly, so
   the items themselves carry little spacing of their own. On shorter
   windows (most laptops, once the browser's tabs and address bar are
   counted) the microphone is smaller and the tutor choice is one slim row. */

@media (min-width: 801px) {
    .controls-panel {
        padding: 14px 16px;
    }

    .controls-panel #status {
        margin-bottom: 0;
    }

    .controls-panel #mic-instructions {
        margin: 6px 0 0;
    }

    .controls-panel .handsfree {
        margin: 0;
    }

    .controls-panel .mode-button {
        margin: 0;
        padding: 10px 14px;
    }

    .controls-panel .help-link {
        padding: 2px 10px;
    }

    .controls-panel .avatar-selection {
        margin-bottom: 0;
    }

    .controls-panel .avatar-selection > p {
        margin-bottom: 8px;
    }
}

@media (min-width: 801px) and (max-height: 820px) {
    .controls-panel #mic-button {
        width: 72px;
        height: 72px;
        font-size: 32px;
    }

    .controls-panel #status {
        font-size: 15px;
    }

    /* Tutor choice: icon and name side by side in a slim button */
    .controls-panel .avatar-options {
        gap: 12px;
    }

    .controls-panel .avatar-option {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        width: auto;
        padding: 4px 12px;
    }

    .controls-panel .avatar {
        height: 28px;
    }

    .controls-panel .avatar svg {
        height: 28px;
        width: auto;
    }

    .controls-panel .avatar-selection > p {
        margin-bottom: 6px;
        font-size: 14px;
    }
}

@media (min-width: 801px) and (max-height: 640px) {
    .controls-panel {
        padding: 10px 14px;
    }

    .controls-panel #mic-button {
        width: 60px;
        height: 60px;
        font-size: 26px;
    }

    .controls-panel .handsfree-hint {
        display: none;
    }
}

/* Short-answer quiz questions: a bigger box and a microphone button */
.quiz-short-input {
    resize: vertical;
    min-height: 90px;
    line-height: 1.5;
}

.quiz-mic {
    margin-top: 10px;
}

.quiz-mic.active {
    border-color: var(--danger, #d9534f);
    color: var(--danger, #d9534f);
}

/* "How was this conversation?" bar */
.convo-feedback {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
}

.convo-feedback-question {
    flex: 1 1 auto;
    font-size: 14px;
}

.convo-feedback-btn {
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: transparent;
    font-size: 18px;
    cursor: pointer;
}

.convo-feedback-close {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
}

.convo-feedback-comment {
    flex: 1 1 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-family: inherit;
    font-size: 15px;
    resize: vertical;
}
