:root {
  --navy: #122757;
  --navy-2: #2a3f72;
  --gold: #ffd46c;
  --paper: #faf8f2;
  --surface: #ffffff;
  --ink: #1a2238;
  --muted: #5a6275;
  --rule: #e4dfd2;
  --amber-bg: #fff4d6;
  --amber-ink: #8a5a00;
  --ok: #1d6b45;
  --err: #a12c1f;
  --stt-w: 3.2rem;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-variant-numeric: tabular-nums;
}

/* ---------- header ---------- */
.masthead {
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 1.25rem;
  border-bottom: 4px solid var(--gold);
  background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 0.75rem; }
.logo-forum { height: 48px; width: auto; }
.logo-newing { height: 30px; width: auto; padding-left: 1.25rem; border-left: 1px solid var(--rule); }
h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.3rem, 2.4vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.sub { margin: 0.35rem 0 0; color: var(--muted); }

main { padding: 1rem clamp(0.75rem, 3vw, 2rem) 2rem; }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.75rem 1.5rem; margin-bottom: 0.9rem;
}
.hint { margin: 0; max-width: 62ch; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
button {
  font: inherit; font-size: 0.93rem; font-weight: 600;
  min-height: 40px; padding: 0.45rem 0.95rem;
  border: 1px solid var(--navy); border-radius: 6px;
  background: var(--surface); color: var(--navy); cursor: pointer;
}
button:hover { background: #eef1f8; }
button.primary { background: var(--navy); color: #fff; }
button.primary:hover { background: var(--navy-2); }
button.quiet { border-color: var(--rule); color: var(--muted); font-weight: 500; }
button.quiet:hover { color: var(--err); border-color: var(--err); background: #fff; }
button.pending-jump {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--amber-bg); color: var(--amber-ink); border-color: #ecd59a;
}
button.pending-jump:hover { background: #ffeebd; }
button.pending-jump[data-zero] { background: #e9f5ee; color: var(--ok); border-color: #b9dcc7; }
.swatch {
  display: inline-block; width: 0.85rem; height: 0.85rem; border-radius: 2px;
  background: var(--amber-bg); border: 1px solid #e3c477; flex: none;
}
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

.status { font-size: 0.875rem; color: var(--muted); min-width: 7rem; }
.status[data-state="saved"] { color: var(--ok); }
.status[data-state="error"] { color: var(--err); font-weight: 600; }
button.undo { min-height: 32px; padding: 0.2rem 0.7rem; font-size: 0.875rem; }

.table-foot { display: flex; align-items: center; gap: 1rem; margin-top: 0.6rem; }
.row-count { color: var(--muted); font-size: 0.875rem; }

/* ---------- table ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overscroll-behavior-x: contain;
}
table { width: 100%; min-width: 1200px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
th, td { vertical-align: top; text-align: left; border-bottom: 1px solid var(--rule); border-right: 1px solid var(--rule); }
th:last-child, td:last-child { border-right: 0; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--navy); color: #fff;
  font-size: 0.85rem; font-weight: 600; line-height: 1.3;
  padding: 0.65rem 0.6rem;
  border-bottom: 3px solid var(--gold); border-right-color: #2b3f70;
}
td { padding: 0; font-size: 0.875rem; }
.cell {
  min-height: 2.6rem; padding: 0.55rem 0.6rem;
  white-space: pre-wrap; overflow-wrap: anywhere;
  outline: none; cursor: text;
}
.cell:hover { background: rgba(18, 39, 87, 0.035); }
td:focus-within { box-shadow: inset 0 0 0 2px var(--navy); background: #fff; }
td:focus-within .cell { background: #fff; }

td.pending { background: var(--amber-bg); color: var(--amber-ink); }
td.pending .cell:hover { background: #ffeebd; }
td.saving .cell { opacity: 0.75; }
td.failed { box-shadow: inset 0 0 0 2px var(--err); }

td[data-col="stt"] .cell { text-align: center; color: var(--muted); }
/* delete-row button under the STT number: quiet until the row is hovered/focused; always shown on touch */
.row-del {
  display: grid; place-items: center; margin: 0 auto 0.4rem;
  min-height: 0; width: 2rem; height: 2rem; padding: 0;
  border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted);
  opacity: 0;
}
.row-del svg { width: 1rem; height: 1rem; }
tr:hover .row-del, tr:focus-within .row-del, .row-del:focus-visible { opacity: 1; }
.row-del:hover { color: var(--err); border-color: var(--err); background: #fff; }
@media (hover: none) { .row-del { opacity: 0.55; } }
td[data-col="speaker"] .cell { font-weight: 600; color: var(--navy); }
td[data-col="kind"] .cell, td[data-col="time"] .cell { font-weight: 600; }
td.pending[data-col="speaker"] .cell, td.pending[data-col="time"] .cell { color: var(--amber-ink); }

tr.group-start td { border-top: 2px solid var(--navy); }
tbody tr:first-child td { border-top: 0; }
tbody tr:last-child td { border-bottom: 0; }

/* first two columns stay visible when the table scrolls sideways */
th:nth-child(1), td:nth-child(1) { position: sticky; left: 0; z-index: 1; }
th:nth-child(2), td:nth-child(2) { position: sticky; left: var(--stt-w); z-index: 1; box-shadow: 1px 0 0 var(--rule), 6px 0 8px -6px rgba(18, 39, 87, 0.25); }
thead th:nth-child(1), thead th:nth-child(2) { z-index: 3; }
td:nth-child(1), td:nth-child(2) { background: var(--surface); }
td.pending:nth-child(1), td.pending:nth-child(2) { background: var(--amber-bg); }
.loading { padding: 2rem; color: var(--muted); text-align: center; }

/* ---------- contacts ---------- */
.contacts { margin-top: 2rem; }
h2 { font-size: 1.15rem; color: var(--navy); margin: 0 0 0.75rem; }
.contacts ul {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.75rem 2rem;
}
.contacts li { border-left: 3px solid var(--gold); padding: 0.15rem 0 0.15rem 0.9rem; }
.contacts p { margin: 0; }
.who { font-weight: 700; color: var(--navy); }
.who span { font-weight: 500; color: var(--muted); }
.role, .via { color: var(--muted); font-size: 0.93rem; }
.contacts a { color: var(--navy); overflow-wrap: anywhere; font-weight: 600; font-size: 0.93rem; }

.note { display: flex; gap: 0.6rem; align-items: baseline; margin: 1.75rem 0 0; color: var(--muted); font-size: 0.93rem; max-width: 75ch; }
.credit { padding: 1.5rem clamp(1rem, 3vw, 2rem) 2rem; font-size: 0.8rem; }
.credit a { color: var(--muted); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* ---------- phone ---------- */
@media (max-width: 720px) {
  :root { --stt-w: 2.6rem; }
  table { min-width: 1500px; }
  colgroup col:nth-child(1) { width: 2.6rem !important; }
  colgroup col:nth-child(2) { width: 6.5rem !important; }
  td, .cell { font-size: 14px; }
  thead th { font-size: 14px; }
  .actions { width: 100%; }
  .status { flex-basis: 100%; }
  .logo-forum { height: 38px; }
  .logo-newing { height: 24px; }
}

@media (prefers-reduced-motion: no-preference) {
  button, .cell, td { transition: background-color 0.15s ease, color 0.15s ease; }
}

/* ---------- print: A4 landscape ---------- */
@page { size: A4 landscape; margin: 9mm 8mm; }
@media print {
  body { background: #fff; font-size: 9pt; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .toolbar, .credit, .table-foot, .row-del { display: none !important; }
  .masthead { padding: 0 0 6pt; border-bottom-width: 2pt; }
  .brand { margin-bottom: 4pt; }
  .logo-forum { height: 30pt; } .logo-newing { height: 18pt; }
  h1 { font-size: 15pt; }
  main { padding: 6pt 0 0; }
  .table-wrap { overflow: visible; border: 0; border-radius: 0; }
  table { min-width: 0; }
  thead { display: table-header-group; }
  thead th { position: static; font-size: 7.5pt; padding: 3pt 4pt; }
  th, td { position: static !important; box-shadow: none !important; }
  td, .cell { font-size: 7.5pt; line-height: 1.3; }
  .cell { min-height: 0; padding: 3pt 4pt; }
  tr { break-inside: avoid; page-break-inside: avoid; }
  .contacts { break-inside: avoid; margin-top: 10pt; }
  .contacts ul { grid-template-columns: repeat(4, 1fr); }
  .note { margin-top: 8pt; font-size: 8pt; }
}
