:root {
  --ink: #212e40;
  --ink-soft: #5c6a72;
  --paper: #edeee5;
  --paper-raised: #f7f7f1;
  --rule: #c7cbb6;
  --accent: #b0522e;
  --accent-soft: #ecd9c9;
  --focus: #2f6f8f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.masthead {
  border-bottom: 3px double var(--ink);
  padding: 2.25rem 1.5rem 1.5rem;
  background: var(--paper-raised);
}

.masthead-inner { max-width: 960px; margin: 0 auto; }

.eyebrow {
  margin: 0 0 .25rem;
  font-size: .8rem;
  letter-spacing: .03em;
  color: var(--ink-soft);
}

.masthead h1 {
  margin: 0;
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.picker {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 1.25rem;
  font-size: .95rem;
}

.picker label { color: var(--ink-soft); }

.picker select {
  font: inherit;
  font-weight: 500;
  padding: .5rem .75rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--paper-raised);
  color: var(--ink);
  min-width: 220px;
}

.empty {
  padding: 2rem 0;
  color: var(--ink-soft);
}

.site-footer {
  margin-top: 2.5rem;
  font-size: .8rem;
  color: var(--ink-soft);
}

@media (max-width: 560px) {
  .picker select { min-width: 0; flex: 1; }
}

/* --- Public timetable board: classes down the side, Monday to Sunday across --- */
.masthead-inner.wide, .wrap.wide { max-width: 1200px; }

body.public {
  background: #fbfaf6;
  font-family: 'Nunito', system-ui, sans-serif;
}

body.public .masthead {
  background: transparent;
  border-bottom: 0;
  padding: 2.25rem 0 .5rem;
}

body.public .masthead-inner { padding: 0 1.5rem; }

body.public .masthead h1 {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  letter-spacing: -.01em;
}

.board-scroll {
  overflow-x: auto;
  border: 1px solid #aeb4bd;
  border-radius: 6px;
  background: #fff;
}

table.board {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
  table-layout: fixed;
}

table.board th,
table.board td {
  border: 1px solid #aeb4bd;
  padding: 0;
  vertical-align: middle;
}

table.board col.std, table.board th.std { width: 92px; }

/* Day colours: --day for the header, --ink for text in that column (darker, so it stays readable). */
.d1 { --day: #d32f2f; --ink-day: #b3261e; }
.d2 { --day: #1e66c8; --ink-day: #1550a0; }
.d3 { --day: #2f8f3f; --ink-day: #1f6e2d; }
.d4 { --day: #d96a00; --ink-day: #a84f00; }
.d5 { --day: #8e3aa8; --ink-day: #7a2a94; }
.d6 { --day: #8a4b22; --ink-day: #7a3f1b; }
.d7 { --day: #d81b60; --ink-day: #b3124d; }

table.board thead th {
  background: var(--day, #55606b);
  color: #fff;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .02em;
  padding: .45rem .5rem;
  text-align: center;
}

table.board thead th.std {
  background: #fff;
  color: var(--ink);
  font-size: 1.05rem;
}

table.board tbody th.std {
  background: var(--row-bg);
  color: var(--row);
  text-align: center;
  padding: .5rem .25rem;
  position: sticky;
  left: 0;
  z-index: 1;
}

table.board thead th.std { position: sticky; left: 0; z-index: 2; }

.std-num {
  display: block;
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 2.4rem;
  line-height: 1;
}

.std-num sup {
  font-size: .95rem;
  font-weight: 700;
  vertical-align: top;
  position: relative;
  top: -.1rem;
  margin-left: .08rem;
}

.std-section {
  display: block;
  margin-top: .2rem;
  font-weight: 800;
  font-size: .85rem;
}

.std-text {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.1;
}

table.board td.cell {
  background: var(--row-bg);
  padding: .35rem .4rem;
  text-align: center;
  height: 5.2rem;
}

.entry {
  padding: .3rem .1rem;
  color: var(--ink-day, var(--ink));
  line-height: 1.25;
}

.entry + .entry {
  border-top: 1px dashed var(--day, #aeb4bd);
}

.entry-time {
  display: block;
  font-weight: 700;
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
}

.entry-who {
  display: block;
  font-weight: 800;
  font-size: .98rem;
}

.entry-note {
  display: block;
  font-weight: 600;
  font-size: .85rem;
}

.entry.dim { opacity: .22; }

/* Today's column */
table.board thead th.today {
  box-shadow: inset 0 -4px 0 rgba(255, 255, 255, .85);
}

table.board td.today {
  box-shadow: inset 3px 0 0 var(--day), inset -3px 0 0 var(--day);
}

@media print {
  @page { size: landscape; margin: 10mm; }
  body.public { background: #fff; }
  .picker, .site-footer { display: none; }
  .board-scroll { overflow: visible; border: 0; }
  table.board { min-width: 0; }
  table.board tbody th.std, table.board thead th.std { position: static; }
  table.board td.today { box-shadow: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* --- Admin --- */
.admin-body { background: var(--paper); }

.admin-shell {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.5rem;
  padding-bottom: .75rem;
}

.admin-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 500;
}

.admin-nav a.active { color: var(--accent); }

.card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  margin-top: 0;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.2rem;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: .75rem;
}

.field-row label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .82rem;
  color: var(--ink-soft);
  flex: 1;
  min-width: 140px;
}

input, select {
  font: inherit;
  padding: .5rem .6rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
}

button, .btn {
  font: inherit;
  font-weight: 600;
  padding: .55rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: var(--paper-raised);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button.secondary, .btn.secondary {
  background: transparent;
  color: var(--ink);
}

button.danger {
  background: var(--accent);
  border-color: var(--accent);
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

table.admin-table th, table.admin-table td {
  text-align: left;
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--rule);
}

.flash {
  padding: .7rem 1rem;
  border-radius: 3px;
  margin-bottom: 1.25rem;
  font-size: .9rem;
}

.flash.ok { background: #e3ede3; color: #2f5233; }
.flash.error { background: #f3ded6; color: #7a3a20; }

.login-shell {
  max-width: 360px;
  margin: 4rem auto;
  padding: 0 1.5rem;
}

/* --- Time slot admin --- */
.hint {
  color: var(--ink-soft);
  font-size: .85rem;
  margin: -.25rem 0 1rem;
}

.field-row label.check {
  flex: 0 0 auto;
  min-width: 0;
  flex-direction: row;
  align-items: center;
  gap: .4rem;
  align-self: flex-end;
  padding-bottom: .55rem;
  color: var(--ink);
}

.slot-edit {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--rule);
}

.slot-edit > form:first-child { flex: 1; margin: 0; }
.slot-edit .field-row { margin-bottom: 0; }

@media (max-width: 560px) {
  .slot-edit { flex-direction: column; align-items: stretch; }
}

/* --- Export to image / PDF --- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  margin-bottom: 1.25rem;
}

.toolbar .picker { margin-bottom: 0; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.actions button { padding: .5rem 1rem; font-size: .9rem; }
.actions button[hidden] { display: none; }
.actions button:disabled { opacity: .55; cursor: progress; }

.export-status {
  font-size: .85rem;
  color: var(--ink-soft);
  min-height: 1.2em;
}

/* The off-screen sheet that gets photographed for the image / PDF. */
.export-sheet {
  position: absolute;
  left: -10000px;
  top: 0;
  padding: 28px;
  background: #fff;
  color: var(--ink);
}

.export-title {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: .75rem;
}

.export-sub {
  margin: -.5rem 0 .75rem;
  color: var(--ink-soft);
  font-size: 1rem;
}

.export-sheet .board-scroll { overflow: visible; }
/* html2canvas measures digits without tabular figures, which leaves a gap in "10:30"; screen view is unaffected. */
.export-sheet .entry-time { font-variant-numeric: normal; }
.export-sheet table.board { min-width: 0; }
.export-sheet table.board tbody th.std,
.export-sheet table.board thead th.std { position: static; }

@media print {
  .toolbar { display: none; }
}

@media (max-width: 560px) {
  .actions { width: 100%; }
}
