/* ==========================================================================
   Ranti — design tokens
   --------------------------------------------------------------------------
   Sampled from the approved mockups, per the Design Direction. Everything
   visual in the app resolves to a token here, so a change of mind about the
   palette is an edit to this block rather than a sweep through the views.

   THE SPINE OF THE SYSTEM: two surfaces.

     Light surface = the library. Home, sources, settings, stats, generation.
     Off-white ground, white cards, navy text. Calm and browsable.

     Dark surface = the act of recall. The review session, and the "cards due"
     hero on Home that launches it.

   Dark is a MODE SIGNAL, not a theme: going dark means you are now doing the
   thing. Never use the dark surface decoratively - if a screen is dark, the
   user is recalling or about to be.
   ========================================================================== */

@import url("../fonts/fonts.css");

:root {
    /* Brand ---------------------------------------------------------------- */
    --navy-900: #02153b;  /* dark surface, and primary text on light */
    --navy-950: #01112c;  /* review screen, the deepest ground in the app */
    --navy-800: #0a2050;
    --navy-700: #14306b;

    /* THE TWO-PRIMARIES RULE.
       Amber is the habit: review, keep a streak, start learning, add
       something new - the daily loop. Indigo is the system: sign up, save,
       generate, confirm - getting work done.
       One amber button per screen, maximum. Amber's job is to be what your eye
       lands on when the app opens; two of them means neither is. */
    --amber-500: #fcaf1c;
    --amber-600: #e09600;
    --amber-tint: #fef3e0;
    --amber-ink:  #7a4f00;

    --indigo-600: #3338de;
    --indigo-700: #2a2eb8;
    --indigo-400: #7980e9;

    /* Surfaces ------------------------------------------------------------- */
    --bg:              #fefefe;
    --surface:         #ffffff;
    --surface-sunken:  #f8f9fb;  /* inputs, inset areas, secondary rows */
    --border:          #e8eaf0;
    --border-dark:     #16295c;  /* hairlines on the dark surface */

    /* Ink ------------------------------------------------------------------ */
    --text:           #02153b;
    --text-secondary: #414a68;
    --text-muted:     #6b7280;
    --on-dark:        #ffffff;
    --on-dark-2:      #9aa6cf;

    /* Rating scale.
       The four ratings are an ORDERED scale, so the colours are ordered too:
       red -> amber -> green -> deep green. The sampled mockup used blue for
       Easy, which read as three steps of a scale and then an unrelated fourth
       - users misjudge which end is "best" on a control they press hundreds of
       times. Position and colour now agree, so "further right is better" needs
       no learning.

       Colour is never the only signal: every button keeps its label, and the
       order never changes. Roughly one man in twelve cannot separate the red
       from the green. */
    --again: #e5484d;
    --hard:  #fca512;
    --good:  #11af71;
    --easy:  #0a7a4e;

    /* Amber and the Hard button both fail contrast against white. Text on
       either is ALWAYS navy. This is a hard constraint, not a preference. */
    --on-amber: #02153b;

    /* Status --------------------------------------------------------------- */
    --safe:      #11af71;
    --safe-tint: #eaf7f1;
    --danger:      #e5484d;
    --danger-tint: #fdecec;

    /* Shape.
       20px cards, 14px buttons and inputs, 10px pills and tags, full round on
       chips and the FAB. The consistent roundness is doing a lot of the
       friendliness - do not sharpen it for "seriousness". */
    --r-tag: 10px;
    --r-md:  14px;
    --r-lg:  20px;
    --r-pill: 999px;

    /* ELEVATION IS ALMOST NONE. Cards are separated by fill and hairline, not
       shadow. The only real shadow in the system belongs to the FAB, because
       it genuinely floats above content. To make something stand out on a
       light surface, reach for --surface-sunken, not a shadow. */
    --shadow-fab: 0 4px 14px rgba(252, 175, 28, .42);
    /* Layers that genuinely float ABOVE content rather than sitting in
       it: the overflow menu and the toast. Same justification as the FAB.
       Not for making a card "pop". */
    --shadow-pop: 0 8px 28px rgba(2, 21, 59, .18);

    /* Spacing, on a 4px base. */
    --gutter: 20px;
    --pad-card: 20px;
    --gap-card: 12px;
    --gap-section: 28px;

    /* Type.
       Nunito is personality: the wordmark, big numbers, screen titles, the
       review question. Inter is the interface, and its job is to disappear.
       Never mix them arbitrarily - a paragraph does not suddenly go Nunito. */
    --font-display: "Nunito", "Segoe UI Variable Display", system-ui, -apple-system, sans-serif;
    --font-ui: "Inter", "Segoe UI Variable Text", system-ui, -apple-system, "Roboto", sans-serif;
}

/* Base ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    /* 17px body, slightly larger than typical, because most of the reading
       here happens one-handed on a phone. */
    font-family: var(--font-ui);
    font-size: 17px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Nunito is reserved for personality: titles, big numbers, the review
   question. Everything else is Inter. */
.display { font-family: var(--font-display); }

[hidden] { display: none !important; }

button {
    font: inherit;
    cursor: pointer;
    border: 0;
    background: none;
    color: inherit;
}

/* ==========================================================================
   S12 — Review session
   --------------------------------------------------------------------------
   Full-bleed, no tab bar, minimal chrome. Nothing may compete with the card.

   The front and revealed states are ONE screen and a state change, not a
   navigation. Elements belonging to only one state are removed from the
   render tree entirely in the other — never dimmed, never disabled. A
   present-but-inactive rating button causes the same failure as an active
   one, because the user starts choosing instead of recalling.
   ========================================================================== */

.session {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--navy-950);
    color: var(--on-dark);
    padding: max(14px, env(safe-area-inset-top)) var(--gutter)
             max(18px, env(safe-area-inset-bottom));
    overflow-y: auto;
}

/* Top chrome --------------------------------------------------------------- */

.session__bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 0 0 auto;
    padding: 4px 0 18px;
}

.session__exit,
.session__menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--on-dark-2);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 8px;
    border-radius: var(--r-tag);
    transition: color .15s ease, background .15s ease;
}

.session__exit:hover,
.session__menu-btn:hover {
    color: var(--on-dark);
    background: rgba(255, 255, 255, .08);
}

.session__progress {
    flex: 1 1 auto;
    height: 5px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .14);
    overflow: hidden;
}

.session__progress-fill {
    display: block;
    height: 100%;
    border-radius: var(--r-pill);
    background: var(--easy);
    transition: width .35s cubic-bezier(.4, 0, .2, 1);
}

.session__count {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 600;
    color: var(--on-dark-2);
    font-variant-numeric: tabular-nums;
}

/* The source context label. Present because it aids retrieval, but it must
   never compete with the question. */
.session__source {
    flex: 0 0 auto;
    text-align: center;
    font-size: 13px;
    color: var(--on-dark-2);
    letter-spacing: .01em;
    padding-bottom: 20px;
}

.session__source em { font-style: italic; }

/* The card ----------------------------------------------------------------- */

.session__stage {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
}

/* State A: the question, large and centred, generous whitespace. The whole
   card body is the affordance. */
.card {
    background: var(--surface);
    color: var(--text);
    border-radius: var(--r-lg);
    padding: 44px 28px;
    text-align: center;
    width: 100%;
    display: block;
    transition: transform .18s ease;
}

.card--tappable:active { transform: scale(.985); }

/* The review question is its own typographic case. It is the only thing on
   the screen and it should look like it knows that - it deliberately matches
   no other text anywhere in the app. */
.card__question {
    font-family: var(--font-display);
    font-size: clamp(24px, 5.4vw, 28px);
    font-weight: 600;
    line-height: 1.34;
    margin: 0;
    letter-spacing: -.01em;
}

.card__hint {
    margin: 22px 0 0;
    font-size: 14px;
    color: var(--text-muted);
}

/* State B: the front stays visible but de-emphasised, above the answer. */
.card__front-recap {
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .12);
    color: var(--on-dark);
    border-radius: var(--r-lg);
    padding: 14px 20px;
    text-align: center;
    font-size: 15px;
    font-weight: 550;
    line-height: 1.4;
}

.card__answer {
    font-size: clamp(19px, 4.6vw, 24px);
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
    letter-spacing: -.005em;
}

/* The reveal deserves a real transition, not a jump cut. */
.reveal-in {
    animation: reveal-in .26s cubic-bezier(.2, .7, .3, 1) both;
}

@keyframes reveal-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .reveal-in { animation: none; }
    .session__progress-fill { transition: none; }
}

/* Rating ------------------------------------------------------------------- */

.rating {
    flex: 0 0 auto;
    max-width: 560px;
    width: 100%;
    margin: 0 auto;
    padding-top: 22px;
}

.rating__prompt {
    text-align: center;
    font-size: 13px;
    color: var(--on-dark-2);
    margin: 0 0 12px;
}

.rating__row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 9px;
}

/* Four buttons, four words, once. No second set of labels anywhere. */
.rating__btn {
    border-radius: var(--r-pill);
    min-height: 52px;
    padding: 10px 4px;
    color: #fff;
    font-weight: 650;
    font-size: 15px;
    line-height: 1.1;
    text-align: center;
    transition: transform .12s ease, filter .12s ease;
}

.rating__btn:active { transform: translateY(1px) scale(.97); }
.rating__btn:disabled { filter: saturate(.5) brightness(.8); cursor: default; }

/* Ordered scale: red -> amber -> green -> deep green, left to right, so
   position and colour agree. Hard is amber and therefore takes navy text,
   by the same contrast rule that governs every amber surface. */
.rating__btn--again { background: var(--again); }
.rating__btn--hard  { background: var(--hard); color: var(--on-amber); }
.rating__btn--good  { background: var(--good); }
.rating__btn--easy  { background: var(--easy); }

/* The interval each answer buys, under its own button. */
.rating__interval {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    font-weight: 500;
    opacity: .82;
    font-variant-numeric: tabular-nums;
}

.session__aside {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
}

/* "Last rated Hard, 6 days ago" — low emphasis, and a scheduling debug
   surface as much as a user-facing line. */
.transparency {
    font-size: 12px;
    color: var(--on-dark-2);
    opacity: .78;
    margin: 0;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: var(--r-pill);
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 550;
    color: var(--on-dark);
    transition: background .15s ease;
}

.btn-ghost:hover { background: rgba(255, 255, 255, .09); }

/* Overflow menu ------------------------------------------------------------ */

.session__menu { position: relative; flex: 0 0 auto; }

.session__menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-pop);
    min-width: 176px;
    padding: 6px;
    z-index: 20;
}

.session__menu-list button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border-radius: var(--r-tag);
    font-size: 14.5px;
}

.session__menu-list button:hover { background: var(--surface-sunken); }
.session__menu-list button.is-danger { color: var(--again); }

/* Toast -------------------------------------------------------------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: var(--navy-800);
    color: var(--on-dark);
    border: 1px solid var(--border-dark);
    padding: 11px 18px;
    border-radius: var(--r-pill);
    font-size: 14px;
    box-shadow: var(--shadow-pop);
    z-index: 50;
}

/* ==========================================================================
   S14 — Session complete
   The emotional payoff, and the reason tomorrow happens.
   ========================================================================== */

.done {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 20px calc(32px + env(safe-area-inset-bottom));
    background: var(--bg);
}

.done__inner { width: 100%; max-width: 440px; }

.done__medal { font-size: 54px; line-height: 1; margin-bottom: 14px; }

.done__title {
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -.02em;
}

.done__sub { color: var(--text-secondary); margin: 0 0 22px; font-size: 15px; }

.streak-chip {
    font-family: var(--font-display);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--amber-tint);
    color: var(--amber-ink);
    border-radius: var(--r-pill);
    padding: 10px 18px;
    font-weight: 650;
    font-size: 16px;
}

.streak-chip--milestone {
    background: var(--amber-500);
    color: #fff;
    box-shadow: 0 6px 20px rgba(245, 165, 36, .4);
}

.done__panel {
    background: var(--surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    padding: 20px 18px;
    margin: 22px 0 18px;
}

.done__reviewed {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 2px;
}

.done__reviewed strong {
    font-family: var(--font-display);
    display: block;
    font-size: 34px;
    color: var(--text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

/* All four ratings, always. Again is the count of cards genuinely forgotten,
   the most diagnostic number here, and the reason tomorrow's queue looks the
   way it does — a breakdown that drops it under-reports the total. */
.breakdown {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 18px;
}

.breakdown__cell {
    background: var(--surface-sunken);
    border-radius: var(--r-md);
    padding: 10px 4px;
}

.breakdown__n {
    font-family: var(--font-display);
    display: block;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.breakdown__label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 1px;
}

.breakdown__cell--again .breakdown__n { color: var(--again); }
.breakdown__cell--hard  .breakdown__n { color: var(--hard); }
.breakdown__cell--good  .breakdown__n { color: var(--good); }
.breakdown__cell--easy  .breakdown__n { color: var(--easy); }

.done__next {
    font-size: 14.5px;
    color: var(--text-secondary);
    margin: 0 0 22px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 52px;
    border-radius: var(--r-md);
    padding: 15px 20px;
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: filter .14s ease, transform .12s ease, background .14s ease;
}

.btn:active { transform: translateY(1px); }

/* THE HABIT: review, keep the streak, start learning, add something new.
   Never white text - amber fails contrast against it, always. */
.btn--habit {
    background: var(--amber-500);
    color: var(--on-amber);
}

.btn--habit:hover { background: var(--amber-600); }

/* THE SYSTEM: sign up, save, generate, confirm. */
.btn--system {
    background: var(--indigo-600);
    color: #fff;
}

.btn--system:hover { background: var(--indigo-700); }

/* Secondary is a text link in indigo, not an outlined button - an outline
   competes with the primary for the same attention. */
.btn--quiet {
    background: none;
    color: var(--indigo-600);
    font-weight: 600;
}

/* Destructive is red text on a light red fill, never a solid red button.
   Deleting a source is irreversible and must not look like a normal action. */
.btn--danger {
    background: var(--danger-tint);
    color: var(--danger);
}

/* ==========================================================================
   S6 — Home
   --------------------------------------------------------------------------
   Answers one question in under a second: do I have anything to do right now?
   The CTA is unmissable and everything else visibly defers to it. Resist
   filling this screen.
   ========================================================================== */

.app {
    max-width: 480px;
    margin: 0 auto;
    padding: max(14px, env(safe-area-inset-top)) var(--gutter) 96px;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0 18px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--r-pill);
    padding: 7px 13px;
    font-size: 13.5px;
    font-weight: 600;
}

.chip--streak { background: var(--amber-tint); color: var(--amber-ink); }
.chip--safe   { background: var(--safe-tint);   color: #07794a; }
.chip--risk   { background: var(--surface);     color: var(--text-muted); border: 1px solid var(--border); }

.greeting {
    margin: 4px 0 18px;
}

.greeting h1 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0 0 3px;
}

.greeting p { margin: 0; color: var(--text-secondary); font-size: 14.5px; }

/* The primary card. Due count and one large CTA — nothing else. */
.hero {
    /* The one card allowed to be dark on a light screen: it is the doorway
       into recall mode, which is why it reads as the most important object
       here without needing to be the biggest. No border. */
    background: var(--navy-900);
    color: var(--on-dark);
    border-radius: var(--r-lg);
    padding: var(--pad-card);
}

.hero__label { font-size: 14px; color: var(--on-dark-2); margin: 0 0 6px; }

.hero__count {
    font-family: var(--font-display);
    font-size: 46px;
    font-weight: 750;
    line-height: 1;
    letter-spacing: -.03em;
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.hero__sub { font-size: 13.5px; color: var(--on-dark-2); margin: 6px 0 18px; }

/* Kept as an alias so the hero CTA reads as what it is at the call site. */
.btn--cta { background: var(--amber-500); color: var(--on-amber); width: 100%; }
.btn--cta:hover { background: var(--amber-600); }

/* Quieter than the CTA on purpose: new cards are a different promise, so the
   primary number stays honest. */
.panel {
    background: var(--surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    padding: 16px 18px;
    margin-top: 14px;
}

.panel__label { font-size: 13.5px; color: var(--text-secondary); margin: 0; }

.panel__count {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    margin: 2px 0 3px;
    font-variant-numeric: tabular-nums;
}

.panel__note { font-size: 12.5px; color: var(--text-muted); margin: 0; }

/* Generation status line (S10's state, surfaced here). */
.status {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--surface);
    border-left: 3px solid var(--indigo-600);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    padding: 13px 15px;
    margin-top: 14px;
    font-size: 13.5px;
    color: var(--text-secondary);
}

.status--deferred { border-left-color: var(--amber-500); }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin: var(--gap-section) 0 10px;
}

.section-head h2 {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 650;
    margin: 0;
}

.section-head a { font-size: 13.5px; color: var(--indigo-600); text-decoration: none; }

.source-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    padding: 13px 15px;
    margin-bottom: var(--gap-card);
    text-decoration: none;
    color: inherit;
}

.source-row__icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: var(--r-tag);
    background: var(--surface-sunken);
    display: grid;
    place-items: center;
    font-size: 18px;
}

.source-row__body { flex: 1 1 auto; min-width: 0; }

.source-row__title {
    font-weight: 620;
    font-size: 15px;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-row__meta { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 0; }

.tag {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 650;
    padding: 3px 8px;
    border-radius: var(--r-pill);
    background: var(--safe-tint);
    color: #07794a;
}

/* S15 — nothing due, rendered inline here rather than as its own page. The
   copy must distinguish "finished today" from "no cards at all". */
.empty {
    background: var(--surface);
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    padding: 30px 22px;
    text-align: center;
}

.empty__art { font-size: 42px; line-height: 1; margin-bottom: 10px; }

.empty h2 {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -.01em;
}

.empty p { color: var(--text-secondary); font-size: 14.5px; margin: 0 0 18px; }

/* Tab bar ------------------------------------------------------------------ */

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 30;
}

.tabbar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
}

.tabbar__item span:first-child { font-size: 18px; line-height: 1; }
.tabbar__item.is-active { color: var(--indigo-600); }

/* Destinations that do not exist yet are rendered but inert, so the bar does
   not promise a screen that is not built. They become links as they land. */
.tabbar__item[aria-disabled="true"] { opacity: .4; cursor: default; }

.tabbar__add {
    justify-self: center;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--amber-500);
    color: var(--on-amber);
    display: grid;
    place-items: center;
    font-size: 24px;
    line-height: 1;
    box-shadow: var(--shadow-fab);
}

/* ==========================================================================
   S7 / S9 — Ingestion
   ========================================================================== */

.sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0 18px;
}

.sheet-head h1 {
    font-family: var(--font-display);
    flex: 1 1 auto;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
}

.sheet-head__close {
    flex: 0 0 auto;
    font-size: 26px;
    line-height: 1;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0 4px;
}

.field { display: block; margin-bottom: 15px; }

.field__label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.field__req { color: var(--again); }

.field__input {
    width: 100%;
    font: inherit;
    font-size: 15.5px;
    color: var(--text);
    background: var(--surface-sunken);
    border: 1px solid transparent;
    border-radius: var(--r-md);
    padding: 14px;
    transition: border-color .14s ease, background .14s ease;
}

.field__input:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--indigo-600);
}

.field__input--area { resize: vertical; line-height: 1.55; min-height: 200px; }

.field__error { display: block; margin-top: 6px; font-size: 13px; color: var(--again); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Going over the part cap is a plan, not an error, so this stays neutral
   until the SOURCE cap is genuinely exceeded. */
/* The counter sits bottom-right of the field it belongs to and warms as it
   approaches the cap. It must NOT turn red before the cap is reached: over
   the PART cap means "this will be split", which is a plan, not an error.
   Red is reserved for the SOURCE cap, which is a real refusal. */
.counter {
    display: block;
    text-align: right;
    font-size: 13px;
    color: var(--text-muted);
    margin: -8px 0 4px;
    font-variant-numeric: tabular-nums;
}

.counter--near { color: var(--amber-ink); }
.counter--over { color: var(--danger); font-weight: 600; }

/* The split notice is a separate line from the count, because it says
   something different: not "how much" but "what happens next". */
.split-note {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin: 0 0 18px;
}

.split-note strong { color: var(--text); }

.notice {
    background: var(--amber-tint);
    color: var(--amber-ink);
    border-radius: var(--r-md);
    padding: 13px 15px;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.notice--plan {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.notice--plan strong { color: var(--text); }

.parts { list-style: none; margin: 0 0 16px; padding: 0; }

.part {
    background: var(--surface);
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    padding: 14px 15px;
    margin-bottom: 10px;
}

.part--done { opacity: .72; }

.part__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.part__index { font-weight: 650; font-size: 14.5px; }
.part__chars { font-size: 12.5px; color: var(--text-muted); }

.part__excerpt {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 6px 0 12px;
}

.part__state {
    display: inline-block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.part__state--busy { color: var(--indigo-600); }
.part__state--done { color: var(--safe); }

.btn--small { width: auto; padding: 9px 18px; font-size: 14px; }

.btn--small { min-height: 44px; }

.fineprint {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0 0 16px;
}

/* ==========================================================================
   Icons
   --------------------------------------------------------------------------
   One system, inlined as SVG. They inherit colour from their container, so an
   icon is never styled separately from the text it sits beside.
   ========================================================================== */

.icon {
    flex: 0 0 auto;
    vertical-align: -0.125em;
}

.icon--muted { color: var(--text-muted); }

/* Tab bar icons read stronger when active: the label changes colour and the
   stroke thickens, so the state does not depend on colour alone. */
.tabbar__item .icon { stroke-width: 1.9; }
.tabbar__item.is-active .icon { stroke-width: 2.4; }

/* The streak flame is the one filled glyph in the set. */
.chip--streak .icon { color: var(--amber-500); }

/* ==========================================================================
   Corrections applied with the design direction
   ========================================================================== */

/* Chips carry an icon now, so they need to align it. */
.chip { line-height: 1; }

/* The source row's tinted icon square is the ONE place in the system where
   colour is allowed to vary per item. Everything else is tokenised. */
.source-row__icon {
    background: var(--surface-sunken);
    color: var(--indigo-600);
}

.empty__art {
    color: var(--indigo-400);
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.done__medal {
    color: var(--amber-500);
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

/* Motion, per the direction: three moments, everything else 120-160ms.
   The reveal is a fade-and-lift - the front settles upward as the answer
   arrives - because it is the most-repeated interaction in the app and the
   one that most needs to feel like turning something over. */
.reveal-in { animation: reveal-in .18s cubic-bezier(.2, .7, .3, 1) both; }

/* Reduced motion degrades all three to instant state changes. The reveal is
   still a distinct STATE - it just arrives without transition. */
@media (prefers-reduced-motion: reduce) {
    .reveal-in { animation: none; }
    .session__progress-fill,
    .btn,
    .field__input { transition: none; }
}

/* Text scaling to 200% must not break the review card: it is the one screen
   where content length varies wildly, and truncation is unacceptable. The
   card scrolls rather than clipping. */
.session__stage { min-height: 0; }
.card { max-height: 100%; overflow-y: auto; }

.field__hint {
    font-weight: 400;
    color: var(--text-muted);
}

/* ==========================================================================
   Design details from the mockups
   ========================================================================== */

/* Source rows carry their counts, a "New cards" badge and a chevron. */
.source-row { gap: 10px; }

.source-row__icon { color: var(--indigo-600); }

/* The one place per-item colour is allowed. Derived from the source id so a
   source keeps the same tint on every render - a colour that changes on
   reload is noise rather than identity. */
.source-row__icon--1 { background: #efe9ff; color: #6d3fd4; }
.source-row__icon--2 { background: #fff0dc; color: #b3701a; }
.source-row__icon--3 { background: #e4efff; color: #2c62c4; }
.source-row__icon--4 { background: #e6f7ef; color: #0d8a5b; }
.source-row__icon--5 { background: #fde9ec; color: #c23b46; }

.tag {
    background: var(--safe-tint);
    color: #07794a;
    white-space: nowrap;
}

.section-head__inert { font-size: 13.5px; color: var(--text-muted); }

/* The add button overlaps the bar upward, as in the mockups - it is the
   primary creation action and should not sit level with navigation. */
.tabbar { overflow: visible; }

.tabbar__add {
    margin-top: -22px;
    border: 4px solid var(--surface);
    width: 52px;
    height: 52px;
}

/* ==========================================================================
   Illustrations
   --------------------------------------------------------------------------
   Extracted from the approved mockups. Confined to status, empty and
   completion states per the design direction - never inside the review
   session, never decorating a working screen.
   ========================================================================== */

.hero { position: relative; overflow: hidden; }

/* The mockup's hero has a radial bloom behind its illustration. Reproducing
   it in CSS rather than baking it into the PNG means the glow scales with the
   card instead of ending at the image's edge. */
.hero::after {
    content: "";
    position: absolute;
    right: -30px;
    top: -20px;
    width: 190px;
    height: 190px;
    background: radial-gradient(circle, rgba(63, 74, 214, .55) 0%, rgba(2, 21, 59, 0) 68%);
    pointer-events: none;
}

.hero__body { position: relative; z-index: 1; max-width: 62%; }

.hero__art {
    position: absolute;
    right: 14px;
    top: 26px;
    width: 112px;
    z-index: 1;
    pointer-events: none;
}

.panel { position: relative; overflow: hidden; }
.panel__body { max-width: 68%; }

.panel__art {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 70px;
}

/* The empty state's soft blue ground, as in the mockup - the illustration
   sits in light rather than on flat white. */
.empty {
    background:
        radial-gradient(120% 90% at 50% 92%, #dbe7fb 0%, rgba(219, 231, 251, 0) 62%),
        var(--surface);
}

.empty__art img { width: 132px; height: auto; }

/* ==========================================================================
   S14 on the dark surface
   --------------------------------------------------------------------------
   Both mockups put session-complete on navy, and it is right: the user
   arrives here straight out of the review session, and flashing to a white
   screen at the moment of payoff breaks the mode they were just in.
   ========================================================================== */

.done {
    background: var(--navy-950);
    color: var(--on-dark);
}

.done__title { color: var(--on-dark); }
.done__sub { color: var(--on-dark-2); }
.done__next { color: var(--on-dark-2); }

.done__panel {
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .10);
}

.done__reviewed { color: var(--on-dark-2); }
.done__reviewed strong { color: var(--on-dark); }

.breakdown__cell { background: rgba(255, 255, 255, .07); }
.breakdown__label { color: var(--on-dark-2); }

.done .btn--quiet { color: var(--on-dark-2); }
.done__medal img { width: 56px; height: auto; }

.status__art { width: 30px; height: auto; flex: 0 0 auto; }

/* --- S14 celebration ------------------------------------------------------ */

.done { position: relative; overflow: hidden; }

.streak-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.streak-chip--milestone {
    background: var(--amber-500);
    color: var(--on-amber);
}

/* "+1 today" only appears when the streak genuinely advanced today. */
.streak-plus {
    font-size: 13px;
    font-weight: 700;
    color: var(--amber-500);
    background: rgba(252, 175, 28, .14);
    border-radius: var(--r-pill);
    padding: 6px 11px;
}

.next-card {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .10);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    margin: 0 0 18px;
}

.next-card__art { width: 42px; height: auto; flex: 0 0 auto; }
.next-card__label { font-size: 12.5px; color: var(--on-dark-2); margin: 0; }

.next-card__value {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
    margin: 1px 0 2px;
}

.next-card__note { font-size: 12.5px; color: var(--on-dark-2); margin: 0; }

.btn--outline-dark {
    border: 1px solid rgba(255, 255, 255, .22);
    color: var(--on-dark);
    background: none;
}

.btn--outline-dark:hover { background: rgba(255, 255, 255, .07); }

/* Confetti: one pass, then gone. Each piece takes its own column, delay and
   tint from its index, so twelve elements need no per-piece styles. */
.confetti {
    position: absolute;
    inset: 0 0 auto 0;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti i {
    position: absolute;
    top: -14px;
    left: calc(var(--i) * 8.5% + 3%);
    width: 8px;
    height: 13px;
    border-radius: 2px;
    opacity: 0;
    background: var(--amber-500);
    animation: confetti-fall 2.4s cubic-bezier(.25, .6, .4, 1) forwards;
    animation-delay: calc(var(--i) * 90ms);
}

.confetti i:nth-child(3n)   { background: var(--indigo-400); width: 7px; height: 7px; border-radius: 50%; }
.confetti i:nth-child(3n+1) { background: var(--good); }
.confetti i:nth-child(4n)   { background: #ffffff; opacity: 0; }

@keyframes confetti-fall {
    0%   { transform: translateY(0) rotate(0deg); opacity: 0; }
    12%  { opacity: 1; }
    100% { transform: translateY(78vh) rotate(520deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .confetti { display: none; }
}

/* --- S9 split confirmation ------------------------------------------------ */

.plan {
    background: var(--amber-tint);
    border-radius: var(--r-md);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.plan__line {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    font-size: 14px;
    line-height: 1.5;
    color: var(--amber-ink);
    margin: 0 0 8px;
}

.plan__line:last-child { margin-bottom: 0; }
.plan__line strong { color: #6b3f00; }
.plan__line .icon { margin-top: 2px; }

.parts { list-style: none; margin: 0 0 16px; padding: 0; }

/* The row is the label, so the whole thing is the tap target - 44px minimum
   matters most on the screens people use one-handed. */
.part {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color .14s ease, background .14s ease;
}

.part:has(.part__radio:checked) {
    border-color: var(--indigo-600);
    background: #f7f8ff;
}

.part--locked { opacity: .62; cursor: default; }

.part__radio {
    appearance: none;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    transition: border-color .14s ease, box-shadow .14s ease;
}

.part__radio:checked {
    border-color: var(--indigo-600);
    box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 12px var(--indigo-600);
}

.part__radio--locked { border-style: dashed; }

.part__body { flex: 1 1 auto; min-width: 0; }

.part__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.part__index { font-weight: 650; font-size: 14.5px; }
.part__chars { font-size: 12.5px; color: var(--text-muted); }

.part__excerpt {
    display: block;
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-top: 4px;
}

.part__state { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.part__state--busy { color: var(--indigo-600); }
.part__state--done { color: var(--safe); }

/* Auth (S2-S5) ============================================================
   The public surface. Light, per the two-surface doctrine - dark means the
   user is recalling, and nobody signing up has recalled anything yet.

   One column, capped narrow, vertically centred on tall screens and top
   aligned on short ones. A form that jumps when the keyboard opens is the
   most common way these screens go wrong on a phone.
   ========================================================================= */

.auth {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 18px;
    padding: 32px var(--gutter) calc(32px + env(safe-area-inset-bottom));
}

@media (max-height: 720px) {
    .auth { justify-content: flex-start; }
}

.auth__brand { display: block; line-height: 0; }
.auth__brand img { width: 184px; height: auto; }

.auth__card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--pad-card);
}

.auth__art { text-align: center; margin-bottom: 4px; }
.auth__art img { width: 120px; height: auto; }

.auth__title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.015em;
    margin: 0 0 6px;
}

.auth__lede {
    color: var(--text-secondary);
    font-size: 14.5px;
    margin: 0 0 20px;
}

.auth__lede strong { color: var(--text); font-weight: 600; }

/* The switch to the other screen. Outside the card, because it is a change of
   destination rather than part of the form. */
.auth__alt {
    font-size: 14.5px;
    color: var(--text-secondary);
    text-align: center;
    margin: 0;
}

.auth__aside {
    font-size: 14px;
    text-align: center;
    margin: 14px 0 0;
}

.auth__alt a,
.auth__aside a { color: var(--indigo-600); font-weight: 600; text-decoration: none; }
.auth__alt a:hover,
.auth__aside a:hover { text-decoration: underline; }

.auth__aside a.is-waiting {
    color: var(--text-muted);
    font-weight: 500;
    cursor: default;
    text-decoration: none;
}

/* Why the friction exists. Sunken rather than bordered - it is context, and a
   second bordered box would read as a second thing to do. */
.auth__why {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    background: var(--surface-sunken);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin: 18px 0 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
}

.auth__why .icon { flex: 0 0 auto; color: var(--indigo-600); margin-top: 1px; }

/* Form pieces shared with the rest of the app ============================= */

.field__wrap { position: relative; display: block; }
.field__wrap .field__input { padding-right: 46px; }

.field__reveal {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 0;
    padding: 0;
    color: var(--text-muted);
    cursor: pointer;
}

.field__reveal:hover { color: var(--text-secondary); }
.field__reveal .field__eye-off { display: none; }
.field__reveal.is-shown .field__eye-on { display: none; }
.field__reveal.is-shown .field__eye-off { display: inline; }

.field__input--bad,
.field__input--bad:focus { border-color: var(--danger); }

/* The six-digit code. Wide tracking and a tabular face, because the job is
   reading a code back off another screen without losing your place. */
.field__input--code {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: .34em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.check {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 14.5px;
    color: var(--text-secondary);
    margin: 0 0 18px;
    cursor: pointer;
}

.check input {
    width: 18px;
    height: 18px;
    accent-color: var(--indigo-600);
    margin: 0;
}

/* Alerts. Inline within the card, above the fields, because a message that
   sits below the submit button is a message nobody reads. */
.alert {
    display: flex;
    gap: 9px;
    align-items: flex-start;
    border-radius: var(--r-md);
    padding: 11px 13px;
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.45;
}

.alert .icon { flex: 0 0 auto; margin-top: 1px; }
.alert--error { background: var(--danger-tint); color: #9b1c21; }
.alert--ok    { background: var(--safe-tint);   color: #07794a; }

/* ==========================================================================
   S10 — Generation status
   --------------------------------------------------------------------------
   Pending/running reuses .done's full-screen dark layout - same immersive
   feel as the review session it is standing in for. Quota-deferred and
   failed are calm, light informational screens instead: nothing has gone
   wrong on those, so nothing here should look like the review session.
   ========================================================================== */

.spinner {
    width: 46px;
    height: 46px;
    margin: 0 auto 22px;
    border: 3px solid rgba(255, 255, 255, .16);
    border-top-color: var(--indigo-400);
    border-radius: 50%;
    animation: spinner-spin .85s linear infinite;
}

@keyframes spinner-spin { to { transform: rotate(360deg); } }

.status-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-icon--deferred { background: var(--amber-tint); color: var(--amber-ink); }
.status-icon--failed   { background: var(--danger-tint); color: var(--danger); }

.status-detail {
    background: var(--danger-tint);
    color: #9b1c21;
    border-radius: var(--r-md);
    padding: 12px 14px;
    font-size: 13.5px;
    line-height: 1.5;
    margin: 4px 0 22px;
    text-align: left;
}

/* ==========================================================================
   S11 — Generated cards review
   --------------------------------------------------------------------------
   A reveal, not a form: dense rows that are satisfying to scan, each with a
   quiet edit/delete pair that never competes with the primary CTA.
   ========================================================================== */

.reveal-list { list-style: none; margin: 0 0 20px; padding: 0; }

.reveal-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 14px;
    margin-bottom: 10px;
}

.reveal-item__front {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
}

.reveal-item__actions { display: flex; gap: 4px; flex: 0 0 auto; }

.reveal-item__icon-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-tag);
    color: var(--text-muted);
    background: none;
}

.reveal-item__icon-btn:hover { background: var(--surface-sunken); color: var(--text); }
.reveal-item__icon-btn--danger:hover { background: var(--danger-tint); color: var(--danger); }

/* ==========================================================================
   S18 — Card editor (modal)
   ========================================================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(2, 21, 59, .45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 60;
}

.modal {
    width: 100%;
    max-width: 480px;
    max-height: 88dvh;
    overflow-y: auto;
    background: var(--surface);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 18px var(--gutter) calc(22px + env(safe-area-inset-bottom));
}

@media (min-width: 540px) {
    .modal-overlay { align-items: center; }
    .modal { border-radius: var(--r-lg); max-height: 80dvh; }
}

.modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal__head h2 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.modal__close {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-muted);
}

.modal__close:hover { background: var(--surface-sunken); }

.modal__save {
    background: none;
    color: var(--indigo-600);
    font-weight: 650;
    font-size: 15px;
    padding: 6px 4px;
}
