/* The page is always the dark waiting room, so there is one palette: the 1-bit scene's paper and ink. */
:root {
  color-scheme: dark;
  --room: #231f1b; /* the 1-bit ink, so page and scene match */
  --ink: #231f1b;
  --paper: #ebe5d6;
  --muted: #a59b8b;
  --line: #4f483f;
  --focus: #d9b26a;
  --font: "Courier Prime", "Courier New", Courier, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--room); color: var(--paper); font-family: var(--font); overflow: hidden; }
#stage { position: fixed; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }


.hint {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  margin: 0; max-width: calc(100% - 32px); text-align: center; font-size: .9rem; color: var(--paper);
  background: var(--room); padding: .3rem .7rem;
  pointer-events: none; transition: opacity .6s;
}
.hint.gone { opacity: 0; }

/* Keyboard route to the robin and the pad: hidden until a button gets focus. */
.skip { position: fixed; top: 16px; left: 50%; transform: translate(-50%, -300%); display: flex; gap: 8px; }
.skip:focus-within { transform: translate(-50%, 0); }
.skip button { font: inherit; background: var(--paper); color: var(--ink); border: 2px solid var(--ink); padding: .4rem .8rem; cursor: pointer; }
.skip button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

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

/* The secretary's dialog: a paper card with a hard shadow. */
dialog {
  padding: 0; border: 2px solid var(--ink); background: var(--paper); color: var(--ink);
  width: min(34rem, calc(100% - 32px)); margin: auto auto calc(env(safe-area-inset-bottom, 0px) + 24px);
  box-shadow: 6px 6px 0 var(--ink); font-family: var(--font);
}
dialog::backdrop { background: rgba(10, 9, 8, .35); }
.dlg-inner { padding: 1rem 1.1rem .9rem; }
.dlg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; border-bottom: 1px dashed var(--ink); padding-bottom: .4rem; }
.dlg-head h2 { margin: 0; font-size: 1rem; letter-spacing: .1em; text-transform: uppercase; }
#dlg-time { font-size: .85rem; }
#dlg-text { margin: .8rem 0 1rem; font-size: 1.05rem; line-height: 1.45; min-height: 3em; cursor: default; }
dialog form { display: flex; justify-content: flex-end; margin: 0; }
dialog button {
  font: inherit; font-weight: 700; background: var(--ink); color: var(--paper); border: 0; padding: .4rem .9rem; cursor: pointer;
}
dialog button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* The note: a square post-it with a hard shadow, slightly askew. */
dialog.note { width: min(24rem, calc(100% - 32px)); margin: auto; transform: rotate(-1deg); }
.note-inner { padding: 1rem 1.1rem .9rem; display: flex; flex-direction: column; gap: .6rem; }
.note h2 { margin: 0; font-size: 1rem; letter-spacing: .1em; text-transform: uppercase; border-bottom: 1px dashed var(--ink); padding-bottom: .4rem; }
.note textarea, .note input {
  font: inherit; font-size: 1.05rem; line-height: 1.45; color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; padding: .2rem 0; width: 100%;
}
.note textarea {
  resize: none; min-height: 10rem; border: 0;
  /* ruled lines, one per text line */
  background-image: linear-gradient(transparent calc(1.45em - 1px), rgba(35, 31, 27, .35) 1px);
  background-size: 100% 1.45em; background-attachment: local;
}
.note textarea:focus-visible, .note input:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.note ::placeholder { color: rgba(35, 31, 27, .55); }
.note-row { display: flex; align-items: baseline; gap: .6rem; }
.note-row label { font-size: .9rem; }
.note-meta { display: flex; justify-content: space-between; margin: 0; font-size: .8rem; opacity: .75; }
#note-status { margin: 0; min-height: 1.3em; font-size: .9rem; font-weight: 700; }
#note-status:empty { min-height: 0; }
.note-actions { display: flex; justify-content: flex-end; gap: .6rem; }
dialog button.secondary { background: transparent; color: var(--ink); border: 2px solid var(--ink); padding: calc(.4rem - 2px) calc(.9rem - 2px); }
dialog button:disabled { opacity: .45; cursor: not-allowed; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Debug toolbar (?debug) */
.bar {
  position: fixed; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center;
  background: rgba(40, 36, 31, .92); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; font-size: .85rem;
}
.bar[hidden] { display: none; }
.group { display: flex; align-items: center; gap: 6px; }
.group > span { font-size: .8rem; color: var(--muted); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.seg button { font: inherit; background: transparent; color: var(--paper); border: 0; padding: .3rem .55rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
#debug-readout { flex-basis: 100%; margin: 0; text-align: center; color: var(--muted); }
#debug:not([hidden]) ~ .hint, body:has(#debug:not([hidden])) .hint { display: none; }

#err { position: fixed; inset: auto 20px 50% 20px; text-align: center; }
#err[hidden] { display: none; }

@media (max-width: 640px) {
  .bar { width: auto; left: 12px; right: 12px; transform: none; }
}
