/* The Shelf — masano.casa/PIC
   Dark slate, same as Pinboard and Casa Calendar. The accent is not fixed:
   every frame picks its own, and that colour does double duty — it themes
   that household's view and tags their photos in everybody else's grid. */

:root {
  --color-bg:        oklch(19% 0.012 250);
  --color-bg-raise:  oklch(23% 0.014 250);
  --color-surface:   oklch(26% 0.015 250);
  --color-line:      oklch(34% 0.016 250);
  --color-text:      oklch(93% 0.008 250);
  --color-text-dim:  oklch(70% 0.012 250);
  --color-danger:    oklch(64% 0.19 25);

  /* Overwritten at runtime from the signed-in frame's choice. */
  --color-accent:      oklch(72% 0.18 55);
  --color-accent-deep: oklch(60% 0.19 45);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

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

.kicker {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin: 0 0 .5rem;
}

/* ===== Buttons ===== */
button.primary {
  border: 0;
  border-radius: 999px;
  padding: .7rem 1.3rem;
  font-weight: 600;
  color: oklch(18% 0.02 60);
  background: linear-gradient(180deg, var(--color-accent), var(--color-accent-deep));
  box-shadow: var(--shadow);
}
button.primary:disabled { opacity: .45; cursor: default; }
button.ghost {
  background: transparent;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  padding: .6rem 1.1rem;
  color: var(--color-text-dim);
}
button.ghost:hover { color: var(--color-text); border-color: var(--color-accent-deep); }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* ===== PIN gate ===== */
#gate {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  /* A soft bloom of the frame's own accent, so the door already feels like
     their frame before they are through it. */
  background:
    radial-gradient(60% 50% at 50% 0%,
      color-mix(in oklch, var(--color-accent) 14%, transparent), transparent 70%),
    var(--color-bg);
}
.gate-inner { width: min(23rem, 100%); text-align: center; }
.gate-inner h1 {
  font-size: clamp(2rem, 8vw, 2.8rem);
  margin: 0 0 .3rem;
  letter-spacing: -.02em;
}
.gate-inner h1 em { font-style: normal; color: var(--color-accent); }
.gate-sub { color: var(--color-text-dim); margin: 0 0 1.8rem; }
#pinInput {
  width: 100%;
  text-align: center;
  font-size: 2rem;
  letter-spacing: .5em;
  text-indent: .5em;               /* centres text that carries a trailing gap */
  padding: .8rem 0;
  background: var(--color-bg-raise);
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
#pinInput:focus { border-color: var(--color-accent); outline: none; }
.gate-error { color: var(--color-danger); min-height: 1.4em; margin: .8rem 0 0; font-size: .9rem; }

/* The setup form lives in the gate, which centres everything — so it needs
   its own field styling rather than the sheet's. */
#setupForm { text-align: left; margin-top: 1.4rem; }
#setupForm label.field {
  display: block;
  margin: .9rem 0 .35rem;
  font-size: .8rem;
  color: var(--color-text-dim);
}
#setupForm input[type="text"] {
  width: 100%;
  background: var(--color-bg-raise);
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: .7rem .8rem;
  font-size: 1rem;
}
#setupForm input[type="text"]:focus { border-color: var(--color-accent); outline: none; }
#setupForm #suCode { letter-spacing: .2em; font-family: var(--mono); }
#setupForm #suPin { letter-spacing: .35em; font-family: var(--mono); }

/* ===== App shell ===== */
/* Installed to the Home Screen the page runs under a translucent status bar,
   so on a notched iPhone the household name sits behind the speaker. The top
   inset is 0 in a normal browser tab, so this costs nothing there. */
#app {
  max-width: 68rem;
  margin: 0 auto;
  padding: calc(1.1rem + env(safe-area-inset-top)) 1.1rem
           calc(2.5rem + env(safe-area-inset-bottom));
}

header.bar {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .3rem 0 1.2rem;
}
header.bar h1 { font-size: 1.35rem; margin: 0; letter-spacing: -.01em; }
header.bar h1 span { color: var(--color-accent); }
header.bar .spacer { flex: 1; }

.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: var(--color-bg-raise);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  color: var(--color-text-dim);
}
.icon-btn:hover { color: var(--color-text); border-color: var(--color-accent-deep); }
.icon-btn { position: relative; flex: none; }

/* Five icons and a household name do not share a phone's width gracefully.
   The icons live in one box that wraps as a UNIT — letting them wrap
   individually left two on one line and three on the next, which reads as a
   mistake rather than a layout. The name claims 13rem, so the moment there
   isn't room for both, the whole row of icons drops underneath together. */
header.bar { flex-wrap: wrap; }
header.bar > div:first-child { flex: 1 1 13rem; min-width: 0; }
.bar-actions { display: flex; gap: .5rem; flex: 0 0 auto; }
@media (max-width: 700px) {
  header.bar { gap: .5rem; padding-bottom: .9rem; }
  header.bar .spacer { display: none; }
  header.bar h1 { font-size: 1.2rem; }
  .icon-btn { width: 38px; height: 38px; }
  /* Its own full-width line, evenly spread — deliberate, not leftovers. */
  .bar-actions { flex: 1 0 100%; justify-content: space-between; }
  .bar-actions .icon-btn { flex: 1 1 auto; max-width: 4.5rem; }
}
.icon-btn .badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  display: grid; place-items: center;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-accent);
  color: oklch(18% 0.02 60);
  font-family: var(--mono); font-size: .62rem; font-weight: 700;
}

/* ===== Inbox ===== */
.inbox-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: .8rem;
  align-items: center;
  padding: .7rem 0;
  border-bottom: 1px solid var(--color-line);
}
.inbox-item:last-child { border-bottom: 0; }
.inbox-item img {
  width: 110px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-line);
  display: block;
}
.inbox-item .t { font-size: .92rem; font-weight: 600; margin: 0; }
.inbox-item .f { font-size: .76rem; color: var(--color-text-dim); margin: .1rem 0 .5rem; }
.inbox-item .row { display: flex; gap: .5rem; }
.inbox-item .row button { padding: .4rem .9rem; font-size: .82rem; }
.inbox-empty { color: var(--color-text-dim); font-size: .86rem; padding: 1rem 0; }

/* ===== Upload destinations ===== */
.dest-boxes { display: grid; gap: .4rem; margin-top: .3rem; }
.dest-boxes label {
  display: flex; align-items: center; gap: .55rem;
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: .55rem .75rem;
  font-size: .9rem;
}
.dest-boxes input { accent-color: var(--color-accent); }
.dest-boxes .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fc); margin-left: auto; }

/* The one tone control that reaches the wall, so it gets room to explain
   itself rather than sitting there as a bare checkbox nobody dares touch. */
.opt-row {
  display: flex; align-items: flex-start; gap: .6rem;
  margin-top: .8rem;
  padding: .6rem .75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
}
.opt-row input { accent-color: var(--color-accent); margin-top: .15rem; }
.opt-row b { display: block; font-size: .88rem; font-weight: 600; }
.opt-row small {
  display: block; margin-top: .15rem;
  font-size: .76rem; line-height: 1.35; color: var(--color-text-dim);
}

/* Folded away by default: most photos never need it, and six sliders on top
   of the crop would bury the thing you actually came here to do. */
.adjust { margin-top: .5rem; }
.adjust > summary {
  cursor: pointer; list-style: none;
  padding: .5rem .75rem;
  font-size: .84rem; color: var(--color-text-dim);
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: .5rem;
}
.adjust > summary::-webkit-details-marker { display: none; }
.adjust > summary::before {
  content: "›"; display: inline-block;
  transition: transform var(--duration-fast, 150ms) ease;
  font-size: 1rem; line-height: 1;
}
.adjust[open] > summary::before { transform: rotate(90deg); }
.adjust > summary:hover { color: var(--color-text); border-color: var(--color-accent-deep); }
/* Says "3 changed" so a folded panel can never hide why a photo looks odd. */
.adjust-state { margin-left: auto; font-family: var(--mono); font-size: .7rem; }
.adjust-state[data-on="1"] { color: var(--color-accent); }

.adjust-grid { display: grid; gap: .5rem; margin: .6rem 0 .5rem; }
.adjust-grid label {
  display: grid; grid-template-columns: 7.5rem 1fr 2.5rem; align-items: center;
  gap: .5rem; font-size: .8rem; color: var(--color-text-dim);
}
.adjust-grid input[type=range] { accent-color: var(--color-accent); min-width: 0; }
.adjust-grid output { font-family: var(--mono); font-size: .72rem; text-align: right; }
.adjust #adjustReset { width: 100%; }
@media (max-width: 560px) {
  .adjust-grid label { grid-template-columns: 5.5rem 1fr 2.2rem; gap: .4rem; font-size: .74rem; }
}

header.bar .statusline {
  margin: .25rem 0 0;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .04em;
  color: var(--color-text-dim);
}

/* ===== What's on the frame ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.now {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(180px, 1fr);
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 1.1rem;
  /* The frame's accent, breathing gently behind its own live view. */
  background:
    radial-gradient(90% 120% at 0% 0%,
      color-mix(in oklch, var(--color-accent) 7%, transparent), transparent 60%),
    var(--color-surface);
}
@media (max-width: 560px) { .now { grid-template-columns: 1fr; } }
.now-view {
  position: relative;
  aspect-ratio: 5 / 3;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-bg-raise);
}
.now-view canvas {
  width: 100%; height: 100%; display: block;
  image-rendering: auto;
}
.now-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: color-mix(in oklch, var(--color-bg) 78%, transparent);
  color: var(--color-text-dim);
  font-size: .84rem; text-align: center; padding: 1rem;
}
.now-label {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.now-sub {
  margin: .25rem 0 .9rem;
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .05em;
  color: var(--color-text-dim);
}
.now-controls { display: flex; gap: .45rem; flex-wrap: wrap; }
.now-controls button { padding: .5rem .85rem; font-size: .85rem; }
button.ghost.danger { color: var(--color-danger); }
button.ghost.danger:hover { border-color: var(--color-danger); }
#wifiForget.armed {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: oklch(97% 0.01 25);
  font-weight: 600;
}
button.ghost.danger.armed {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: oklch(97% 0.01 25);
  font-weight: 600;
}
.cmd-hint {
  margin: .7rem 0 0;
  font-size: .76rem;
  color: var(--color-accent);
}

/* ===== Home-screen install hint ===== */
.install-hint {
  display: flex;
  align-items: center;
  gap: .8rem;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius);
  padding: .7rem .9rem;
  margin-bottom: 1.1rem;
}
.install-hint img { border-radius: 9px; flex: none; }
.install-hint .t { margin: 0; font-size: .88rem; font-weight: 600; }
.install-hint .s { margin: .15rem 0 0; font-size: .76rem; color: var(--color-text-dim); }
.install-hint .icon-btn { width: 32px; height: 32px; flex: none; margin-left: auto; }
.install-hint .ghost { flex: none; padding: .45rem .9rem; font-size: .82rem; }

/* ===== Frame filter =====
   One button that says whose shelf you are on, and a menu with all of them.
   The old chip row put the fourth household off the right-hand edge, which
   on a phone meant scrolling sideways to find your neighbours. */
.frame-filter { position: relative; margin-bottom: .9rem; }
.filter-btn {
  display: flex; align-items: center; gap: .6rem;
  width: 100%;
  background: var(--color-bg-raise);
  border: 1px solid var(--color-line);
  border-left: 3px solid var(--fc, var(--color-accent));
  border-radius: var(--radius);
  padding: .7rem .9rem;
  color: var(--color-text);
  font-size: .95rem;
  text-align: left;
}
.filter-btn:hover { border-color: var(--fc, var(--color-accent)); }
.filter-btn .dot,
.filter-opt .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--fc); flex: none; }
.filter-btn .lbl, .filter-opt .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-btn .n, .filter-opt .n { font-family: var(--mono); font-size: .74rem; color: var(--color-text-dim); flex: none; }
.filter-btn .caret { color: var(--color-text-dim); flex: none; }
.filter-btn[aria-expanded="true"] .caret { transform: rotate(180deg); }

.filter-menu {
  position: absolute; z-index: 45;
  top: calc(100% + .35rem); left: 0; right: 0;
  display: grid; gap: .15rem;
  padding: .3rem;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60svh; overflow-y: auto;
}
.filter-opt {
  display: flex; align-items: center; gap: .6rem;
  width: 100%;
  background: transparent;
  border: 0; border-radius: var(--radius-sm);
  padding: .6rem .7rem;
  color: var(--color-text-dim);
  font-size: .92rem;
  text-align: left;
}
.filter-opt:hover { background: var(--color-bg-raise); color: var(--color-text); }
.filter-opt[aria-selected="true"] {
  background: color-mix(in oklch, var(--fc) 16%, transparent);
  color: var(--color-text);
  font-weight: 600;
}

/* ===== Filter chips (collections, senders) ===== */
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .9rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: .45rem;
  background: var(--color-bg-raise);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  padding: .45rem .9rem;
  color: var(--color-text-dim);
  white-space: nowrap;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--fc, var(--color-accent)); }
.chip[aria-pressed="true"] { color: var(--color-text); border-color: var(--fc, var(--color-accent)); }
.chip .n { font-family: var(--mono); font-size: .74rem; opacity: .6; }

/* ===== Photo grid ===== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .8rem;
}
.tile {
  position: relative;
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  overflow: hidden;
  text-align: left;
  /* The owning frame's accent, as a hairline down the side — enough to read
     "whose is this" across a grid without colouring the photo itself. */
  border-left: 3px solid var(--fc, var(--color-accent));
  transition: transform .12s ease, border-color .12s ease;
}
.tile:hover { transform: translateY(-2px); }
.tile canvas { display: block; width: 100%; height: auto; background: var(--color-bg-raise); }
.tile .meta { padding: .5rem .6rem .6rem; }
.tile .t { display: block; font-size: .85rem; line-height: 1.25; }
.tile .f {
  display: block;
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  margin-top: .2rem;
}
.tile .mine {
  position: absolute; top: .5rem; right: .5rem;
  font-family: var(--mono); font-size: .6rem; letter-spacing: .08em;
  background: rgb(0 0 0 / .55); backdrop-filter: blur(4px);
  padding: .2rem .45rem; border-radius: 999px;
  color: var(--color-text-dim);
}
.tile .mine.showing {
  background: var(--color-accent);
  color: oklch(18% 0.02 60);
  font-weight: 700;
}

.empty {
  border: 1px dashed var(--color-line);
  border-radius: var(--radius);
  padding: 2.5rem 1.2rem;
  text-align: center;
  color: var(--color-text-dim);
}

/* ===== Incoming tray ===== */
#tray {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%);
  width: min(30rem, calc(100vw - 1.6rem));
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .7rem .9rem;
  z-index: 40;
}
#tray p { margin: 0; font-size: .84rem; color: var(--color-text-dim); }
#tray b { color: var(--color-text); font-weight: 600; }

/* ===== Sheets (upload, settings) ===== */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 60;
  background: rgb(0 0 0 / .55);
  display: grid; place-items: end center;
  padding: 0;
}
@media (min-width: 700px) { .sheet-wrap { place-items: center; padding: 1.5rem; } }
.sheet {
  width: min(34rem, 100%);
  max-height: 92svh; overflow-y: auto;
  background: var(--color-bg-raise);
  border: 1px solid var(--color-line);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
@media (min-width: 700px) { .sheet { border-radius: var(--radius); } }
.sheet h2 { margin: 0 0 1rem; font-size: 1.1rem; }
.sheet label.field { display: block; margin: .9rem 0 .35rem; font-size: .8rem; color: var(--color-text-dim); }
.sheet input[type="text"], .sheet select {
  width: 100%;
  background: var(--color-bg);
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: .65rem .75rem;
}
.sheet input:focus, .sheet select:focus { border-color: var(--color-accent); outline: none; }
/* Wraps rather than crushes. No breakpoint: min-width makes the secondary
   buttons wrap whenever they can't each hold their label, at any viewport
   or sheet width. The primary always takes its own full-width row at the
   bottom — a big unambiguous thumb target, and it reads as the answer to
   the sheet rather than one of four equal options. */
.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1.2rem;
}
.sheet-actions button {
  flex: 1 1 auto;
  min-width: 6.5rem;
  white-space: nowrap;
  padding-inline: .9rem;
}
.sheet-actions .primary { flex: 1 1 100%; order: 99; }

/* ===== Crop stage — the part that has to work on a phone ===== */
#stage {
  position: relative;
  width: 100%;
  aspect-ratio: 800 / 480;
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  touch-action: none;            /* we own pinch and pan */
  cursor: grab;
}
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#stage.dragging { cursor: grabbing; }
.stage-hint {
  position: absolute; left: 50%; bottom: .5rem; transform: translateX(-50%);
  font-family: var(--mono); font-size: .64rem; letter-spacing: .06em;
  background: rgb(0 0 0 / .5); padding: .25rem .6rem; border-radius: 999px;
  color: var(--color-text-dim); pointer-events: none;
}
/* Who the crop is for — quiet, but never absent when the answer is
   "not the person dragging". */
.crop-note {
  margin: .7rem 0 0;
  padding: .5rem .7rem;
  font-size: .78rem; line-height: 1.4;
  color: var(--color-text-dim);
  background: var(--color-bg);
  border: 1px dashed var(--color-line);
  border-radius: var(--radius-sm);
}
.zoom-row { display: flex; align-items: center; gap: .7rem; margin-top: .8rem; }
.zoom-row input[type="range"] { flex: 1; accent-color: var(--color-accent); }

/* ===== Accent picker ===== */
.swatches { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.swatches button {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid transparent; background: var(--c);
}
.swatches button.sel { border-color: var(--color-text); }

/* ===== Note composer + settings furniture ===== */
.sheet textarea {
  width: 100%;
  background: var(--color-bg);
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: .65rem .75rem;
  resize: vertical;
}
.sheet textarea:focus { border-color: var(--color-accent); outline: none; }
.emoji-pick { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .6rem; }
.emoji-pick button {
  width: 40px; height: 40px;
  font-size: 1.25rem; line-height: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
}
.emoji-pick button:hover { border-color: var(--color-accent-deep); }

/* Settings folds into collapsible groups — the sheet had grown into one
   long scroll where the thing you wanted was always off-screen. */
.set-group { border-top: 1px solid var(--color-line); }
.set-group:first-of-type { border-top: 0; }
.set-group > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 0 .7rem;
  user-select: none;
}
.set-group > summary::-webkit-details-marker { display: none; }
.set-group > summary::after {
  content: "›";
  margin-left: auto;
  font-size: 1.1rem;
  color: var(--color-text-dim);
  transition: transform .15s ease;
}
.set-group[open] > summary::after { transform: rotate(90deg); }
.set-group > summary:hover { color: var(--color-text); }
.set-group > *:last-child { margin-bottom: .9rem; }

.set-h {
  margin: 1.3rem 0 .4rem;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--color-accent);
  font-weight: 600;
}
.seg { display: flex; gap: 0; border: 1px solid var(--color-line); border-radius: 999px; overflow: hidden; }
.seg button {
  flex: 1;
  padding: .5rem .4rem;
  background: transparent;
  border: 0;
  font-size: .84rem;
  color: var(--color-text-dim);
}
.seg button + button { border-left: 1px solid var(--color-line); }
.seg button[aria-pressed="true"] {
  background: color-mix(in oklch, var(--color-accent) 22%, transparent);
  color: var(--color-text);
}
.check-row {
  display: flex; align-items: center; gap: .5rem;
  margin: .8rem 0 0; font-size: .88rem;
}
.check-row input { accent-color: var(--color-accent); }
.sheet .row { display: flex; gap: .6rem; align-items: center; margin-top: .5rem; }
.sheet input[type="time"] {
  background: var(--color-bg);
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
  color-scheme: dark;
}
.tone-v { width: 2.2rem; text-align: right; font-family: var(--mono); font-size: .78rem; color: var(--color-text-dim); }
/* Note lettering — CSS stand-ins for the panel's four GFX faces. */
.font-seg { margin-top: .3rem; }
.font-seg button { font-size: 1.05rem; }
.font-seg [data-font="sans"]   { font-weight: 700; }
.font-seg [data-font="serif"]  { font-family: Georgia, "Times New Roman", serif; font-weight: 700; }
.font-seg [data-font="italic"] { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-style: italic; }
.font-seg [data-font="mono"]   { font-family: ui-monospace, Menlo, monospace; font-weight: 700; }

/* Collections row — nested under the frame chips, quieter on purpose. */
.album-chips { padding-top: 0; margin-top: -.3rem; }
.album-chips .chip { font-size: .8rem; padding: .35rem .8rem; }
.album-chips .chip.new-album {
  font-weight: 700;
  color: var(--color-accent);
  border-style: dashed;
}
.chip-input {
  background: var(--color-bg-raise);
  border: 1px solid var(--color-accent);
  border-radius: 999px;
  padding: .35rem .8rem;
  font-size: .8rem;
  width: 9rem;
}
.chip-input:focus { outline: none; }
.album-chips .chip.save-all {
  border-color: var(--color-accent-deep);
  color: var(--color-accent);
  font-weight: 600;
}
.album-chips .chip.save-all.armed {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: oklch(18% 0.02 60);
}
.album-chips .chip.save-all:disabled {
  opacity: .5;
  border-color: var(--color-line);
  color: var(--color-text-dim);
  font-weight: 400;
  cursor: default;
}
.album-chips .chip.danger-chip { color: var(--color-danger); border-style: dashed; }
.album-chips .chip.danger-chip.armed {
  background: var(--color-danger);
  border-color: var(--color-danger);
  border-style: solid;
  color: oklch(97% 0.01 25);
  font-weight: 600;
}
.album-chips .chip.play {
  border-color: var(--color-accent-deep);
  color: var(--color-accent);
}

/* Sounds — one row per voice. */
.sound-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: .6rem;
  align-items: center;
  margin-top: .6rem;
}
.sound-row .lbl { display: flex; align-items: center; gap: .5rem; font-size: .86rem; min-width: 9.5rem; }
.sound-row .lbl input { accent-color: var(--color-accent); }
.sound-row select {
  width: 100%;
  background: var(--color-bg);
  border: 1.5px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
}
.sound-row .test {
  background: transparent;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  padding: .4rem .8rem;
  font-size: .8rem;
  color: var(--color-text-dim);
}
.sound-row .test:hover { color: var(--color-text); border-color: var(--color-accent-deep); }
@media (max-width: 560px) {
  .sound-row { grid-template-columns: 1fr auto; }
  .sound-row .lbl { grid-column: 1 / -1; }
}

.album-chip {
  display: inline-flex; align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  padding: .35rem .8rem;
  font-size: .8rem;
  color: var(--color-text-dim);
}
.album-chip[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-text); }

/* "We can see a frame waiting" — reassurance before anything is typed. */
.seen-note {
  font-size: .78rem;
  color: var(--color-text);
  background: color-mix(in oklch, var(--color-accent) 14%, transparent);
  border: 1px solid var(--color-accent-deep);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  margin: 0 0 .6rem;
}
.frame-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--color-line);
  font-size: .9rem;
}
.frame-row:last-child { border-bottom: 0; }
.frame-row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--fc); flex: none; }
.frame-row .nm { flex: 1; }
.frame-row button { padding: .3rem .8rem; font-size: .78rem; flex: none; }
.frame-row button.armed {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: oklch(97% 0.01 25);
  font-weight: 600;
}

.seen-note code {
  font-family: var(--mono);
  letter-spacing: .12em;
  font-weight: 700;
}

.pull-note {
  margin: 1.1rem 0 0;
  text-align: center;
  font-size: .84rem;
  color: var(--color-text-dim);
  background: var(--color-bg);
  border: 1px dashed var(--color-line);
  border-radius: var(--radius-sm);
  padding: .6rem;
}

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: 999px;
  padding: .6rem 1.1rem;
  font-size: .87rem;
  box-shadow: var(--shadow);
  z-index: 80;
}

/* ===== Upload button =====
   Was a floating pill in the bottom-right corner, which put the app's main
   action furthest from where the eye starts and left it sitting on top of
   the grid. Full width, above the frame's own view: impossible to miss,
   impossible to mis-tap. */
#fab {
  display: block;
  width: 100%;
  height: 54px;
  margin: 0 0 1.1rem;
  border: 0; border-radius: var(--radius);
  font-weight: 600; font-size: 1rem;
  color: oklch(18% 0.02 60);
  background: linear-gradient(180deg, var(--color-accent), var(--color-accent-deep));
  box-shadow: var(--shadow);
}
#fab:hover { filter: brightness(1.06); }

/* The note, the same size and shape as the upload but in the quieter
   treatment: both are things you do, and a second gradient competing with
   the first would make the pair read as a fork rather than a hierarchy. */
#noteBtn {
  display: block;
  width: 100%;
  height: 54px;
  margin: -0.35rem 0 1.1rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  font-weight: 600; font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg-raise);
  transition: border-color var(--duration-fast), color var(--duration-fast);
}
#noteBtn:hover { border-color: var(--color-accent-deep); }
#noteBtn:active { filter: brightness(1.1); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Frame picker — shown when somebody arrives without an invite link. */
#framePick { display: grid; gap: .6rem; margin-bottom: 1.1rem; }
.frame-tile {
  display: flex; align-items: center; gap: .7rem;
  background: var(--color-bg-raise);
  border: 1px solid var(--color-line);
  border-left: 3px solid var(--fc, var(--color-accent));
  border-radius: var(--radius);
  padding: .9rem 1rem;
  font-size: 1rem; text-align: left;
  transition: border-color .12s ease, transform .12s ease;
}
.frame-tile:hover { transform: translateY(-1px); border-color: var(--fc, var(--color-accent)); }
.frame-tile .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--fc); flex: none; }
.frame-tile.new-frame {
  border-style: dashed;
  border-left-color: var(--color-line);
  color: var(--color-text-dim);
}
.frame-tile.new-frame:hover { color: var(--color-text); border-color: var(--color-accent-deep); }
.frame-tile .plus {
  width: 10px; text-align: center; flex: none;
  color: var(--color-accent); font-weight: 700;
}
/* Arrived by scanning a frame — this tile is the one they came to press. */
.frame-tile.new-frame.armed {
  border-style: solid;
  border-color: var(--color-accent-deep);
  border-left-color: var(--color-accent);
  color: var(--color-text);
  background: color-mix(in oklch, var(--color-accent) 12%, var(--color-bg-raise));
}
.frame-tile .code {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .82rem;
  letter-spacing: .14em;
  color: var(--color-accent);
  font-weight: 700;
}
