:root {
  color-scheme: light;
  --ink: #1c1916;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #d5cbbd;
  --accent: #9d3416;
  --pass: #0c5a42;
  --fail: #8d1d1d;
  --handoff: #8a4b08;
  --focus: #1c1916;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 1.05rem;
  line-height: 1.5;
}

body:focus { outline: none; }

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

.skip {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  transform: translateY(-150%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.75rem;
  z-index: 2;
}

.skip:focus { transform: none; }

.site-header, main, .site-footer {
  width: min(46rem, calc(100% - 2rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  padding: 1.25rem 0 1rem;
  border-bottom: 2px solid var(--ink);
}

.wordmark {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 1.4rem;
  color: inherit;
  text-decoration: none;
}

.site-tag { margin: 0; color: var(--accent); font-weight: 650; }

.site-nav { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-left: auto; }

.site-nav a { color: inherit; }

main { padding: 1.5rem 0 2.5rem; }

h1, h2, h3 {
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 650;
  line-height: 1.2;
}

h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 0.75rem; }

h2 { font-size: 1.35rem; margin: 1.75rem 0 0.5rem; }

p { margin: 0.6rem 0; }

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

.modes, .level-links { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0; margin: 0.75rem 0 0; list-style: none; }

.modes a, .level-links a, button, .button {
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  border: 2px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.modes a, .level-links a, a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button {
  display: inline-block;
  text-align: center;
  vertical-align: middle;
}

.modes a[aria-current="page"], button.primary, .button.primary {
  background: var(--ink);
  color: var(--paper);
}

button.handoff {
  background: transparent;
  border-color: var(--handoff);
  color: var(--handoff);
}

label { display: block; font-weight: 650; margin: 0.9rem 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input:not([type]) {
  display: block;
  width: 100%;
  max-width: 28rem;
  margin-top: 0.35rem;
  min-height: 44px;
  padding: 0.4rem 0.55rem;
  border: 2px solid var(--ink);
  background: white;
  color: inherit;
  font: inherit;
}

input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--ink);
  vertical-align: middle;
}

.callout, .rules, .fix, .outcome {
  background: var(--card);
  border: 2px solid var(--line);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
}

.callout { border-left: 6px solid var(--accent); }

.outcome[data-outcome="PASS"] { border-color: var(--pass); }
.outcome[data-outcome="FAIL"] { border-color: var(--fail); }
.outcome[data-outcome="HANDOFF"] { border-color: var(--handoff); }

.outcome strong { font-size: 1.15rem; }
.outcome[data-outcome="PASS"] strong { color: var(--pass); }
.outcome[data-outcome="FAIL"] strong { color: var(--fail); }
.outcome[data-outcome="HANDOFF"] strong { color: var(--handoff); }

.tiles {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 0;
}

.tiles.cols-2 { --cols: 2; max-width: 22rem; }
.tiles.cols-4 { --cols: 4; }

#status-widget,
#account-panel {
  border: 2px solid var(--line);
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
}

#drop-zone {
  border: 2px dashed var(--line);
  padding: 1rem;
  margin: 0.75rem 0;
}

#filename-chip:not(:empty) {
  font-weight: 650;
  margin: 0.75rem 0 0;
}

#recorder-status,
#fake-sent {
  font-weight: 650;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0;
  padding: 0.5rem;
  border: 2px solid var(--line);
  background: white;
  font-weight: 650;
}

.tile img { width: 100%; height: auto; background: #f7f3ea; }

.slider-puzzle { max-width: 400px; }
.slider-puzzle img { width: 100%; height: auto; display: block; }
.slider-puzzle input[type="range"] { width: 100%; margin: 0.4rem 0 0; accent-color: var(--ink); }

figure { margin: 0.5rem 0 0; }
figure img { max-width: 100%; height: auto; border: 2px solid var(--line); background: white; }

#hold-button { min-width: 14rem; font-weight: 700; }
#hold-progress {
  width: min(100%, 22rem);
  height: 1.25rem;
  background: var(--line);
  margin: 0.75rem 0;
}
#hold-fill { width: 0; height: 100%; background: var(--accent); }

.token, code, pre {
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 0.92rem;
}

#next-step:focus,
#form-error:focus {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

#completion-token, #run-token, #run-seed {
  display: block;
  overflow-wrap: anywhere;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem;
}

pre {
  overflow-x: auto;
  max-width: 100%;
  background: var(--ink);
  color: var(--paper);
  padding: 0.85rem;
}

.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.85rem; }

.level-list { list-style: none; padding: 0; }
.level-list li { border-top: 1px solid var(--line); padding: 0.85rem 0; }
.level-list h2 { margin: 0; font-size: 1.2rem; }

.site-footer {
  border-top: 2px solid var(--ink);
  padding: 1rem 0 2rem;
  font-size: 0.95rem;
}

.crosslinks { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.crosslinks-title { margin: 0 0 0.35rem; font-weight: 650; }
.crosslinks ul { margin: 0; padding-left: 1.25rem; }
.crosslinks a { color: var(--ink); text-decoration: underline; text-underline-offset: 0.15em; }
.crosslinks a:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.form-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.5rem; }

.password-row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
.password-row label { flex: 1 1 16rem; }

.fake-toast {
  background: #e7f6ee;
  border: 2px solid var(--pass);
  padding: 0.75rem 1rem;
}

.memory-note {
  border: 2px dashed var(--line);
  padding: 0.85rem 1rem;
  margin: 1rem 0;
}

fieldset { border: 2px solid var(--line); margin: 1rem 0; padding: 0.75rem 1rem; }
legend { font-weight: 650; padding: 0 0.3rem; }

[role="alert"] {
  border: 2px solid var(--fail);
  background: #fff6f4;
  padding: 0.75rem 1rem;
}

@media (max-width: 640px) {
  .site-header, main, .site-footer { width: min(46rem, calc(100% - 1.25rem)); }
  .site-nav { margin-left: 0; }
  h1 { font-size: 1.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Pages after P12 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal { background: #fff; color: #111; max-width: 28rem; width: 100%; padding: 1.25rem; border-radius: 8px; position: relative; }
.modal-close { position: absolute; top: 0.5rem; right: 0.5rem; font-size: 1.25rem; }
.link-button { background: none; border: none; text-decoration: underline; padding: 0; color: inherit; cursor: pointer; }
.hint { display: block; font-size: 0.9rem; opacity: 0.85; }
.combo { position: relative; }
.combo [role="listbox"] { list-style: none; margin: 0.25rem 0; padding: 0; border: 1px solid #777; max-width: 28rem; }
.combo [role="option"] { padding: 0.4rem 0.6rem; cursor: pointer; }
.combo [role="option"].active { background: #1d4ed8; color: #fff; }
.calendar { border-collapse: collapse; }
.calendar td, .calendar th { padding: 0.15rem; text-align: center; }
.calendar button.day { min-width: 2.4rem; min-height: 2.4rem; }
.calendar button.day[aria-pressed="true"] { outline: 3px solid #1d4ed8; }
.calendar-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
form.inline { display: inline; }
.sortable-item { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; padding: 0.3rem 0; }
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.kanban-col { border: 1px dashed #777; min-height: 6rem; padding: 0.5rem; }
.kanban-card { border: 1px solid #333; background: #f5f5f5; color: #111; padding: 0.5rem; cursor: grab; }
.drop-zone { border: 2px dashed #777; padding: 1rem; }
#posting-frame { width: 100%; min-height: 8rem; border: 1px solid #777; }
button.big { font-size: 1.25rem; padding: 0.8rem 1.6rem; }
