/* Fieldnote: warm paper palette, plain utility layout, light and dark. */

:root {
  --bg: #f6f1e7;
  --surface: #fffcf6;
  --surface-2: #efe7d8;
  --ink: #2a2520;
  --muted: #6d6358;
  --line: #ddd2bf;
  --accent: #a8471f;
  --accent-ink: #fffaf2;
  --accent-soft: #f3dccd;
  --logo-ink: #fffaf2;
  --warn: #c98a0c;
  --warn-bg: #fbe7a6;
  --warn-ink: #4a3500;
  --ok: #3d7a4c;
  --danger: #a33a2c;
  --focus: #2f6db3;
  --flash: #ffd34d;
  --event-bg: #e6eef0;
  --event-line: #b9cdd3;
  --event-ink: #2f5d6b;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --radius: 12px;
  --tap: 48px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #1b1916;
    --surface: #24211d;
    --surface-2: #2f2a24;
    --ink: #eee7da;
    --muted: #a99e8f;
    --line: #3d372f;
    --accent: #e08a5c;
    --accent-ink: #1b1916;
    --accent-soft: #4a2e1f;
    --logo-ink: #1b1916;
    --warn: #e7b53b;
    --warn-bg: #5a4510;
    --warn-ink: #fff1c7;
    --ok: #79b98a;
    --danger: #ef8a7a;
    --focus: #7fb0ea;
    --flash: #806000;
  --event-bg: #1e2b30;
  --event-line: #35505a;
  --event-ink: #8fc3d1;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #1b1916;
  --surface: #24211d;
  --surface-2: #2f2a24;
  --ink: #eee7da;
  --muted: #a99e8f;
  --line: #3d372f;
  --accent: #e08a5c;
  --accent-ink: #1b1916;
  --accent-soft: #4a2e1f;
  --logo-ink: #1b1916;
  --warn: #e7b53b;
  --warn-bg: #5a4510;
  --warn-ink: #fff1c7;
  --ok: #79b98a;
  --danger: #ef8a7a;
  --focus: #7fb0ea;
  --flash: #806000;
  --event-bg: #1e2b30;
  --event-line: #35505a;
  --event-ink: #8fc3d1;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; margin-top: 0.5rem; }
p { margin: 0.25rem 0 0.75rem; }
a { color: var(--accent); }
kbd { font-family: var(--mono); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.block { display: block; }
.warn-text { color: var(--warn); }
.lede { color: var(--muted); font-size: 1.02rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 600 0.95rem/1.2 var(--sans);
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--accent-ink); }
.btn.danger-ghost { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { min-height: 36px; padding: 0.3rem 0.75rem; font-size: 0.85rem; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.wide { width: 100%; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.remove { width: 36px; height: 36px; font-size: 1.3rem; color: var(--muted); flex: none; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: 600 0.8rem/1 var(--sans);
  cursor: pointer;
  white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.ok .dot { background: var(--ok); }
.pill.wait { color: var(--ink); }
.pill.wait .dot { background: var(--warn); }
.pill.busy .dot { background: var(--focus); }

.row { display: flex; gap: 0.5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* ---------- page frame ---------- */

.page { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: calc(0.5rem + env(safe-area-inset-top)) 1rem 0.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 1.25rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 0.25rem; }
.brand-mark { color: var(--accent); display: inline-grid; place-items: center; width: 36px; }
.back { font-size: 2rem; margin-left: -0.5rem; }

.content { width: 100%; max-width: 1080px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.content.narrow { max-width: 760px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.25rem 0 0.75rem; }

.notice {
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin: 0.75rem 0;
}
.notice.error { border-color: var(--danger); color: var(--danger); background: var(--surface); }
.notice.error ul { margin: 0; padding-left: 1.2rem; }
.notice.active-session { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-color: var(--accent); }

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

/* ---------- sign-in ---------- */

.signin { min-height: 100dvh; display: grid; justify-items: center; align-content: start; gap: 2rem; padding: 3rem 1rem 2rem; }
.signin-card { width: 100%; max-width: 420px; display: grid; gap: 0.75rem; }
.signin-card h1 { font-size: 2.4rem; }
.signin-logo { color: var(--accent); }
.signin-logo svg { width: 56px; height: 56px; }

/* ---------- forms ---------- */

.field { display: grid; gap: 0.35rem; margin: 0 0 1rem; border: 0; padding: 0; min-width: 0; }
.field-label { font-weight: 600; font-size: 0.92rem; padding: 0; }
.field-hint { color: var(--muted); font-size: 0.82rem; }

input[type='text'], input[type='url'], input[type='number'], input[type='email'], input[type='date'], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 1rem/1.3 var(--sans);
}
textarea { resize: vertical; }
input:disabled { opacity: 0.5; }
input[type='color'] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); flex: none; }
input.strong { font-weight: 700; font-family: var(--serif); font-size: 1.05rem; }

.choice { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.choice input { margin-top: 0.25rem; accent-color: var(--accent); width: 18px; height: 18px; }

.toggle { display: inline-flex; align-items: center; gap: 0.6rem; min-height: 44px; cursor: pointer; margin-right: 1rem; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track { width: 42px; height: 26px; border-radius: 13px; background: var(--line); position: relative; flex: none; transition: background 0.15s; }
.toggle-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform 0.15s; }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 3px solid var(--focus); outline-offset: 2px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 0.75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 0.75rem; }
@media (max-width: 560px) {
  .grid-3 { grid-template-columns: 1fr; }
}

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; }
.chip span {
  display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; padding: 0.4rem 0.9rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-weight: 600;
}
.chip span::before { content: ''; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--subject); }
.chip input:checked + span { border-color: var(--subject); background: color-mix(in srgb, var(--subject) 14%, var(--surface)); }
.chip input:checked + span::before { background: var(--subject); }
.chip input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.segmented { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: inline-flex; align-items: center; min-height: 40px; padding: 0.35rem 0.85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.segmented input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- home ---------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 0.75rem; }
.card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 0.75rem;
  padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.card h3 { font-size: 1.2rem; margin: 0 0 0.15rem; }
.card .meta { margin: 0.15rem 0; }
.card-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.card-actions .btn.primary { flex: 1; }
.meta { color: var(--muted); font-size: 0.875rem; }

.session-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.session-item { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border-top: 1px solid var(--line); }
.session-item:first-child { border-top: 0; }
.session-title { font-weight: 600; }

/* ---------- editor ---------- */

.panel { padding: 1rem; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel > h2 { margin-bottom: 0.75rem; }
.panel input[type='text'], .panel input[type='url'], .panel input[type='number'], .panel select { background: var(--bg); }

.list { display: grid; gap: 0.5rem; margin: 0.5rem 0 0.75rem; }
.list-row { display: flex; gap: 0.5rem; align-items: center; }
.list-row input[type='text'] { min-width: 0; flex: 1 1 0; }
.list-row .grow { flex: 3 1 0; }
.list-row .key-input { flex: 0 0 3.2rem; }
.key-input { width: 3.2rem !important; flex: none; text-align: center; font-family: var(--mono); }
.subject-row input[type='text']:last-of-type { flex: 1.4 1 0; }
.question-row select { width: auto; flex: none; }

.channel-edit { padding: 0.75rem; margin: 0 0 0.75rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.channel-edit > input { margin-top: 0.5rem; }
.channel-edit .panel, .channel-edit input[type='text'], .channel-edit select { background: var(--surface); }
.channel-edit-head { display: flex; gap: 0.5rem; align-items: center; }
.channel-edit-head select { width: auto; flex: none; }

.panel h3 { margin: 1rem 0 0.6rem; }

@media (max-width: 640px) {
  .behavior-row { display: grid; grid-template-columns: 1fr 3.2rem 36px; gap: 0.4rem; padding-bottom: 0.6rem; border-bottom: 1px solid var(--line); }
  .behavior-row > :nth-child(3), .behavior-row > :nth-child(4) { grid-column: 1 / -1; }
  .behavior-row > .remove { grid-column: 3; grid-row: 1; }
  .question-row { flex-wrap: wrap; }
  .question-row input:first-child { flex: 1 1 50%; }
  .question-row .grow { flex: 1 1 100%; }
}

.map-preview img { display: block; max-width: 100%; max-height: 280px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 0.75rem; }

.save-bar {
  position: sticky; bottom: 0; display: flex; gap: 0.5rem; justify-content: flex-end;
  padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line);
}
.save-bar .btn.ghost { margin-right: auto; }

.start-head { margin: 0.5rem 0 1rem; }
.start-head h2 { font-size: 1.6rem; }

.summary-counts { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0; }
.stat { padding: 0.75rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 120px; }
.stat-n { font: 600 1.8rem/1.1 var(--serif); }

/* ---------- recording screen ---------- */

.record { --rec-gap: 0.75rem; }
.record-head {
  position: sticky; top: 0; z-index: 10; background: var(--bg);
  padding: calc(0.5rem + env(safe-area-inset-top)) 0.75rem 0.5rem; border-bottom: 1px solid var(--line);
}
.record-title { font-size: 0.85rem; margin-bottom: 0.4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timer {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.timer.warning { background: var(--warn-bg); border-color: var(--warn); color: var(--warn-ink); }
.timer.warning .muted { color: inherit; }
.timer.paused { opacity: 0.7; }
.timer-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.timer.warning .timer-label { color: inherit; }
.timer-big { font: 600 2.2rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.timer-side { display: grid; gap: 0.1rem; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.timer-actions { display: flex; gap: 0.4rem; }

body.flash .timer { animation: none; background: var(--flash); border-color: var(--warn); }
body.flash .record-head { background: var(--flash); }

.subject-tiles { display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.5rem 0 0.1rem; scrollbar-width: none; }
.subject-tiles::-webkit-scrollbar { display: none; }
.subject-tile {
  position: relative; flex: 0 0 auto; min-width: 92px; min-height: 56px; padding: 0.4rem 0.75rem;
  display: grid; gap: 0.25rem; justify-items: start; text-align: left;
  border: 2px solid var(--line); border-left: 6px solid var(--subject); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: 600 0.95rem/1.15 var(--sans); cursor: pointer;
}
.subject-tile.active { border-color: var(--subject); background: color-mix(in srgb, var(--subject) 16%, var(--surface)); }
.subject-tile.done .tile-name::after { content: ' ✓'; color: var(--ok); }
.tile-name { padding-right: 0.9rem; }
.tile-key { position: absolute; top: 3px; right: 6px; font: 600 0.7rem var(--mono); color: var(--muted); }
.tile-dots { display: flex; gap: 3px; }
.tdot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--muted); }
.tdot.on { background: var(--subject); border-color: var(--subject); }

.record-body { flex: 1; padding: 0.75rem 0.75rem 6rem; display: grid; gap: var(--rec-gap); align-content: start; }
.channels { display: grid; gap: var(--rec-gap); }
.channel { padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.channel-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.channel-head h2 { font-size: 1.1rem; }
.badge { font: 600 0.7rem/1 var(--sans); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 0.3rem 0.45rem; border: 1px solid var(--line); border-radius: 6px; }
.stopwatch, .scored { margin-left: auto; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.scored { color: var(--ok); font-weight: 600; }
.stopwatch strong { font-family: var(--mono); }
.channel-def { font-size: 0.85rem; color: var(--muted); margin: -0.25rem 0 0.5rem; }

.behaviors { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(46%, 150px), 1fr)); gap: 0.5rem; }
.behavior {
  position: relative; min-height: 56px; padding: 0.55rem 0.7rem; display: grid; align-content: center; gap: 0.2rem;
  text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
  font: 600 1rem/1.2 var(--sans); cursor: pointer; touch-action: manipulation; user-select: none;
}
.behavior:active { transform: scale(0.98); }
.behavior.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.behavior:disabled { opacity: 0.4; }
.b-count {
  position: absolute; top: 50%; right: 0.6rem; transform: translateY(-50%);
  min-width: 2rem; padding: 0.2rem 0.4rem; border-radius: 8px; background: var(--surface-2);
  font: 700 1.05rem/1 var(--mono); text-align: center;
}
.m-all-occurrence .b-name { padding-right: 2.6rem; }
.b-key { display: none; position: absolute; top: 4px; right: 6px; font-size: 0.7rem; color: var(--muted); }
.m-all-occurrence .b-key { top: 3px; right: 3px; }
.behavior.on .b-key { color: inherit; opacity: 0.8; }
.b-def { font: 400 0.78rem/1.25 var(--sans); color: var(--muted); }
.behavior.on .b-def { color: inherit; opacity: 0.85; }
@media (hover: hover) and (pointer: fine) {
  .b-key { display: block; }
  .m-all-occurrence .b-key { display: none; }
}

.map-surface { position: relative; display: inline-block; max-width: 100%; cursor: crosshair; line-height: 0; touch-action: manipulation; }
.map-surface img { max-width: 100%; max-height: 60vh; border-radius: 8px; user-select: none; -webkit-user-drag: none; }
.map-grid {
  position: absolute; inset: 0; pointer-events: none; border-radius: 8px;
  background-image: linear-gradient(to right, rgb(255 255 255 / 0.5) 1px, transparent 1px), linear-gradient(to bottom, rgb(255 255 255 / 0.5) 1px, transparent 1px);
}
.marker {
  position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  display: grid; place-items: center; background: var(--subject); color: #fff; border: 2px solid #fff;
  font: 700 0.75rem/1 var(--sans); box-shadow: 0 1px 4px rgb(0 0 0 / 0.4); pointer-events: none;
}

.record-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 0.5rem; align-items: center;
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line);
}
.undo-btn { min-width: 0; max-width: 22rem; justify-content: flex-start; white-space: nowrap; overflow: hidden; }
.undo-what { font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.record-bar .sync-pill { margin-left: auto; }
.defs-toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; min-height: 44px; cursor: pointer; }
.defs-toggle input { accent-color: var(--accent); width: 18px; height: 18px; }

@media (max-width: 600px) {
  .record-head { padding: calc(0.4rem + env(safe-area-inset-top)) 0.6rem 0.4rem; }
  .record-title { margin-bottom: 0.3rem; }
  .timer { gap: 0.6rem; padding: 0.4rem 0.6rem; }
  .timer-big { font-size: 1.9rem; }
  .timer-side { font-size: 0.82rem; line-height: 1.3; }
  .timer-actions { flex-direction: column; gap: 0.3rem; }
  .timer-actions .btn { min-height: 36px; padding: 0.25rem 0.7rem; font-size: 0.85rem; }
  .subject-tiles { padding-top: 0.4rem; }
  .subject-tile { min-height: 50px; min-width: 84px; }
  .record-body { padding: 0.6rem 0.6rem 6rem; }
  .channel { padding: 0.6rem; }
  .behavior { min-height: 52px; }
  .undo-what { display: none; }
  .record-bar .sync-pill .pill-text { max-width: 7rem; overflow: hidden; text-overflow: ellipsis; }
}

/* Landscape tablets and laptops: timer and subjects on the left, buttons on the right. */
@media (min-width: 900px) and (orientation: landscape) {
  .record { display: grid; grid-template-columns: 320px 1fr; grid-template-rows: 1fr auto; min-height: 100dvh; }
  .record .record-head { grid-column: 1; grid-row: 1; position: sticky; top: 0; height: 100dvh; overflow-y: auto; border-bottom: 0; border-right: 1px solid var(--line); padding: 1rem; }
  .record .timer { grid-template-columns: 1fr; }
  .record .timer-big { font-size: 3rem; }
  .record .subject-tiles { flex-direction: column; overflow: visible; padding-top: 0.75rem; }
  .record .subject-tile { width: 100%; min-height: 60px; }
  .record .record-body { grid-column: 2; grid-row: 1; padding: 1rem 1rem 6rem; }
  .record .channels { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); align-items: start; }
  .record .record-bar { left: 320px; }
}

/* ---------- modal and toast ---------- */

.modal {
  width: min(92vw, 440px); max-height: 85dvh; padding: 0; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 50px rgb(0 0 0 / 0.3);
}
.modal::backdrop { background: rgb(20 16 12 / 0.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.75rem 0.75rem 0 1rem; }
.modal-head h2 { font-size: 1.15rem; }
.modal-body { padding: 0.5rem 1rem 1rem; display: grid; gap: 0.75rem; }
.modifier-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.5rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(5rem + env(safe-area-inset-bottom)); z-index: 100;
  max-width: min(92vw, 520px); padding: 0.7rem 1rem; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 0.92rem;
  transform: translate(-50%, 1rem); opacity: 0; pointer-events: none; transition: opacity 0.15s, transform 0.15s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .behavior:active { transform: none; }
}
.channel-edit-head input { flex: 1 1 0; min-width: 0; }

/* Scan channels still waiting for this scan's answer stand out; all-occurrence channels get their own tint. */
.channel.needs { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.needs-label { margin-left: auto; font-size: 0.8rem; font-weight: 700; color: var(--accent); }
.record:has(.timer.warning) .channel.needs { background: color-mix(in srgb, var(--warn-bg) 55%, var(--surface)); }
.channel.m-all-occurrence { background: var(--event-bg); border-color: var(--event-line); }
.channel.m-all-occurrence .badge { color: var(--event-ink); border-color: var(--event-line); }
.channel.m-all-occurrence .behavior { background: var(--surface); border-color: var(--event-line); }
.channel.m-all-occurrence .b-count { background: var(--event-bg); color: var(--event-ink); }
.notice.warn { border-color: var(--warn); background: var(--warn-bg); color: var(--warn-ink); display: grid; gap: 0.5rem; justify-items: start; }
.notice.warn p { margin: 0; }

.b-recv { font: 600 0.7rem/1 var(--sans); color: var(--muted); }

/* Guide: sign-in page and the Guide view */
.guide-wrap { width: 100%; max-width: 760px; }
.guide h2 { margin-bottom: 0.5rem; }
.guide ul, .guide ol { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.6rem; line-height: 1.45; }
.guide p { line-height: 1.45; }
.guide.warnings { border-color: var(--warn); background: var(--warn-bg); color: var(--warn-ink); }
.ack { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.92rem; line-height: 1.4; }
.ack input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.help-btn { font: 600 1.15rem/1 var(--sans); }
