/* ============================================================
   Coach board — visual system
   Concept: a tactics whiteboard. Cool white surface, ink colours carry meaning:
   blue = structure, red = cannot be done, amber = unknown, green = fits.
   ============================================================ */
:root {
  --paper: #F4F6F4;
  --surface: #FFFFFF;
  --ink: #1C2430;
  --ink-2: #4E5968;
  --ink-3: #7A8492;
  --line: #D9DEE4;
  --line-soft: #E8ECEF;
  --blue: #1F4FA8;
  --blue-wash: #E7EDF9;
  --red: #BE3129;
  --red-wash: #FBE9E7;
  --amber: #9A5B00;
  --amber-wash: #FFF2D9;
  --green: #276F44;
  --green-wash: #E4F2E9;
  --focus: #1F4FA8;
  --shadow: 0 1px 0 rgba(28, 36, 48, .06);
  --r-chip: 4px;
  --r-panel: 10px;
  --font-body: "IBM Plex Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
  --font-board: "Secular One", "IBM Plex Sans Hebrew", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #161B22; --surface: #1D242D; --ink: #E6EBF1; --ink-2: #B4BDC9; --ink-3: #8B95A3;
    --line: #313B47; --line-soft: #27303A;
    --blue: #93B3F0; --blue-wash: #22304A; --red: #F08C84; --red-wash: #3D2323;
    --amber: #EDBB66; --amber-wash: #3A2F1B; --green: #84CF9E; --green-wash: #1E3328; --focus: #93B3F0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #161B22; --surface: #1D242D; --ink: #E6EBF1; --ink-2: #B4BDC9; --ink-3: #8B95A3;
  --line: #313B47; --line-soft: #27303A;
  --blue: #93B3F0; --blue-wash: #22304A; --red: #F08C84; --red-wash: #3D2323;
  --amber: #EDBB66; --amber-wash: #3A2F1B; --green: #84CF9E; --green-wash: #1E3328; --focus: #93B3F0;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
a { color: var(--blue); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-family: var(--font-board); font-weight: 400; font-size: 1.9rem; letter-spacing: .01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: .25rem 0 .75rem; max-width: 70ch; }
small, .muted { color: var(--ink-3); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Shell ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface);
  border-bottom: 2px solid var(--ink); display: flex; align-items: center; gap: 1rem;
  padding-block: .55rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.brand { font-family: var(--font-board); font-size: 1.25rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--blue); }
.nav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none; color: var(--ink-2); padding: .4rem .7rem; border-radius: var(--r-chip);
  white-space: nowrap; font-weight: 500;
}
.nav a[aria-current="page"] { color: var(--ink); background: var(--blue-wash); box-shadow: inset 0 -2px 0 var(--blue); }
.topbar .who { font-size: .85rem; color: var(--ink-3); white-space: nowrap; }
.demo-band {
  background: var(--amber-wash); color: var(--amber); font-size: .85rem; padding-block: .35rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
}
main { max-width: 1180px; margin: 0 auto; padding-block: 1.25rem 4rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
main > *, .grid > * { min-width: 0; }
h1, h2 { text-wrap: balance; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head p { margin: .2rem 0 0; color: var(--ink-2); }

/* ---------- Panels & sections ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 1rem; }
.panel > h2 { margin-bottom: .6rem; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 3fr 2fr; } .grid.half { grid-template-columns: 1fr 1fr; } }

.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { display: flex; gap: .75rem; align-items: baseline; padding: .6rem 0; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.rows > li:first-child { border-top: 0; }
.rows .when { font-weight: 600; min-width: 7.5rem; }
.rows .grow { flex: 1; min-width: 12rem; }
.empty { color: var(--ink-3); padding: .5rem 0; }

/* ---------- Chips (status ink) ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; font-weight: 600;
  padding: .08rem .45rem; border-radius: var(--r-chip); border: 1px solid currentColor; white-space: nowrap; line-height: 1.5;
}
.chip.blue { color: var(--blue); background: var(--blue-wash); }
.chip.red { color: var(--red); background: var(--red-wash); }
.chip.amber { color: var(--amber); background: var(--amber-wash); }
.chip.green { color: var(--green); background: var(--green-wash); }
.chip.plain { color: var(--ink-2); background: transparent; border-color: var(--line); }
.md { font-family: var(--font-board); font-weight: 400; font-size: .9rem; color: var(--blue); }

/* ---------- Buttons & forms ---------- */
button, .btn {
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  border: 1px solid var(--ink); background: var(--surface); color: var(--ink);
  padding: .45rem .9rem; border-radius: 6px; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem;
}
button.primary { background: var(--blue); border-color: var(--blue); color: var(--surface); }
button.quiet { border-color: var(--line); color: var(--ink-2); }
button.danger { border-color: var(--red); color: var(--red); }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .2rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; min-width: 0;
}
textarea { min-height: 4.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-wash); }
.fields { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.field-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.field-row > * { flex: 1; min-width: 7rem; }
.check { display: flex; align-items: center; gap: .4rem; font-weight: 500; }
.check input { width: auto; }

/* ---------- The board: session plan ---------- */
.board-block { display: grid; grid-template-columns: 3.2rem 1fr; gap: .9rem; padding: .9rem 0; border-top: 1px dashed var(--line); }
.board-block:first-of-type { border-top: 0; }
.board-letter {
  font-family: var(--font-board); font-size: 2.1rem; line-height: 1; color: var(--blue);
  width: 3.2rem; height: 3.2rem; display: grid; place-items: center;
  border: 2.5px solid var(--blue); border-radius: 50% 46% 52% 48%;
}
.board-block h3 { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; }
.board-block h3 small { font-weight: 500; }
.items { list-style: none; padding: 0; margin: .4rem 0 0; }
.items li { display: grid; grid-template-columns: 2.4rem minmax(9rem, 1.3fr) 2fr; gap: .6rem; padding: .35rem 0; border-top: 1px solid var(--line-soft); align-items: baseline; }
.items li:first-child { border-top: 0; }
.items .lbl { font-weight: 700; color: var(--ink-2); }
.items .ex { font-weight: 600; }
.items .ex small { display: block; font-weight: 400; }
.items .dose { color: var(--ink-2); }
.items .cues { grid-column: 2 / -1; font-size: .85rem; color: var(--ink-3); }
.items .adj { grid-column: 2 / -1; font-size: .85rem; color: var(--amber); }
@media (max-width: 640px) {
  .board-block { grid-template-columns: 1fr; }
  .items li { grid-template-columns: 2.2rem 1fr; }
  .items .dose { grid-column: 2; }
}

/* ---------- Time-budget bar: the one bold element ---------- */
.tbar { margin: .75rem 0 .35rem; }
.tbar-track {
  position: relative; height: 2.4rem; display: flex; border: 2px solid var(--ink); border-radius: 6px;
  overflow: hidden; background: repeating-linear-gradient(-45deg, var(--surface) 0 6px, var(--line-soft) 6px 12px);
}
.tbar-seg { height: 100%; display: grid; place-items: center; font-family: var(--font-board); font-size: .95rem; color: var(--ink); border-inline-start: 1px solid var(--surface); overflow: hidden; white-space: nowrap; }
.tbar-seg.block { background: var(--blue-wash); color: var(--blue); }
.tbar-seg.block:nth-of-type(odd) { background: color-mix(in srgb, var(--blue-wash) 70%, var(--blue) 12%); }
.tbar-seg.frame { background: var(--line-soft); color: var(--ink-3); font-family: var(--font-body); font-size: .75rem; }
.tbar-seg.over { background: repeating-linear-gradient(-45deg, var(--red-wash) 0 6px, color-mix(in srgb, var(--red) 25%, transparent) 6px 12px); }
.tbar-window { position: absolute; top: -6px; bottom: -6px; width: 0; border-inline-start: 3px solid var(--red); }
.tbar-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; font-size: .88rem; color: var(--ink-2); }
.tbar-legend strong { color: var(--ink); }

/* ---------- Issues ---------- */
.issues { list-style: none; padding: 0; margin: .5rem 0 0; }
.issues li { padding: .45rem .6rem; border-radius: 6px; margin-top: .35rem; border-inline-start: 4px solid; }
.issues li.block { background: var(--red-wash); border-color: var(--red); }
.issues li.warning { background: var(--amber-wash); border-color: var(--amber); }
.issues .sugs { margin-top: .35rem; display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }

/* ---------- Week grid ---------- */
.week { width: 100%; border-collapse: separate; border-spacing: 0; }
.week th, .week td { border-bottom: 1px solid var(--line-soft); vertical-align: top; padding: .5rem; text-align: start; }
.week thead th { font-size: .85rem; color: var(--ink-2); font-weight: 600; background: var(--paper); }
.week tbody th { font-family: var(--font-board); font-weight: 400; font-size: 1.05rem; white-space: nowrap; }
.week td.today { background: color-mix(in srgb, var(--blue-wash) 45%, transparent); }
.slot { display: block; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: .3rem .45rem; margin-bottom: .35rem; background: var(--surface); font-size: .85rem; }
.slot:hover { border-color: var(--blue); }
.slot b { display: block; }
.slot.match { border-style: dashed; border-color: var(--ink-2); background: transparent; }
.week-wrap { overflow-x: auto; }
@media (max-width: 760px) { .week { display: none; } }
@media (min-width: 761px) { .week-mobile { display: none; } }

/* ---------- Dialog & toast ---------- */
dialog { border: 2px solid var(--ink); border-radius: var(--r-panel); padding: 0; max-width: min(720px, calc(100vw - 32px)); width: 100%; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(20, 26, 34, .45); }
dialog .dlg-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
dialog .dlg-body { padding: 1rem 1.1rem; max-height: 70vh; overflow: auto; }
dialog .dlg-foot { padding: .8rem 1.1rem; border-top: 1px solid var(--line); }
.toast {
  position: fixed; inset-inline: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); margin: 0 auto; max-width: 560px; z-index: 50;
  background: var(--ink); color: var(--surface); padding: .7rem 1rem; border-radius: 8px; font-weight: 500;
  transform: translateY(0); transition: transform .2s ease, opacity .2s ease;
}
.toast.err { background: var(--red); color: #fff; }
.toast[hidden] { display: block; opacity: 0; transform: translateY(1rem); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* ---------- Editor ---------- */
.ed-block { border: 1px solid var(--line); border-radius: var(--r-panel); padding: .8rem; margin-top: .8rem; background: var(--paper); }
.ed-block > .field-row { margin-bottom: .6rem; }
.ed-item { display: grid; gap: .4rem; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); padding: .55rem; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--surface); margin-top: .4rem; }
.ed-item .ex-field { grid-column: span 3; min-width: 0; }
.ed-item .cues-field { grid-column: 1 / -1; }
.ed-item label { font-size: .75rem; }
@media (max-width: 640px) { .ed-item .ex-field { grid-column: 1 / -1; } }

/* ---------- Login ---------- */
.login { max-width: 380px; margin: 12vh auto; }
.login h1 { margin-bottom: .2rem; }

details summary { cursor: pointer; font-weight: 600; color: var(--blue); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; font-size: .92rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
pre.prompt { white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: .7rem; font-family: var(--font-body); font-size: .9rem; margin: .3rem 0 .6rem; }
