/* The People's Inference Bureau: one stylesheet, no imports, no remote assets.
   Every color resolves from a custom property defined in both the light and
   the dark block below. Contrast ratios were checked against WCAG 2.1 AA. */

:root {
  color-scheme: light dark;

  --bg: #F1EBDD;
  --surface: #FBF7EE;
  --surface-2: #F6F0E3;
  --border: #D6CBB4;
  --border-strong: #8C7F66;
  --text: #221D19;
  --muted: #5A5045;
  --accent: #A81C1C;
  --accent-strong: #8E1616;
  --on-accent: #FDF9F1;
  --night: #4B44A0;
  --night-bg: #E8E6F5;
  --ok: #2E6B39;
  --warn: #855508;
  --danger: #A81C1C;
  --focus: #1F4FD8;
  --series-1: #A81C1C;
  --track: #E3DAC6;
  --shadow: rgba(60, 45, 25, 0.22);
  --scrim: rgba(30, 20, 10, 0.45);

  --radius: 4px;
  --gap: 0.75rem;
  --maxw: 62rem;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131010;
    --surface: #1D1817;
    --surface-2: #241E1C;
    --border: #3B302C;
    --border-strong: #7A675C;
    --text: #EFE4CA;
    --muted: #B2A18D;
    --accent: #D93A32;
    --accent-strong: #C41E1E;
    --on-accent: #FFF3E0;
    --night: #8385CE;
    --night-bg: #23213A;
    --ok: #6FBF7F;
    --warn: #D9A441;
    --danger: #E8615F;
    --focus: #7FA8FF;
    --series-1: #D93A32;
    --track: #2E2724;
    --shadow: rgba(0, 0, 0, 0.55);
    --scrim: rgba(0, 0, 0, 0.65);
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.4em; font-weight: 700; }
h1 { font-size: 1.2rem; letter-spacing: 0.06em; text-transform: uppercase; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--accent); }
a:hover { color: var(--accent-strong); }
code, kbd, pre, .mono { font-family: var(--mono); font-size: 0.875em; }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--text);
  padding: 0.6rem 1rem;
  z-index: 50;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- banner ---------- */

.banner {
  background: var(--accent-strong);
  color: var(--on-accent);
  border-bottom: 3px solid var(--border-strong);
}
.banner-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.banner-star { font-size: 1.6rem; line-height: 1; }
.banner-titles { flex: 1 1 14rem; min-width: 0; }
.banner h1 { color: var(--on-accent); margin: 0; }
.decree {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--on-accent);
  opacity: 0.82;
}
.banner-side { font-size: 0.85rem; text-align: right; }
.banner-side .credits { font-weight: 700; }
.banner-side button { margin-left: 0.5rem; }

/* ---------- nav ---------- */

.nav { background: var(--surface); border-bottom: 1px solid var(--border); }
.nav ul {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 0.5rem;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
}
.nav a {
  display: block;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  font-size: 0.95rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] {
  border-bottom-color: var(--accent);
  font-weight: 700;
  color: var(--accent);
}

/* ---------- layout ---------- */

.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.25rem 1rem 8rem;
}
.view:focus { outline: none; }
.foot {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}
.foot p { margin: 0.2rem 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  margin: 0 0 1rem;
}
.panel-warn { border-left-color: var(--warn); }
.panel-error { border-left-color: var(--danger); }
.panel-ok { border-left-color: var(--ok); }
.panel h2, .panel h3 { margin-top: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1rem;
}
.card h3 { margin-top: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.loading { color: var(--muted); }
.stack > * + * { margin-top: 0.75rem; }
.row-wrap { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }
.spread { display: flex; flex-wrap: wrap; gap: var(--gap); justify-content: space-between; align-items: baseline; }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- forms and buttons ---------- */

label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0.5rem; font-weight: 400; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="datetime-local"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.5rem 0.6rem;
  width: 100%;
  max-width: 30rem;
}
textarea { font-family: var(--mono); font-size: 0.85rem; min-height: 6rem; max-width: 44rem; }
select { max-width: 14rem; }

.field { margin-bottom: 0.9rem; }
.field-error { color: var(--danger); font-weight: 600; font-size: 0.9rem; }

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--accent-strong);
  background: var(--accent-strong);
  color: var(--on-accent);
  padding: 0.5rem 0.9rem;
  min-height: 2.5rem;
}
.btn:hover { background: var(--accent); border-color: var(--accent); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-quiet {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn-danger:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-big { font-size: 1.05rem; padding: 0.8rem 1.2rem; }
.btn-small { font-size: 0.85rem; padding: 0.3rem 0.6rem; min-height: 2rem; }

/* ---------- login ---------- */

.login { max-width: 26rem; margin: 2rem auto; text-align: center; }
.login .star { font-size: 3rem; color: var(--accent); line-height: 1; }
.login form { margin-top: 1rem; text-align: left; }
.login input { text-align: center; letter-spacing: 0.1em; }
.login .btn { width: 100%; }
.login .slogan {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ---------- calendar ---------- */

.legend { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; font-size: 0.85rem; }
.legend li { display: flex; align-items: center; gap: 0.35rem; }
.legend .swatch {
  width: 1.1rem; height: 1.1rem; border-radius: 2px;
  border: 1px solid var(--border-strong); display: inline-block; flex: none;
}
.swatch-peak { background: var(--surface); }
.swatch-standard { background: var(--surface-2); }
.swatch-night { background: var(--night-bg); }
.swatch-taken { background: var(--track); }
.swatch-closed { background: var(--track); background-image: repeating-linear-gradient(45deg, transparent 0 4px, var(--border-strong) 4px 6px); }
.swatch-mine { background: var(--surface); border-left: 4px solid var(--accent); }

.daychips { display: flex; gap: 0.35rem; overflow-x: auto; padding: 0 0 0.5rem; margin: 0 0 0.75rem; }
.daychip {
  flex: none;
  font: inherit;
  font-size: 0.82rem;
  padding: 0.35rem 0.6rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.daychip:hover { background: var(--surface-2); }

.hours { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.dayhead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  scroll-margin-top: 0;
}
.dayhead .dayhead-sub { font-weight: 400; color: var(--muted); font-size: 0.8rem; margin-left: 0.5rem; }

.hour {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-top: 1px solid var(--border);
  border-left: 4px solid transparent;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.9rem;
}
.hour:first-child { border-top: none; }
.hour .hour-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.hour .hour-band { color: var(--muted); display: flex; align-items: center; gap: 0.35rem; }
.hour .hour-price { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hour .glyph { font-size: 0.95em; }

.hour-standard { background: var(--surface-2); }
.hour-night { background: var(--night-bg); }
.hour-night .hour-band { color: var(--night); font-weight: 600; }
.hour-taken, .hour-closed { cursor: not-allowed; color: var(--muted); background: var(--track); }
.hour-closed { background-image: repeating-linear-gradient(45deg, transparent 0 5px, var(--border) 5px 7px); }
.hour-taken .hour-time, .hour-closed .hour-time { text-decoration: line-through; }
.hour-mine { border-left-color: var(--accent); }
.hour-mine .hour-band { color: var(--accent); font-weight: 600; }
.hour-past { opacity: 0.55; cursor: not-allowed; }

.hour[aria-selected="true"] {
  background: var(--accent-strong);
  color: var(--on-accent);
  border-left-color: var(--on-accent);
}
.hour[aria-selected="true"] .hour-band,
.hour[aria-selected="true"] .hour-price { color: var(--on-accent); }
.hour:hover:not([aria-disabled="true"]) { outline: 2px solid var(--border-strong); outline-offset: -2px; }

.quote {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--surface);
  border-top: 3px solid var(--accent);
  box-shadow: 0 -4px 12px var(--shadow);
  margin: 0 -1rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
}
.quote-grid { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: flex-end; justify-content: space-between; }
.quote-when { font-weight: 700; }
.quote-total { font-size: 1.5rem; font-weight: 700; }
.quote-lines { font-size: 0.85rem; color: var(--muted); }
.quote label { font-size: 0.85rem; }
.quote .btn { white-space: nowrap; }

/* ---------- bookings and status ---------- */

.booking { border-left-width: 4px; }
.booking-active { border-left-color: var(--ok); }
.booking-past { color: var(--muted); }
.booking dl { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.75rem; margin: 0.5rem 0; font-size: 0.9rem; }
.booking dt { color: var(--muted); }
.booking dd { margin: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}
.pill-ok { border-color: var(--ok); color: var(--ok); }
.pill-warn { border-color: var(--warn); color: var(--warn); }
.pill-off { border-color: var(--muted); color: var(--muted); }

pre.cmd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  overflow-x: auto;
  margin: 0.4rem 0;
}
.copyrow { display: flex; gap: 0.5rem; align-items: flex-start; }
.copyrow pre { flex: 1 1 auto; min-width: 0; }

.status-hero { text-align: center; padding: 1.25rem 1rem; }
.status-hero .star { font-size: 2.5rem; color: var(--accent); line-height: 1; }
.status-hero .headline { font-size: 1.5rem; font-weight: 700; letter-spacing: 0.03em; }
.status-hero .sub { color: var(--muted); }

/* ---------- leaderboard ---------- */

.hero-figure { font-size: 3rem; font-weight: 700; line-height: 1.05; }
.hero-label { color: var(--muted); font-size: 0.9rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: var(--gap); margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.8rem 0.9rem; }
.tile .tile-label { color: var(--muted); font-size: 0.85rem; }
.tile .tile-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.tile .tile-note { color: var(--muted); font-size: 0.8rem; }

/* Wide content scrolls inside its own box; the page body never does. */
.tablewrap { overflow-x: auto; }
table.board { width: 100%; min-width: 22rem; border-collapse: collapse; font-size: 0.92rem; }
table.board caption { text-align: left; color: var(--muted); font-size: 0.85rem; padding-bottom: 0.4rem; }
table.board th, table.board td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.board thead th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
table.board tbody tr:hover { background: var(--surface-2); }
table.board .num { text-align: right; font-variant-numeric: tabular-nums; }
.barcell { width: 55%; }
.barwrap { display: flex; align-items: center; gap: 0.5rem; }
.bartrack { flex: 1 1 auto; background: var(--track); border-radius: 0 2px 2px 0; min-width: 3rem; }
.bar {
  display: block;
  height: 16px;
  background: var(--series-1);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.barval { font-variant-numeric: tabular-nums; flex: none; }

/* ---------- toasts and dialog ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: min(30rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  box-shadow: 0 4px 14px var(--shadow);
  font-size: 0.9rem;
}
.toast-ok { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }

.dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 30rem;
  width: calc(100vw - 2rem);
  padding: 1rem;
}
.dialog::backdrop { background: var(--scrim); }
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }

/* ---------- responsive ---------- */

@media (max-width: 34rem) {
  .hour { grid-template-columns: 4.6rem 1fr auto; font-size: 0.86rem; padding: 0.5rem 0.5rem; }
  .view { padding: 1rem 0.75rem 9rem; }
  .quote { margin: 0 -0.75rem; padding-left: 0.75rem; padding-right: 0.75rem; }
  .banner-side { text-align: left; flex-basis: 100%; }
  .hero-figure { font-size: 2.4rem; }
  .barcell { width: 45%; }
}

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