/* Scheduler Review Lab. A small navy and teal system; no external fonts or images. */

:root {
  --navy-900: #0f2a43;
  --navy-700: #1d4266;
  --navy-100: #e4ecf4;
  --teal-700: #0b6e7a;
  --teal-600: #0e8594;
  --teal-100: #dff2f4;
  --ink: #142433;
  --muted: #4d5d6c;
  --line: #d3dce6;
  --surface: #ffffff;
  --page: #f2f5f8;
  --ok: #1c6b47;
  --ok-bg: #e2f3ea;
  --info: #1b4f8f;
  --info-bg: #e4eefb;
  --warn: #7d5200;
  --warn-bg: #fcefd3;
  --bad: #9c2f28;
  --bad-bg: #fbe5e2;
  --radius: 10px;
  --focus: 3px solid #f2a900;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-wrap: break-word;
}

[hidden] { display: none !important; }

h1, h2, h3, h4 { color: var(--navy-900); line-height: 1.25; margin: 0; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
h4 { font-size: 0.95rem; }
p { margin: 0.5rem 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.875em; overflow-wrap: anywhere; }
a { color: var(--teal-700); }

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

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

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 10;
  background: var(--surface); color: var(--navy-900); padding: 10px 14px; border-radius: 6px;
}
.skip-link:focus { top: 8px; }

/* Masthead and staging panel */

.masthead { background: var(--navy-900); color: #ffffff; }
.masthead-inner {
  max-width: 1160px; margin: 0 auto; padding: 24px 20px;
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start;
}
.masthead h1 { color: #ffffff; }
.eyebrow { margin: 0 0 6px; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; color: #a9d9df; }
.lede { color: #d8e4ef; max-width: 46rem; }

.staging { background: var(--navy-700); border: 1px solid #36608a; border-radius: var(--radius); padding: 14px 16px; font-size: 0.9rem; }
.staging h2 { color: #ffffff; font-size: 1rem; }
.staging p { color: #dbe6f1; }
.staging a.external { color: #ffffff; font-weight: 600; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 12px; font-size: 0.82rem; font-weight: 600; }
.pill-pending { background: var(--warn-bg); color: var(--warn); border: 1px solid #e7c670; }
.staging .pill-pending { color: #5a3b00; }

/* Page structure */

main { max-width: 1160px; margin: 0 auto; padding: 20px; }
.footer { max-width: 1160px; margin: 0 auto; padding: 8px 20px 32px; color: var(--muted); font-size: 0.85rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.step { margin: 0 0 28px; }
.step > h2, .step-head h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.step-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.step-number {
  display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; flex: none;
  border-radius: 50%; background: var(--teal-700); color: #ffffff; font-size: 0.95rem; font-weight: 700;
}
.hint { color: var(--muted); font-size: 0.9rem; margin: 4px 0 8px; }
.muted { color: var(--muted); }

.note { border-left: 4px solid var(--line); background: #f7f9fb; border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 0.92rem; }
.note-info { border-color: var(--info); background: var(--info-bg); }
.note-warn { border-color: #c98a00; background: var(--warn-bg); color: #4d3300; }
.note-bad { border-color: var(--bad); background: var(--bad-bg); color: #5f1c18; }
.note ul { margin: 6px 0 0 18px; padding: 0; }

/* Buttons and inputs */

.btn {
  font: inherit; font-weight: 600; cursor: pointer; min-height: 40px;
  border: 1px solid var(--navy-700); background: var(--surface); color: var(--navy-900);
  border-radius: 8px; padding: 8px 14px;
}
.btn:hover { background: var(--navy-100); }
.btn-primary { background: var(--teal-700); border-color: var(--teal-700); color: #ffffff; }
.btn-primary:hover { background: #095c66; }
.btn-large { font-size: 1.05rem; padding: 10px 26px; min-height: 46px; }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

input[type="text"], input[type="password"], select, textarea {
  font: inherit; color: var(--ink); background: #ffffff; max-width: 100%;
  border: 1px solid #8b9bab; border-radius: 6px; padding: 7px 9px; min-height: 38px;
}
input[type="text"], input[type="password"], select { width: 100%; }
input.num { width: 6.5rem; }
input.short { max-width: 16rem; }
input.is-odd { border-color: #c98a00; background: #fff8e6; }
input[type="checkbox"], input[type="radio"] { width: 1.1rem; height: 1.1rem; accent-color: var(--teal-700); flex: none; margin: 0; }

.field { margin: 10px 0; max-width: 34rem; }
.field > label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 3px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 4px 20px; }
.inline-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 6px 0; }
.interp { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.interp.is-odd { color: var(--warn); font-weight: 600; }

.check { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 2px 10px 2px 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; }

/* Mode and example choices */

.mode-cards, .example-cards { display: grid; gap: 12px; }
.mode-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.example-cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.choice-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; row-gap: 4px; align-items: start;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
}
.choice-card input { margin-top: 4px; grid-row: 1 / span 4; }
.choice-card:has(input:checked) { border-color: var(--teal-700); background: var(--teal-100); }
.choice-card:has(input:focus-visible) { outline: var(--focus); outline-offset: 2px; }
.choice-card:has(input:disabled) { cursor: not-allowed; opacity: 0.7; }
.choice-name { font-weight: 700; color: var(--navy-900); }
.choice-text { font-size: 0.9rem; grid-column: 2; }
.choice-limit { font-size: 0.86rem; color: var(--warn); grid-column: 2; }
.choice-tag { font-size: 0.8rem; color: var(--muted); grid-column: 2; }

.example-about h3 { margin-bottom: 4px; }
.example-about ul { margin: 4px 0 0 20px; padding: 0; }
.backend-box { margin-top: 12px; }
.backend-box > div { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 6px; }

/* Input form */

.form-root { display: grid; gap: 12px; }
.form-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.form-section > h3 { margin-bottom: 2px; }
.sub-block { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.sub-block > h4 { margin-bottom: 4px; }

.weekday-set { display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px; padding: 6px 0; border-bottom: 1px solid #edf1f5; }
.weekday-set legend { float: left; width: 11rem; max-width: 100%; margin-right: 8px; padding-top: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88rem; overflow-wrap: anywhere; }
.weekday-set .count { color: var(--muted); font-size: 0.85rem; margin-left: 6px; }
.room-set { display: flex; flex-wrap: wrap; gap: 0 6px; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; padding: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--teal-100); border: 1px solid #a9d6dc; border-radius: 6px; padding: 2px 8px; font-size: 0.88rem; }
.chip-pos { font-size: 0.75rem; color: var(--muted); }
.chip-unknown { background: var(--warn-bg); border-color: #e7c670; }

details.person, details.option-box { border: 1px solid var(--line); border-radius: 8px; padding: 0; margin: 8px 0; background: #fbfcfd; }
details.person > summary, details.option-box > summary { cursor: pointer; padding: 10px 12px; font-size: 0.94rem; }
details.person > .person-body, details.option-box > .option-body { padding: 0 12px 12px; }
.person-line { color: var(--muted); }
.fact-list { margin: 6px 0; padding: 0 0 0 18px; font-size: 0.9rem; color: var(--muted); }

.rule-row { border-top: 1px solid #edf1f5; padding: 8px 0; }
.rule-row:first-of-type { border-top: 0; }
.rule-sentence { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.rule-meta { font-size: 0.82rem; color: var(--muted); }
.tag { display: inline-block; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; font-size: 0.78rem; color: var(--muted); background: #f7f9fb; }

.advanced > summary { cursor: pointer; font-weight: 600; color: var(--navy-900); }
.json-editor { width: 100%; font: 0.84rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre; overflow: auto; resize: vertical; tab-size: 2; }

/* Calculate */

.run-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.run-status { margin: 0; color: var(--muted); }

/* Result */

.stale-banner { background: var(--warn-bg); border: 2px solid #c98a00; border-radius: var(--radius); padding: 10px 14px; margin: 8px 0 12px; color: #4d3300; }
.result-root.is-stale > * { opacity: 0.62; }

.summary { border-left-width: 10px; }
.summary.tone-ok { border-left-color: var(--ok); }
.summary.tone-info { border-left-color: var(--info); }
.summary.tone-warn { border-left-color: #c98a00; }
.summary.tone-bad { border-left-color: var(--bad); }
.summary.tone-neutral { border-left-color: #7b8794; }
.summary-kicker { margin: 0; font-size: 0.85rem; color: var(--muted); }
.summary-title { display: flex; align-items: center; gap: 10px; margin: 4px 0; font-size: 1.3rem; font-weight: 700; color: var(--navy-900); line-height: 1.25; }
.summary-icon { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; flex: none; border-radius: 50%; color: #ffffff; font-size: 1rem; font-weight: 700; background: #7b8794; }
.tone-ok .summary-icon { background: var(--ok); }
.tone-info .summary-icon { background: var(--info); }
.tone-warn .summary-icon { background: #a96f00; }
.tone-bad .summary-icon { background: var(--bad); }
.summary-meta, .pending { font-size: 0.86rem; color: var(--muted); }

.status-chip { display: inline-block; border-radius: 6px; padding: 1px 8px; font-size: 0.8rem; font-weight: 700; border: 1px solid transparent; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
.status-chip.tone-ok { background: var(--ok-bg); color: var(--ok); border-color: #a8d6bd; }
.status-chip.tone-info { background: var(--info-bg); color: var(--info); border-color: #a9c4ea; }
.status-chip.tone-warn { background: var(--warn-bg); color: var(--warn); border-color: #e7c670; }
.status-chip.tone-bad { background: var(--bad-bg); color: var(--bad); border-color: #e6aaa5; }
.status-chip.tone-neutral { background: #eef1f4; color: #3d4a57; border-color: var(--line); }

.result-card > h3 { margin-bottom: 6px; }
.pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.pair > div { background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.pair h4 { margin-bottom: 4px; }

dl.facts { display: grid; grid-template-columns: minmax(9rem, 16rem) minmax(0, 1fr); gap: 4px 14px; margin: 6px 0; font-size: 0.92rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

.finding-list { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 8px; }
.finding { border: 1px solid var(--line); border-left-width: 6px; border-radius: 8px; padding: 8px 12px; background: #ffffff; }
.finding.tone-bad { border-left-color: var(--bad); }
.finding.tone-warn { border-left-color: #c98a00; }
.finding.tone-neutral { border-left-color: #7b8794; }
.finding p { margin: 2px 0; }
.finding .btn { min-height: 32px; padding: 3px 10px; font-size: 0.85rem; margin-top: 4px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 18px; margin: 6px 0 8px; }
.toolbar .field { margin: 0; max-width: 24rem; }
.legend { font-size: 0.84rem; color: var(--muted); }

.table-scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; }
table { border-collapse: separate; border-spacing: 0; font-size: 0.86rem; }
table.grid, table.plain { width: 100%; }
th, td { border-bottom: 1px solid #e3e9ef; border-right: 1px solid #e3e9ef; padding: 5px 8px; text-align: left; vertical-align: top; }
thead th { position: sticky; top: 0; z-index: 2; background: var(--navy-100); color: var(--navy-900); white-space: nowrap; }
th.sticky-col { position: sticky; left: 0; z-index: 1; background: #f4f7fa; white-space: nowrap; font-weight: 600; }
thead th.sticky-col { z-index: 3; background: var(--navy-100); }
.th-sub { display: block; font-weight: 400; font-size: 0.76rem; color: var(--muted); }
table.grid td { white-space: nowrap; }
td.c-off { color: #8a97a5; text-align: center; }
td.c-unknown { background: var(--warn-bg); text-align: center; font-weight: 700; color: var(--warn); }
td.c-work { background: #eaf6f1; }
td.c-noroom { background: var(--bad-bg); color: #5f1c18; }
tr.is-weekend th.sticky-col { background: #e9eff6; }
tr.is-context td, tr.is-context th.sticky-col { background: #eef0f2; color: #5b6772; }
td.mark-bad { box-shadow: inset 0 0 0 3px var(--bad); }
td.mark-gap { box-shadow: inset 0 0 0 3px #c98a00; }
th.mark-bad { box-shadow: inset 5px 0 0 var(--bad); }
th.mark-gap { box-shadow: inset 5px 0 0 #c98a00; }

.report-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #ffffff; margin-top: 8px; }

details.card > summary { cursor: pointer; font-weight: 600; color: var(--navy-900); }
.feedback textarea { width: 100%; min-height: 4.5rem; resize: vertical; }
.feedback .feedback-preview { min-height: 12rem; font: 0.84rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: #f7f9fb; }

.history-list { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 6px; }
.history-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 0.9rem; }
.history-list li.is-shown { border-color: var(--teal-700); }
.history-list .btn { min-height: 32px; padding: 3px 12px; font-size: 0.85rem; margin-left: auto; }

.gate { max-width: 32rem; margin: 24px auto; }

@media (max-width: 820px) {
  .masthead-inner { grid-template-columns: minmax(0, 1fr); }
  .mode-cards { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 480px) {
  body { font-size: 15px; }
  main { padding: 12px; }
  .masthead-inner { padding: 16px 12px; }
  .footer { padding: 8px 12px 24px; }
  h1 { font-size: 1.45rem; }
  .card, .form-section { padding: 12px; }
  .weekday-set legend { float: none; width: 100%; padding-top: 0; }
  dl.facts { grid-template-columns: minmax(0, 1fr); }
  dl.facts dt { margin-top: 6px; }
  .btn-large { width: 100%; }
  .summary-title { font-size: 1.12rem; }
  .history-list .btn { margin-left: 0; }
}

@media (pointer: coarse) {
  .btn, input[type="text"], input[type="password"], select { min-height: 44px; }
  .check { min-height: 44px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .choice-card { transition: background-color 0.12s ease, border-color 0.12s ease; }
}
