/* Old Book Palettes: a reading-room noticeboard after closing, cut into comic panels.
   Chalk-white wobbly panel borders, bare navy gutters, one full-colour window: the player's palette. */

:root {
  --gut: 8px;
  --chalk: var(--ak-ink);
  --chalk-line: 3px;
  --panel-r: 4px 11px 5px 13px / 12px 4px 10px 5px;
  --panel-r2: 12px 4px 13px 5px / 5px 11px 4px 12px;
  --top: calc(max(var(--ac-status-h, 0px), 64px) + 6px);
  --c0: #ffffff;
  --c1: #ffffff;
  --c2: #ffffff;
  --c3: #ffffff;
  --c4: #ffffff;
  --wash: 700ms;
  --turn: 520ms;
  --slot-h: auto;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background-color: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
}

body {
  background-image: var(--ak-backdrop-layer, var(--ak-bg-art));
  background-size: cover;
  background-position: center;
  -webkit-tap-highlight-color: transparent;
}

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

/* ---------- The page of panels ---------- */

/* The workspace waits under the opening until it hands over, so nothing behind it looks tappable. */
/* Before the opening hands over, the studio rests dim and untouchable under a tilted title plate,
   so the first frame is never bare navy and nothing behind it looks ready to tap. */
body:not(.is-started) #app { opacity: 0.3; filter: saturate(0.5); }
body:not(.is-started) .coach { visibility: hidden; }
.waiting {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  pointer-events: none;
}
body.is-started .waiting,
body:has(#activity-start) .waiting { display: none; }
.waiting-logo { width: min(78vw, 420px, 52dvh); height: auto; rotate: -4deg; }
.taped-note {
  position: relative;
  margin: 0;
  padding: 16px 22px 14px;
  border: 2px solid var(--chalk);
  border-radius: var(--panel-r2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: clamp(18px, 4.6vw, 24px);
  rotate: 2deg;
}
.taped-note::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  width: 72px;
  height: 20px;
  translate: -50% 0;
  rotate: -3deg;
  background: var(--ak-accent);
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto var(--slot-h) auto;
  grid-template-areas: "stage" "chips" "slot" "tools";
  gap: var(--gut);
  width: min(100%, 560px);
  margin: 0 auto;
  padding:
    var(--top)
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: var(--chalk-line) solid var(--chalk);
  border-radius: var(--panel-r);
  background: var(--ak-bg);
}

.p-stage { grid-area: stage; display: flex; flex-direction: column; padding: 6px; background: var(--ak-surface); }
.p-chips { grid-area: chips; padding: 8px 6px 4px; border-radius: var(--panel-r2); }
.p-slot { grid-area: slot; padding: 4px 8px 4px; overflow-x: hidden; overflow-y: auto; }
.p-tools { grid-area: tools; display: flex; gap: 6px; padding: 5px; border-radius: var(--panel-r2); }

/* ---------- The palette's name, and where it is kept ---------- */

.palette-name { max-width: calc(100% - 8px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: none; }
.palette-name.is-untitled { background: var(--ak-bg); color: var(--ak-ink); border-color: var(--chalk); }
.kept { margin: 0; font-size: 12px; color: var(--ak-ink-muted); line-height: 1.25; }
.kept.is-trouble { color: var(--ak-link); }
.logo { display: block; height: 40px; width: auto; flex: 0 0 auto; align-self: center; }

/* ---------- Stage: the window that shows the work ---------- */

.caption-box {
  position: relative;
  flex: 0 0 auto;
  z-index: 2;
  align-self: flex-start;
  margin: -18px 0 4px -2px;
  padding: 3px 10px 2px;
  border: 2px solid var(--ak-bg);
  border-radius: 2px;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  font-family: var(--ak-font-display);
  font-size: 15px;
  letter-spacing: 0.04em;
  line-height: 1.3;
}

/* The caption box and Done sit across the stage panel's top edge, like a comic panel's captions. */
.stage-head {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  margin: -18px -2px 4px -2px;
}
.stage-head .caption-box { margin: 0; min-width: 0; flex: 0 1 auto; }
.request-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 48px;
  margin-left: auto;
  padding: 0 12px;
  border: 2px dashed var(--ak-accent);
  border-radius: 3px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 16px;
}
.request-btn svg { color: var(--ak-accent); }
.request-btn.is-new { border-style: solid; background: var(--ak-surface); }
.request-btn.is-filled { border-style: solid; border-color: var(--ak-outline); color: var(--ak-ink-muted); }
.done-btn {
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 48px;
  padding: 0 16px;
  border: 2px solid var(--ak-bg);
  border-radius: var(--panel-r2);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 18px;
}

.window {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
  background: var(--c0);
  touch-action: pan-y;
  cursor: grab;
}
.window:active { cursor: grabbing; }

.track {
  display: flex;
  width: 300%;
  height: 100%;
  transform: translateX(calc(var(--at, 0) * -33.3333%));
}
.slide { flex: 0 0 33.3333%; height: 100%; display: flex; align-items: center; justify-content: center; }
.mock { display: block; width: 100%; height: 100%; }

.f0 { fill: var(--c0); }
.f1 { fill: var(--c1); }
.f2 { fill: var(--c2); }
.f3 { fill: var(--c3); }
.f4 { fill: var(--c4); }
.t4 { fill: var(--c4); }
.s4 { fill: none; stroke: var(--c4); stroke-width: 3; stroke-linecap: round; opacity: 0.45; }
.soft { opacity: 0.22; }
.glow { opacity: 0.24; }
.display { font-family: var(--ak-font-display); }
.body { font-family: var(--ak-font-body); font-weight: 700; letter-spacing: 0.04em; }

/* No mood yet: the mocks wait as chalk outlines. */
.p-stage.is-blank .window { background: var(--ak-bg); }
.p-stage.is-blank .mock * { fill: none; stroke: var(--chalk); stroke-width: 1.4; opacity: 0.7; }
.p-stage.is-blank .mock .back { stroke: none; }
.p-stage.is-blank .mock text { fill: var(--chalk); stroke: none; opacity: 0.85; }

.stage-note {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 10px;
  translate: -50% 0;
  width: max-content;
  max-width: calc(100% - 20px);
  margin: 0;
  padding: 8px 14px;
  border-radius: 18px 18px 18px 4px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
}
.p-stage.is-blank .stage-note { top: auto; bottom: 10px; }

.mock-tabs { display: flex; align-items: stretch; gap: 6px; padding-top: 6px; }
.mock-tab {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: 0 6px;
  border: 2px solid var(--chalk);
  border-radius: var(--panel-r2);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 16px;
}
/* Each tab stacks a live thumbnail over its word, so the cover, room and mug all show at once. */
.mock-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 3px 4px; }
.mock-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--ak-font-body); font-size: 13px; font-weight: 700; line-height: 1.1; }
.thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 30px;
  overflow: hidden;
  border: 1.5px solid var(--chalk);
  border-radius: 6px;
  background: var(--c0);
}
.thumb .mock { width: 100%; height: 100%; }
.mock-tab[aria-pressed="true"] .thumb { border-color: var(--ak-choice-selected-ink); border-width: 2px; }
.mock-tab[aria-pressed="true"] {
  background: var(--ak-choice-selected-bg);
  border-color: var(--ak-choice-selected-border);
  color: var(--ak-choice-selected-ink);
}

/* ---------- The last panel: a card sliding into its drawer ---------- */

.last-panel {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6%;
  background: var(--ak-bg);
  overflow: hidden;
}
.last-panel .saved-line {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 4;
  width: auto;
  margin: 0;
  border-radius: 16px 16px 16px 4px;
  font-size: 14.5px;
}
/* While the line is up, the card sits smaller in its drawer so the words never cover it. */
.last-panel:has(.saved-line:not([hidden])) .lib-card { width: min(50%, 240px); }
.last-panel:has(.saved-line:not([hidden])) .last-mark { height: 44%; }
.last-panel .saved-line::after { left: 12%; right: auto; border-right-width: 6px; border-left-width: 0; }
.drawer-back, .drawer-front {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  width: min(78%, 360px);
  border: 3px solid var(--chalk);
}
.drawer-back { bottom: 6%; height: 44%; border-radius: 6px 6px 2px 2px; background: var(--ak-surface); }
.drawer-front {
  bottom: 6%;
  z-index: 2;
  height: 26%;
  border-radius: 3px 8px 4px 9px;
  background: var(--ak-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pull { width: 34%; height: 14px; border: 3px solid var(--chalk); border-radius: 8px; background: var(--ak-accent); }
.last-mark {
  position: absolute;
  right: max(4%, calc(50% - 210px));
  bottom: 18%;
  z-index: 1;
  height: 58%;
  aspect-ratio: 202 / 384;
}
.last-mark img { display: block; width: 100%; height: 100%; }
.last-mark span {
  position: absolute;
  left: 50%;
  top: 56%;
  translate: -50% -50%;
  writing-mode: vertical-rl;
  rotate: 180deg;
  color: var(--ak-ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.last-panel .lib-card {
  position: absolute;
  left: 50%;
  bottom: 18%;
  z-index: 1;
  width: min(66%, 300px);
  translate: -50% 0;
}

/* ---------- Library card (shelf and last panel) ---------- */

.lib-card {
  position: relative;
  aspect-ratio: 384 / 252;
  background: url("art/library-card.png") center / 100% 100% no-repeat;
  color: #0F1B33;
  container-type: inline-size;
}
.lib-stripes {
  position: absolute;
  left: 1.7%;
  top: 2.6%;
  width: 15.8%;
  height: 94.8%;
  display: flex;
  flex-direction: column;
  gap: 2%;
  padding: 0;
  border-radius: 6px 0 0 6px;
  overflow: hidden;
  background: #F6EBD3;
}
.lib-stripes span { flex: 1 1 0; }
.lib-name {
  position: absolute;
  left: 22%;
  right: 30%;
  top: 22%;
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: 9.5cqw;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lib-mood { position: absolute; left: 22%; right: 6%; top: 50.5%; margin: 0; font-size: 5.6cqw; font-weight: 700; line-height: 1.2; }
.lib-stamp {
  position: absolute;
  right: 2.4%;
  top: 2.2%;
  width: 23%;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #F6EBD3;
  color: #B43E1E;
  font-family: var(--ak-font-body);
  font-weight: 700;
  font-size: 3.5cqw;
  line-height: 1.1;
  white-space: nowrap;
  text-align: center;
  rotate: -12deg;
  border: 0.7cqw solid currentColor;
}
.lib-stamp b { font-size: 4.6cqw; letter-spacing: 0.06em; }

/* ---------- Chips: five torn paper swatches ---------- */

.chips {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 48px;
  padding: 0 0 4px;
  border: 0;
  background: none;
  touch-action: none;
}
.chip-paper {
  position: relative;
  display: block;
  width: min(100%, 64px);
  aspect-ratio: 361 / 384;
  isolation: isolate;
  filter:
    drop-shadow(1.5px 0 0 var(--chalk))
    drop-shadow(-1.5px 0 0 var(--chalk))
    drop-shadow(0 1.5px 0 var(--chalk))
    drop-shadow(0 -1.5px 0 var(--chalk));
}
.chip-fill {
  position: absolute;
  inset: 0;
  background: var(--chip, #ffffff);
  -webkit-mask: url("art/swatch-chip.png") center / 100% 100% no-repeat;
  mask: url("art/swatch-chip.png") center / 100% 100% no-repeat;
}
.chip-art, .chip-tape {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.chip-art { mix-blend-mode: multiply; }
.chip-tape { clip-path: inset(0 29% 83% 29%); }
.chip-tag {
  position: absolute;
  z-index: 2;
  left: -16%;
  top: 38%;
  width: 132%;
  height: auto;
  pointer-events: none;
}
.chip-role {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ak-ink);
  line-height: 1.2;
  padding: 1px 2px;
  border-bottom: 3px solid transparent;
}
.chip[aria-pressed="true"] .chip-role { border-bottom-color: var(--ak-accent); }
.chip[aria-pressed="true"] .chip-paper { translate: 0 -3px; }
.chip.is-dragging { z-index: 5; }
.chip.is-dragging .chip-paper { scale: 1.08; }
.chip.is-target .chip-paper {
  filter:
    drop-shadow(3px 0 0 var(--ak-accent))
    drop-shadow(-3px 0 0 var(--ak-accent))
    drop-shadow(0 3px 0 var(--ak-accent))
    drop-shadow(0 -3px 0 var(--ak-accent));
}

/* Word bubbles: what is wrong, said plainly, until it is fixed. */
.bubble {
  position: relative;
  margin: 0 0 12px auto;
  width: fit-content;
  max-width: 100%;
  padding: 7px 12px;
  border: 2px solid var(--ak-bg);
  border-radius: 16px 16px 4px 16px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}
.bubble::after {
  content: '';
  position: absolute;
  right: 6%;
  bottom: -11px;
  border: 6px solid transparent;
  border-top: 7px solid var(--ak-btn-fill);
  border-right-width: 0;
}

.chips-caption { margin: 0 0 6px; font-size: 13px; color: var(--ak-ink-muted); text-align: center; }
.p-chips .bubble:not([hidden]) + .chips-caption { display: none; }

/* ---------- Slot: moods or dials, swapped like panels ---------- */

.slot-caption {
  margin: 0 0 6px;
  font-family: var(--ak-font-display);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ak-ink);
}

.moods-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.moods-head .slot-caption { margin: 0; flex: 0 0 auto; }
.moods-head .kept { min-width: 0; text-align: right; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.moods {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
/* A ribbon bookmark lying flat: chalk edge, a forked tail, a tangerine tassel. */
.mood {
  --edge: var(--chalk);
  --face: var(--ak-surface);
  position: relative;
  flex: 1 0 auto;
  min-height: 44px;
  padding: 0 13px 0 15px;
  border: 0;
  background: var(--edge);
  color: var(--ak-ink);
  font-size: 12.5px;
  font-weight: 700;
  clip-path: polygon(0 0, 100% 0, calc(100% - 11px) 50%, 100% 100%, 0 100%);
  isolation: isolate;
}
.mood::before {
  content: '';
  position: absolute;
  inset: 2px 2px 2px 2px;
  z-index: -1;
  background: var(--face);
  clip-path: polygon(0 0, 100% 0, calc(100% - 9.5px) 50%, 100% 100%, 0 100%);
}
.mood::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 50%;
  width: 6px;
  height: 6px;
  translate: 0 -50%;
  border-radius: 50%;
  background: var(--ak-accent);
  box-shadow: 0 0 0 2px var(--ak-bg);
}
.mood span { position: relative; white-space: nowrap; }
.mood[aria-pressed="true"] { --edge: var(--ak-choice-selected-border); --face: var(--ak-choice-selected-bg); color: var(--ak-choice-selected-ink); }
.mood[aria-pressed="true"]::after { width: 8px; height: 8px; border-radius: 1px; rotate: 45deg; background: var(--ak-bg); box-shadow: none; }

.dials-head { display: flex; align-items: center; gap: 8px; min-height: 50px; }
.dials-head .slot-caption { margin: 0; flex: 0 1 auto; white-space: nowrap; }
.hex { flex: 1 1 auto; font-size: 13px; color: var(--ak-ink-muted); font-variant-numeric: tabular-nums; }
.moods-back {
  flex: 0 0 auto;
  min-height: 48px;
  min-width: 48px;
  padding: 0 12px;
  border: 2px solid var(--chalk);
  border-radius: var(--panel-r2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 15px;
}
.slot-page .step-head { margin: 0; }
.p-slot.is-called { border-color: var(--ak-accent); }
.grey-note { margin: 0 0 2px; font-size: 13px; color: var(--ak-ink-muted); }
/* The same warning, said in the dials' own header on a short phone, so the window keeps its room. */
.dial-bubble { display: none; }

.dial { display: grid; grid-template-columns: 66px 44px minmax(0, 1fr) 44px 34px; align-items: center; gap: 5px; min-height: 48px; }
.dial-name { font-family: var(--ak-font-display); font-size: 15px; line-height: 1.1; }
.dial-name small { display: block; margin-top: 2px; font-family: var(--ak-font-body); font-size: 10.5px; font-weight: 700; color: var(--ak-ink-muted); white-space: nowrap; }
.nudge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--chalk);
  border-radius: 50%;
  background: var(--ak-surface);
  color: var(--ak-ink);
}
.nudge:active { background: var(--ak-choice-selected-bg); color: var(--ak-choice-selected-ink); }
.dial output { font-size: 14px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

input[type="range"] {
  --thumb: #ffffff;
  width: 100%;
  height: 44px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  touch-action: none;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 16px;
  border: 2px solid var(--chalk);
  border-radius: 9px 4px 8px 5px;
  background: var(--track, var(--ak-surface));
}
input[type="range"]::-moz-range-track {
  height: 12px;
  border: 2px solid var(--chalk);
  border-radius: 9px 4px 8px 5px;
  background: var(--track, var(--ak-surface));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 36px;
  height: 36px;
  margin-top: -12px;
  border: 3px solid var(--chalk);
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 0 0 2px var(--ak-bg);
}
input[type="range"]::-moz-range-thumb {
  width: 30px;
  height: 30px;
  border: 3px solid var(--chalk);
  border-radius: 50%;
  background: var(--thumb);
  box-shadow: 0 0 0 2px var(--ak-bg);
}

/* ---------- Tools: catalogue drawer labels with a brass pull ---------- */

.tool {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: 50px;
  padding: 0 4px 10px;
  border: 2px solid var(--chalk);
  border-radius: 3px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 17px;
}
.tool span {
  display: inline-block;
  padding: 0 6px;
  border-bottom: 1.5px solid var(--ak-ink-muted);
}
.tool::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 9px;
  height: 9px;
  translate: -50% 0;
  border-radius: 50%;
  background: var(--ak-accent);
}
.tool-hint { border-style: dashed; border-color: var(--ak-accent); background: var(--ak-bg); }

/* ---------- Shelf: card-catalogue drawers in chalk ---------- */

.shelf-screen {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding:
    var(--top)
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, var(--ak-bg-art));
  background-size: cover;
  overflow: hidden;
}
.shelf-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 12px 10px 8px;
  border: var(--chalk-line) solid var(--chalk);
  border-radius: var(--panel-r);
  background: var(--ak-bg);
}
.shelf-head .caption-box { margin: 0; }
.shelf-head .kept { flex: 1 1 160px; margin: 0; }
.shelf-empty {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 14px;
  border: 2px dashed var(--chalk);
  border-radius: var(--panel-r2);
  background: var(--ak-bg);
  font-size: 17px;
}
.drawers {
  flex: 1 1 auto;
  width: min(100%, 860px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  align-content: start;
  gap: 14px 10px;
  overflow-y: auto;
  padding: 18px 4px 12px;
  overscroll-behavior: contain;
}
.drawer {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0 6px 6px;
  border: var(--chalk-line) solid var(--chalk);
  border-top-width: 0;
  border-radius: 0 0 6px 8px;
  background: var(--ak-bg);
}
.drawer-open {
  display: block;
  padding: 0;
  margin-top: -12px;
  border: 0;
  background: none;
  text-align: left;
}
.drawer-plate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 2px solid var(--chalk);
}
.drawer-plate .label { min-width: 0; font-size: 12.5px; color: var(--ak-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drawer-plate .pull { width: 22px; height: 10px; flex: 0 0 auto; }
.take-out {
  min-height: 48px;
  min-width: 48px;
  padding: 0 8px;
  border: 2px solid var(--ak-outline);
  border-radius: var(--panel-r2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- In-page sheets ---------- */

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 27;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding:
    var(--top)
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--ak-bg) 72%, transparent);
}
.sheet-layer.is-compact { background: color-mix(in srgb, var(--ak-bg) 28%, transparent); }
.sheet-layer.is-compact .sheet { width: min(100%, 560px); padding: 14px 16px 12px; }
@media (orientation: landscape) {
  /* Sideways the naming strip stands over the side column, so the preview on the left stays in view. */
  .sheet-layer.is-compact { justify-content: flex-end; }
  .sheet-layer.is-compact .sheet { width: min(54vw, 520px); padding-top: 10px; }
  /* The button already says what happens; the heading stays for screen readers only. */
  .sheet-layer.is-compact .sheet h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .sheet-layer.is-compact .idea-chips { gap: 6px; margin-top: 8px; }
  .sheet-layer.is-compact .idea-chip { padding: 4px 10px; font-size: 15px; }
}
@media (orientation: landscape) and (max-height: 400px) {
  /* A short phone on its side: the prompt moves into the empty field, so the clue keeps its line. */
  .sheet-layer.is-compact .name-head > span,
  .sheet-layer.is-compact .name-head .count { display: none; }
  .sheet-layer.is-compact .name-input { min-height: 44px; font-size: 18px; }
}
.sheet-layer.is-compact .sheet h2 { margin-bottom: 6px; font-size: 19px; }
.name-head { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 8px; font-size: 14px; color: var(--ak-ink-muted); }
.name-head .name-input { grid-column: 1 / -1; margin: 2px 0 0; }
.name-head .count { margin: 0; }
.idea-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.idea-chip {
  min-height: 44px;
  padding: 4px 14px;
  border: 2px solid var(--chalk);
  border-radius: 3px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 16px;
  rotate: -1.5deg;
}
.idea-chip:nth-child(even) { rotate: 1.5deg; }
.idea-chip[aria-pressed="true"] { background: var(--ak-choice-selected-bg); border-color: var(--ak-choice-selected-border); color: var(--ak-choice-selected-ink); }
.idea-chip.more { background: var(--ak-bg); color: var(--ak-ink); border-style: dashed; rotate: 0deg; font-size: 15px; }
.clue-line { margin: 6px 0 0; min-height: 1.35em; font-size: 15px; color: var(--ak-ink); }
.clue-line.is-warn { padding: 6px 10px; border-radius: 12px 12px 12px 3px; background: var(--ak-btn-fill); color: var(--ak-btn-ink); font-weight: 700; }
.sheet {
  width: min(100%, 460px);
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 16px 14px;
}
.sheet h2 {
  margin: 0 0 8px;
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: 22px;
}
.sheet p { margin: 0 0 10px; font-size: 16px; line-height: 1.35; }
.name-input {
  width: 100%;
  min-height: 50px;
  margin: 0 0 4px;
  padding: 6px 12px;
  border: 2px solid var(--chalk);
  border-radius: var(--panel-r2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 20px;
  user-select: text;
  -webkit-user-select: text;
}
.count { display: block; margin-bottom: 10px; font-size: 12.5px; color: var(--ak-ink-muted); text-align: right; }
.ideas { display: grid; gap: 6px; margin-bottom: 8px; }
.idea {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 6px 12px;
  border: 2px solid var(--ak-choice-border);
  border-radius: var(--panel-r2);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  text-align: left;
}
.idea b { display: block; font-family: var(--ak-font-display); font-weight: 400; font-size: 17px; }
.idea small { display: block; font-size: 13.5px; color: var(--ak-ink-muted); }
.idea[aria-pressed="true"] { background: var(--ak-choice-selected-bg); border-color: var(--ak-choice-selected-border); color: var(--ak-choice-selected-ink); }
.idea[aria-pressed="true"] small { color: var(--ak-choice-selected-ink); }
.sheet-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sheet-btn {
  min-height: 48px;
  padding: 0 16px;
  border: 2px solid var(--chalk);
  border-radius: var(--panel-r2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 16px;
}
.sheet-btn.primary { flex: 1 1 auto; background: var(--ak-btn-fill); color: var(--ak-btn-ink); }
.sheet-btn.quiet { border-style: dashed; }
.sheet .lib-card { width: min(100%, 240px); margin: 0 auto 10px; }
/* The sheet's buttons stay in reach while the ideas scroll above them. */
.sheet .sheet-row {
  position: sticky;
  bottom: -14px;
  z-index: 1;
  margin: 10px -16px -14px;
  padding: 10px 16px 14px;
  background: var(--ak-bg);
  border-top: 2px solid var(--ak-outline);
}
.sheet .step-head { margin: 4px 0 6px; font-weight: 700; font-size: 16px; }
.sheet .step-sub { margin: 2px 0 6px; font-size: 14px; color: var(--ak-ink-muted); }
.sheet .step-ok, .sheet .step-warn {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 14px 14px 14px 4px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-weight: 700;
}
.sheet .step-warn { border: 3px solid var(--ak-accent); }
.slip {
  margin: 0 0 12px;
  padding: 14px 16px 12px;
  border: 2px solid var(--ak-bg);
  border-left: 10px solid var(--ak-accent);
  border-radius: 3px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}
.sheet .slip p { margin: 0; }
.sheet .slip .slip-word { font-family: var(--ak-font-display); font-size: 24px; line-height: 1.2; }
.sheet .slip .slip-clue { margin-top: 4px; font-size: 16px; }
.sheet .slip .slip-meta { margin-top: 8px; font-size: 13.5px; font-weight: 700; }
.lib-stamp.is-request b { font-size: 3.4cqw; letter-spacing: 0.02em; }
#activity-chrome-status .ac-progress { cursor: pointer; }

/* The pinned print and its words always fit: the card centres with room to scroll, never cut at the top. */
html body #activity-chrome-ending.site-inspicacity { justify-content: flex-start; padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom)); }
html body #activity-chrome-ending.site-inspicacity .ac-card { margin: auto; flex: 0 0 auto; }
html body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: 34dvh; width: auto; }
html body #activity-chrome-ending.site-inspicacity .ac-actions button { min-height: 54px; padding: 0 24px; font-size: 19px; }
@media (orientation: portrait) and (max-height: 740px) {
  html body #activity-chrome-ending.site-inspicacity .ac-card { gap: 6px; padding: 26px 18px 16px; }
  html body #activity-chrome-ending.site-inspicacity .ac-verdict { font-size: 22px; }
  html body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: 30dvh; }
}
@media (orientation: landscape) {
  html body #activity-chrome-ending.site-inspicacity { padding: 14px max(18px, env(safe-area-inset-right)) 14px max(18px, env(safe-area-inset-left)); }
  html body #activity-chrome-ending.site-inspicacity .ac-card {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    grid-template-areas: "number work" "verdict work" "lines work" "actions work";
    align-content: center;
    align-items: center;
    gap: 10px 30px;
    width: min(92vw, 800px);
    padding: 26px 30px 22px;
    text-align: left;
    transform: rotate(-1deg);
  }
  html body #activity-chrome-ending.site-inspicacity .ac-number { grid-area: number; }
  html body #activity-chrome-ending.site-inspicacity .ac-number { font-size: 17px; }
  html body #activity-chrome-ending.site-inspicacity .ac-verdict { grid-area: verdict; font-size: clamp(22px, 3.4vw, 30px); line-height: 1.25; }
  html body #activity-chrome-ending.site-inspicacity .ac-lines { grid-area: lines; font-size: 17px; line-height: 1.4; }
  html body #activity-chrome-ending.site-inspicacity .ac-work { grid-area: work; justify-self: center; }
  html body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: calc(100dvh - 140px); }
  html body #activity-chrome-ending.site-inspicacity .ac-actions { grid-area: actions; justify-content: flex-start; }
}

/* ---------- Guided first round ---------- */

.coach { position: fixed; inset: 0; z-index: 22; pointer-events: none; }
.coach-ring {
  position: fixed;
  border: 4px solid var(--ak-accent);
  border-radius: 14px;
  box-shadow: 0 0 0 3px var(--ak-bg);
}
.coach-arrow { position: fixed; color: var(--ak-accent); filter: drop-shadow(0 0 1px var(--ak-bg)); }
.coach-say {
  position: fixed;
  margin: 0;
  max-width: min(340px, calc(100vw - 24px));
  padding: 12px 16px;
  border: 3px solid var(--ak-accent);
  border-radius: 18px 18px 18px 6px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.fly-layer { position: fixed; inset: 0; z-index: 21; pointer-events: none; }
.fly {
  position: fixed;
  border-radius: 4px;
  border: 2px solid var(--chalk);
}

/* ---------- Turned sideways: the window on one side, the tools on the other ---------- */

@media (orientation: landscape) {
  :root { --slot-h: minmax(0, 1fr); }
  #app {
    width: min(100%, 1100px);
    grid-template-columns: minmax(0, 1fr) clamp(300px, 42dvw, 440px) auto;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "stage chips tools"
      "stage slot tools";
  }
  .p-tools { flex-direction: column; width: 92px; }
  .chips-caption { display: none; }
  .tool { flex: 1 1 0; min-height: 48px; max-height: 72px; font-size: 16px; }
  .logo { height: 34px; }
  .p-slot { overflow-y: auto; padding-top: 4px; }
  .chip-paper { width: min(100%, 56px, calc((100dvh - 330px) * 0.5 + 44px)); }
  .chip-role { font-size: 11px; }
  .p-chips { padding-top: 6px; }
  .p-chips .bubble {
    position: absolute;
    right: -3px;
    bottom: calc(100% + 6px);
    z-index: 4;
    max-width: calc(100% + 6px);
    margin: 0;
    font-size: 13.5px;
  }
  .p-chips .bubble::after { bottom: -11px; }
  .dial { min-height: 44px; }
  .dials-head { margin-bottom: 0; }
  .moods-head { margin-bottom: 4px; }
  .mood { min-height: 44px; }
}

@media (max-width: 380px) {
  .thumb { width: 40px; height: 28px; }
  .chips { gap: 2px; }
  .p-chips { padding-left: 3px; padding-right: 3px; }
  .chip-role { font-size: 11px; letter-spacing: -0.01em; }
}

@media (orientation: landscape) and (max-width: 760px) {
  .thumb { width: 36px; height: 24px; }
  .mock-tab { padding: 2px; }
  /* A narrow side column: the dial keeps its − and + and a usable track; the number goes. */
  .dial { grid-template-columns: 54px 44px minmax(0, 1fr) 44px; gap: 4px; }
  .dial output, .dial-name small { display: none; }
}

@media (orientation: landscape) and (max-width: 720px) {
  .logo { height: 26px; }
  .mock-tab { font-size: 14px; padding: 0 2px; }
  .p-tools { width: 84px; }
}

@media (orientation: landscape) {
  /* Sideways the window is short, so the card stands on the left and the line sits beside it. */
  .last-panel:has(.saved-line:not([hidden])) .lib-card { left: 27%; width: 40%; }
  .last-panel:has(.saved-line:not([hidden])) .last-mark { display: none; }
  .last-panel .saved-line { left: 50%; right: 8px; top: 8px; font-size: 13px; padding: 6px 10px; }
  .last-panel .saved-line::after { left: -8px; bottom: auto; top: 24px; border: 6px solid transparent; border-right: 8px solid var(--ak-btn-fill); border-left-width: 0; }
}

@media (orientation: landscape) and (max-height: 430px) {
  .mock-tab { min-height: 48px; font-size: 15px; }
  .stage-note { font-size: 14px; }
  .grey-note { display: none; }
}

@media (orientation: portrait) and (max-height: 740px) {
  .moods-head { display: none; }
  .stage-note { font-size: 14px; padding: 6px 10px; top: 6px; }
  .chips-caption { display: none; }
  #app.is-dialing .p-chips .bubble { display: none; }
  #app.is-dialing .dial-bubble:not([hidden]) {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 4px 8px;
    border-radius: 10px 10px 10px 3px;
    background: var(--ak-btn-fill);
    color: var(--ak-btn-ink);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
  }
  #app.is-dialing .dial-bubble:not([hidden]) ~ .moods-back { flex: 0 0 auto; }
  #app.is-dialing .dials-head:has(.dial-bubble:not([hidden])) .hex { display: none; }
  #app.is-dialing .chip-paper { width: min(100%, 44px); }
  .p-tools { padding: 3px; }
  #app.is-dialing .mock-tabs { display: none; }
  .p-chips .bubble { font-size: 13.5px; padding: 5px 10px; margin-bottom: 10px; }
  .logo { height: 34px; }
  .chip-paper { width: min(100%, 52px); }
  .dial { min-height: 44px; }
  .moods-head { margin-bottom: 4px; }
  .tool { min-height: 48px; }
  .grey-note { display: none; }
}

@media (orientation: portrait) and (max-height: 600px) {
  :root { --gut: 6px; }
  .chip-paper { width: min(100%, 46px); }
  .mock-tabs { padding-top: 4px; }
}

/* ---------- Motion: slow and quiet, and never when asked to be still ---------- */

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .track { transition: transform var(--turn) cubic-bezier(0.3, 0.7, 0.2, 1); }
  :root:not(.ac-still) .mock * { transition: fill var(--wash) ease, stroke var(--wash) ease, opacity var(--wash) ease; }
  :root:not(.ac-still) .window { transition: background-color var(--wash) ease; }
  :root:not(.ac-still) .chip-fill { transition: background-color 420ms ease; }
  :root:not(.ac-still) .chip-paper,
  :root:not(.ac-still) .mood { transition: translate 260ms ease, scale 200ms ease; }
  :root:not(.ac-still) .chip.is-pressed .chip-paper { animation: tape-press 360ms ease-out; }
  :root:not(.ac-still) .chip-tag { animation: tape-slap 380ms ease-out; }
  :root:not(.ac-still) .slot-page.is-entering { animation: panel-in 420ms cubic-bezier(0.3, 0.7, 0.2, 1); }
  :root:not(.ac-still) .slot-page.is-entering.from-left { animation-name: panel-in-left; }
  :root:not(.ac-still) .shelf-screen.is-entering { animation: panel-in 480ms cubic-bezier(0.3, 0.7, 0.2, 1); }
  :root:not(.ac-still) .sheet-layer:not([hidden]) .sheet { animation: sheet-in 360ms cubic-bezier(0.3, 0.7, 0.2, 1); }
  :root:not(.ac-still) .coach-ring { animation: ring-pulse 1600ms ease-in-out infinite; }
  :root:not(.ac-still) .last-panel:not([hidden]) { animation: panel-in 420ms cubic-bezier(0.3, 0.7, 0.2, 1); }
  :root:not(.ac-still) .last-panel:not([hidden]) .lib-card { animation: card-file 1100ms 380ms cubic-bezier(0.4, 0, 0.2, 1) both; }
  :root:not(.ac-still) .lib-stamp.is-wet { animation: stamp-thump 520ms 120ms ease-out both; }
  :root:not(.ac-still) .lib-stamp.is-wet::after { animation: ink-spread 1400ms 300ms ease-out both; }
  :root:not(.ac-still) .settled { animation: settle 500ms ease-out; }
  :root:not(.ac-still) .p-slot.is-called { animation: called 900ms ease-out; }
}

.lib-stamp.is-wet::after {
  content: '';
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  border: 0.5cqw solid currentColor;
  opacity: 0.35;
}

@keyframes tape-press { 0% { scale: 0.94; } 100% { scale: 1; } }
@keyframes tape-slap { 0% { opacity: 0; translate: 0 -8px; } 100% { opacity: 1; translate: 0 0; } }
@keyframes panel-in { 0% { opacity: 0; transform: translateX(14%); } 100% { opacity: 1; transform: none; } }
@keyframes panel-in-left { 0% { opacity: 0; transform: translateX(-14%); } 100% { opacity: 1; transform: none; } }
@keyframes sheet-in { 0% { opacity: 0; transform: translateY(24px); } 100% { opacity: 1; transform: none; } }
@keyframes ring-pulse { 0%, 100% { scale: 1; opacity: 1; } 50% { scale: 1.04; opacity: 0.75; } }
@keyframes card-file { 0% { translate: -50% -70%; } 100% { translate: -50% 0; } }
@keyframes stamp-thump { 0% { scale: 1.5; opacity: 0; } 60% { scale: 0.96; opacity: 1; } 100% { scale: 1; opacity: 1; } }
@keyframes ink-spread { 0% { inset: 2%; opacity: 0.7; } 100% { inset: -8%; opacity: 0.25; } }
@keyframes called { 0% { border-color: var(--ak-accent); } 100% { border-color: var(--ak-accent); } }
@keyframes settle { 0% { opacity: 0.4; } 100% { opacity: 1; } }
