/* ==========================================================================
   GuestQR design system
   --------------------------------------------------------------------------
   Hand-written, no build step. The cPanel host needs no Node.js and no asset
   pipeline, and a style change is a file edit rather than a rebuild someone
   can forget to commit.

   Three themes, in this order of precedence:

     html[data-theme="light"]  explicit choice
     html[data-theme="dark"]   explicit choice
     (nothing)                 follow the operating system

   Every colour is a token defined on :root first, so a value can never exist
   only inside a media query - that is the classic unreadable-page bug.

   Owned by the UX Designer role.
   ========================================================================== */

/* ------------------------------------------------------- light (default) -- */

:root {
  color-scheme: light;

  /* Neutrals carry a slight blue-steel bias so they read as chosen rather
     than as the browser default grey. */
  --bg:            #eef1f4;
  --surface:       #ffffff;
  --surface-sunk:  #f5f7f9;
  --surface-hover: #f0f4f7;

  --ink:    #14202b;
  --ink-2:  #45566a;
  --ink-3:  #6f8298;

  --line:        #dbe3ea;
  --line-strong: #bccbd8;

  --accent:       #0d6d75;
  --accent-hover: #0a555c;
  --accent-soft:  #dcecee;
  --accent-line:  #8fc4c8;
  --on-accent:    #ffffff;

  /* Semantic, kept separate from the accent. These three carry the meaning of
     the gate and are never used decoratively. */
  --allow:      #14794a;
  --allow-soft: #dcf0e5;
  --deny:       #b3281d;
  --deny-soft:  #fadedb;
  --hold:       #92590a;
  --hold-soft:  #fbecd2;

  --radius:    8px;
  --radius-sm: 5px;

  --shadow-sm: 0 1px 2px rgb(20 32 43 / 5%);
  --shadow:    0 1px 3px rgb(20 32 43 / 7%), 0 8px 20px -12px rgb(20 32 43 / 18%);
  --shadow-lg: 0 2px 6px rgb(20 32 43 / 8%), 0 20px 44px -24px rgb(20 32 43 / 30%);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

/* ------------------------------------------------------------------ dark -- */

/* Shared by both dark paths so the palette is written once. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg:            #0c1319;
    --surface:       #151f28;
    --surface-sunk:  #111a22;
    --surface-hover: #1b2733;

    --ink:    #e3eaf1;
    --ink-2:  #a7b7c6;
    --ink-3:  #7b8b9c;

    --line:        #263440;
    --line-strong: #3a4c5c;

    --accent:       #4cc0c7;
    --accent-hover: #6fd6dc;
    --accent-soft:  #103139;
    --accent-line:  #1f5860;
    --on-accent:    #07131a;

    --allow:      #47bd82;
    --allow-soft: #10301f;
    --deny:       #e88a80;
    --deny-soft:  #33181a;
    --hold:       #dba53f;
    --hold-soft:  #302511;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
    --shadow:    0 1px 3px rgb(0 0 0 / 50%), 0 10px 26px -14px rgb(0 0 0 / 80%);
    --shadow-lg: 0 2px 8px rgb(0 0 0 / 55%), 0 24px 50px -28px rgb(0 0 0 / 95%);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:            #0c1319;
  --surface:       #151f28;
  --surface-sunk:  #111a22;
  --surface-hover: #1b2733;

  --ink:    #e3eaf1;
  --ink-2:  #a7b7c6;
  --ink-3:  #7b8b9c;

  --line:        #263440;
  --line-strong: #3a4c5c;

  --accent:       #4cc0c7;
  --accent-hover: #6fd6dc;
  --accent-soft:  #103139;
  --accent-line:  #1f5860;
  --on-accent:    #07131a;

  --allow:      #47bd82;
  --allow-soft: #10301f;
  --deny:       #e88a80;
  --deny-soft:  #33181a;
  --hold:       #dba53f;
  --hold-soft:  #302511;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow:    0 1px 3px rgb(0 0 0 / 50%), 0 10px 26px -14px rgb(0 0 0 / 80%);
  --shadow-lg: 0 2px 8px rgb(0 0 0 / 55%), 0 24px 50px -28px rgb(0 0 0 / 95%);
}

/* ------------------------------------------------------------------ base -- */

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

/* The hidden attribute means hidden.

   The browser's own rule is display:none with no specificity worth the name, so
   any component that sets a display of its own quietly defeats it - and
   `element.hidden = true` in a script stops doing anything at all. That has
   been found twice in this build, both times as something the reader could
   still see and interact with, and the answer both times was another scoped
   patch. This is that patch, once, for everything.

   It is !important so a component cannot win by accident, and a deliberate
   override still can: an id or class beside the attribute outranks it, which is
   how the no-JavaScript fallbacks on the registration forms reveal a section
   that script would otherwise have opened. */
[hidden] { display: none !important; }

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

/* Every image in this build is already given an explicit width, so this changes
   nothing today. It is here so the next one added cannot push a phone sideways
   before anybody notices. */
img, svg, video, canvas { max-width: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* A word longer than the screen breaks rather than pushing the page sideways.
     This application shows several: a pass URL, a reference, an audit payload
     encoded as JSON with no spaces in it at all. Without this a single one of
     them gives every page on a phone a horizontal scrollbar. */
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.25;
  text-wrap: balance;
  font-weight: 650;
  letter-spacing: -0.011em;
}
h1 { font-size: 1.6rem; letter-spacing: -0.021em; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p  { margin: 0; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

/* "anywhere" rather than "break-word", because these hold the strings that have
   no break opportunity in them - a token, a reference, a URL, a JSON blob - and
   unlike break-word it also lets the element report a narrow minimum width, so a
   table column holding one can actually shrink. */
code, kbd, .mono {
  font-family: var(--mono);
  font-size: 0.86em;
  overflow-wrap: anywhere;
}

code {
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink);
}

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

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

/* ----------------------------------------------------------------- shell -- */

.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  margin-bottom: 8px;
}

.brand .mark {
  width: 30px; height: 30px; flex: none;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem;
  letter-spacing: -0.03em;
}

.brand strong { font-size: 1rem; letter-spacing: -0.02em; display: block; line-height: 1.15; }
.brand span {
  font-size: 0.64rem; text-transform: uppercase; letter-spacing: 0.13em;
  color: var(--ink-3);
}

.nav-group {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 650;
  color: var(--ink-3);
  padding: 16px 20px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 1px 10px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.nav-link:hover { background: var(--surface-hover); color: var(--ink); }

.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .who {
  font-size: 0.85rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar .who a { color: var(--ink-2); text-decoration: none; }
.topbar .who a:hover { color: var(--accent); }

.content { padding: 28px; flex: 1; max-width: 1280px; width: 100%; }

/* A page whose content is one column.
   The profile and account screens are a single 560px column, but .page-head
   spreads to the full content width - so "Back to dashboard" ended up eleven
   hundred pixels from the heading it belongs to, marooned in empty space. This
   keeps the heading, the button and the cards on the same measure. */
.page-narrow { max-width: 560px; }

/* ------------------------------------------------------- account menu -- */

/* A <details>, not a scripted dropdown: Sign out is in here, and it must open
   without JavaScript. The marker is removed and a chevron drawn in the summary
   instead, because the default triangle cannot be positioned. */
.account { position: relative; }

.account > summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px 5px 11px;
  font-size: 0.85rem;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}
.account > summary::-webkit-details-marker { display: none; }
.account > summary::marker { content: ''; }
.account > summary:hover { color: var(--ink); border-color: var(--line-strong); }
.account[open] > summary { color: var(--ink); border-color: var(--accent-line); }
.account[open] > summary svg { transform: rotate(180deg); }
.account > summary svg { transition: transform 0.12s ease; flex: none; }

.account-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: min(250px, calc(100vw - 24px));
  overflow: hidden;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.account-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.account-head strong { font-size: 0.9rem; }
/* The address is the one thing in here that can be long enough to widen the
   panel, and a menu that changes width per person reads as a glitch. */
.account-head .small { overflow: hidden; text-overflow: ellipsis; }

.topbar .who .account-item {
  display: block;
  width: 100%;
  padding: 9px 14px;
  font: inherit;
  font-size: 0.87rem;
  text-align: left;
  color: var(--ink-2);
  background: none;
  border: 0;
  text-decoration: none;
  cursor: pointer;
}
.topbar .who .account-item:hover { color: var(--ink); background: var(--surface-hover); }

.account-foot { margin: 0; border-top: 1px solid var(--line); }
.topbar .who .account-signout { color: var(--deny); }
.topbar .who .account-signout:hover { color: var(--deny); background: var(--deny-soft); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
}
.page-head .sub { color: var(--ink-3); font-size: 0.92rem; margin-top: 4px; }

/* ------------------------------------------------------------- colours -- */

/* A swatch you can click, beside the hex value it sets. Neither is the master:
   changing one updates the other. */
.colour-field { display: flex; align-items: center; gap: 8px; }
.colour-field input[type="color"] {
  width: 42px; height: 38px; flex: none;
  padding: 2px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.colour-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.colour-field input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 3px; }
.colour-field input[type="text"] { font-family: var(--mono); text-transform: uppercase; }

/* --------------------------------------------------------- live preview -- */

/* While a new preview is being produced the old code stays on screen, dimmed:
   blanking it would leave the administrator with nothing to compare against. */
#previewImg.is-stale { opacity: 0.45; transition: opacity 0.15s ease; }

.preview-state {
  display: block;
  margin-top: 8px;
  font-size: 0.79rem;
  line-height: 1.45;
  color: var(--ink-3);
  min-height: 1.2em;
}
.preview-state.is-busy { color: var(--ink-3); }
.preview-state.is-ok { color: var(--allow); }
.preview-state.is-warn { color: var(--hold); }
.preview-state.is-bad { color: var(--deny); font-weight: 600; }

/* -------------------------------------------------------- notifications -- */

.notif { position: relative; }

.notif-button {
  position: relative;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}
.notif-button:hover { color: var(--ink); background: var(--surface-hover); }
.notif-button[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-line); }

.notif-count {
  position: absolute; top: -5px; right: -7px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--deny);
  color: #ffffff;
  font-size: 0.66rem; font-weight: 700;
  line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}

.notif-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30;
  width: min(360px, calc(100vw - 24px));
  overflow: hidden;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.notif-head, .notif-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
}
.notif-head { border-bottom: 1px solid var(--line); color: var(--ink); }
.notif-head form { margin: 0; }
.notif-foot { border-top: 1px solid var(--line); background: var(--surface-sunk); font-size: 0.82rem; }
.topbar .who .notif-foot a { color: var(--accent); }

.notif-link {
  padding: 0;
  font: inherit; font-size: 0.8rem;
  color: var(--accent);
  background: none; border: 0;
  cursor: pointer;
}

.notif-list { max-height: 360px; overflow-y: auto; }
.topbar .who .notif-item,
.notif-item {
  display: flex; gap: 10px;
  padding: 11px 14px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.notif-item:last-child { border-bottom: 0; }
.topbar .who .notif-item:hover { color: var(--ink); background: var(--surface-hover); }
.notif-item strong { display: block; font-size: 0.86rem; font-weight: 600; line-height: 1.35; }
.notif-item small { display: block; margin-top: 2px; font-size: 0.8rem; color: var(--ink-2); }
.notif-item time { display: block; margin-top: 3px; font-size: 0.74rem; color: var(--ink-3); }
.notif-item.is-unread { background: var(--accent-soft); }
.notif-empty { margin: 0; padding: 22px 14px; text-align: center; font-size: 0.84rem; color: var(--ink-3); }

.notif-dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: transparent; }
.is-unread > .notif-dot { background: var(--accent); }

.notif-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.notif-row:last-child { border-bottom: 0; }
.notif-row.is-unread { background: var(--accent-soft); }
.notif-row .notif-dot { align-self: flex-start; }
.notif-row-text { flex: 1; min-width: 0; }
.notif-row-text strong { font-size: 0.92rem; }
.notif-row-body { margin-top: 2px; font-size: 0.85rem; color: var(--ink-2); }
.notif-row-meta { margin-top: 4px; font-size: 0.78rem; color: var(--ink-3); }

.queue-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.queue-figure strong { font-size: 1.6rem; line-height: 1; color: var(--ink); }
.queue-figure span { width: 100%; font-size: 0.78rem; color: var(--ink-3); }
.queue-figure.is-stuck strong { color: var(--deny); }

/* --------------------------------------------------------- theme toggle -- */

.theme-toggle {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.theme-toggle button {
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 4px 9px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-3);
  line-height: 1.4;
}

.theme-toggle button:hover { color: var(--ink); }

.theme-toggle button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* ----------------------------------------------------------------- cards -- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card + .card { margin-top: 18px; }

.card-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 20px; }
.card-body > * + * { margin-top: 15px; }

.grid {
  display: grid;
  gap: 16px;
  /* min() rather than a bare 220px. A track declared minmax(220px, 1fr) has a
     hard floor of 220px: in a container narrower than that the track keeps its
     size and the container overflows, because grid does not shrink a minimum.
     min(220px, 100%) lets the floor fall away exactly when it would not fit. */
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}

/* A form beside a panel: the QR preview, the test-message sender, the captured
   photo, the list being added to.

   Each of these was written inline as two tracks with real minimums - 300px
   beside 250px, 280px beside 300px. That is a declared floor of 550 to 580
   pixels, which no phone has, and grid honours a floor by overflowing rather
   than by shrinking. Every one of these four screens ran off the side.

   Here both tracks may shrink to nothing and the aside keeps a preferred width
   rather than a required one, so the pair fits whatever it is given - and below
   the breakpoint they stack, which is what they should have done all along. */
.split {
  display: grid;
  gap: 20px;
  align-items: start;
  grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
}

/* The same, where the narrow half comes first in the source. */
.split-aside-first {
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
}

@media (max-width: 880px) {
  .split,
  .split-aside-first { grid-template-columns: minmax(0, 1fr); }
}

/* Stat tiles. Used only where the number itself is the point of the screen. */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.stat .label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-weight: 650;
  color: var(--ink-3);
}
.stat .value {
  font-size: 2.1rem;
  font-weight: 680;
  line-height: 1.05;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat .value.is-quiet { color: var(--ink-3); font-weight: 500; }
.stat .foot { font-size: 0.8rem; color: var(--ink-3); margin-top: 5px; }

/* ---------------------------------------------------------------- tables -- */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th {
  text-align: left;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--ink-3);
  font-weight: 650;
  padding: 10px 16px;
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

/* The server check: a verdict, a name, and a sentence that has to stay
   readable. Widths here rather than inline on every row, so the mobile rule
   below can drop them. */
table.data.checks .checks-status { width: 6rem; }
table.data.checks .checks-name { width: 14rem; }

@media (max-width: 620px) {
  /* Three columns of prose do not fit a phone, and scrolling sideways to read
     a diagnostic is worse than reading it stacked. */
  table.data.checks,
  table.data.checks tbody,
  table.data.checks tr,
  table.data.checks td { display: block; width: auto; }

  table.data.checks tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  table.data.checks tr:last-child { border-bottom: 0; }
  table.data.checks td { border-bottom: 0; padding: 0 16px 4px; }
  table.data.checks .checks-status { padding-bottom: 8px; }
}

/* A label/value table: the first cell of each row names the field. Sized in
   characters rather than pixels so it scales with the text, and allowed to
   shrink on a narrow screen - a fixed 190px label left barely a third of a
   phone for the value beside it. */
table.data th.rowhead { width: 12rem; }

@media (max-width: 620px) {
  table.data th.rowhead {
    width: 7.5rem;
    white-space: normal;
  }
}

table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { text-align: right; white-space: nowrap; }
table.data .actions .btn + .btn,
table.data .actions form { margin-left: 4px; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty strong { display: block; color: var(--ink-2); margin-bottom: 5px; font-size: 0.98rem; }

/* ----------------------------------------------------------------- forms -- */

/* A fieldset will not shrink below its widest child unless told to: browsers
   give it min-inline-size: min-content, and unlike other elements that cannot
   be overridden by width alone. Left as it comes, one group of fields drags the
   whole page wider than the screen. */
fieldset { min-width: 0; }

.field { display: block; margin-bottom: 16px; }
.field > label,
.field-label {
  display: block;
  font-size: 0.83rem;
  font-weight: 620;
  margin-bottom: 5px;
}
.field .hint { font-size: 0.79rem; color: var(--ink-3); margin-top: 5px; line-height: 1.5; }

input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="tel"], input[type="number"],
input[type="date"], input[type="datetime-local"], input[type="file"],
select, textarea {
  width: 100%;
  /* A grid or flex child refuses by default to shrink below its content's
     minimum width. For a date picker, a file input, or a select holding a long
     option - the timezone list runs to "Australia / Lord Howe (UTC+11:00)" -
     that minimum is wider than a phone, and the field pushes the form open
     instead of fitting inside it. */
  min-width: 0;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-sunk);
  color: var(--ink-3);
}

input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 0.75; }

textarea { min-height: 88px; resize: vertical; }

input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

.field-row {
  display: grid;
  gap: 0 18px;
  /* Same trap as .grid: a bare 210px floor overflows a container narrower than
     one field rather than collapsing to a single column. */
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
}

/* A crew's rows, and a crew's passes. Rows after the first are separated by a
   rule so thirty people do not read as one long form. */
.crew-row + .crew-row { border-top: 1px dashed var(--line); padding-top: 10px; }

.crew-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  margin-bottom: 16px;
}

.crew-grid .card { margin-bottom: 0; }

/* The language switch on the visitor pages. Plain links, so it works before
   any script has run and on a connection that never finishes loading one. */
.reg-top-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
  font-size: 0.78rem;
}

.lang-toggle a, .lang-toggle span {
  padding: 3px 8px;
  border-radius: 3px;
  text-decoration: none;
  color: var(--ink-2);
  white-space: nowrap;
}

.lang-toggle a:hover { background: var(--surface-hover); color: var(--ink); }
.lang-toggle [aria-current="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }

/* The signature pad. A ruled line rather than a box, because a box invites
   people to write inside it and a line is what a signature sits on. */
.sign { margin-top: 12px; }

.sign-pad {
  display: block;
  width: 100%;
  max-width: 420px;
  height: 120px;
  margin: 6px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--line-strong);
  border-radius: var(--radius-sm);
  touch-action: none;
  cursor: crosshair;
}

/* Quiet: starting again is a correction, not one of the two things this form
   is asking somebody to do. */
.sign-clear { font-size: 0.8rem; }

/* The host's decision page. Approve is the large obvious action; rejecting is
   folded away behind a summary, because it is the rarer answer and it asks a
   question before it can be given. */
.reg-decide { margin-top: 18px; }
.reg-decide .btn { width: 100%; padding: 12px; font-size: 1rem; }

.reg-decide-reject { margin-top: 14px; }
.reg-decide-reject > summary {
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink-2);
  padding: 6px 0;
}
.reg-decide-reject > summary:hover { color: var(--ink); }
.reg-decide-reject form { margin-top: 10px; }

/* The original text beside the box you translate it into. Sunk and slightly
   quieter, so it reads as reference rather than as something to edit. */
.doc-original {
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 340px;
  overflow-y: auto;
  color: var(--ink-2);
  font-size: 0.92rem;
}

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.check input { margin-top: 3px; flex: none; }
.check label { font-size: 0.9rem; }

.field-error { color: var(--deny); font-size: 0.81rem; margin-top: 5px; font-weight: 500; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--deny); }

/* --------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.87rem;
  font-weight: 620;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}

.btn:hover { background: var(--surface-hover); color: var(--ink); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}

.btn-danger { border-color: var(--deny); color: var(--deny); background: var(--surface); }
.btn-danger:hover { background: var(--deny-soft); color: var(--deny); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }

/* ----------------------------------------------------------------- pills -- */

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 620;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  background: var(--surface-sunk);
  white-space: nowrap;
  line-height: 1.55;
}

.pill-allow { background: var(--allow-soft); color: var(--allow); border-color: transparent; }
.pill-deny  { background: var(--deny-soft);  color: var(--deny);  border-color: transparent; }
.pill-hold  { background: var(--hold-soft);  color: var(--hold);  border-color: transparent; }
.pill-quiet { color: var(--ink-3); }

/* ---------------------------------------------------------------- alerts -- */

.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  background: var(--surface);
  font-size: 0.9rem;
  margin-bottom: 18px;
}
.alert strong { display: block; margin-bottom: 3px; font-weight: 650; }
.alert-success { border-left-color: var(--allow); background: var(--allow-soft); border-color: transparent; }
.alert-error   { border-left-color: var(--deny);  background: var(--deny-soft);  border-color: transparent; }
.alert-warn    { border-left-color: var(--hold);  background: var(--hold-soft);  border-color: transparent; }
.alert-info    { border-left-color: var(--accent); background: var(--accent-soft); border-color: transparent; }

.alert ul { margin: 7px 0 0; padding-left: 18px; }
.alert li { margin-bottom: 2px; }

/* ------------------------------------------------------------- auth page -- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 500px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 30px 28px;
}

.auth-card h1 { font-size: 1.4rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--ink-3); font-size: 0.89rem; margin-bottom: 22px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 10px; }
.auth-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.79rem;
  color: var(--ink-3);
  line-height: 1.55;
}

/* Split sign-in. A centred two-panel card, deliberately not a full-screen
   takeover. The brand panel keeps the same deep teal in both themes: it is a
   branded surface, not a themed one, and white text on it passes in either. */

.auth { align-content: center; gap: 4px; }

.auth-split {
  width: 100%;
  max-width: 880px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 36px 34px;
  color: #ffffff;
  background:
    radial-gradient(420px 260px at 110% -10%, rgb(255 255 255 / 16%), transparent 70%),
    linear-gradient(155deg, #10808a 0%, #0b5a61 55%, #083d42 100%);
}

.auth-brand-top {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
}

.auth-mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: #ffffff;
  color: #0b5a61;
  font-weight: 700; font-size: 0.85rem;
  letter-spacing: -0.03em;
}

.auth-brand-body { position: relative; margin-top: auto; }

.auth-brand h2 {
  margin: 0 0 10px;
  color: #ffffff;
  font-size: 1.45rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.auth-brand p { margin: 0; color: rgb(255 255 255 / 82%); font-size: 0.92rem; line-height: 1.55; }

.auth-points { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 9px; }
.auth-points li { position: relative; padding-left: 22px; font-size: 0.87rem; color: rgb(255 255 255 / 90%); }
.auth-points li::before {
  content: "";
  position: absolute; left: 0; top: 0.38em;
  width: 10px; height: 10px;
  border-radius: 3px;
  border: 2px solid rgb(255 255 255 / 75%);
}

.auth-brand .auth-brand-foot {
  position: relative;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgb(255 255 255 / 60%);
}

/* Echoes of a QR code's finder squares. Decoration only. */
.auth-art span {
  position: absolute;
  width: 120px; height: 120px;
  border-radius: 18px;
  border: 14px solid rgb(255 255 255 / 7%);
}
.auth-art span:nth-child(1) { right: -30px; top: 70px; }
.auth-art span:nth-child(2) { right: 110px; bottom: -40px; }
.auth-art span:nth-child(3) { right: -50px; bottom: -40px; }

.auth-form {
  padding: 40px 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-form h1 { font-size: 1.45rem; margin-bottom: 4px; }
.auth-form .sub { color: var(--ink-3); font-size: 0.89rem; margin-bottom: 22px; }
.auth-form .btn { width: 100%; justify-content: center; padding: 10px; }

/* The theme switch sits in the form panel's top corner, out of the way of the
   fields. Its buttons are not the full-width sign-in button. */
.auth-form { position: relative; }
.auth-theme { position: absolute; top: 16px; right: 16px; }
.auth-form .auth-theme .btn,
.auth-form .theme-toggle button { width: auto; padding: 4px 9px; }

@media (max-width: 760px) {
  .auth-split { grid-template-columns: 1fr; max-width: 430px; }
  .auth-brand { padding: 22px 24px; gap: 14px; }
  .auth-brand h2 { font-size: 1.1rem; }
  .auth-points, .auth-art, .auth-brand .auth-brand-foot { display: none; }
  .auth-form { padding: 28px 24px; }
}

/* -------------------------------------------------- visitor registration -- */

/* Public pages for people outside the company. Built only from the theme
   tokens, so light, dark and auto all work without separate rules. */

.reg {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 420px at 15% -120px, var(--accent-soft), transparent 70%),
    var(--bg);
}

.reg-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.reg-top-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.reg-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.reg-brand:hover { color: var(--ink); }
.reg-mark {
  width: 32px; height: 32px; flex: none;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700; font-size: 0.8rem;
  letter-spacing: -0.03em;
}
.reg-brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.reg-brand-text strong { font-size: 0.95rem; }
.reg-brand-text span { font-size: 0.72rem; color: var(--ink-3); }

.reg-top-actions { display: flex; align-items: center; gap: 12px; }
.reg-captcha {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 8px;
}
.reg-captcha img {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5f7f9;
}

.reg-wrap {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 16px 48px;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.reg-aside { position: sticky; top: 88px; }
.reg-eyebrow {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}
.reg-aside h1, .reg-done h1 { margin: 0 0 10px; font-size: 1.9rem; letter-spacing: -0.025em; }
.reg-lede { margin: 0 0 26px; color: var(--ink-2); font-size: 0.97rem; line-height: 1.6; }

.reg-steps { list-style: none; margin: 0; padding: 0; }
.reg-steps li { position: relative; display: flex; gap: 12px; padding-bottom: 18px; }
.reg-steps li:last-child { padding-bottom: 0; }
.reg-steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13px; top: 30px; bottom: 2px;
  width: 2px;
  background: var(--line);
}
.reg-steps li > span {
  position: relative; z-index: 1;
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.78rem; font-weight: 700;
  background: var(--surface);
  color: var(--accent);
  border: 2px solid var(--accent-line);
}
.reg-steps strong { display: block; margin-top: 3px; font-size: 0.9rem; color: var(--ink); }
.reg-steps p { margin: 2px 0 0; font-size: 0.82rem; color: var(--ink-3); line-height: 1.45; }
.reg-steps li.is-done > span { background: var(--allow); border-color: var(--allow); color: #ffffff; }

.reg-main { min-width: 0; }
.reg-errors { margin-bottom: 18px; }
.reg-errors a { color: inherit; }
.reg-errors:focus { outline: 2px solid var(--deny); outline-offset: 2px; }

.reg-section .card-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1rem; }
.reg-num {
  width: 24px; height: 24px; flex: none;
  border-radius: 7px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem; font-weight: 700;
}
.reg-opt { margin-left: 6px; font-size: 0.74rem; font-weight: 500; color: var(--ink-3); }
.reg-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.reg-count { font-size: 0.74rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Several blocks here set their own display, which would otherwise override
   the hidden attribute the script toggles - an empty host card on load. */

/* A label inside the counter row is no longer a direct child of .field, so it
   is given the field label style explicitly. */
.reg-label-row label { display: block; font-size: 0.83rem; font-weight: 620; margin-bottom: 5px; }

/* Spacing comes from each field's own bottom margin. The card body's sibling
   margin added a second gap after every two-column row. */
.reg .card-body > * + * { margin-top: 0; }

.reg-host { position: relative; }
.reg-host-list {
  position: absolute; z-index: 15;
  left: 0; right: 0;
  margin-top: 4px;
  padding: 4px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.reg-host-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.reg-host-option:hover,
.reg-host-option[aria-selected="true"] { background: var(--accent-soft); }
.reg-host-option strong, .reg-chosen strong { display: block; font-size: 0.9rem; color: var(--ink); }
.reg-host-option small, .reg-chosen small { display: block; font-size: 0.78rem; color: var(--ink-3); }
.reg-host-empty { padding: 12px; font-size: 0.85rem; color: var(--ink-3); }
.reg-status:empty { display: none; }

.reg-avatar {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.78rem; font-weight: 700;
}
.reg-chosen {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
}
.reg-chosen > div { flex: 1; min-width: 0; }

.reg-duration { margin: -4px 0 16px; font-size: 0.8rem; color: var(--ink-2); }
.reg-duration:empty { display: none; }
.reg-duration.is-warn { color: var(--deny); font-weight: 600; }

.reg-doc {
  overflow: hidden;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease;
}
.reg-doc + .reg-doc { margin-top: 12px; }
.reg-doc:has(input:checked) { border-color: var(--allow); }
.reg-doc h3 { margin: 0; padding: 12px 14px; font-size: 0.93rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.reg-doc .body { max-height: 220px; overflow-y: auto; padding: 12px 14px; font-size: 0.88rem; color: var(--ink-2); line-height: 1.6; }
.reg-doc .body > :first-child { margin-top: 0; }
.reg-doc .body p { margin: 0 0 0.6em; }
.reg-doc .body h2 { margin: 0.8em 0 0.3em; font-size: 1rem; color: var(--ink); }
.reg-doc .body h3, .reg-doc .body h4 { margin: 0.7em 0 0.3em; padding: 0; font-size: 0.93rem; color: var(--ink); background: none; border: 0; }
.reg-doc .body ul, .reg-doc .body ol { margin: 0 0 0.6em; padding-left: 1.3em; }
.reg-doc .body blockquote { margin: 0 0 0.6em; padding-left: 10px; border-left: 3px solid var(--accent-line); }
.reg-doc .body hr { border: 0; border-top: 1px solid var(--line); margin: 0.8em 0; }
.reg-doc .accept { padding: 12px 14px; background: var(--surface); border-top: 1px solid var(--line); }
.reg-doc .check { margin: 0; }

.reg-submit { margin-top: 20px; }
.reg-submit .btn-primary { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; }
.reg-privacy { margin: 12px 0 0; text-align: center; font-size: 0.8rem; color: var(--ink-3); }

/* The honeypot. Off-screen rather than display:none, which some bots skip. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.reg-done-wrap { flex: 1; display: grid; place-items: center; padding: 40px 16px; }
.reg-done { width: 100%; max-width: 560px; padding: 34px 32px; }
.reg-done-icon {
  width: 52px; height: 52px;
  margin-bottom: 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--allow-soft);
  color: var(--allow);
}
.reg-done .reg-lede { margin-bottom: 18px; }
.reg-done h2 { margin: 26px 0 14px; font-size: 1rem; }
.reg-notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--hold-soft);
  border-left: 3px solid var(--hold);
  border-radius: var(--radius-sm);
}
.reg-notice strong { color: var(--hold); }
.reg-ref {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 12px 14px;
  background: var(--surface-sunk);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.reg-ref span { width: 100%; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-3); }
.reg-ref strong { flex: 1; font-size: 1.1rem; letter-spacing: 0.04em; color: var(--ink); }
.reg-ref-hint { margin: 6px 0 0; font-size: 0.8rem; color: var(--ink-3); }
.reg-foot { margin: 22px 0 18px; padding-top: 14px; font-size: 0.82rem; line-height: 1.55; color: var(--ink-3); border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  .reg-wrap { grid-template-columns: 1fr; gap: 22px; padding-top: 24px; }
  .reg-aside { position: static; }
  .reg-aside h1 { font-size: 1.55rem; }
  .reg-aside .reg-lede { margin-bottom: 18px; }
  .reg-aside .reg-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .reg-aside .reg-steps li { flex-direction: column; align-items: center; gap: 6px; padding: 0; text-align: center; }
  .reg-aside .reg-steps li::after { display: none; }
  .reg-aside .reg-steps strong { margin: 0; font-size: 0.72rem; line-height: 1.3; }
  .reg-aside .reg-steps p { display: none; }
}

@media (max-width: 480px) {
  .reg-brand-text span { display: none; }
  .reg-done { padding: 24px 18px; }
  .reg-done h1 { font-size: 1.55rem; }

  /* Four steps across a phone leaves each about seventy pixels, which turns
     "Get your QR pass" into three stacked fragments. Two by two reads. */
  .reg-aside .reg-steps { grid-template-columns: repeat(2, 1fr); gap: 14px 10px; }
}

/* ------------------------------------------------------------- rich text -- */

.wysiwyg {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.wysiwyg:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--line);
}
.wysiwyg-toolbar button,
.wysiwyg-toolbar select {
  width: auto;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  font: inherit;
  font-size: 0.82rem;
  line-height: 1;
  color: var(--ink-2);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  box-shadow: none;
  cursor: pointer;
}
.wysiwyg-toolbar select { background: var(--surface); border-color: var(--line); padding-right: 24px; }
.wysiwyg-toolbar button:hover:not(:disabled) { background: var(--surface-hover); color: var(--ink); }
.wysiwyg-toolbar button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.wysiwyg-toolbar :disabled { opacity: 0.4; cursor: default; }
.wysiwyg-toolbar .sep { width: 1px; height: 18px; margin: 0 4px; background: var(--line); }
.wysiwyg-toolbar .spacer { flex: 1; }

.wysiwyg-area {
  min-height: 320px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 14px 16px;
  outline: none;
  color: var(--ink);
  line-height: 1.6;
}
.wysiwyg-area > :first-child { margin-top: 0; }
.wysiwyg-area p { margin: 0 0 0.75em; }
.wysiwyg-area h2 { font-size: 1.2rem; margin: 1em 0 0.4em; }
.wysiwyg-area h3 { font-size: 1.02rem; margin: 0.9em 0 0.35em; }
.wysiwyg-area ul, .wysiwyg-area ol { margin: 0 0 0.75em; padding-left: 1.5em; }
.wysiwyg-area blockquote { margin: 0 0 0.75em; padding: 2px 0 2px 12px; border-left: 3px solid var(--accent-line); color: var(--ink-2); }
.wysiwyg-area a { color: var(--accent); }
.wysiwyg-area hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }

textarea.wysiwyg-source {
  display: block;
  width: 100%;
  min-height: 320px;
  padding: 14px 16px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--mono);
  font-size: 0.84rem;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
}

/* ------------------------------------------------------------ pagination -- */

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-sunk);
  font-size: 0.85rem;
  color: var(--ink-3);
}
.pager nav { display: flex; gap: 4px; flex-wrap: wrap; }
.pager a, .pager span {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink-2);
  background: var(--surface);
}
.pager a:hover { background: var(--surface-hover); }
.pager [aria-current="page"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
}
.pager .disabled { opacity: 0.4; background: none; border-color: transparent; }

/* --------------------------------------------------------------- utility -- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.toolbar form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.toolbar .field { margin-bottom: 0; }
.toolbar input[type="search"], .toolbar select { min-width: 180px; }

.muted   { color: var(--ink-3); }
.small   { font-size: 0.83rem; }
.nowrap  { white-space: nowrap; }
.stack > * + * { margin-top: 12px; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- mobile -- */

/* The menu button exists only on a narrow screen. Hidden here rather than
   shown there, so that a browser which never matches the media query - or a
   print stylesheet - never renders a control that does nothing. */
.nav-toggle { display: none; }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
    /* It was sticky and full-height for a column beside the page. Left that
       way in one column it becomes a 100vh scroll region wrapped around the
       navigation, which on a phone traps the scroll. */
    overflow-y: visible;
  }
  .brand { margin-bottom: 4px; }
  .nav-group { padding-top: 12px; }
  .content { padding: 20px 16px; }
  .topbar { padding: 12px 16px; position: static; }
  .page-head { align-items: flex-start; }

  /* The collapsed menu, but only where the script that reopens it has run.
     Without JavaScript the navigation stays exactly as it was - long, but
     reachable, which is the right way round for the failure. */
  .js .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
    padding: 7px 11px;
    font: inherit;
    font-size: 0.85rem;
    color: var(--ink-2);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    cursor: pointer;
  }
  .js .nav-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
  .js .nav-toggle[aria-expanded="true"] {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
  }

  .js .sidebar { padding-bottom: 0; }
  .js .nav-items { display: none; padding-bottom: 12px; }
  .js .nav-items.is-open { display: block; }
}

/* The header of a signed-in page, on a phone.

   Everything in it was laid out in a single non-wrapping row: the bell, a
   three-segment theme switch, the user's name, a link and a button. That is
   comfortably wider than a phone, and because the row could not wrap it simply
   ran off the side of the screen and took the page's horizontal scroll with
   it. */
@media (max-width: 620px) {
  .topbar { gap: 8px 12px; }
  .topbar .who {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 12px;
    /* Without this the row is allowed to size itself from its contents and
       overflows the header rather than wrapping inside it. */
    min-width: 0;
  }
  .topbar > div:first-child { min-width: 0; }
  .topbar > div:first-child strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 460px) {
  /* The name is the menu's own label now, so it stays - but it need not carry
     a surname on a screen this narrow. */
  .account-name {
    display: inline-block;
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .theme-toggle button { padding: 4px 8px; font-size: 0.78rem; }
  .content { padding: 16px 12px; }
  .page-head h1 { font-size: 1.35rem; }
  .card-head { flex-wrap: wrap; gap: 6px 12px; }
  .btn-row { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar, .topbar, .toolbar, .btn-row, .actions, .pager { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { box-shadow: none; border-color: #999; }
  body { background: #fff; }
}
