:root {
  --bg: #f4f6f9; --card: #fff; --ink: #172033; --muted: #5d6b82; --line: #dde3ec;
  --brand: #1d4ed8; --brand-ink: #fff; --ok: #15803d; --ok-bg: #dcfce7;
  --early: #1d4ed8; --early-bg: #dbeafe; --late: #b45309; --late-bg: #fef3c7;
  --miss: #b91c1c; --miss-bg: #fee2e2; --cur: #fff7d6; --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1623; --card: #172033; --ink: #e8edf6; --muted: #9aa8c0; --line: #2a3752;
    --brand: #3b82f6; --ok: #4ade80; --ok-bg: #12351f; --early: #93c5fd; --early-bg: #172a4d;
    --late: #fbbf24; --late-bg: #3a2c0d; --miss: #f87171; --miss-bg: #3b1818; --cur: #3a3412;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.25rem; } h3 { font-size: 1rem; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea { min-height: 8rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
button {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .9rem;
  cursor: pointer; min-height: 2.5rem;
}
button:hover { border-color: var(--brand); }
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.good { background: var(--ok); color: #fff; border-color: var(--ok); font-weight: 700; }
button.danger { color: var(--miss); }
button.small { min-height: 2rem; padding: .2rem .6rem; font-size: .875rem; }
button.link { border: 0; background: none; color: var(--brand); padding: 0 .25rem; min-height: 0; }
button:disabled { opacity: .5; cursor: default; }

header.top {
  background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; padding: .5rem 1rem;
}
header.top .brand { font-weight: 700; margin-right: .5rem; }
header.top nav { display: flex; flex-wrap: wrap; gap: .25rem; flex: 1; }
header.top nav a {
  text-decoration: none; color: var(--muted); padding: .35rem .7rem; border-radius: 8px; font-weight: 500;
}
header.top nav a.active { background: var(--brand); color: var(--brand-ink); }
header.top .who { color: var(--muted); font-size: .875rem; display: flex; gap: .5rem; align-items: center; }
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 12rem; }
.muted { color: var(--muted); }
.small-text { font-size: .875rem; }
.stack > * + * { margin-top: .75rem; }
.center-card { max-width: 26rem; margin: 10vh auto; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .75rem; }
.err { color: var(--miss); }

.badge { display: inline-block; min-width: 1.7rem; text-align: center; padding: .05rem .45rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; border: 1px solid var(--line); color: var(--muted); }
.badge.E { background: var(--early-bg); color: var(--early); border-color: transparent; }
.badge.X { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.late { background: var(--late-bg); color: var(--late); border-color: transparent; }
.badge.noanswer { background: var(--miss-bg); color: var(--miss); border-color: transparent; }
.badge.src { font-weight: 500; }

.phasebar { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.phasebar button { border: 0; border-radius: 0; background: var(--card); color: var(--muted); }
.phasebar button + button { border-left: 1px solid var(--line); }
.phasebar button.on { background: var(--brand); color: var(--brand-ink); font-weight: 600; }

.counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.counts div { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .6rem; text-align: center; }
.counts b { display: block; font-size: 1.5rem; line-height: 1.1; }
.counts span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

.sugg { margin-top: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.sugg button { text-align: left; display: flex; gap: .6rem; align-items: center; min-height: 2.8rem; }
.sugg button.active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.sugg .cs { font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; }
.ci-input { font-size: 1.25rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }

.current { border: 2px solid var(--brand); background: var(--cur); text-align: center; }
.current .big { font-size: clamp(2.2rem, 9vw, 4rem); font-weight: 800; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .04em; }
.current .big .sfx { color: var(--brand); }
.current .phon { font-size: 1.1rem; color: var(--muted); }
.current .btns { display: flex; gap: .75rem; justify-content: center; margin-top: .75rem; flex-wrap: wrap; }
.current .btns button { min-width: 9rem; min-height: 3.2rem; font-size: 1.1rem; }
.upnext { margin-top: .75rem; font-size: .9rem; color: var(--muted); }

.cols { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 900px) { .cols { grid-template-columns: 1fr 1fr; align-items: start; } }
.scroll { max-height: 60vh; overflow: auto; position: relative; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); position: sticky; top: 0; background: var(--card); }
td.cs, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; }
tr.cur td { background: var(--cur); }
tr.done td { color: var(--muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 1rem; text-align: center; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink); padding: 1.25rem; width: min(30rem, 94vw); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }

#toast { position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 20; pointer-events: none; }
#toast div { background: #172033; color: #fff; padding: .6rem 1rem; border-radius: 8px; margin-top: .4rem; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
#toast div.err { background: var(--miss); }

@media print {
  header.top, button, .noprint, #toast { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border: 0; padding: 0; }
  th { position: static; }
  table { font-size: 11pt; }
}

/* scripts, personal details */
details.script { padding: .5rem 1rem; }
details.script summary { cursor: pointer; font-weight: 600; padding: .25rem 0; }
.scriptbody { margin-top: .5rem; line-height: 1.5; max-height: clamp(7rem, 26vh, 16rem); min-height: 4rem; overflow: auto; resize: vertical; }
.scriptbody .gap { height: .6rem; }
.scriptbody .sb { padding-left: 1.2rem; text-indent: -.9rem; }
.scriptbody .sb::before { content: "• "; color: var(--muted); }
.scriptbody .blank { border-bottom: 1px dashed var(--muted); color: var(--muted); }
.scriptbody ul.nets { margin: .25rem 0 .25rem 1.2rem; padding: 0; }
.scriptbody ul.nets li { margin: .3rem 0; }
.scriptbody .cont { color: var(--muted); font-size: .9em; }
.personal { margin-top: .35rem; font-size: 1rem; }

/* AllStar status / voter side panel (wide screens only) */
.statuspanel[hidden] { display: none; }
.statuspanel .sframe { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.statuspanel .sframe[hidden] { display: none; }
.statuspanel iframe.sframe { flex: 1; min-height: 0; }
@media (min-width: 1280px) {
  main.withstatus { max-width: 1900px; }
  main.withstatus .netwrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(430px, 38%); gap: 1rem; align-items: start; }
  .statuspanel { position: sticky; top: 4rem; height: calc(100vh - 5rem); display: flex; flex-direction: column; }
}
@media (max-width: 1279px) { .statuspanel, #statustoggle { display: none !important; } }
@media print { .statuspanel, #statustoggle { display: none !important; } }

/* keep the call sign box in view on desktop-size screens while scrolling */
@media (min-width: 900px) {
  .card.checkin { position: sticky; top: 3.6rem; z-index: 4; box-shadow: 0 6px 12px -8px rgba(0,0,0,.35); }
}
