/* Explainers hub, Popsicle (house-design §15).
   Three oranges: --accent carries no text; --accent-fill is any fill with text on it; --accent-text
   is any orange text. Contrast is measured by tools/check-contrast.mjs on every deploy, both themes. */
:root {
  --bg: #f6f5fa; --surface: #ffffff; --surface2: #efedf8; --line: #e2def0;
  --ink: #241f33; --muted: #6f6885;
  --accent: #e2570e; --accent-fill: #c94d0c; --accent-text: #b7460b; --accent-ink: #ffffff;
  --teal: #0a9d90; --grape: #6b4de6; --gold: #e0a400; --danger: #d64545; --danger-fill: #c23b3b; --chip-ink: #14100c;
  --shadow: 0 6px 20px rgba(36, 31, 51, .08);
  --glass: rgba(246, 245, 250, .86);
  --radius: 15px;
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI Variable Text", "Nunito", system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #191625; --surface: #241f33; --surface2: #2e2840; --line: #3b3352;
  --ink: #f2eef9; --muted: #a69dba;
  --accent: #ff8a3d; --accent-fill: #ff8a3d; --accent-text: #ff8a3d; --accent-ink: #2a1206;
  --teal: #2fd4c4; --grape: #ab8dff; --gold: #e0b24d; --danger: #ff6b78; --danger-fill: #ff6b78; --chip-ink: #ffffff;
  --shadow: 0 10px 26px rgba(0, 0, 0, .42);
  --glass: rgba(25, 22, 37, .86);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent-text); }

/* Version badge: tiny, fixed, never in the way. Contrast muted on bg: 5.07 light, 6.53 dark (checked). */
.ver { position: fixed; z-index: 90; top: calc(env(safe-area-inset-top, 0px) + 2px); left: calc(env(safe-area-inset-left, 0px) + 6px);
  font-size: 10px; line-height: 1; color: var(--muted); pointer-events: none; font-variant-numeric: tabular-nums; }
.ver.bad { color: var(--danger); }

/* ---- the PIN gate (team-manager/docs/pin-keypad-standard.md) ---- */
.gate { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(10px, 2.4vh, 22px); padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--accent) 14%, var(--bg)), var(--bg)); }
.gate-brand { text-align: center; }
.gate-brand img { width: clamp(44px, 9vh, 64px); height: auto; }
.gate-brand h1 { margin: 6px 0 2px; font-size: clamp(22px, 4vh, 30px); }
.gate-brand p, .gate-note { margin: 0; color: var(--muted); font-size: 16px; }
.pin-gate { display: flex; flex-direction: column; align-items: center; gap: clamp(10px, 2.2vh, 20px);
  touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pin-dots { display: flex; gap: 10px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); }
.pin-dots span.on { background: var(--ink); }
.pin-gate.busy .pin-dots span.on { animation: pinpulse .9s ease-in-out infinite; }
@keyframes pinpulse { 50% { opacity: .35; } }
.pin-gate.bad .pin-dots { animation: pinshake .35s; }
@keyframes pinshake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-msg { min-height: 1.3em; font-size: 16px; color: var(--muted); text-align: center; }
.pin-pad { display: grid; grid-template-columns: repeat(3, clamp(64px, 22vw, 84px)); gap: clamp(8px, 1.8vh, 16px); }
.pin-pad button { height: clamp(58px, 9.5vh, 84px); border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: clamp(26px, 4vh, 32px); line-height: 1; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; box-shadow: var(--shadow); }
.pin-pad button:active { background: var(--accent-fill); color: var(--accent-ink); }
.pin-pad button:disabled { opacity: .5; }
.pin-pad .pin-del { border: none; background: transparent; box-shadow: none; font-size: 24px; }

/* ---- the app: fixed header and tab bar, only the middle scrolls (rule 3, fallback 3) ---- */
.app { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right, 0px) + 16px) 10px calc(env(safe-area-inset-left, 0px) + 16px);
  background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.theme-pill { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.theme-pill button { border: 0; background: transparent; width: 34px; height: 30px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.theme-pill button.on { background: var(--accent-fill); color: var(--accent-ink); }

.main { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 14px calc(env(safe-area-inset-right, 0px) + 16px) 18px calc(env(safe-area-inset-left, 0px) + 16px); }
.view { max-width: 1500px; margin: 0 auto; }

.tabs { display: flex; justify-content: center; gap: 8px; background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px calc(env(safe-area-inset-right, 0px) + 12px) calc(env(safe-area-inset-bottom, 0px) + 6px) calc(env(safe-area-inset-left, 0px) + 12px); }
.tabs button { flex: 0 1 180px; display: flex; flex-direction: column; align-items: center; gap: 1px; border: 0; background: transparent;
  padding: 6px 10px; border-radius: 12px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button span { font-size: 20px; line-height: 1.1; }
.tabs button.on { color: var(--accent-text); background: var(--surface2); }

/* ---- filter chips ---- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 13px; font-size: 14px; font-weight: 700; cursor: pointer; color: var(--ink); }
.chip .n { color: var(--muted); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.chip.on .n { color: var(--accent-ink); }
.note { background: var(--surface2); border-radius: 12px; padding: 9px 13px; margin: 0 0 12px; font-size: 14px; color: var(--ink); }

/* ---- cards ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--surface2); display: block; overflow: hidden; }
.thumb img { position: relative; width: 100%; height: 100%; object-fit: cover; display: block; background: var(--surface2); }
.thumb .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 40px; }
.thumb .len { position: absolute; right: 8px; bottom: 8px; background: rgba(20, 16, 28, .78); color: #ffffff; /* 14.9:1 */
  font-size: 12.5px; font-weight: 700; padding: 2px 7px; border-radius: 7px; font-variant-numeric: tabular-nums; }
.body { padding: 11px 13px 12px; display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 0; }
.card h3 { margin: 0; font-size: 17px; line-height: 1.25; overflow-wrap: anywhere; }
.blurb { margin: 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12.5px; }
.tag { border-radius: 999px; padding: 2px 9px; font-weight: 700; color: var(--chip-ink); background: color-mix(in srgb, var(--hue, var(--grape)) 18%, var(--surface)); }
.tag.julia { --hue: var(--teal); } .tag.david { --hue: var(--grape); } .tag.family { --hue: var(--gold); } .tag.private { --hue: var(--danger); }
.tag.draft { --hue: var(--accent); } .tag.warn { --hue: var(--danger); } .tag.app { --hue: var(--gold); }
.meta .when { color: var(--muted); }
/* Texts of a piece: one line each. Status words stay ink (teal text measures 3.4 on white); weight carries "played". */
.sends { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13.5px; line-height: 1.4; color: var(--ink); }
.sends li { padding: 2px 0; overflow-wrap: anywhere; }
.sends .st { color: var(--muted); }
.sends .st.good { color: var(--ink); font-weight: 700; }
.sends .st.bad { color: var(--ink); font-weight: 700; text-decoration: underline wavy var(--danger); }
/* Made for: one line per person (2026-11-10). Text colors are ink and muted only (both measured in
   check-contrast); "not sent yet" is ink, bold, with a danger underline, never danger-colored text.
   The Text now button is accent-text on the card surface: 5.39 light, 6.79 dark. */
.people { display: flex; gap: 8px; align-items: baseline; margin: 8px 0 0; font-size: 13.5px; line-height: 1.4; }
.people .lbl, .madefor-none { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.madefor-none { margin: 8px 0 0; }
.madefor-none .st { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: 13px; }
.people ul { list-style: none; margin: 0; padding: 0; min-width: 0; flex: 1; color: var(--ink); }
.people li { padding: 2px 0; overflow-wrap: anywhere; }
.people .st { color: var(--muted); }
.people .st.good { color: var(--ink); font-weight: 700; }
.people .st.warn { color: var(--ink); font-weight: 800; text-decoration: underline wavy var(--danger); text-underline-offset: 3px; }
.people .mini { margin-left: 4px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--accent-text); font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.people .mini.armed { background: var(--danger-fill); border-color: var(--danger-fill); color: #fff; }
.menu fieldset.madefor { border: 0; margin: 0; padding: 4px 11px 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.menu fieldset.madefor legend { padding: 0; font-size: 14.5px; font-weight: 600; color: var(--ink); }
.menu fieldset.madefor label.ck { padding: 2px 0; justify-content: flex-start; gap: 5px; }
.menu fieldset.madefor .others { flex: 1 1 100%; font-size: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface2); color: var(--ink); padding: 6px 8px; }
.menu fieldset.madefor button { padding: 7px 0; color: var(--accent-text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface2); color: var(--ink);
  border-radius: 11px; padding: 7px 12px; font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 36px; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.armed { background: var(--danger-fill); border-color: var(--danger-fill); color: #ffffff; }
:root[data-theme="dark"] .btn.armed, :root[data-theme="dark"] .people .mini.armed { color: #2a0a0e; }

details.more { position: relative; }
details.more > summary { list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
.menu { position: absolute; z-index: 20; right: 0; bottom: calc(100% + 6px); min-width: 230px; max-width: calc(100vw - 48px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.menu button, .menu a { border: 0; background: transparent; text-align: left; padding: 9px 11px; border-radius: 9px; font-size: 14.5px; font-weight: 600; color: var(--ink); cursor: pointer; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--surface2); }
.menu label { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 11px; font-size: 14.5px; font-weight: 600; }
.menu select { font-size: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface2); padding: 4px 6px; }
.menu .sep { height: 1px; background: var(--line); margin: 4px 6px; }
.out { font-size: 13.5px; color: var(--ink); background: var(--surface2); border-radius: 10px; padding: 8px 10px; overflow-wrap: anywhere; }
.out.bad { color: var(--danger); }
.log { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); max-height: 180px; overflow-y: auto; }
.log li { margin-bottom: 4px; overflow-wrap: anywhere; }
.empty { color: var(--muted); }

/* ---- pieces that live in other apps: one collapsed group per app ---- */
.groups { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 14px; align-items: start; }
.appgroup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.appgroup summary { cursor: pointer; padding: 12px 15px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.appgroup summary span:first-child { font-weight: 800; font-size: 16px; }
.appgroup summary .n { color: var(--muted); font-size: 13.5px; }
.appgroup ul { list-style: none; margin: 0; padding: 0 10px 10px; }
.appgroup li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 5px; border-top: 1px solid var(--line); }
.appgroup .t { font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; }
.appgroup .t .b { display: block; color: var(--muted); font-size: 13px; line-height: 1.35; margin-top: 2px; }
.warnline { color: var(--ink); }
.appgroup .len2 { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.appgroup .btn { flex: 0 0 auto; min-height: 32px; padding: 5px 10px; }

/* ---- settings ---- */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 14px; align-items: start; }
.settings details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.settings summary { cursor: pointer; padding: 13px 15px; font-weight: 800; font-size: 16px; }
.settings .inner { padding: 0 15px 15px; font-size: 14.5px; }
.settings table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.settings td, .settings th { text-align: left; padding: 6px 6px 6px 0; border-top: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.settings th { color: var(--muted); font-weight: 700; }
.tablewrap { overflow-x: auto; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row select, .row input { font-size: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface2); padding: 5px 8px; }
.ok { color: var(--teal); font-weight: 700; } .no { color: var(--danger); font-weight: 700; }
:root:not([data-theme="dark"]) .ok { color: #077a70; } /* teal as text: #077a70 on white 5.24 */

.toast { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 78px);
  max-width: min(520px, calc(100vw - 32px)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; box-shadow: var(--shadow); }
.toast.bad { background: var(--danger-fill); color: #ffffff; }
:root[data-theme="dark"] .toast.bad { color: #2a0a0e; }
