/* Snow Notice — built for a phone held in a cold hand: big targets, high
   contrast, nothing that needs a precise tap. */

:root {
  color-scheme: light dark;
  --bg: #eef1f5;
  --card: #ffffff;
  --ink: #16202c;
  --muted: #5b6b7f;
  --line: #dbe2ea;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --ok: #17803d;
  --warn: #a15c00;
  --danger: #c02525;
  --chip: #f1f4f8;
  --radius: 14px;
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1319;
    --card: #18202a;
    --ink: #e9eef4;
    --muted: #9aa9bb;
    --line: #2a3543;
    --accent: #4c8dff;
    --accent-ink: #06121f;
    --ok: #4ade80;
    --warn: #fbbf24;
    --danger: #f87171;
    --chip: #212b37;
  }
}

* { box-sizing: border-box; }

/* Class-level `display` outranks the UA rule for [hidden], which would leave a
   hidden modal's backdrop on top of the page swallowing every tap. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 1rem; margin: 0 0 4px; }
code {
  font-size: .8125em;
  background: var(--chip);
  padding: 1px 5px;
  border-radius: 5px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.center-text { text-align: center; }
.error { color: var(--danger); font-size: .875rem; margin: 12px 0 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

/* Layout ------------------------------------------------------------------ */

.screen.center {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 1.0625rem; }
.topbar-right { display: flex; align-items: center; gap: 4px; }
.role-badge {
  font-size: .6875rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  background: var(--chip); padding: 4px 9px; border-radius: 999px;
}

/* Recipients / Opt-outs switch, board only. */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: var(--chip); border-radius: 12px; padding: 4px;
}
.seg {
  min-height: 42px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: .9375rem; font-weight: 600; cursor: pointer;
}
.seg.active { background: var(--card); color: var(--ink); }
.segmented-3 { grid-template-columns: repeat(3, 1fr); }
.seg-badge {
  display: inline-block; margin-left: 5px; min-width: 18px; padding: 1px 5px;
  background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; font-size: .6875rem; font-weight: 700;
}
.pending-actions { display: flex; gap: 8px; margin-top: 12px; }
.pending-actions .btn { flex: 1; }
.pending-asks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.tab { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--line);
}
.login-card { width: 100%; max-width: 22rem; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img { border-radius: 12px; }
.brand h1 { margin: 0; font-size: 1.375rem; }

/* Form elements ----------------------------------------------------------- */

.field { display: block; margin: 14px 0 0; }
.field > span { display: block; font-size: .8125rem; font-weight: 600; margin-bottom: 6px; }
.field em { font-weight: 400; font-style: normal; }

input[type="text"], input[type="password"], input[type="search"], input[type="tel"],
input[type="email"], textarea, select {
  width: 100%;
  min-height: var(--tap);
  padding: 12px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  min-height: var(--tap);
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--chip);
  color: var(--ink);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.big { width: 100%; min-height: 60px; font-size: 1.0625rem; }
.small-btn { min-height: 40px; padding: 8px 14px; font-size: .875rem; }
.link-btn {
  background: none; border: 0; color: var(--accent);
  font: inherit; cursor: pointer; padding: 8px; min-height: var(--tap);
}

/* Lot picker -------------------------------------------------------------- */

.quick-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.lot-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 4px;
}
@media (min-width: 26rem) { .lot-grid { gap: 8px; } }

.lot {
  min-height: 62px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: var(--chip);
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  padding: 6px 4px;
}
.lot .letter { font-size: 1.1875rem; font-weight: 700; line-height: 1; }
.lot .reach { font-size: .6875rem; color: var(--muted); }
.lot[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.lot[aria-pressed="true"] .reach { color: var(--accent-ink); opacity: .85; }
/* F+G and H+J are cleared as a unit; the tie-bar shows the pairing. */
.lot.paired { position: relative; }
.lot.pair-start::after {
  content: ""; position: absolute; right: calc(var(--pair-gap) * -1); top: 50%;
  width: var(--pair-gap); height: 2px; background: var(--accent); opacity: .55;
}
.lot-grid { --pair-gap: 6px; }
@media (min-width: 26rem) { .lot-grid { --pair-gap: 8px; } }

.summary { margin: 12px 0 0; font-weight: 600; font-size: .9375rem; }

/* Chips ------------------------------------------------------------------- */

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
#template-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
  scroll-snap-type: x proximity;
}
#template-row::-webkit-scrollbar { display: none; }
#template-row .chip { flex: none; scroll-snap-align: start; }
.chip {
  min-height: 40px;
  padding: 8px 14px;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font: inherit; font-size: .875rem;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.small-chips .chip { min-height: 34px; padding: 5px 12px; font-size: .8125rem; }

/* Channels ---------------------------------------------------------------- */

.channel-row { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.channel {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px; padding: 10px 14px;
  background: var(--chip);
  border: 2px solid transparent;
  border-radius: 12px;
  color: var(--ink);
  font: inherit; text-align: left; cursor: pointer;
}
.channel[aria-pressed="true"] { border-color: var(--accent); background: var(--card); }
.channel .mark {
  width: 26px; height: 26px; flex: none;
  border-radius: 8px; border: 2px solid var(--muted);
  display: grid; place-items: center; font-size: .875rem; font-weight: 700;
}
.channel[aria-pressed="true"] .mark {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.channel .label { font-weight: 600; }
.channel .sub { display: block; font-size: .75rem; font-weight: 400; color: var(--muted); }

/* Preview ----------------------------------------------------------------- */

.counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.count-pill {
  padding: 8px 12px; border-radius: 10px;
  background: var(--chip); font-size: .8125rem; font-weight: 600;
}
.count-pill.warn { color: var(--warn); }
summary { cursor: pointer; padding: 10px 0; font-size: .875rem; font-weight: 600; }
.preview-block { margin: 12px 0; }
.preview-block h3 { margin: 0 0 6px; font-size: .75rem; text-transform: uppercase;
                    letter-spacing: .06em; color: var(--muted); }
.preview-block pre {
  margin: 0; padding: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  white-space: pre-wrap; word-break: break-word;
  font: inherit; font-size: .875rem;
}

/* History ----------------------------------------------------------------- */

.msg-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.msg-lots { font-weight: 700; }
.msg-when { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.msg-body { margin: 8px 0; font-size: .9375rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: .75rem; font-weight: 600;
  padding: 4px 9px; border-radius: 999px; background: var(--chip);
}
.badge.ok { color: var(--ok); }
.badge.bad { color: var(--danger); }
.badge.pending { color: var(--warn); }

/* People ------------------------------------------------------------------ */

.person { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.person-main { min-width: 0; }
.person-name { font-weight: 600; }
.person-contact { font-size: .8125rem; color: var(--muted); word-break: break-word; }
.person-lots { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.lot-tag {
  font-size: .6875rem; font-weight: 700;
  padding: 2px 7px; border-radius: 6px; background: var(--chip);
}
.lot-tag.bad { color: var(--danger); }
.opted-out { text-decoration: line-through; opacity: .6; }

/* Tab bar ----------------------------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  min-height: 58px;
  background: none; border: 0; color: var(--muted);
  font: inherit; font-size: .8125rem; font-weight: 600; cursor: pointer;
}
.tab-btn.active { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }

/* Modal ------------------------------------------------------------------- */

.modal { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 12, 20, .55); }
.modal-sheet {
  position: relative;
  width: min(34rem, 100%);
  margin: 0 auto;
  max-height: 88dvh;
  overflow-y: auto;
  border-radius: var(--radius) var(--radius) 0 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
@media (min-width: 36rem) {
  .modal { align-items: center; }
  .modal-sheet { border-radius: var(--radius); }
}
.modal-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.modal-actions .btn { width: 100%; }

/* Toast ------------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  background: var(--ink); color: var(--bg);
  border-radius: 10px; font-size: .875rem; font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .28);
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .2s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
}
