/* Tributary palette (website STYLE-GUIDE.md): Yale Blue primary, Stormy Teal hover,
   Graphite text, Dust Grey rules, Surface background. System font stack, 4px radius. */
:root {
  --yale: #284b63; --teal: #3c6e71; --graphite: #353535; --dust: #d9d9d9; --surface: #f5f7f9; --white: #ffffff;
  --ok: #2e7d32; --danger: #c0392b; --warn: #b26a00;
  --bg: var(--surface); --panel: var(--white); --ink: var(--graphite); --muted: #6b7278; --line: var(--dust);
  --accent: var(--yale); --accent-hover: var(--teal); --accent-ink: #ffffff; --chip: #eef2f5; --chip-ink: #3b4248;
  --warn-bg: #fff7e8; --bad-bg: #fdecea; --ok-bg: #e9f5ea; --accent-bg: #e9eff4;
  --radius: 4px; --radius-lg: 8px; --shadow: 0 1px 2px rgba(28, 33, 39, .06), 0 4px 14px rgba(28, 33, 39, .05);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14191e; --panel: #1c2127; --ink: #e6e9ec; --muted: #9aa5ad; --line: #2e363d;
    --accent: #7fb0d1; --accent-hover: #9cc9c5; --accent-ink: #0f1419; --chip: #262d34; --chip-ink: #c9d1d8;
    --warn-bg: #3a2d12; --bad-bg: #3b1f1c; --ok-bg: #19301c; --accent-bg: #1f2b36; --shadow: none;
    --ok: #6fc27a; --danger: #ff8a7f; --warn: #f0b24a;
  }
}
:root[data-theme="dark"] {
  --bg: #14191e; --panel: #1c2127; --ink: #e6e9ec; --muted: #9aa5ad; --line: #2e363d;
  --accent: #7fb0d1; --accent-hover: #9cc9c5; --accent-ink: #0f1419; --chip: #262d34; --chip-ink: #c9d1d8;
  --warn-bg: #3a2d12; --bad-bg: #3b1f1c; --ok-bg: #19301c; --accent-bg: #1f2b36; --shadow: none;
  --ok: #6fc27a; --danger: #ff8a7f; --warn: #f0b24a;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
main { max-width: 1120px; margin: 0 auto; padding: 20px 16px 72px; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; color: var(--accent); font-weight: 700; letter-spacing: -.1px; }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--accent); font-weight: 600; }
h3 { font-size: 15px; margin: 0 0 6px; font-weight: 600; }
p { margin: 0 0 10px; }
p.lead { color: var(--muted); margin: 0 0 18px; font-size: 15.5px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
code { background: var(--chip); padding: 1px 5px; border-radius: 3px; font-size: 13px; font-family: var(--mono); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* header */
header.top { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
header.top .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
header.top .brand img { width: 28px; height: 28px; border-radius: 6px; }
header.top .brand b { color: var(--accent); white-space: nowrap; }
header.top .brand small { color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top nav { display: flex; gap: 2px; }
header.top nav a { padding: 7px 11px; border-radius: var(--radius); text-decoration: none; color: var(--ink); font-weight: 500; }
header.top nav a:hover { background: var(--chip); color: var(--ink); }
header.top nav a.active { background: var(--accent-bg); color: var(--accent); }
header.top .spacer { flex: 1; }
header.top .who { color: var(--muted); font-size: 13px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) { header.top { flex-wrap: wrap; } header.top nav { order: 5; width: 100%; } header.top .who { display: none; } }

/* panels, cards */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; margin: 12px 0; box-shadow: var(--shadow); }
.panel.tight { padding: 12px 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.card a.title { font-weight: 600; font-size: 16px; text-decoration: none; color: var(--accent); }
.card .meta { color: var(--muted); font-size: 13.5px; }
.card .foot { display: flex; gap: 8px; align-items: center; margin-top: auto; flex-wrap: wrap; }

/* steps */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.step { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.step .n { width: 30px; height: 30px; border-radius: 50%; background: var(--chip); color: var(--chip-ink); display: grid; place-items: center; font-weight: 700; flex: none; }
.step.now { border-color: var(--accent); background: var(--accent-bg); }
.step.now .n { background: var(--accent); color: var(--accent-ink); }
.step.done .n { background: var(--ok); color: #fff; }
.step b { display: block; }
.step span { color: var(--muted); font-size: 13px; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }

/* capture tiles: always ink on a light surface, never white-on-white; the
   "hero" tile is the recommended one. Hover only moves the border. */
.actions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
button.action, a.action { display: flex; flex-direction: column; gap: 6px; padding: 16px; min-height: 96px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); text-align: left; cursor: pointer; color: var(--ink); font: inherit; font-weight: 400; text-decoration: none; transition: border-color .15s, box-shadow .15s; }
button.action:hover, a.action:hover { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); transform: none; background: var(--panel); }
button.action.hero, a.action.hero { border: 2px solid var(--accent); background: var(--panel); }
.action .ic { font-size: 24px; line-height: 1; }
.action b { font-size: 15.5px; color: var(--accent); }
.action span { color: var(--muted); font-size: 13.5px; }
.action span a { color: var(--accent); }

/* mobile quick bar on the event page */
.quickbar { display: none; }
@media (max-width: 720px) {
  .quickbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--panel); border-top: 1px solid var(--line); z-index: 15; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 6px; }
  .quickbar a, .quickbar button { flex: 1; justify-content: center; min-height: 44px; font-size: 14px; }
  main { padding-bottom: 96px; }
  button, .btn { min-height: 40px; }
  button.small, .btn.small { min-height: 36px; }
  .rev .acts button { flex: 1 1 auto; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--panel); padding: 8px 12px; border: 1px solid var(--accent); border-radius: var(--radius); z-index: 100; }
.skip:focus { left: 8px; }
.banner { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: var(--radius); margin: 0 0 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.roles td:first-child { font-weight: 600; white-space: nowrap; }

/* forms */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.field { flex: 1 1 160px; min-width: 140px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; letter-spacing: .2px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); font: inherit; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 320px; }
input[type="file"] { padding: 7px; }

/* buttons */
button, .btn { padding: 9px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; transition: background .2s, border-color .2s, transform .15s; }
button:hover, .btn:hover { border-color: var(--graphite); color: var(--ink); }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); color: var(--accent-ink); }
button.danger { color: var(--danger); border-color: var(--danger); }
button.ghost { background: none; }
button.small, .btn.small { padding: 5px 9px; font-size: 13px; }
button:disabled, .btn:disabled { opacity: .55; cursor: default; transform: none; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* tables / review rows */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: 0; }
.rev { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); margin: 8px 0; padding: 12px 14px; display: grid; grid-template-columns: 34px 1.3fr 1.5fr auto; gap: 10px 14px; align-items: start; }
.rev.flagged { border-left: 4px solid var(--warn); }
.rev.bad { border-left: 4px solid var(--danger); }
.rev.ready { border-left: 4px solid var(--ok); }
.rev .no { font-weight: 700; color: var(--muted); padding-top: 2px; }
.rev .name { font-weight: 600; font-size: 15px; }
.rev .sub { color: var(--muted); font-size: 13px; }
.rev .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.rev .edit { grid-column: 1 / -1; background: var(--bg); border-radius: var(--radius); padding: 10px 12px; }
.rev .cands { grid-column: 2 / -1; }
@media (max-width: 720px) { .rev { grid-template-columns: 28px 1fr; } .rev .match { grid-column: 2; } .rev .acts { grid-column: 1 / -1; justify-content: flex-start; } .rev .cands { grid-column: 1 / -1; } }

/* chips, status, notices */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--chip-ink); font-size: 12px; margin: 1px 4px 1px 0; white-space: nowrap; font-weight: 500; }
.chip.ok { background: var(--ok-bg); color: var(--ok); } .chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.bad { background: var(--bad-bg); color: var(--danger); } .chip.accent { background: var(--accent-bg); color: var(--accent); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.open { background: var(--chip); color: var(--chip-ink); } .pill.reviewed { background: var(--accent-bg); color: var(--accent); } .pill.exported { background: var(--ok-bg); color: var(--ok); }
.status { font-weight: 600; }
.status.matched, .status.confirmed { color: var(--ok); }
.status.ambiguous { color: var(--warn); }
.status.not_found, .status.error, .status.excluded { color: var(--danger); }
.notice { padding: 10px 12px; border-radius: var(--radius); background: var(--chip); margin: 10px 0; }
.notice.bad { background: var(--bad-bg); color: var(--danger); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }
.filters button { border-radius: 999px; padding: 5px 12px; font-size: 13px; }
.filters button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cands { margin: 6px 0 0; padding: 0; list-style: none; }
.cands li { padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); margin: 4px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--bg); }
.cands li .score { font-weight: 700; min-width: 34px; color: var(--accent); }
details summary { cursor: pointer; color: var(--accent); }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* progress + toast */
.progress { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; width: min(520px, calc(100% - 32px)); }
.toast { background: var(--graphite); color: #fff; padding: 10px 14px; border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 14px; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--danger); }

/* landing */
.hero { padding: 36px 0 12px; max-width: 720px; }
.hero h1 { font-size: 34px; line-height: 1.15; }
.hero p { font-size: 17px; color: var(--muted); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; position: sticky; top: 56px; background: var(--bg); padding: 8px 0; z-index: 5; }
.subnav a { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); text-decoration: none; color: var(--ink); font-size: 13px; }
.right { text-align: right; }

/* site footer (landing, terms, support, app shell) */
.site-foot { max-width: 1120px; margin: 0 auto; padding: 8px 16px 24px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }
.site-foot .built { white-space: nowrap; }
.site-foot .built a { font-weight: 600; text-decoration: none; }
@media (max-width: 720px) { .site-foot { padding-bottom: calc(24px + env(safe-area-inset-bottom)); } }

/* tables on phones: each row becomes a card, header text becomes the cell label
   (app.mjs copies <th> text onto td[data-label] after every render) */
@media (max-width: 720px) {
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; box-sizing: border-box; }
  table.stack thead { display: none; }
  table.stack tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; margin: 0 0 8px; background: var(--panel); }
  table.stack td { border: 0; padding: 3px 0; display: flex; gap: 10px; align-items: baseline; }
  table.stack td::before { content: attr(data-label); flex: 0 0 34%; max-width: 120px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
  table.stack td:not([data-label])::before, table.stack td[data-label=""]::before { display: none; }
  table.stack td > * { min-width: 0; }
  table.stack td.right { text-align: left; }
  table.stack td .btnrow, table.stack td button { width: auto; }
  .scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .subnav { top: auto; position: static; }
  main { padding-left: 12px; padding-right: 12px; }
  .panel { padding: 14px; }
}
