/* Clinical Calm — Design Tokens */
:root {
    --primary:       #0D7178;
    --primary-light: #EAF6F7;
    --primary-muted: #ADD8DC;
    --bg:            #F3F5F7;
    --card-bg:       #FFFFFF;
    --text:          #1A2332;
    --text-sec:      #5E6E82;
    --border:        #DCE3EA;
    --border-light:  #ECF0F4;
    --success:       #0C8C5E;
    --success-light: #E6F5EF;
    --danger:        #DC2626;
    --score1:        #0D7178;
    --score2:        #3BA3AA;
    --score3:        #0C8C5E;
    --radius:        8px;
    --shadow:        0 1px 2px rgba(0,0,0,.04);
    --font:          'Source Sans 3', sans-serif;
}

/* Responsive breakpoints (CSS vars can't be used in @media, documented here):
   tablet  → min-width: 640px
   desktop → min-width: 1024px */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* App shell — full-bleed: header and background span the viewport.
   Content width is constrained per-section via .layout-container / .page. */
#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--bg);
}

/* ---- Header ---- */
/* Fixed min-height keeps the bar identical whether or not the avatar (the
   tallest child) is present, so header height matches across all pages. */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-mark {
    width: 30px;
    height: 30px;
    background: var(--primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.header-brand-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    letter-spacing: -0.01em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-switch {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.lang-switch-btn {
    padding: 5px 10px;
    border: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.lang-switch-btn + .lang-switch-btn { border-left: 1px solid var(--border); }
.lang-switch-btn:hover { background: var(--bg); }
.lang-switch-btn--active {
    background: var(--primary);
    color: #fff;
}
.lang-switch-btn--active:hover { background: var(--primary); }

.avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 600;
    font-size: 12px;
    border: none;
    cursor: pointer;
    font-family: var(--font);
    list-style: none;
}
.avatar::-webkit-details-marker { display: none; }

.avatar-menu { position: relative; }
.avatar-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 160px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 20;
    display: flex;
    flex-direction: column;
}
.avatar-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 9px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}
.avatar-dropdown-item:hover { background: var(--bg); }

/* ---- Layout ---- */
/* Content column: full-bleed shell, but content re-centers at a readable width
   (matches .layout-container so it lines up under the header content). */
.page { flex: 1; padding: 24px 20px 28px; width: 100%; max-width: 1120px; margin: 0 auto; }
.page--recording { padding: 20px 20px 28px; }
.page--auth {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 28px;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}
@media (min-width: 1024px) {
    .page { padding: 32px 40px 40px; }
    .page--recording { padding: 28px 40px 40px; }
}

/* ---- Responsive content layouts ---- */
.task-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px)  { .task-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }
@media (min-width: 1024px) { .task-grid { grid-template-columns: repeat(3, 1fr); } }

.results-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .results-grid { grid-template-columns: 1fr 1fr; align-items: start; } }

.recording-grid { display: flex; flex-direction: column; gap: 28px; }
@media (min-width: 900px) {
    .recording-grid { flex-direction: row; align-items: center; gap: 40px; }
    .recording-grid > * { flex: 1; min-width: 0; }
}

/* ---- Cards ---- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: opacity .15s;
}
.btn:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-danger   { background: #DC2626; color: #fff; }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-full     { width: 100%; }

/* ---- Back link ---- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-sec);
    margin-bottom: 16px;
    text-decoration: none;
}

/* ---- Form elements ---- */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-row   { display: flex; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; }

.field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}
.field-optional { font-size: 12px; font-weight: 400; color: var(--text-sec); }

.field-input {
    padding: 11px 14px;
    font-size: 14px;
    font-family: var(--font);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    color: var(--text);
    outline: none;
    width: 100%;
}
.field-input:focus { border-color: var(--primary); }

/* ---- Status & spinner ---- */
.status {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-top: 12px;
    display: none;
}
.status.show       { display: block; }
.status--warning   { background: #FEF9EC; border: 1px solid #F59E0B; color: #92400E; }
.status--danger    { background: #FEF2F2; border: 1px solid #FCA5A5; color: #991B1B; }
.status--error     { background: #FEF2F2; border: 1px solid #FCA5A5; color: #991B1B; }
.status--info      { background: var(--primary-light); border: 1px solid var(--primary-muted); color: var(--primary); }
.status--success   { background: var(--success-light); border: 1px solid var(--success); color: var(--success); }

/* Server-rendered flash messages (django.contrib.messages) */
.messages { padding: 16px 20px 0; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 1120px; margin: 0 auto; }
.messages .status { margin-top: 0; }

.spinner-wrap { text-align: center; padding: 32px 0; display: none; }
.spinner-wrap.show { display: block; }

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Progress bars ---- */
.progress-track {
    height: 5px;
    background: var(--border-light);
    border-radius: 99px;
    overflow: hidden;
}
.progress-fill { height: 100%; border-radius: inherit; }

/* ---- Accordion ---- */
.accordion { display: flex; flex-direction: column; gap: 6px; }

.acc-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.acc-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    font-family: var(--font);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
}

.acc-chevron { flex-shrink: 0; transition: transform .2s; color: var(--text-sec); }
.acc-item.open .acc-chevron { transform: rotate(180deg); }

.acc-body { display: none; padding: 0 16px 14px; }
.acc-item.open .acc-body { display: block; }

.acc-body ul { padding-left: 18px; }
.acc-body li { font-size: 13px; line-height: 1.6; color: var(--text); margin-bottom: 4px; }

/* ---- Desktop shadow ---- */
@media (min-width: 600px) {
    body { background: #E8EDF2; }
    #app { box-shadow: 0 0 0 1px var(--border), 0 4px 24px rgba(0,0,0,.08); }
}

/* ---- Landing page ---- */
.landing-nav { display: flex; align-items: center; gap: 16px; }
.landing-nav-link { font-size: 14px; font-weight: 500; color: var(--text-sec); text-decoration: none; }
.landing-nav-link:hover { color: var(--text); }
.landing-nav-cta { padding: 8px 16px; font-size: 14px; }

.landing-hero { text-align: center; max-width: 640px; margin: 0 auto; padding: 24px 0 40px; }
.landing-hero-title {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin-bottom: 14px;
}
@media (min-width: 640px) { .landing-hero-title { font-size: 36px; } }
.landing-hero-text {
    font-size: 15px;
    color: var(--text-sec);
    line-height: 1.6;
    margin-bottom: 28px;
}
.landing-cta { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.landing-cta-btn { padding: 12px 24px; font-size: 15px; }

/* Re-centers full-bleed sections (header content, landing) at a readable width */
.layout-container { width: 100%; max-width: 1120px; margin-left: auto; margin-right: auto; }
.app-header-inner { display: flex; align-items: center; justify-content: space-between; }

/* Fluid grid: cards reflow by available space instead of fixed breakpoints */
.landing-features { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.landing-feature { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.landing-feature-title { font-size: 16px; font-weight: 600; }
.landing-feature-text { font-size: 13px; color: var(--text-sec); line-height: 1.5; }

/* ============================================================
   Extracted from inline template styles
   ============================================================ */

/* ---- Generic helpers ---- */
.text-center   { text-align: center; }
.text-muted    { color: var(--text-sec); }
.text-muted-sm { font-size: 12px; color: var(--text-sec); }
.text-13-sec   { font-size: 13px; color: var(--text-sec); }
.field-error   { font-size: 12px; color: var(--danger); }
.link-primary  { color: var(--primary); font-weight: 500; text-decoration: none; }
.link-inline   { color: var(--primary); }
.self-start    { align-self: flex-start; }
.form-inline   { margin: 0; }
.is-hidden     { display: none; }

.mb-4  { margin-bottom: 4px; }
.mb-6  { margin-bottom: 6px; }
.mb-8  { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-4  { margin-top: 4px; }
.mt-16 { margin-top: 16px; }

/* ---- Headings ---- */
.page-title    { font-size: 24px; font-weight: 700; }
.page-title-sm { font-size: 22px; font-weight: 700; }
.section-title { font-size: 16px; font-weight: 600; }
.task-heading  { font-size: 19px; font-weight: 700; margin-bottom: 16px; }
.results-title { font-size: 19px; font-weight: 700; margin-bottom: 20px; }
.danger-title  { color: #991B1B; }

/* ---- Centered narrow page (settings, delete account) ---- */
.page--narrow { max-width: 560px; margin: 0 auto; width: 100%; }

/* ---- Auth / informational pages ---- */
.auth-subtitle { font-size: 14px; color: var(--text-sec); line-height: 1.5; margin-bottom: 28px; }
.auth-text     { font-size: 14px; color: var(--text-sec); line-height: 1.6; }
.auth-note     { font-size: 13px; color: var(--text-sec); line-height: 1.5; }
.auth-alt      { font-size: 13px; color: var(--text-sec); line-height: 1.5; text-align: center; margin-top: 24px; }
.auth-icon     { margin: 0 auto 20px; }

.btn-google { padding: 13px 24px; font-size: 15px; border: 1px solid var(--border); background: #fff; color: var(--text); }
.btn-lg     { padding: 13px 24px; font-size: 15px; }
.btn-md     { padding: 11px 20px; }
.btn-wide   { padding: 11px 24px; }

.form-hint { font-size: 12px; color: var(--text-sec); margin-top: 10px; text-align: center; line-height: 1.5; }

.auth-divider       { display: flex; align-items: center; gap: 12px; margin: 20px 0; }
.auth-divider-rule  { flex: 1; height: 1px; background: var(--border); }
.auth-divider-label { font-size: 12px; color: var(--text-sec); text-transform: uppercase; letter-spacing: .05em; }

.consent-group { display: flex; flex-direction: column; gap: 10px; padding: 14px 0 2px; }
.consent-row   { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; line-height: 1.5; }

/* ---- Settings ---- */
.settings-card         { padding: 20px; margin-bottom: 18px; }
.settings-card--danger { padding: 20px; border-color: #FCA5A5; }
.danger-card           { padding: 24px; border-color: #FCA5A5; }

/* ---- List rows (task list, history) ---- */
.list-row          { padding: 12px 16px; display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.list-row-main     { flex: 1; min-width: 0; }
.list-row-title    { font-size: 14px; font-weight: 500; line-height: 1.3; margin-bottom: 3px; }
.list-row-meta     { font-size: 12px; color: var(--text-sec); display: flex; align-items: center; gap: 4px; }
.list-status       { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; background: var(--primary-light); color: var(--primary); }
.list-status--done { background: var(--success-light); color: var(--success); }
.list-chevron      { flex-shrink: 0; color: var(--text-sec); }
.list-empty        { color: var(--text-sec); }

.cefr-badge        { background: var(--primary-light); color: var(--primary); padding: 3px 10px; border-radius: 3px; font-size: 12px; font-weight: 600; letter-spacing: .02em; flex-shrink: 0; }
.cefr-badge--lock  { display: flex; align-items: center; gap: 4px; }

/* ---- Results ---- */
.cefr-card        { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 14px; }
.cefr-disc        { width: 52px; height: 52px; flex-shrink: 0; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px; font-weight: 700; }
.cefr-disc-label  { font-size: 15px; font-weight: 600; }
.cefr-disc-desc   { font-size: 12px; color: var(--text-sec); margin-top: 1px; }
.score-card       { padding: 18px; }
.score-card-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.score-list       { display: flex; flex-direction: column; gap: 14px; }
.score-row-head   { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.score-row-name   { font-weight: 500; }
.score-row-val    { color: var(--text-sec); font-weight: 500; }
.progress-fill--1 { background: var(--score1); }
.progress-fill--2 { background: var(--score2); }
.progress-fill--3 { background: var(--score3); }
.transcript-text  { font-size: 13px; line-height: 1.6; color: var(--text); }
.acc-item--standalone { margin-top: 6px; }
.attempts-list    { display: flex; flex-direction: column; gap: 6px; }
.attempt-row      { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border-light); }
.attempt-date     { font-size: 13px; color: var(--text-sec); }
.attempt-actions  { display: flex; align-items: center; gap: 8px; }
.attempt-badge    { background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; }
.attempt-link     { font-size: 12px; color: var(--primary); font-weight: 500; text-decoration: none; }
.attempt-current  { font-size: 12px; color: var(--text-sec); }
.results-actions  { display: flex; gap: 10px; margin-top: 18px; }
.results-action   { flex: 1; padding: 12px 16px; font-size: 14px; }

/* ---- Task detail (recorder) ---- */
.prompt-card    { padding: 16px 18px; }
.prompt-text    { font-size: 14px; line-height: 1.65; color: var(--text); margin: 0; }
.prompt-image   { width: 100%; border-radius: var(--radius); margin-top: 12px; }
.prompt-meta    { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-sec); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); }
.recorder-stack { display: flex; flex-direction: column; align-items: center; gap: 24px; }
.timer-ring     { position: relative; width: 156px; height: 156px; }
.timer-ring svg { display: block; }
.timer-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.timer-display  { font-size: 32px; font-weight: 700; letter-spacing: .04em; }
.timer-sub      { font-size: 11px; color: var(--text-sec); margin-top: 2px; }
.btn-record     { padding: 14px 32px; font-size: 15px; max-width: 260px; width: 100%; }
.spinner-text   { font-size: 13px; color: var(--text-sec); }

/* ---- Audio record page ---- */
.record-card    { padding: 28px 18px; margin-bottom: 14px; text-align: center; }
.record-timer   { font-size: 40px; font-weight: 700; letter-spacing: .04em; margin-bottom: 8px; }
.record-hint    { font-size: 13px; color: var(--text-sec); margin-bottom: 20px; }
.record-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.error-list     { padding-left: 18px; margin: 0; }

/* ---- Payment / pricing ---- */
.pricing-title    { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.pricing-subtitle { font-size: 13px; color: var(--text-sec); text-align: center; margin-bottom: 24px; }
.plan-grid        { align-items: start; }
.plan-card        { padding: 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.plan-card--featured { border-color: var(--primary); box-shadow: 0 8px 24px rgba(13,113,120,.12); }
.plan-badge       { display: inline-block; width: fit-content; background: var(--primary-light); color: var(--primary); padding: 3px 10px; border-radius: 3px; font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.plan-name        { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.plan-price       { font-size: 28px; font-weight: 700; line-height: 1.1; }
.plan-price-unit  { font-size: 13px; font-weight: 500; color: var(--text-sec); }
.plan-desc        { font-size: 13px; color: var(--text-sec); line-height: 1.5; }
.plan-features    { list-style: none; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.plan-feature     { display: flex; align-items: center; gap: 8px; font-size: 13px; }

/* ---- Billing success ---- */
.confirm-card  { max-width: 480px; margin: 48px auto; padding: 32px; text-align: center; }
.confirm-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }

/* ---- Pagination ---- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; font-size: 13px; }
