:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1c1c1a;
  --muted: #5c5c58;
  --line: #d8d8d2;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --tint: #edf3ef;
  --filler-bg: #ececea;
  --filler-ink: #6a6a63;
  --warn-bg: #fdf3e3;
  --warn-line: #c9a227;
  --err: #a4231f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141613;
    --panel: #1d201c;
    --ink: #ecebe6;
    --muted: #a6a69e;
    --line: #3a3e37;
    --accent: #7fc39d;
    --accent-ink: #10231a;
    --tint: #24302a;
    --filler-bg: #232522;
    --filler-ink: #9c9c94;
    --warn-bg: #2b2416;
    --warn-line: #8a7420;
    --err: #f0a49f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.hero { padding: 0.5rem 0 0.75rem; }

h1 { font-size: 1.7rem; margin: 0 0 0.25rem; letter-spacing: -0.01em; }

h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }

.lead { margin: 0; color: var(--muted); max-width: 38rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.field { margin-bottom: 0.75rem; }

label { font-weight: 600; }

.field label, .field .hint { display: block; }

input, textarea, select, button { font: inherit; color: inherit; }

input[type="date"],
input[type="number"],
input[type="text"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  min-width: 0;
}

input[type="text"], textarea { width: 100%; }

select { max-width: 100%; }

textarea { resize: vertical; }

input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible, .chip input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

button.preset {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  padding: 0.2rem 0.6rem;
  font-size: 0.87rem;
  margin: 0 0.15rem;
}

button:hover { filter: brightness(1.06); }

.days {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem 0.75rem;
  margin: 0 0 0.75rem;
}

.days legend { font-weight: 600; padding: 0 0.35rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 500;
  margin: 0.2rem 0.6rem 0.2rem 0;
}

.hint { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.87rem; font-weight: 400; }

.status { margin: 0.5rem 0 0; min-height: 1.4em; color: var(--muted); }

.status.error { color: var(--err); font-weight: 600; }

/* The printed-sheet estimate above the buttons. It reads as plain grey while the plan fits one sheet,
   and takes the same amber tint and border as the leftover-topics box when the plan will run onto a
   second sheet: print.js adds the "over" class, the wording itself says "Heads-up", so the colour is
   never the only sign. */
.status.over {
  color: var(--ink);
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

/* The line at the top of the plan panel: empty while the plan matches the fields above it, and a
   short notice (with the reason) when the planner could not build and the older plan is still there. */
.plan-note {
  display: none;
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  font-size: 0.9rem;
}

.plan-note.shown { display: block; }

.summary p { margin: 0 0 0.4rem; }

.result { overflow-x: auto; }

table { border-collapse: collapse; width: 100%; margin-top: 0.5rem; }

th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.5rem;
  vertical-align: top;
}

th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

td.num { width: 2.5rem; color: var(--muted); }

td.date { white-space: nowrap; }

/* The optional per-session notes: quieter than the topic, and free to wrap onto more lines. */
td.note {
  color: var(--muted);
  font-size: 0.92rem;
  min-width: 7rem;
  max-width: 16rem;
  overflow-wrap: break-word;
}

tr.revision td {
  background: var(--tint);
  font-weight: 600;
}

/* Sessions with no topic of their own (a catch-up on the end, or sessions spread between topics):
   greyed and italic so they read as placeholders you can rename, not as topics you planned. */
tr.filler td {
  background: var(--filler-bg);
  color: var(--filler-ink);
  font-style: italic;
}

.warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-top: 0.75rem;
}

.warn p { margin: 0 0 0.35rem; }

.warn ul { margin: 0; padding-left: 1.2rem; }

.copy-area { margin-top: 0.75rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

/* Heading lines that only appear on paper: see @media print below. */
.print-head { display: none; }

.print-covers { display: none; }

/* The heading row print.js writes into the table: out of the way on screen, and the running head on paper. */
tr.print-repeat { display: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

footer {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Print: hide the controls, keep the dated plan on one clean sheet. */
@media print {
  :root {
    --bg: #ffffff;
    --panel: #ffffff;
    --ink: #000000;
    --muted: #444444;
    --line: #999999;
    --tint: #f0f0f0;
    --filler-bg: #f6f6f6;
    --filler-ink: #555555;
    --warn-bg: #ffffff;
    --warn-line: #666666;
  }

  body { background: #ffffff; color: #000000; font-size: 12pt; }

  main { max-width: none; padding: 0; }

  .hero { padding: 0; }

  .no-print { display: none !important; }

  .print-head {
    display: block;
    font-weight: 700;
    font-size: 10pt;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.5rem;
  }

  /* The second heading line, used when there is no table to put it in: what the plan covers and the
     stretch of dates it runs over. */
  .print-covers {
    display: block;
    font-weight: 600;
    font-size: 10.5pt;
    letter-spacing: 0;
    text-transform: none;
    color: #000000;
    margin: 0 0 0.6rem;
  }

  .panel {
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 0 0 0.75rem;
    background: #ffffff;
  }

  .result { overflow: visible; }

  table { margin-top: 0.25rem; }

  th, td { padding: 0.25rem 0.35rem; border-bottom: 1px solid #bbbbbb; }

  thead { display: table-header-group; }

  /* The heading row repeats at the top of every page of a plan that runs over more than one sheet. */
  tr.print-repeat { display: table-row; }

  th.print-repeat-cell {
    border-bottom: 1px solid #999999;
    padding: 0.25rem 0.35rem 0.4rem;
    font-size: 10.5pt;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: #000000;
  }

  tr { break-inside: avoid; page-break-inside: avoid; }

  tr.revision td { background: #f0f0f0; }

  tr.filler td { background: #ffffff; color: #444444; font-style: italic; -webkit-print-color-adjust: exact; }

  td.note { min-width: 0; max-width: none; font-size: 10pt; color: #333333; }

  .warn { padding: 0.4rem 0.5rem; }
}
