/* Talio design tokens.
 *
 * The default is Slate & Basil: a blue-grey ground with a fresh green.
 * palettes.css holds this same set under [data-palette="slate"] and three
 * alternatives; the two copies of slate must move together, and a test
 * pins that they do.
 *
 * The one hard rule: colour never carries meaning alone. Every authority
 * level has a shape or a label as well as a hue, because the person reading
 * this is walking, holding a phone in one hand, in bad supermarket lighting.
 */

:root {
  color-scheme: light;

  --paper:        #f7f9fa;
  --surface:      #ffffff;
  --surface-2:    #eef2f5;
  --surface-3:    #e0e7ec;

  --ink:          #1e262b;
  --ink-2:        #4a565e;
  --muted:        #667179;
  --line:         #dde5ea;
  --line-strong:  #8c949a;

  /* Text on a filled button. Not a constant across palettes. */
  --on-primary:   #ffffff;
  --on-accent:    #161412;

  /* Each hue twice: the fill, and the same hue darkened enough to read as
     12px type on paper, on surface, and on its own -soft background. Text
     rules use -ink; fills use the base. See palettes.css. */
  --primary:        #2e7d5b;
  --primary-ink:    #2b7656;
  --primary-soft:   #e0f0e8;
  --accent:         #d1584a;
  --accent-ink:     #ae493e;
  --accent-soft:    #fbe8e5;
  --warn:           #b07a10;
  --warn-ink:       #90640d;
  --warn-soft:      #f8f0dc;
  --maybe:          #6a63a8;
  --maybe-ink:      #665fa1;
  --maybe-soft:     #eaeaf6;
  --meal:           #2b6a9c;
  --meal-ink:       #2b6a9c;
  --meal-soft:      #e3eff7;

  --radius:       14px;
  --radius-sm:    9px;
  --radius-lg:    22px;

  --shadow-sm:    0 1px 2px rgba(43, 39, 36, .06), 0 1px 3px rgba(43, 39, 36, .04);
  --shadow:       0 2px 8px rgba(43, 39, 36, .07), 0 8px 24px rgba(43, 39, 36, .05);
  --shadow-lg:    0 8px 32px rgba(43, 39, 36, .14);

  --sans: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
          "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;

  --nav-h: 4.25rem;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --paper:        #0f1518;
    --surface:      #161e22;
    --surface-2:    #1f292e;
    --surface-3:    #2b373d;

    --ink:          #eaf1f4;
    --ink-2:        #b9c7cf;
    --muted:        #86959e;
    --line:         #2b373d;
    --line-strong:  #5f6b72;

    --on-primary:   #06180f;
    --on-accent:    #161412;

    --primary:        #63c295;
    --primary-ink:    #63c295;
    --primary-soft:   #143024;
    --accent:         #f0806f;
    --accent-ink:     #f0806f;
    --accent-soft:    #3a1f1b;
    --warn:           #e0b95e;
    --warn-ink:       #e0b95e;
    --warn-soft:      #332c15;
    --maybe:          #9a92e0;
    --maybe-ink:      #9a92e0;
    --maybe-soft:     #22203c;
    --meal:           #6bb0e0;
    --meal-ink:       #6bb0e0;
    --meal-soft:      #16283a;

    --shadow-sm:    0 1px 2px rgba(0, 0, 0, .35);
    --shadow:       0 2px 10px rgba(0, 0, 0, .4);
    --shadow-lg:    0 10px 36px rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0f1518; --surface: #161e22; --surface-2: #1f292e; --surface-3: #2b373d;
  --ink: #eaf1f4; --ink-2: #b9c7cf; --muted: #86959e;
  --line: #2b373d; --line-strong: #5f6b72;
  --on-primary: #06180f; --on-accent: #161412;
  --primary: #63c295; --primary-ink: #63c295; --primary-soft: #143024;
  --accent: #f0806f; --accent-ink: #f0806f; --accent-soft: #3a1f1b;
  --warn: #e0b95e; --warn-ink: #e0b95e; --warn-soft: #332c15;
  --maybe: #9a92e0; --maybe-ink: #9a92e0; --maybe-soft: #22203c;
  --meal: #6bb0e0; --meal-ink: #6bb0e0; --meal-soft: #16283a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow: 0 2px 10px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 36px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -.015em; }

/* --------------------------------------------------------------------- */
/* Shell                                                                  */
/* --------------------------------------------------------------------- */

#app {
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 1rem);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem .7rem;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}

.topbar--scrolled { border-bottom-color: var(--line); }

.topbar__title {
  flex: 1;
  min-width: 0;
  font-size: 1.35rem;
  font-weight: 680;
  letter-spacing: -.02em;
}

.topbar__sub {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.view { padding: 0 1rem; max-width: 44rem; margin: 0 auto; }

/* --------------------------------------------------------------------- */
/* Bottom navigation                                                      */
/* --------------------------------------------------------------------- */

.nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: .15rem;
  padding: .4rem .4rem calc(.4rem + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}

.nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .18rem;
  padding: .45rem .2rem .35rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 560;
  letter-spacing: .01em;
  cursor: pointer;
  transition: color .15s, background .15s;
}

.nav__item svg { width: 23px; height: 23px; }
.nav__item:hover { color: var(--ink-2); }

.nav__item--on {
  color: var(--primary-ink);
  background: var(--primary-soft);
}

.nav__badge {
  position: absolute;
  transform: translate(.85rem, -.4rem);
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 .28rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: .63rem;
  font-weight: 700;
  line-height: 1.05rem;
  text-align: center;
}

/* --------------------------------------------------------------------- */
/* Buttons                                                                */
/* --------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .62rem 1.05rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s;
}

.btn:active { transform: scale(.97); }
.btn svg { width: 17px; height: 17px; }

/* Contrast against --primary is not a constant across four palettes, so the
   text colour is a token each one sets rather than a hardcoded white. Light
   palettes use a dark primary and white text; dark palettes lighten the
   primary and flip the text to near-black. */
.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn--sm { padding: .4rem .75rem; font-size: .82rem; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }

.iconbtn {
  display: inline-grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.iconbtn:active { transform: scale(.94); }
.iconbtn:hover { background: var(--surface-3); }
.iconbtn svg { width: 19px; height: 19px; }

/* --------------------------------------------------------------------- */
/* Quick add                                                              */
/* --------------------------------------------------------------------- */

.quickadd {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin: .25rem 0 1rem;
  padding: .3rem .3rem .3rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}

.quickadd:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.quickadd input {
  flex: 1;
  min-width: 0;
  padding: .55rem 0;
  border: 0;
  background: none;
  outline: none;
  font-size: 1rem;
}

.quickadd input::placeholder { color: var(--muted); }

/* --------------------------------------------------------------------- */
/* Aisle groups and items                                                 */
/* --------------------------------------------------------------------- */

.aisle { margin-bottom: 1.35rem; }

.aisle__head {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  margin: 0 .25rem .5rem;
}

.aisle__name {
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

.aisle__count {
  font-size: .74rem;
  font-weight: 600;
  /* Was --line-strong, which is a border colour and read at 1.6:1 -- all but
     invisible. "3 left" is information, not decoration. */
  color: var(--muted);
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--line);
  transition: background .15s, opacity .2s;
}

.item:last-child { border-bottom: 0; }
.item:hover { background: var(--surface-2); }
.item--bought { opacity: .42; }
.item--bought .item__name { text-decoration: line-through; }

.check {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.55rem;
  height: 1.55rem;
  margin-top: .1rem;
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  background: none;
  color: transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}

.check:active { transform: scale(.88); }
.check svg { width: 13px; height: 13px; }

.check--on {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.item__body { flex: 1; min-width: 0; }

.item__line {
  display: flex;
  align-items: baseline;
  gap: .45rem;
  flex-wrap: wrap;
}

.item__name {
  font-size: 1rem;
  font-weight: 560;
  letter-spacing: -.005em;
}

.item__qty {
  font-size: .84rem;
  font-weight: 640;
  color: var(--primary-ink);
  font-variant-numeric: tabular-nums;
}

/* The quiet intelligence lives on this line. Brand memory, pantry doubt and
 * repeat asks are all annotations -- never dialogs, never blocking. */
.item__hints {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .12rem;
  font-size: .78rem;
  color: var(--muted);
}

.hint { display: inline-flex; align-items: center; gap: .22rem; }
.hint svg { width: 12px; height: 12px; opacity: .75; }
.hint--brand { color: var(--meal-ink); font-weight: 560; }
.hint--pantry { color: var(--warn-ink); }
.hint--repeat { color: var(--accent-ink); font-weight: 560; }

.who {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .76rem;
  font-weight: 560;
  color: var(--muted);
}

.who__dot {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: currentColor;
}

/* Authority level. A left rule, not a background wash -- it survives dark
 * mode, bad screens and colour blindness better, and it does not fight the
 * check circle for attention. */
.item--recipe     { box-shadow: inset 3px 0 0 var(--meal); }
.item--commitment { box-shadow: inset 3px 0 0 var(--primary); }
.item--staple     { box-shadow: inset 3px 0 0 var(--warn); }
.item--suggestion { box-shadow: inset 3px 0 0 var(--maybe); }

.tag {
  display: inline-flex;
  align-items: center;
  padding: .1rem .42rem;
  border-radius: 5px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.tag--recipe     { background: var(--meal-soft); color: var(--meal-ink); }
.tag--staple     { background: var(--warn-soft); color: var(--warn-ink); }
.tag--suggestion { background: var(--maybe-soft); color: var(--maybe-ink); }

/* --------------------------------------------------------------------- */
/* Cards, sections, empty states                                          */
/* --------------------------------------------------------------------- */

.card {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.section { margin: 1.6rem 0; }

.section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  margin: 0 .25rem .6rem;
}

.section__title { font-size: 1.02rem; font-weight: 660; }

.section__note {
  font-size: .8rem;
  color: var(--muted);
  margin: -.3rem .25rem .6rem;
}

.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.empty svg { width: 46px; height: 46px; opacity: .3; margin-bottom: .85rem; }
.empty h3 { font-size: 1.08rem; color: var(--ink-2); margin-bottom: .3rem; }
.empty p { margin: 0 0 1.1rem; font-size: .9rem; }

/* --------------------------------------------------------------------- */
/* Progress                                                               */
/* --------------------------------------------------------------------- */

.progress {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin: 0 .25rem 1.1rem;
}

.progress__track {
  flex: 1;
  height: .42rem;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}

.progress__label {
  font-size: .78rem;
  font-weight: 640;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------- */
/* Recipe cards                                                           */
/* --------------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: .8rem;
}

.rcard {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform .12s, box-shadow .18s;
}

.rcard:active { transform: scale(.985); }
.rcard:hover { box-shadow: var(--shadow); }

.rcard__img {
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.rcard__img svg { width: 32px; height: 32px; }
.rcard__body { padding: .6rem .7rem .75rem; }

.rcard__title {
  font-size: .92rem;
  font-weight: 620;
  line-height: 1.25;
  letter-spacing: -.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rcard__meta {
  margin-top: .3rem;
  font-size: .75rem;
  color: var(--muted);
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* The pantry payoff: "4 of 6 on hand" on a recipe card. */
.coverage {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .73rem;
  font-weight: 620;
  color: var(--primary-ink);
}

.coverage--partial { color: var(--warn-ink); }
.coverage--none { color: var(--muted); }

/* --------------------------------------------------------------------- */
/* Recipe detail                                                          */
/* --------------------------------------------------------------------- */

.hero {
  margin: 0 -1rem 1rem;
  aspect-ratio: 16 / 10;
  background: var(--surface-3);
  background-size: cover;
  background-position: center;
}

.recipe__title {
  font-family: var(--serif);
  font-size: 1.9rem;
  line-height: 1.15;
  letter-spacing: -.02em;
  margin-bottom: .4rem;
}

.recipe__meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .84rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.ing {
  display: flex;
  gap: .7rem;
  padding: .5rem .2rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.ing:last-child { border-bottom: 0; }
.ing--on { opacity: .4; text-decoration: line-through; }
.ing__qty { flex: none; min-width: 4.6rem; font-weight: 640; color: var(--primary-ink); font-variant-numeric: tabular-nums; }
.ing__note { color: var(--muted); font-size: .86rem; }

.step {
  display: flex;
  gap: .85rem;
  padding: .8rem 0;
  border-bottom: 1px solid var(--line);
}

.step__n {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: .8rem;
  font-weight: 700;
}

.scaler {
  display: inline-flex;
  align-items: center;
  gap: .1rem;
  padding: .2rem;
  background: var(--surface-2);
  border-radius: 999px;
}

.scaler button {
  width: 1.9rem; height: 1.9rem;
  border: 0; border-radius: 50%;
  background: none; color: var(--ink-2);
  font-size: 1.05rem; font-weight: 600; cursor: pointer;
}

.scaler button:hover { background: var(--surface-3); }
.scaler span { min-width: 3.4rem; text-align: center; font-size: .85rem; font-weight: 640; }

/* --------------------------------------------------------------------- */
/* Cook mode                                                              */
/* --------------------------------------------------------------------- */

/* A different register from the rest of the app on purpose: full bleed, no
 * bottom nav, and type sized to be read at arm's length across a counter
 * rather than held six inches from your face. */

.cook {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  padding-bottom: var(--safe-b);
}

.cook__bar {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .7rem .8rem;
  border-bottom: 1px solid var(--line);
}

.cook__pips {
  flex: 1;
  display: flex;
  gap: .25rem;
  align-items: center;
  min-width: 0;
}

.pip {
  flex: 1;
  height: .3rem;
  min-width: .35rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface-3);
  cursor: pointer;
  transition: background .2s;
}

.pip--done { background: var(--primary-soft); }
.pip--on { background: var(--primary); }

.cook__count {
  font-size: .8rem;
  font-weight: 660;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cook__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.6rem 1.4rem 2rem;
  max-width: 40rem;
  width: 100%;
  margin: 0 auto;
}

.cook__section {
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--primary-ink);
  margin-bottom: .9rem;
}

/* The ingredients this step actually uses, above the instruction. This is
 * the whole reason cook mode beats scrolling a recipe. */
.cook__uses {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: .85rem 1rem;
  background: var(--primary-soft);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.1rem;
}

.cook__uses li {
  font-size: .95rem;
  font-weight: 580;
  color: var(--primary-ink);
}

.cook__text {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 5.5vw, 2.1rem);
  line-height: 1.35;
  letter-spacing: -.015em;
}

.cook__timers {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 2rem;
}

.timer {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 2.9rem;
  padding: .55rem .9rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  overflow: hidden;
}

.timer__face {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  padding: 0;
}

.timer__x {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  margin-left: .15rem;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
}

.timer__track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: .2rem;
  background: transparent;
}

.timer__fill {
  height: 100%;
  background: var(--primary);
  transition: width 1s linear;
}

.timer--running { border-color: var(--primary); color: var(--primary-ink); }
.timer--paused { opacity: .7; }

.timer--done {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
  animation: nudge .6s ease 3;
}

.timer--done .timer__fill { background: var(--accent); }

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.cook__nav {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: .6rem;
  padding: .8rem 1rem calc(.8rem + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.cook__nav .btn { min-height: 3.1rem; font-size: 1rem; }

/* --------------------------------------------------------------------- */
/* Pantry                                                                 */
/* --------------------------------------------------------------------- */

.level {
  display: inline-flex;
  padding: .15rem .5rem;
  border-radius: 6px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.level--plenty { background: var(--primary-soft); color: var(--primary-ink); }
.level--low    { background: var(--warn-soft); color: var(--warn-ink); }
.level--out    { background: var(--accent-soft); color: var(--accent-ink); }

/* Confidence is rendered as fade, not as a number. A three-week-old baseline
 * should *look* like a three-week-old baseline. */
.conf--fresh  { opacity: 1; }
.conf--fading { opacity: .72; }
.conf--stale  { opacity: .45; }

.seg {
  display: inline-flex;
  padding: .18rem;
  background: var(--surface-2);
  border-radius: 999px;
}

.seg button {
  padding: .32rem .7rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------- */
/* Palette picker                                                          */
/* --------------------------------------------------------------------- */

.pal {
  display: flex;
  align-items: center;
  gap: .85rem;
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}

.pal:active { transform: scale(.99); }
.pal--on { border-color: var(--primary); }

/* The swatch paints itself with the palette's own paper and line colours, so
   each row previews the whole thing rather than three dots floating on the
   background of whichever palette happens to be on. */
.pal__chips {
  flex: none;
  display: flex;
  gap: .22rem;
  padding: .4rem .45rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

.pal__chip {
  width: .95rem;
  height: 1.5rem;
  border-radius: 3px;
  background: var(--surface-3);
}

.pal__text { flex: 1; min-width: 0; }
.pal__name { display: block; font-weight: 620; font-size: .95rem; }

.pal__blurb {
  display: block;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.3;
}

.pal__tick { flex: none; color: var(--primary-ink); display: grid; place-items: center; }

/* --------------------------------------------------------------------- */
/* Sheets, toasts, forms                                                  */
/* --------------------------------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(30, 26, 22, .45);
  backdrop-filter: blur(3px);
  animation: fade .18s ease;
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 91;
  max-height: 86dvh;
  overflow-y: auto;
  padding: 1rem 1rem calc(1.4rem + var(--safe-b));
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  animation: rise .26s cubic-bezier(.22, 1, .36, 1);
}

.sheet__grip {
  width: 2.4rem; height: .26rem;
  margin: 0 auto .9rem;
  border-radius: 999px;
  background: var(--line-strong);
}

.sheet__title { font-size: 1.15rem; font-weight: 660; margin-bottom: .2rem; }
.sheet__sub { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 1rem);
  z-index: 95;
  transform: translateX(-50%);
  max-width: calc(100vw - 2rem);
  padding: .65rem 1.1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-size: .87rem;
  font-weight: 560;
  box-shadow: var(--shadow-lg);
  animation: rise .22s cubic-bezier(.22, 1, .36, 1);
}

.field { margin-bottom: .9rem; }

.field label {
  display: block;
  margin-bottom: .3rem;
  font-size: .78rem;
  font-weight: 640;
  color: var(--muted);
  letter-spacing: .02em;
}

.field input, .field textarea, .field select {
  width: 100%;
  padding: .62rem .8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
.row { display: flex; gap: .6rem; }
.row > * { flex: 1; }

/* --------------------------------------------------------------------- */
/* Sign in                                                                */
/* --------------------------------------------------------------------- */

.signin {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 2rem 1.25rem;
}

.signin__inner { width: 100%; max-width: 22rem; text-align: center; }

.signin__mark {
  font-family: var(--serif);
  font-size: 2.5rem;
  letter-spacing: -.03em;
  margin-bottom: .2rem;
}

.signin__tag { color: var(--muted); font-size: .9rem; margin-bottom: 2rem; }

.people {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr));
  gap: .7rem;
  margin-bottom: 1.2rem;
}

.person {
  padding: 1rem .6rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}

.person:active { transform: scale(.97); }
.person[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); }
.person__emoji { font-size: 1.7rem; line-height: 1; }
.person__name { margin-top: .35rem; font-size: .85rem; font-weight: 620; }

.pin {
  width: 100%;
  padding: .8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 1.4rem;
  letter-spacing: .5em;
  text-align: center;
  outline: none;
}

.pin:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* --------------------------------------------------------------------- */
/* Utility                                                                */
/* --------------------------------------------------------------------- */

.offline {
  padding: .45rem 1rem;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: .8rem;
  font-weight: 620;
  text-align: center;
}

.muted { color: var(--muted); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.stack { display: flex; flex-direction: column; gap: .55rem; }
.wrap { display: flex; gap: .5rem; flex-wrap: wrap; }
.center { text-align: center; }
.hidden { display: none !important; }

.spin {
  width: 1.1rem; height: 1.1rem;
  border: 2px solid var(--line-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
