/* Pantry Palettes: one riso-printed cupboard, front on. Riso blue (--ak-accent) carries lines,
   edges and lettering; sunflower (--ak-accent-2) carries shelf paper and the caption ribbon.
   Every blue edge has a thin sunflower ghost a hair out of register. */

:root {
  --blue: var(--ak-accent);
  --sun: var(--ak-accent-2);
  --ink: var(--ak-ink);
  --ghost: 3px 3px 0 var(--sun);
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --lid: max(44px, min(13.5dvw, 6.6dvh, 62px));
  --jar: max(48px, min(15.5dvw, 8.2dvh, 92px));
  --jar-s: max(44px, min(12dvw, 6.6dvh, 66px));
  --tab-h: 50px;
  --paper-sun: color-mix(in srgb, var(--sun) 72%, #fff);
  --c-background: #FFF6D8;
  --c-surface: #FFD166;
  --c-main: #F4A259;
  --c-accent: #5B8E7D;
  --c-text: #2E2A24;
}

* { box-sizing: border-box; }

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

body {
  overflow: hidden;
  background-color: var(--ak-bg);
  background-image: var(--ak-bg-art), var(--ak-backdrop-layer, none);
  background-size: var(--ak-bg-size), cover;
  background-position: 0 0, center;
  color: var(--ink);
  font-family: var(--ak-font-body);
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---- the cupboard frame ---- */

.door {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 1;
  width: 8px;
  background: var(--sun);
  border-inline: 2px solid var(--blue);
  pointer-events: none;
}
.door-left { left: 0; transform-origin: 0 50%; }
.door-right { right: 0; transform-origin: 100% 50%; }

.app {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding:
    calc(var(--ac-status-h, 72px) + 2px)
    max(14px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: manipulation;
}

.app[data-view="mixer"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  grid-template-areas: "head" "stage" "lids" "drawer" "ribbon" "tabs";
}

.app[data-view="shelf"] {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(96px, 1fr) auto auto auto auto;
  row-gap: 4px;
  grid-template-areas: "head" "wall" "saved" "pantry" "ribbon" "tabs";
}

.app[data-view="shelf"] .stage,
.app[data-view="shelf"] .tag-slot,
.app[data-view="shelf"] .lid-shelf,
.app[data-view="shelf"] .drawer-note,
.app[data-view="mixer"] .wall,
.app[data-view="shelf"] .drawer,
.app[data-view="mixer"] .saved-shelf,
.app[data-view="mixer"] .pantry-shelf { display: none; }

.head { grid-area: head; display: flex; align-items: center; gap: 10px; min-height: 48px; }
.saved-shelf { grid-area: saved; }
.pantry-shelf { grid-area: pantry; }
.stage { grid-area: stage; }
.wall { grid-area: wall; }
.drawer-note { grid-area: drawer; }
.lid-shelf { grid-area: lids; }
.drawer { grid-area: drawer; }
.ribbon { grid-area: ribbon; }
.tabs { grid-area: tabs; }

@media (orientation: landscape) {
  :root {
    --lid: max(44px, min(5.4dvw, 11dvh, 60px));
    --jar: max(46px, min(6.4dvw, 13dvh, 96px));
    --jar-s: max(44px, min(5.4dvw, 11.5dvh, 70px));
    --tab-h: 48px;
  }
  .app { max-width: 1180px; column-gap: 12px; row-gap: 4px; }
  .app[data-view="mixer"] {
    /* Wide enough for six 48px tools (Hint shows in the first round). */
    grid-template-columns: minmax(0, 1fr) minmax(326px, min(40%, 440px));
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "stage lids"
      "stage drawer"
      "stage ."
      "ribbon tabs";
  }
  .app[data-view="shelf"] {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "pantry wall"
      "pantry saved"
      "ribbon tabs";
  }
  .head {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    right: calc(72px + env(safe-area-inset-right));
    z-index: 3;
    width: min(460px, calc(100% - 380px));
    min-height: 54px;
    justify-content: flex-end;
  }
  .head .logo { height: 44px; order: 2; }
  .head .tag-slot { order: 1; }
}

/* ---- head: logo, kept mark and the tape tag ---- */

.logo { display: block; height: 36px; width: auto; }

.kept {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--ak-ink-muted);
  font-size: 14px;
  font-weight: 500;
}
.kept svg { width: 16px; height: 16px; fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* ---- shelf paper: a blue shelf edge, a sunflower band and scallops ---- */

.shelf-paper { position: relative; padding-bottom: 18px; }
.shelf-paper::after {
  content: '';
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: 0;
  height: 18px;
  pointer-events: none;
  background:
    linear-gradient(var(--blue), var(--blue)) 0 0 / 100% 3px no-repeat,
    linear-gradient(var(--sun), var(--sun)) 0 3px / 100% 6px no-repeat,
    radial-gradient(circle at 9px 0, var(--sun) 0 8px, transparent 8.6px) 0 9px / 18px 9px repeat-x,
    radial-gradient(circle at 9px 0, var(--blue) 0 2px, transparent 2.5px) 0 11px / 18px 9px repeat-x;
}

.shelf-title {
  margin: 0 0 6px;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--blue);
  text-shadow: 1.5px 1.5px 0 var(--sun);
}

/* ---- jars (front shelf and saved shelf) ---- */

.jar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 48px;
  min-height: 48px;
  padding: 4px 2px;
  border: 0;
  background: none;
  cursor: pointer;
}
.jar-art {
  position: relative;
  display: block;
  width: var(--jar);
  aspect-ratio: 370 / 384;
  filter: drop-shadow(1.5px 1.5px 0 var(--sun));
}
.jar-art img { display: block; width: 100%; height: 100%; }
.jar-stripes {
  position: absolute;
  inset: 0;
  mix-blend-mode: multiply;
  -webkit-mask: url("art/shelf-jar.png") center / 100% 100% no-repeat;
  mask: url("art/shelf-jar.png") center / 100% 100% no-repeat;
  background: linear-gradient(
    to bottom,
    transparent 0 46.6%,
    var(--s1) 46.6% 58.6%,
    var(--s2) 58.6% 69%,
    var(--s3) 69% 79.4%,
    var(--s4) 79.4% 90.1%,
    var(--s5) 90.1% 100%
  );
}
.jar-word {
  max-width: 100%;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  overflow-wrap: anywhere;
}
.jar[aria-current="true"] .jar-word {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-content: start;
  gap: 4px 2px;
}

.another {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 48px;
  padding: 4px 2px;
  border: 0;
  background: none;
  cursor: pointer;
}
.another-art {
  display: grid;
  place-items: center;
  width: var(--jar);
  aspect-ratio: 370 / 384;
  border: 2.5px dashed var(--blue);
  border-radius: 18% 18% 22% 22%;
  background: var(--ak-surface);
}
.another-art svg { width: 46%; height: 46%; fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; }

.jar-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 2px 2px 4px;
  min-height: calc(var(--jar-s) * 1.04 + 42px);
  align-items: flex-start;
}
.jar-row.is-empty { min-height: 0; }
.jar-row .saved { flex: 0 0 auto; width: calc(var(--jar-s) + 96px); scroll-snap-align: start; }
.jar-row .saved .jar-art { width: var(--jar-s); }
.saved-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: 0 0 auto; }
.jar-row .jar-word {
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.jar-note {
  max-width: 100%;
  overflow: hidden;
  color: var(--ak-ink-muted);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.jar-note.is-note { color: var(--ink); font-style: italic; }
.take-off {
  min-height: 44px;
  min-width: 48px;
  padding: 0 8px;
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--ak-surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.empty-shelf {
  margin: 0;
  align-self: center;
  padding: 10px 14px;
  border: 2px dashed var(--blue);
  border-radius: var(--wobble);
  background: var(--ak-surface);
  color: var(--ak-ink-muted);
  font-size: 14px;
}
.where { margin: 4px 0 0; color: var(--ak-ink-muted); font-size: 14px; line-height: 1.3; }

/* ---- the stage: the mock stands on the middle shelf ---- */

.stage {
  position: relative;
  min-height: 0;
  container: stage / size;
  touch-action: pan-y;
}
/* The grid lives one level in, so the stage's own shape (its container query) can rearrange it. */
.stage-inner {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
}

/* The print: a sheet of sketchbook paper taped to the shelf, the mockup in its window and the
   palette's name signed in the wide bottom margin. Flat, front on, a hair off straight. */
.print-cell { min-height: 0; display: grid; place-items: center; container-type: size; }
.print {
  position: relative;
  width: min(100cqw, 100cqh * 1.9);
  height: min(100cqh, 100cqw * 1.35);
  margin: 0;
  padding: 10px 10px 34px;
  border: 2px solid var(--ink);
  border-radius: 3px 2px 4px 3px;
  background: var(--ak-surface);
  box-shadow: var(--ghost);
  rotate: -0.6deg;
}
.print::before,
.print::after {
  content: '';
  position: absolute;
  top: -9px;
  width: 54px;
  height: 18px;
  background: var(--paper-sun);
  border: 1px solid color-mix(in srgb, var(--sun) 80%, var(--blue));
}
.print::before { left: -12px; rotate: -28deg; }
.print::after { right: -12px; rotate: 28deg; }
.print-window {
  position: relative;
  height: 100%;
  overflow: hidden;
  border: 2px solid var(--blue);
  background: var(--c-background);
}
.mock-track { display: flex; height: 100%; }
/* Each mockup's wall, stripes and counter run past its drawing; its own slot clips them. */
.mock { flex: 0 0 100%; height: 100%; overflow: hidden; }
.mock svg { display: block; width: 100%; height: 100%; overflow: visible; }
.print-name {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 5px;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--ak-font-display);
  font-size: 14px;
  line-height: 1.6;
  text-align: right;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Every colour on the picture can be tapped to open its dials. */
.mock [data-paint] { cursor: pointer; }

/* Today's brief, written on the print's mat above the name, with a mark that fills when it is met. */
.stage.has-brief .print { padding-bottom: 56px; }
.print-brief {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 29px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
}
.print-brief span:last-child { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.brief-mark {
  position: relative;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: var(--ak-surface);
}
.print-brief.is-met .brief-mark { background: var(--blue); }
.print-brief.is-met .brief-mark::after {
  content: '';
  position: absolute;
  left: 3.5px;
  top: 0.5px;
  width: 4px;
  height: 8px;
  border: solid var(--ak-btn-ink);
  border-width: 0 2px 2px 0;
  rotate: 45deg;
}

/* A saved jar that met its day's brief wears a small stamp on its shoulder. */
.brief-stamp {
  position: absolute;
  top: -2px;
  right: -6px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--blue);
  border-radius: 50%;
  background: var(--sun);
}
.brief-stamp::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1.5px;
  width: 5px;
  height: 9px;
  border: solid var(--blue);
  border-width: 0 2.5px 2.5px 0;
  rotate: 45deg;
}

/* The contact strip: all three mockups, small and live, labelled; the one on the print is marked. */
.contact { display: flex; gap: 8px; justify-content: center; }
.contact-thumb {
  flex: 1 1 0;
  max-width: 150px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 3px;
  min-height: 48px;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--ak-surface);
  color: var(--ink);
  box-shadow: 2px 2px 0 var(--sun);
  cursor: pointer;
}
.contact-thumb:nth-child(odd) { rotate: -1deg; }
.contact-thumb:nth-child(even) { rotate: 1deg; }
.thumb-art {
  display: block;
  height: clamp(34px, 15cqh, 78px);
  overflow: hidden;
  border: 1.5px solid var(--blue);
  background: var(--c-background);
}
.thumb-art svg { display: block; width: 100%; height: 100%; overflow: visible; }
.thumb-name { font-size: 14px; font-weight: 600; line-height: 1.2; text-align: center; }
.contact-thumb[aria-pressed="true"] { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue), 3px 3px 0 var(--sun); }
.contact-thumb[aria-pressed="true"] .thumb-name { border-radius: 3px; background: var(--ak-choice-selected-bg); color: var(--ak-choice-selected-ink); }

/* A wide, short stage stands the contact strip in a column beside the print. */
@container stage (min-aspect-ratio: 3 / 2) {
  .stage-inner { grid-template-rows: minmax(0, 1fr); grid-template-columns: 104px minmax(0, 1fr); }
  .contact { grid-row: 1; grid-column: 1; flex-direction: column; justify-content: center; }
  .print-cell { grid-column: 2; }
  .contact-thumb { flex: 0 1 auto; max-width: none; }
  .thumb-art { height: clamp(26px, calc((100cqh - 96px) / 3), 64px); }
}

/* The print on the cupboard wall: the palette on all three mockups at once. */
.wall { min-height: 0; display: grid; padding: 4px 2px 2px; }
.wall-print {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 96px;
  padding: 8px 8px 48px;
  border: 2px solid var(--ink);
  border-radius: 3px 2px 4px 3px;
  background: var(--ak-surface);
  box-shadow: var(--ghost);
  rotate: 0.5deg;
  cursor: pointer;
}
.wall-print::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 50%;
  width: 70px;
  height: 18px;
  translate: -50% 0;
  rotate: -3deg;
  background: var(--paper-sun);
  border: 1px solid color-mix(in srgb, var(--sun) 80%, var(--blue));
}
.wall-strip { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.wall-caption {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.wall-caption .print-name { position: static; max-width: 100%; line-height: 1.35; }
.wall-brief {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wall-mock { display: block; min-height: 0; overflow: hidden; border: 1.5px solid var(--blue); background: var(--c-background); }
.wall-mock svg { display: block; width: 100%; height: 100%; overflow: visible; }

.drawer-note {
  margin: 0;
  padding: 10px 14px;
  border: 2px solid var(--ink);
  border-radius: 6px 4px 8px 5px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  box-shadow: var(--ghost);
}

/* mock paint classes: each role is one CSS variable on .app */
.f-background { fill: var(--c-background); }
.f-surface { fill: var(--c-surface); }
.f-main { fill: var(--c-main); }
.f-accent { fill: var(--c-accent); }
.f-text { fill: var(--c-text); }
.s-main { stroke: var(--c-main); fill: none; }
.s-text { stroke: var(--c-text); fill: none; }
.s-surface { stroke: var(--c-surface); fill: none; }
.steam-rise { opacity: 0; }

/* ---- the tape tag slot ---- */

.tag-slot {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 44px;
}
.tag-slot .kept { margin-right: auto; white-space: nowrap; }
.tape-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  max-width: 100%;
  margin: 0;
  padding: 6px 30px 8px 16px;
  border: 0;
  background: url("art/tape-tag.png") center 54% / 100% 301% no-repeat;
  color: var(--ak-choice-selected-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  text-align: left;
  cursor: pointer;
}
.tape-fix {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-size: 13px;
  white-space: nowrap;
}
.tag-quiet { margin: 0; color: var(--ak-ink-muted); font-size: 14px; text-align: right; }

/* ---- the lower shelf: five lids ---- */

.lid-row { display: flex; justify-content: space-between; gap: 2px; }
.lid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 48px;
  min-height: 48px;
  padding: 8px 0 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.lid-art {
  position: relative;
  display: block;
  width: var(--lid);
  aspect-ratio: 374 / 384;
  filter: drop-shadow(1.5px 1.5px 0 var(--blue));
}
.lid-art img { display: block; width: 100%; height: 100%; }
.disc {
  position: absolute;
  left: 49.7%;
  top: 48.6%;
  width: 60%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 2.5px var(--blue);
}
.blink i {
  position: absolute;
  top: 6.6%;
  width: 7.4%;
  height: 6.4%;
  border-radius: 50%;
  background: var(--paper-sun);
  border-bottom: 2px solid var(--blue);
  opacity: 0;
}
.blink i:first-child { left: 35.9%; }
.blink i:last-child { left: 56.2%; }
.lid.is-blinking .blink i { opacity: 1; }
.lid-name {
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}
.lid[aria-pressed="true"] .lid-art { transform: translateY(-8px); }
.lid[aria-pressed="true"] .lid-name { background: var(--blue); color: var(--ak-btn-ink); }

/* ---- the drawer: three big dials on a riso-blue drawer front ---- */

.drawer {
  display: grid;
  gap: 2px;
  padding: 6px 12px;
  border: 2px solid var(--ink);
  border-radius: 6px 4px 8px 5px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  box-shadow: var(--ghost);
}
.drawer-note { margin: 0; align-self: center; font-size: 15px; font-weight: 500; }
.dial { display: grid; grid-template-columns: 116px minmax(0, 1fr); align-items: center; gap: 8px; }
.dial label { display: flex; flex-direction: column; gap: 2px; line-height: 1.1; }
.dial-name { font-family: var(--ak-font-display); font-size: 13px; letter-spacing: 0.03em; white-space: nowrap; }
.dial-value { font-family: var(--ak-font-body); font-size: 14px; font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.dial-hint { font-size: 13.5px; font-weight: 500; line-height: 1.15; }

.dial input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 46px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.dial input[type="range"]::-webkit-slider-runnable-track {
  height: 18px;
  border: 2px solid var(--ak-btn-ink);
  border-radius: 10px;
  background: var(--track);
}
.dial input[type="range"]::-moz-range-track {
  height: 14px;
  border: 2px solid var(--ak-btn-ink);
  border-radius: 10px;
  background: var(--track);
}
.dial input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 38px;
  height: 38px;
  margin-top: -12px;
  border: 3px solid var(--ak-btn-ink);
  border-radius: 52% 46% 50% 48% / 48% 52% 46% 50%;
  background: var(--thumb);
  box-shadow: 2px 2px 0 var(--sun);
}
.dial input[type="range"]::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border: 3px solid var(--ak-btn-ink);
  border-radius: 52% 46% 50% 48% / 48% 52% 46% 50%;
  background: var(--thumb);
  box-shadow: 2px 2px 0 var(--sun);
}

/* ---- the caption ribbon: a sunflower price ticket with the jar-keeper at its end ---- */

.ribbon {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 6px 64px 6px 40px;
}
.ribbon::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 26px 50%, var(--ak-bg) 0 5px, var(--blue) 5.5px 7px, transparent 7.5px),
    var(--sun);
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 50%, 100% 100%, 0 100%, 12px 50%);
  filter: drop-shadow(2px 2px 0 var(--blue));
}
.caption {
  margin: 0;
  color: var(--ak-choice-selected-ink);
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.25;
  text-wrap: pretty;
}
.ribbon.is-teaching .caption { font-size: 18px; font-weight: 600; }

.keeper {
  position: absolute;
  right: 8px;
  bottom: 2px;
  width: 54px;
  aspect-ratio: 311 / 384;
  transform-origin: 50% 100%;
  pointer-events: none;
}
.keeper img { display: block; width: 100%; height: 100%; }
.eyelid {
  position: absolute;
  top: 50.4%;
  width: 11.6%;
  height: 7.4%;
  border-radius: 50% 50% 10% 10%;
  background: var(--paper-sun);
  border-bottom: 2px solid var(--blue);
  opacity: 0;
}
.eyelid.one { left: 21.4%; }
.eyelid.two { left: 44.6%; }
.keeper.is-squinting .eyelid { opacity: 1; }
.keeper.is-leaning { transform: rotate(-9deg) translateX(-3px); }
.keeper.is-holding { transform: translateY(-8px); }
.mini-jar {
  position: absolute;
  left: 66.9%;
  top: 55.2%;
  width: 11.9%;
  height: 6.4%;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  opacity: 0;
}
.mini-jar i:nth-child(1) { background: var(--j1, var(--c-background)); }
.mini-jar i:nth-child(2) { background: var(--j2, var(--c-surface)); }
.mini-jar i:nth-child(3) { background: var(--j3, var(--c-main)); }
.mini-jar i:nth-child(4) { background: var(--j4, var(--c-accent)); }
.mini-jar i:nth-child(5) { background: var(--j5, var(--c-text)); }
.keeper.is-holding .mini-jar { opacity: 1; }

/* ---- the tools: tilted paper tabs on a riso-blue shelf-edge label strip ---- */

.tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  min-height: calc(var(--tab-h) + 12px);
  padding: 2px 8px 6px;
  border-radius: 0;
  background: linear-gradient(to bottom, transparent 0 48%, var(--sun) 48% calc(48% + 3px), var(--blue) calc(48% + 3px));
}
.tab {
  flex: 1 1 0;
  max-width: 96px;
  min-width: 48px;
  min-height: var(--tab-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px 4px;
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--ak-surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.05;
  text-align: center;
  box-shadow: 2px 2px 0 var(--sun);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.tab:nth-child(odd) { rotate: -2deg; }
.tab:nth-child(even) { rotate: 1.5deg; }
.tab[data-act="squint"] { touch-action: none; }
.tab.is-wide { max-width: 150px; flex-grow: 1.6; }
.tab[aria-expanded="true"] { background: var(--ak-choice-selected-bg); color: var(--ak-choice-selected-ink); }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-pressed="true"] { background: var(--ak-choice-selected-bg); color: var(--ak-choice-selected-ink); }
.tab-note { margin: 0; align-self: center; color: var(--ak-btn-ink); font-size: 15px; font-weight: 500; }

/* ---- the More menu: a small taped note above the tool strip ---- */

.more-wash { position: fixed; inset: 0; z-index: 26; background: transparent; }
.more-menu {
  position: fixed;
  z-index: 27;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(290px, calc(100vw - 20px));
  padding: 12px 10px 10px;
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--ak-surface);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--sun);
  rotate: -1deg;
}
.more-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  border-radius: 6px 4px 7px 5px;
  background: var(--ak-bg);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.more-menu svg { flex: 0 0 auto; width: 24px; height: 24px; fill: none; stroke: var(--blue); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.more-menu b { display: block; font-size: 16px; }
.more-menu small { display: block; color: var(--ak-ink-muted); font-size: 14px; line-height: 1.25; }

/* ---- the opening screen's peek at the front shelf (over start.js's empty lower space) ---- */

.first-shelf {
  position: fixed;
  left: 50%;
  z-index: 41;
  width: min(420px, calc(100vw - 32px));
  translate: -50% 0;
  pointer-events: none;
  text-align: center;
}
.first-jars {
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 0 6px 7px;
  background:
    linear-gradient(var(--blue), var(--blue)) 0 100% / 100% 3px no-repeat;
}
.first-jars .jar-art { width: min(38px, calc((100vw - 60px) / 8)); }
.first-line {
  margin: 6px 0 0;
  padding: 0 8px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
}

/* ---- teaching: a pulsing ring and an arrow, never over the thing it points at ---- */

.coach { position: fixed; inset: 0; z-index: 25; pointer-events: none; }
.coach-ring {
  position: fixed;
  border: 4px solid var(--blue);
  border-radius: 50% 46% 52% 48%;
  box-shadow: 0 0 0 3px var(--sun);
}
.coach-arrow {
  position: fixed;
  width: 40px;
  height: 56px;
  fill: none;
  stroke: var(--blue);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(2px 2px 0 var(--sun));
}
.coach.is-below .coach-arrow { rotate: 180deg; }

/* ---- in-page sheets: a taped note ---- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: grid;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--ak-bg) 78%, transparent);
}
.sheet-note {
  position: relative;
  width: min(100%, 380px);
  padding: 26px 22px 18px;
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  background: var(--ak-surface);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--sun);
  rotate: -1deg;
}
.sheet-note::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  width: 92px;
  height: 22px;
  translate: -50% 0;
  rotate: 3deg;
  background: var(--paper-sun);
  border: 1px solid color-mix(in srgb, var(--sun) 80%, var(--blue));
}
.sheet-title { margin: 0 0 8px; font-family: var(--ak-font-display); font-weight: var(--ak-title-weight); font-size: 19px; color: var(--blue); }
.sheet-body { margin: 0 0 12px; font-size: 16px; line-height: 1.35; }
.sheet-label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--ak-ink-muted); }
.sheet-form input {
  width: 100%;
  min-height: 48px;
  margin-bottom: 10px;
  padding: 0 12px;
  border: 2px solid var(--ink);
  border-radius: 6px 4px 7px 5px;
  background: var(--ak-bg);
  color: var(--ink);
  font: 500 18px var(--ak-font-body);
}
/* The Name sheet sits high, so a phone keyboard never covers the field or its button. */
.sheet.is-input { place-items: start center; padding-top: max(24px, calc(var(--ac-status-h, 72px) + 8px)); }
.name-note { margin: -6px 0 14px; color: var(--ak-ink-muted); font-size: 14px; line-height: 1.3; }
.sheet-form input::placeholder { color: var(--ak-ink-muted); font-style: italic; font-weight: 400; opacity: 1; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sheet-actions button {
  flex: 1 1 auto;
  min-height: 50px;
  padding: 0 16px;
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.sheet-yes { background: var(--ak-btn-fill); color: var(--ak-btn-ink); rotate: -1deg; }
.sheet-no { background: var(--ak-choice-bg); color: var(--ak-choice-ink); rotate: 1deg; }

/* A saved jar is a small card: the jar, then its name and note beside it, so the shelf keeps
   its height for the pantry and the wall print. */
@media all {
  .jar-row { min-height: calc(var(--jar-s) * 1.04 + 10px); }
  .jar-row.is-empty { min-height: 0; }
  .jar-row .saved {
    width: calc(var(--jar-s) + 132px);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 2px;
    text-align: left;
  }
  .jar-row .saved .jar-art { grid-row: 1 / span 2; }
  .jar-row .saved .jar-word { align-self: end; justify-self: start; }
  .jar-row .saved .jar-note { align-self: start; justify-self: start; }
  .saved-slot { align-items: flex-start; }
}

/* ---- short phones: keep the stage the biggest thing ---- */

@media (orientation: portrait) and (max-width: 380px) {
  .word-grid .jar-word { font-size: 13.5px; overflow-wrap: normal; }
  .ribbon { padding: 6px 58px 6px 34px; }
  .ribbon::before { background: radial-gradient(circle at 22px 50%, var(--ak-bg) 0 4.5px, var(--blue) 5px 6.5px, transparent 7px), var(--sun); }
  .keeper { width: 48px; right: 6px; }
  .caption { font-size: 15px; }
  .tape-tag { padding: 6px 24px 8px 12px; font-size: 13px; gap: 6px; }
  .logo { height: 30px; }
}

@media (orientation: portrait) and (max-height: 760px) {
  .app[data-view="shelf"] { grid-template-rows: auto minmax(88px, 1fr) auto auto auto auto; }
  .wall-print { min-height: 88px; }
}

@media (orientation: portrait) and (max-height: 720px) {
  :root { --tab-h: 48px; --lid: max(44px, min(13dvw, 6.4dvh, 62px)); }
  .head { min-height: 40px; }
  .logo { height: 30px; }
  .lid { padding-top: 6px; }
  .drawer { padding: 3px 12px; gap: 0; }
  .dial input[type="range"] { height: 44px; }
  .ribbon { min-height: 48px; }
  .caption { font-size: 15px; }
}

@media (orientation: landscape) {
  .tabs { min-height: calc(var(--tab-h) + 8px); padding: 4px 8px; }
  .lid-shelf { padding-bottom: 0; }
  .lid-shelf::after { display: none; }
  .lid { padding-top: 6px; }
  .drawer { align-self: start; padding: 3px 12px; gap: 0; }
  .dial input[type="range"] { height: 44px; }
  .jar-word { font-size: 14px; }
  .saved-shelf { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .wall-print { min-height: 0; }
  .wall-strip { min-height: 30px; }

  .saved-shelf .jar-row { flex: 0 0 auto; }
}

@media (orientation: landscape) {
  .tabs { gap: 4px; padding-inline: 4px; }
  .tab { padding-inline: 1px; }
}

/* Narrow sideways phones: a smaller logo, the Kept mark as its tick alone, a slimmer tools
   column and a smaller caption, so the tape tag stays in the strip and the caption in its ribbon. */
@media (orientation: landscape) and (max-width: 760px) {
  .wall-tap { display: none; }
  .head { width: calc(100% - 360px); gap: 6px; }
  .head .logo { height: 30px; }
  .kept #keptText { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tape-tag { padding: 5px 22px 7px 10px; font-size: 13px; gap: 6px; }
  .tape-fix { font-size: 13px; padding: 3px 6px; }
  .app[data-view="mixer"] { grid-template-columns: minmax(0, 1fr) minmax(318px, 46%); }
  .tab { font-size: 13px; }

  .dial { grid-template-columns: 108px minmax(0, 1fr); }
  .dial-hint { font-size: 13px; }
  .lid-name { font-size: 13px; padding: 1px 3px; }
}

@media (orientation: landscape) and (max-height: 420px) {
  /* The wall print turns sideways too: the three mockups, then today's jar and brief beside them. */
  .wall-print { flex-direction: row; align-items: stretch; gap: 10px; padding: 8px; }
  .wall-strip { flex: 1 1 50%; min-height: 0; }
  .wall-caption { position: static; flex: 1 1 50%; min-width: 0; justify-content: center; align-items: flex-start; }
  .wall-caption .print-name { font-size: 13px; }
  .wall-brief { font-size: 13px; }
  .wall-caption .print-name { text-align: left; white-space: normal; line-height: 1.25; }
  .wall-brief { white-space: normal; line-height: 1.25; }
  .app { padding-bottom: max(5px, env(safe-area-inset-bottom)); }
  .tabs { min-height: calc(var(--tab-h) + 4px); padding-block: 1px 3px; }
  .drawer { padding-block: 2px; }
  .lid { padding-top: 4px; }
  .ribbon { min-height: 48px; padding: 5px 58px 5px 34px; }
  .ribbon::before { background: radial-gradient(circle at 22px 50%, var(--ak-bg) 0 4.5px, var(--blue) 5px 6.5px, transparent 7px), var(--sun); }
  .keeper { width: 46px; }
  .caption { font-size: 14px; line-height: 1.22; }
}

@media (orientation: landscape) and (min-height: 600px) {
  :root {
    --jar: max(48px, min(8.5dvw, 17dvh, 140px));
    --jar-s: max(44px, min(6.5dvw, 12dvh, 96px));
  }
  .jar-word { font-size: 15px; }
}

/* ---- motion: slow and quiet, only when wanted ---- */

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .mock-track { transition: transform 520ms cubic-bezier(0.22, 1, 0.36, 1); }
  :root:not(.ac-still) .lid-art { transition: transform 320ms ease-out; }
  :root:not(.ac-still) .keeper { transition: transform 450ms ease-in-out; }
  :root:not(.ac-still) .eyelid,
  :root:not(.ac-still) .mini-jar { transition: opacity 240ms ease; }
  :root:not(.ac-still) .is-steaming .steam-rise { animation: steam-rise 2s ease-out both; }
  :root:not(.ac-still) .jar.is-arriving .jar-art { animation: jar-arrive 900ms cubic-bezier(0.22, 1, 0.36, 1) both; }
  :root:not(.ac-still) .jar.is-new .jar-art { animation: jar-in 600ms ease-out both; }
  :root:not(.ac-still) .door.is-swaying { animation: door-sway 1.6s ease-in-out 1; }
  :root:not(.ac-still) .coach-ring { animation: ring-pulse 1.6s ease-in-out infinite; }
  :root:not(.ac-still) .coach-arrow { animation: arrow-nod 1.6s ease-in-out infinite; }
  :root:not(.ac-still) .kept:not([hidden]) { animation: kept-settle 500ms ease-out both; }
}

@keyframes steam-rise {
  0% { opacity: 0; transform: translateY(8px); }
  25% { opacity: 0.95; }
  100% { opacity: 0; transform: translateY(-26px); }
}
@keyframes jar-arrive {
  0% { opacity: 0; transform: translateX(-70px); filter: drop-shadow(6px 2px 0 var(--sun)); }
  70% { opacity: 1; filter: drop-shadow(-2px 1px 0 var(--sun)); }
  100% { opacity: 1; transform: none; filter: drop-shadow(1.5px 1.5px 0 var(--sun)); }
}
@keyframes jar-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: none; }
}
@keyframes door-sway {
  0%, 100% { transform: scaleX(1); }
  35% { transform: scaleX(2.4); }
  70% { transform: scaleX(0.6); }
}
@keyframes ring-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}
@keyframes arrow-nod {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 5px; }
}
@keyframes kept-settle {
  from { opacity: 0; }
  to { opacity: 1; }
}
