/* TVRC Tour Manager — staff portal
   One shell for every role: rail → list → detail. Light paper by default,
   a night palette behind data-theme="dark". Every colour, size, space and
   radius below comes from the tokens in :root; DESIGN.md documents them.
   The accent family ships green; a person's own colour arrives as a second
   stylesheet (/accent/<hex>.css) that redefines only that family. */

:root {
  color-scheme: light;
  --paper: #f2f4f1;
  --surface: #ffffff;
  --surface-soft: #f7f8f6;
  --surface-sunk: #eff2f0;
  --surface-hover: #f4f7f4;
  --surface-disabled: #e9ece9;
  --ink: #172824;
  --ink-muted: #56645f;
  --ink-faint: #66736e;
  --line: #d8e0db;
  --line-strong: #becbc3;
  --line-hover: #94a69c;
  --accent: #145f4c;
  --accent-hover: #0d4b3b;
  --accent-deep: #102a22;
  --accent-soft: #e6f2ec;
  --accent-line: #c3dfcf;
  --amber: #704800;
  --amber-soft: #fbf1d8;
  --amber-line: #ead7a7;
  --amber-ink: #563700;
  --red: #9c302d;
  --red-soft: #fff0ed;
  --red-line: #f1c7c1;
  --red-ink: #762420;
  --focus: #087eaf;
  --white: #fff;
  /* Text on the accent and on the danger ground, and the toast, invert with the theme. */
  --on-accent: #ffffff;
  --toast-bg: #172824;
  --toast-fg: #ffffff;
  --scrim: rgb(12 25 22 / 50%);
  --checker-dark: #d8dee8;
  --checker-light: #eef1f6;
  /* A third party's mark, not part of the palette: WhatsApp's own green, so the share button is recognisable. */
  --whatsapp: #128c4a;
  --radius: 10px;
  --radius-lg: 12px;
  --radius-control: 7px;
  --radius-panel: 14px;
  --radius-dialog: 18px;
  --radius-pill: 999px;
  --control-height: 42px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 20px;
  --space-5: 32px;
  --space-6: 52px;
  --ease: cubic-bezier(0.2, 0, 0.2, 1);
  --dur: 160ms;
  --shadow-raised: 0 10px 28px rgb(25 46 38 / 8%);
  --shadow-sunk: 0 1px 3px rgb(23 40 36 / 12%);
  --shadow-overlay: 0 28px 90px rgb(16 33 28 / 24%);
  --text-xs: 0.8rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.125rem;
  --text-lg: 1.5rem;
  --text-xl: 1.9rem;
  --text-2xl: 2.2rem;
  --rail: 212px;
  --list: 372px;
  --tabbar: 64px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--paper);
  color: var(--ink);
  accent-color: var(--accent);
  caret-color: var(--accent);
  scrollbar-color: var(--line-strong) var(--paper);
  scrollbar-width: thin;
}

/* Night: the same roles on a neutral dark grey, so only the accent carries
   colour whichever one a person chose. The accent lifts so it still reads on
   a dark ground, and text on the accent turns dark to keep its contrast. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121315;
  --surface: #1a1c1f;
  --surface-soft: #1f2225;
  --surface-sunk: #151719;
  --surface-hover: #24272b;
  --surface-disabled: #282b2f;
  --ink: #e8eaed;
  --ink-muted: #a9adb3;
  --ink-faint: #82878e;
  --line: #2b2f33;
  --line-strong: #3a3f45;
  --line-hover: #575e66;
  --accent: #5fc39d;
  --accent-hover: #7dd3b3;
  --accent-deep: #d6ece2;
  --accent-soft: #17302a;
  --accent-line: #245944;
  --amber: #e6b560;
  --amber-soft: #2d2413;
  --amber-line: #4f3f1b;
  --amber-ink: #f1d190;
  --red: #f0918a;
  --red-soft: #332020;
  --red-line: #56302d;
  --red-ink: #f6b6b0;
  --focus: #63b8e0;
  --on-accent: #0d1f19;
  --toast-bg: #e8eaed;
  --toast-fg: #121315;
  --scrim: rgb(0 0 0 / 60%);
  --checker-dark: #2c3034;
  --checker-light: #1f2225;
  --whatsapp: #4fd07f;
  --shadow-raised: 0 10px 28px rgb(0 0 0 / 35%);
  --shadow-sunk: 0 1px 3px rgb(0 0 0 / 40%);
  --shadow-overlay: 0 28px 90px rgb(0 0 0 / 60%);
}

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

html {
  height: 100%;
  min-width: 320px;
}

body {
  height: 100%;
  min-width: 320px;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
}

/* `hidden` means hidden, whatever display a class set. This used to lose to a
   flex rule and left a "Discard that upload" button on every fresh dialog. */
[hidden] {
  display: none !important;
}

h1, h2, h3, p, dl, dd, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }

::selection {
  background: var(--accent-line);
  color: var(--accent-deep);
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--accent-hover);
  text-decoration-thickness: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button,
input,
select,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

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

code {
  padding: 1px 6px;
  border-radius: var(--radius-control);
  background: var(--surface-sunk);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

svg.i {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.num { font-variant-numeric: tabular-nums; }

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

.skip-link {
  position: fixed;
  z-index: 50;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  transform: translateY(-160%);
  border-radius: var(--radius-control);
  background: var(--toast-bg);
  color: var(--toast-fg);
  font-weight: 650;
}

.skip-link:focus,
.skip-link:hover {
  transform: translateY(0);
  color: var(--toast-fg);
}

/* ---------------------------------------------------------------- type */
.muted {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.lede {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* --------------------------------------------------------------- brand */
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 750;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark .mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--on-accent);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0;
}

/* --------------------------------------------------------------- shell */
.app {
  display: grid;
  grid-template-columns: var(--rail) var(--list) minmax(0, 1fr);
  grid-template-rows: 100%;
  height: 100%;
}

.app.one-column {
  grid-template-columns: var(--rail) minmax(0, 1fr);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 0;
  padding: var(--space-4) var(--space-3);
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.rail .brand-mark {
  padding: 2px var(--space-2) var(--space-4);
}

.rail nav {
  display: grid;
  gap: 2px;
}

.rail nav a,
.rail .me .link-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.rail nav a:hover,
.rail .me .link-button:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.rail nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.rail .count {
  min-width: 22px;
  margin-left: auto;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
  text-align: center;
}

.rail .count.hot {
  background: var(--amber-soft);
  color: var(--amber);
}

.rail .me {
  display: grid;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.rail .who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px var(--space-2);
}

.rail .avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-sunk);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 700;
}

.rail .who b {
  display: block;
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.2;
}

.rail .who small {
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.rail .inline-form {
  display: block;
}

/* The appearance switch: two options, the chosen one raised. */
.theme {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-sunk);
}

.theme button {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
  cursor: pointer;
}

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

.theme svg.i { width: 15px; height: 15px; }

/* The accent: nine swatches and a well for any colour, the chosen one ringed. */
.appearance { display: grid; gap: 6px; }

.accents {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  padding: 0 2px;
}

.accent-swatch {
  position: relative;
  display: block;
  aspect-ratio: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--swatch, var(--accent));
  /* impeccable-disable-next-line design-system-color -- a hairline over any colour, so a light swatch keeps an edge */
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 12%);
  cursor: pointer;
  transition: transform var(--dur) var(--ease);
}

.accent-swatch:hover { transform: scale(1.12); }

.accent-swatch[aria-pressed="true"],
.accent-swatch.is-on {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink);
}

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

.accent-swatch[data-accent="#145f4c"] { --swatch: #145f4c; }
.accent-swatch[data-accent="#0f6b73"] { --swatch: #0f6b73; }
.accent-swatch[data-accent="#0b5ea8"] { --swatch: #0b5ea8; }
.accent-swatch[data-accent="#3f3fa8"] { --swatch: #3f3fa8; }
.accent-swatch[data-accent="#6d2f8a"] { --swatch: #6d2f8a; }
.accent-swatch[data-accent="#a8264f"] { --swatch: #a8264f; }
.accent-swatch[data-accent="#b43e12"] { --swatch: #b43e12; }
.accent-swatch[data-accent="#8a5a00"] { --swatch: #8a5a00; }
.accent-swatch[data-accent="#3f4d5a"] { --swatch: #3f4d5a; }

/* The well: a hue wheel over the colour input, which keeps its own picker. */
.swatch-any {
  /* impeccable-disable-next-line design-system-color -- the wheel is made of the accent presets themselves, in hue order */
  background: conic-gradient(from 90deg, #a8264f, #b43e12, #8a5a00, #145f4c, #0f6b73, #0b5ea8, #3f3fa8, #6d2f8a, #a8264f);
  overflow: hidden;
}

.swatch-any input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.swatch-any:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }

/* The palette button stands in for the swatches where the rail is narrow. */
.rail .me .me-appearance { display: none; }

.appearance-dialog {
  width: min(100% - 32px, 380px);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-dialog);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-overlay);
}

.appearance-dialog::backdrop { background: var(--scrim); }
.appearance-dialog .lede { margin: 0 0 var(--space-3); }
.appearance-dialog .accents { grid-template-columns: repeat(5, 1fr); gap: var(--space-2); padding: var(--space-2) 0 0; }
.appearance-dialog .accent-swatch { max-width: 44px; }
.appearance-dialog .dialog-heading { margin-bottom: var(--space-2); }

/* ----------------------------------------------------------- list pane */
.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.pane-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.pane-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.pane-title h1 {
  font-size: var(--text-lg);
  font-weight: 680;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.pane-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.search {
  position: relative;
  margin: 0;
}

.search input {
  width: 100%;
  min-height: 38px;
  padding: 0 var(--space-3) 0 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.search svg.i {
  position: absolute;
  top: 10px;
  left: 11px;
  color: var(--ink-faint);
  pointer-events: none;
}

/* Every filter in view at once: a chip that has to be scrolled to is a filter nobody finds. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 1px;
}

.chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.chip:hover {
  border-color: var(--line-hover);
  color: var(--ink);
}

.chip[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.chip .n {
  margin-left: 5px;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* An active detail filter: the chip is the way to remove it. */
.chip.chip-active {
  border-color: var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber-ink);
}

.chip.chip-active .x {
  margin-left: 6px;
  font-size: var(--text-base);
  line-height: 1;
}

/* Filter by details: folded under the chips, a plain form when open. */
.filters > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.filters > summary::-webkit-details-marker { display: none; }

.filters > summary:hover { color: var(--ink); }

.filters > summary .n {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--amber-soft);
  color: var(--amber-ink);
  font-size: var(--text-xs);
}

.filter-form {
  margin-top: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-3);
}

.filter-field {
  display: grid;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 650;
  color: var(--ink-muted);
}

.filter-field select,
.filter-field input {
  width: 100%;
  min-height: 36px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
}

.filter-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  margin-top: var(--space-3);
}

.pane-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.pane-meta label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.pane-meta select {
  width: auto;
  min-height: 26px;
  padding: 0 18px 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 600;
}

.rows {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* A row is its link plus a star beside it; the star stays out of the link so a press never opens the tour. */
.row-wrap {
  position: relative;
}

.row-star {
  position: absolute;
  top: 8px;
  right: var(--space-2);
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

/* A row without a star (the admin sections) keeps its right edge, and its line of text may wrap. */
.row-plain { padding-right: var(--space-4); }
.row-plain .sub { white-space: normal; }

.row-star svg.i { width: 16px; height: 16px; }
.row-star:hover { background: var(--surface-sunk); color: var(--ink); }
.row-star.is-on { color: var(--amber); }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px var(--space-3);
  width: 100%;
  padding: 12px 44px 12px var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  transition: background-color var(--dur) var(--ease);
}

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

.row[aria-current="true"] {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.row .name {
  grid-column: 1;
  grid-row: 1;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .sub {
  display: flex;
  grid-column: 1;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}

/* The access words are the one part of the line that may be long; they trail off rather than clip mid-letter. */
.row .sub > span:not(.status-pill):not(.flags):not(.sep) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .sub.is-pressing {
  color: var(--amber);
  font-weight: 650;
}

.row .sub .sep { opacity: 0.5; }

.row .side {
  display: flex;
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  justify-content: flex-end;
}

.row .side small {
  color: var(--ink-faint);
  font-size: var(--text-xs);
}

.row .flags {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 4px;
  margin-left: 2px;
}

.flag {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--space-1);
  background: var(--surface-sunk);
  color: var(--ink-muted);
}

.flag svg.i { width: 12px; height: 12px; }

.flag.lock {
  background: var(--amber-soft);
  color: var(--amber);
}

/* The public copy differs from the saved folder: the one flag that means something is wrong. */
.flag.drift {
  background: var(--red-soft);
  color: var(--red);
}

/* A starred tour: the person's own shortlist, so it reads warm rather than as a state. */
.flag.star {
  background: var(--amber-soft);
  color: var(--amber);
}

.star-form { margin-right: var(--space-1); }

.star-button {
  width: 32px;
  height: 32px;
  margin-left: -6px;
}

.star-button svg.i { width: 18px; height: 18px; }

.star-button[aria-pressed="true"] { color: var(--amber); }

.star-button[aria-pressed="true"]:hover { color: var(--amber-ink); }

/* --------------------------------------------------------- detail pane */
.detail {
  min-height: 0;
  overflow-y: auto;
  background: var(--paper);
}

.detail-inner {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) 96px;
}

.detail-inner.narrow {
  width: min(100%, 720px);
}

.crumb {
  display: none;
}

/* Title and actions share a row while the title keeps room to read; when it would
   not, the actions drop under it rather than squeezing the name into a column. */
.head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  align-items: flex-start;
  margin-bottom: var(--space-4);
}

.head > :first-child {
  flex: 1 1 320px;
  min-width: 0;
}

.head h1 {
  font-size: var(--text-2xl);
  font-weight: 680;
  line-height: 1.12;
  letter-spacing: -0.035em;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.head .status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px var(--space-3);
  margin-top: 10px;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.head .lede {
  margin-top: 8px;
}

.head .actions {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-left: auto;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  overflow: hidden;
  margin: 0 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* Each cell rules its own right and bottom edge; the last column's and row's
   rules slip under the frame, so an odd count leaves no grey gap behind. */
.facts > div {
  margin: 0 -1px -1px 0;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.facts dt {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
}

.facts dd {
  margin-top: 2px;
  font-size: var(--text-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Details inside a card: the same cells, without the card-in-card border. */
.facts.facts-plain {
  margin-bottom: var(--space-3);
  border: 0;
  border-radius: 0;
  background: transparent;
  gap: 0 var(--space-4);
}

.facts.facts-plain > div {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
}

/* Several choices: a grid of tick boxes that reads as one question. */
.choice-set {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.choice-set legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: var(--text-sm);
  font-weight: 650;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px var(--space-3);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: var(--text-sm);
  font-weight: 500;
}

/* A field's key is an identifier: it never wraps mid-word. */
.tour-table td small code { white-space: nowrap; }

/* The share card preview: the card itself, then the text a chat would show under it. */
.share-card-preview {
  margin: 0 0 var(--space-4);
  overflow: hidden;
  max-width: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

.share-card-preview img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  background: var(--accent);
}

.share-card-preview figcaption {
  display: grid;
  gap: 2px;
  padding: 10px 14px 12px;
  font-size: var(--text-sm);
}

.share-card-preview figcaption span { color: var(--ink-muted); }

.share-card-preview figcaption small {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.row-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.import-report ul {
  margin: var(--space-2) 0 0;
  padding-left: 18px;
}

.tabs {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--line-strong);
  scrollbar-width: none;
}

.tabs [role="tab"] {
  position: relative;
  padding: 10px 2px 12px;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.tabs [role="tab"]:hover { color: var(--ink); }

.tabs [role="tab"][aria-selected="true"] {
  color: var(--accent);
}

.tabs [role="tab"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--accent);
}

.tabs .n {
  margin-left: 6px;
  color: var(--ink-faint);
  font-weight: 500;
}

.stack {
  display: grid;
  gap: var(--space-4);
}

.tabpanel + .tabpanel {
  margin-top: var(--space-4);
}

.card {
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-md);
  font-weight: 680;
  letter-spacing: -0.015em;
}

.card h2 + .lede {
  margin-top: 4px;
}

.card > .lede + *,
.card > p + *,
.card > h2 + :not(.lede):not(p) {
  margin-top: var(--space-3);
}

.card.quiet {
  background: var(--surface-soft);
}

.card.table-card {
  padding: var(--space-2) 0 0;
}

.card.table-card h2 {
  padding: var(--space-2) var(--space-4) var(--space-3);
}

.card.table-card > .muted {
  padding: var(--space-3) var(--space-4);
}

.card.danger-region {
  border-color: var(--red-line);
  background: var(--red-soft);
}

.card.danger-region h2,
.card.danger-region p {
  color: var(--red-ink);
}

.card.danger-region .danger-zone {
  margin-top: var(--space-3);
}

details.card > summary.card-summary {
  list-style: none;
  cursor: pointer;
}

details.card > summary.card-summary::-webkit-details-marker { display: none; }

details.card > summary.card-summary h2::after {
  content: "+";
  margin-left: auto;
  color: var(--ink-faint);
  font-weight: 500;
}

details.card[open] > summary.card-summary h2::after { content: "–"; }

details.card[open] > summary.card-summary { margin-bottom: var(--space-3); }

.detail-empty {
  padding-top: 18vh;
  border: 0;
  background: transparent;
}

/* ------------------------------------------------------ setting rows */
.setting-rows {
  margin-top: var(--space-3);
  border-top: 1px solid var(--line);
  container-type: inline-size;
}

/* In a narrow pane the action drops under its state rather than squeezing the words into a column. */
@container (max-width: 640px) {
  .setting-row { grid-template-columns: 120px minmax(0, 1fr); }
  .setting-row .setting-act { grid-column: 2; justify-self: start; }
}

.setting-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: var(--space-2) var(--space-4);
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row dt {
  padding-top: 3px;
  font-size: var(--text-sm);
  font-weight: 650;
}

.setting-state {
  font-size: var(--text-sm);
}

.setting-hint {
  margin-top: 2px;
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.setting-act {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-self: end;
  gap: var(--space-2);
}

.setting-act form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.setting-act input[type="datetime-local"] {
  width: auto;
  min-height: 36px;
  padding: 0 10px;
  font-size: var(--text-sm);
}

.tour-status {
  margin-top: var(--space-3);
  font-weight: 630;
}

.tour-status + .muted { margin-top: 4px; }

/* ------------------------------------------------------------ share */
.share-link {
  display: flex;
  gap: 8px;
  margin-top: var(--space-3);
}

.share-link input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  background: var(--surface-soft);
  font-size: var(--text-sm);
}

.share-ways {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.share-ways a,
.share-ways button {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.share-ways a:hover,
.share-ways button:hover {
  border-color: var(--line-hover);
  background: var(--surface-hover);
  color: var(--ink);
}

.share-ways svg.i { width: 22px; height: 22px; }

.share-ways .wa { color: var(--whatsapp); }

.share-dialog {
  width: min(100% - 32px, 520px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-dialog);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-overlay);
}

.share-dialog::backdrop { background: var(--scrim); }

.share-panel {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
}

.share-panel h2 {
  font-size: var(--text-lg);
  font-weight: 680;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------- thumb bar */
.thumb { display: none; }

/* ---------------------------------------------------------- buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-height);
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.button svg.i { width: 16px; height: 16px; }

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sunk);
}

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

.button-secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--line-hover);
  background: var(--surface-hover);
  color: var(--ink);
}

.button-danger {
  border-color: var(--red);
  background: var(--red);
  color: var(--on-accent);
  box-shadow: var(--shadow-sunk);
}

.button-danger:hover:not(:disabled) {
  border-color: var(--red-ink);
  background: var(--red-ink);
  color: var(--on-accent);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}

.button:disabled {
  border-color: var(--line);
  background: var(--surface-disabled);
  color: var(--ink-faint);
  box-shadow: none;
  cursor: not-allowed;
}

.button-small {
  min-height: 34px;
  padding: 0 11px;
  font-size: var(--text-xs);
}

/* Work in flight says so where the action was taken. */
.button[aria-busy="true"] {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.button[aria-busy="true"]::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentcolor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--on-accent);
  animation: button-working 700ms linear infinite;
}

.button-secondary[aria-busy="true"]::after { color: var(--ink); }

@keyframes button-working { to { transform: rotate(1turn); } }

.link-button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 0.18em;
  cursor: pointer;
}

.link-button:hover {
  color: var(--accent-hover);
  text-decoration-thickness: 2px;
}

.link-button:disabled {
  color: var(--ink-faint);
  text-decoration: none;
  cursor: not-allowed;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: var(--space-3);
}

.only-phone { display: none; }

/* -------------------------------------------------------------- forms */
label {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 640;
}

input,
select,
textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}

input::placeholder { color: var(--ink-faint); opacity: 1; }

input:hover, select:hover { border-color: var(--line-hover); }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

input:disabled,
select:disabled {
  background: var(--surface-disabled);
  color: var(--ink-faint);
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
}

input[type="range"] {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

input[type="file"] {
  padding: 8px;
  background: var(--surface-soft);
}

.form-grid {
  display: grid;
  gap: var(--space-3);
}

.form-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-3);
  align-items: start;
}

.form-2.cards { gap: var(--space-4); }

.field {
  display: grid;
  gap: 6px;
}

.field.narrow { max-width: 220px; }

.field-help {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  line-height: 1.5;
}

.field-label {
  font-size: var(--text-sm);
  font-weight: 640;
}

output[data-range-value] {
  margin-left: var(--space-2);
  color: var(--ink-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.replace-confirm {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
  line-height: 1.45;
}

.replace-confirm input { margin-top: 2px; }

/* Radio cards: a choice with consequences reads better than a checkbox. */
.choice {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice legend {
  margin-bottom: 2px;
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 640;
}

.choice label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 500;
  cursor: pointer;
}

.choice label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice input { margin-top: 3px; }

.choice b {
  display: block;
  font-size: var(--text-sm);
  font-weight: 650;
}

.choice small {
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.danger-zone {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--red-line);
  border-radius: var(--radius);
  background: var(--red-soft);
}

.danger-zone + .danger-zone { margin-top: var(--space-3); }

.danger-zone > summary {
  color: var(--red-ink);
  font-weight: 650;
  cursor: pointer;
}

.danger-zone p {
  margin-top: var(--space-2);
  color: var(--red-ink);
  font-size: var(--text-sm);
}

.danger-zone form { margin-top: var(--space-3); }

.card.danger-region .danger-zone {
  border-color: var(--red-line);
  background: var(--surface);
}

.disclosure { margin-top: var(--space-3); }

.disclosure > summary {
  color: var(--accent);
  font-weight: 650;
  cursor: pointer;
}

.disclosure > p, .disclosure > form { margin-top: var(--space-2); }

/* ------------------------------------------------------------ notices */
.notice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  align-items: start;
  margin: 0 0 var(--space-3);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: var(--text-sm);
  animation: notice-in 220ms var(--ease);
}

.notice > svg.i { margin-top: 2px; }

.notice > :not(svg) { grid-column: 2; }

.notice:not(:has(> svg.i)) > * { grid-column: 1 / -1; }

.notice p { margin: 0; }

.notice p + p, .notice strong + p { margin-top: 4px; }

.notice strong { font-weight: 680; }

.notice .form-actions { margin-top: var(--space-2); }

.notice-local {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.notice-success {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.notice-error {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red-ink);
}

.notice-warning {
  border-color: var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber-ink);
}

.notice a { color: inherit; }

@keyframes notice-in {
  from { opacity: 0; transform: translateY(-4px); }
}

.workspace-operation { display: block; }

.operation-phase,
.operation-reason {
  margin-top: 6px !important;
  font-size: var(--text-sm);
  font-weight: 600;
}

.operation-progress,
.meter {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-pill);
  appearance: none;
  background: var(--surface-sunk);
  color: var(--accent);
}

.operation-progress::-webkit-progress-bar,
.meter::-webkit-progress-bar { background: var(--surface-sunk); border-radius: var(--radius-pill); }

.operation-progress::-webkit-progress-value,
.meter::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-pill); transition: inline-size 240ms var(--ease); }

.operation-progress::-moz-progress-bar,
.meter::-moz-progress-bar { background: var(--accent); }

.meter { height: 8px; margin-top: 8px; }

.meter.warn { color: var(--amber); }
.meter.warn::-webkit-progress-value { background: var(--amber); }
.meter.warn::-moz-progress-bar { background: var(--amber); }

/* ------------------------------------------------------------- pills */
.status-pill,
.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
  line-height: 1.2;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

.status-pill.status-active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.status-pill.status-warning {
  border-color: var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.status-danger {
  border-color: var(--red-line);
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.status-busy::before {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.count-badge {
  padding: 0 7px;
  border-radius: var(--radius-pill);
}

/* -------------------------------------------------------- empty states */
.empty-state {
  padding: var(--space-6) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 6px;
  font-size: var(--text-md);
  font-weight: 680;
}

.empty-state p {
  max-width: 36ch;
  margin: 0 auto;
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.empty-state .empty-actions { margin-top: var(--space-3); }

.rows .empty-state {
  border: 0;
  border-radius: 0;
}

/* ------------------------------------------------------------- tables */
.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
}

td {
  font-size: var(--text-sm);
}

td small {
  display: block;
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.tour-table th:first-child,
.tour-table td:first-child { padding-left: var(--space-4); }

.tour-table th:last-child,
.tour-table td:last-child { padding-right: var(--space-4); }

.tour-table tbody tr:last-child td { border-bottom: 0; }

/* Numbers line up on their units, so a column can be read down rather than
   across. The heading sits over the digits it describes. */
.tour-table th.num,
.tour-table td.num { text-align: right; }

/* A heading is two words at most; it never wraps under its own column. */
.tour-table th { white-space: nowrap; }

.tour-table tbody tr:hover { background: var(--surface-hover); }

.tour-table.compact th, .tour-table.compact td { padding: 8px 12px; }

.tour-table td > form { margin: 0; }

.purge-form {
  display: grid;
  gap: 8px;
  justify-items: start;
}

/* The account panel opens as a full-width block under its button. */
.row-actions > summary {
  list-style: none;
}

.row-actions > summary::-webkit-details-marker { display: none; }

.row-actions[open] > summary { margin-bottom: var(--space-3); }

/* A row's controls, floated over the page in the browser's top layer; a click outside closes it. */
.popover-card {
  width: min(560px, calc(100vw - 32px));
  max-height: min(86vh, 760px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-dialog);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-overlay);
}

.popover-card::backdrop { background: var(--scrim); }
[popover]:not(:popover-open):not(dialog[open]) { display: none; }

.popover-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.popover-head h3 { margin: 0; font-size: var(--text-base); font-weight: 680; }

.popover-card .user-management-forms {
  margin: 0;
  padding: var(--space-4);
  border: 0;
  border-radius: 0;
  background: transparent;
}

.user-management-forms {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  margin: 0 0 var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.user-management-forms .button { width: auto; }

/* Deciding on a request: pick the role and approve in one movement, decline beside it. */
.request-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.request-actions .inline-form { gap: var(--space-2); align-items: center; }
.request-actions select { height: 34px; }

/* --------------------------------------------------------------- kpis */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}

.kpi {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.kpi small {
  display: block;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
}

.kpi b {
  font-size: var(--text-md);
  font-weight: 680;
}

.kpis + .muted { margin-top: var(--space-3); }

/* ---------------------------------------------------------- analytics */
/* The numbers pages: a period and an audience switch, then cards of charts.
   Charts are inline SVG; their colours come from the same tokens as the rest. */
.an-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}

.chip.on,
.chip[aria-current="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.chips.wrap { margin-bottom: var(--space-3); }

.kpi > span {
  display: block;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
}

.kpi .delta { font-weight: 700; }
.delta.up { color: var(--accent); }
.delta.down { color: var(--amber); }
.delta.flat { color: var(--ink-faint); }

.an-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: var(--space-3);
}

.an-grid > .card { min-width: 0; }
.an-grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }

.card h3 {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--ink-muted);
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .axis { stroke: var(--line-strong); stroke-width: 1; }
.chart .tick { fill: var(--ink-faint); font-size: 10px; font-weight: 600; }
.chart .bar-slot { fill: transparent; }
.chart .bar { fill: var(--accent); }
.chart .bar-presented { fill: var(--accent-deep); }
.chart g:hover .bar-slot { fill: var(--surface-sunk); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: var(--space-2) 0 0;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border-radius: 3px;
  vertical-align: -1px;
}

.swatch.bar { background: var(--accent); }
.swatch.bar-presented { background: var(--accent-deep); }

.hbars {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hbars li {
  display: grid;
  grid-template-columns: minmax(96px, 38%) 1fr auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.hbar-label {
  min-width: 0;
  overflow: hidden;
  font-size: var(--text-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hbar-label small {
  display: block;
  color: var(--ink-faint);
  font-size: var(--text-xs);
}

.hbar {
  display: block;
  width: 100%;
  height: 8px;
}

.hbar-track { fill: var(--surface-sunk); }
.hbar-fill { fill: var(--accent); }

.hbar-n {
  min-width: 52px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: right;
}

.hbar-n small {
  margin-left: 4px;
  color: var(--ink-faint);
  font-weight: 600;
}

.heatmap { max-width: 640px; }
.heat-0 { fill: var(--surface-sunk); }
.heat-1 { fill: var(--accent-line); }
.heat-2 { fill: color-mix(in oklab, var(--accent) 55%, var(--accent-line)); }
.heat-3 { fill: color-mix(in oklab, var(--accent) 80%, var(--accent-line)); }
.heat-4 { fill: var(--accent); }

.muted.fine {
  margin: var(--space-3) 0 0;
  font-size: var(--text-xs);
}

.visits td small {
  display: block;
  color: var(--ink-faint);
  font-size: var(--text-xs);
}

.tour-table tr.off td { color: var(--ink-faint); }

.mini-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mini-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 10px;
  font-size: var(--text-sm);
}

.mini-list li a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-list .num { font-weight: 700; font-variant-numeric: tabular-nums; }

/* One tap more time on a dated tour: a label and three buttons on one line. */
.extend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-top: var(--space-3);
}

.extend-label {
  margin-right: 2px;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 650;
}

.setting-act .extend-row { margin-top: var(--space-2); }

/* A row with several controls (the deadline: a date, its buttons, the extensions)
   puts them on their own line under the state, so the words keep the width. */
.setting-row.stacked .setting-act { grid-column: 2 / -1; justify-self: start; }
.setting-row.stacked .setting-act .extend-row { flex-basis: 100%; margin-top: 0; }
@container (max-width: 640px) {
  .setting-row.stacked .setting-act { grid-column: 2; }
}
@media (max-width: 960px) {
  .setting-row.stacked .setting-act { grid-column: 1 / -1; }
}

/* ------------------------------------------------------- delivery kit */
.delivery-pick { max-width: 360px; margin-bottom: var(--space-3); }

.delivery-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.delivery .qr {
  display: grid;
  gap: 6px;
  justify-items: center;
  margin: 0;
}

.delivery .qr img {
  display: block;
  width: 180px;
  height: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.delivery .qr figcaption {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 650;
}

.delivery .embed { min-width: 0; }

.delivery .embed label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--text-sm);
  font-weight: 650;
}

.delivery textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  color: var(--ink);
  font: 500 var(--text-xs) / 1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}

.delivery .embed .form-actions { margin-top: var(--space-2); }

/* ------------------------------------------------------------ aliases */
.alias-list {
  display: grid;
  gap: 8px;
  margin: 0 0 var(--space-3);
  padding: 0;
  list-style: none;
}

.alias-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px var(--space-3);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.alias-row > div { min-width: 0; }
/* The clean address sits first in the card, set apart from the demo names under it. */
.clean-link { display: grid; gap: var(--space-3); padding-bottom: var(--space-3); margin-bottom: var(--space-3); border-bottom: 1px solid var(--line); }
.clean-row { border-color: var(--accent-line); background: var(--accent-soft); }
.clean-row code { font-weight: 600; }
.alias-row code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alias-row small { display: block; color: var(--ink-muted); font-size: var(--text-xs); }

.alias-input {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
}

.alias-input .prefix,
.alias-input .suffix {
  padding: 0 8px;
  color: var(--ink-faint);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.alias-input .prefix { padding-right: 0; }
.alias-input input { flex: 1 1 120px; min-width: 0; border: 0; background: transparent; }
.alias-input input:focus { outline: none; }
.alias-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

@media (max-width: 720px) {
  .delivery-grid { grid-template-columns: 1fr; }
  .delivery .qr { justify-items: start; }
  .alias-input .prefix { display: none; }
}

/* ------------------------------------------------------- tracked links */
/* The client page: several tours ticked, one action for all of them. The bar
   sits above the table; buttons sleep until something is ticked. */
.bulk-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.bulk-all { margin: 0; font-weight: 650; }

/* The same controls without the dashed enclosure: this one is always
   available, so it does not announce itself as a place to drop something. */
.bulk-bar.plain {
  justify-content: flex-end;
  padding: 0 0 var(--space-3);
  border: 0;
  border-bottom: 1px solid var(--line);
  gap: var(--space-2) var(--space-3);
}

.bulk-bar.plain .count { margin-right: auto; color: var(--ink-muted); font-size: var(--text-sm); }

.bulk-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.bulk-label {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.bulk-danger { margin-top: var(--space-3); }

.pick-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.pick-name input { margin: 0; }

/* ----------------------------------------------------------- galleries */
/* The tour rows on a gallery page lead with the picture the page shows. */
.tile-thumb {
  flex: 0 0 auto;
  width: 96px;
  height: 60px;
  border-radius: var(--radius-control);
  object-fit: cover;
  background: var(--surface-sunk);
}

.pick-name > span > a { text-decoration: none; }
.pick-name > span > small { display: block; color: var(--ink-muted); font-size: var(--text-xs); }

.gallery-tours td.pos { width: 2.5em; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.gallery-tours td.row-actions { white-space: nowrap; text-align: right; }
.gallery-tours td.row-actions .inline-form { display: inline-flex; gap: 2px; vertical-align: middle; }
.gallery-tours td.row-actions .link-button { margin-left: var(--space-2); }

/* The picker: a search, then live tours as tick rows; typing narrows them. */
.add-tours { margin-top: var(--space-3); }
.add-tours > form { margin-top: var(--space-2); }
.pick-search { margin-bottom: var(--space-2); }

.pick-list {
  display: grid;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.pick-list > .muted { margin: 0; padding: var(--space-3); }

.pick-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.pick-row:last-child { border-bottom: 0; }
.pick-row:hover { background: var(--surface-hover); }
.pick-row:has(input:checked) { background: var(--accent-soft); }
.pick-row[hidden] { display: none; }
.pick-row input { margin: 0; flex: 0 0 auto; }
.pick-row .pick-name { min-width: 0; }
.pick-row .pick-name > span { min-width: 0; }
.pick-row .pick-name b { display: block; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.add-tours .form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.galleries-table td small { display: block; color: var(--ink-muted); font-size: var(--text-xs); }

/* Whose work this is, under the line that says what it is doing. */
.operation-by {
  margin: 2px 0 0;
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

/* A backup that cannot be restored yet says by how much, and where to fix it. */
.no-room { display: block; }
.no-room small { display: block; color: var(--ink-faint); }
.tour-table td .no-room + .link-button { margin-top: 4px; }

/* A switch in a table cell: nothing above or below it, so the rows stay the
   height of one line and the column can be read straight down. */
.tour-table td .switch { vertical-align: middle; }

/* A control that names an action keeps its words on one line; the column
   gives way before the label does. */
.tour-table td .link-button,
.tour-table td .switch { white-space: nowrap; }

/* Turning a page on or off is an act of its own, set apart from the form. */
.page-toggle {
  display: grid;
  gap: var(--space-2);
  justify-items: start;
  margin-top: var(--space-3);
}

.page-toggle p { margin: 0; }

/* How a portfolio link is doing: four figures, then bars and the tours it fed. */
.measure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: var(--space-4);
  margin: var(--space-4) 0;
}

.measure-grid h3 { margin: 0 0 var(--space-2); font-size: var(--text-sm); font-weight: 650; }

/* The list's offer to keep a search or filter as a gallery, on its own line under the chips. */
.list-offer { margin: 0; font-size: var(--text-xs); }
.list-offer .link-button { font-size: inherit; }

.share-make {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.share-make .form-actions { margin: 0; }

.share-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px var(--space-3);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.share-row.off { opacity: 0.6; }
.share-row-main { min-width: 0; }
.share-row-main b { display: block; }

.share-row-main small,
.share-row-stats small {
  display: block;
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.share-code {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: var(--text-xs);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-row-stats {
  text-align: right;
}

.share-row-stats .num {
  display: block;
  font-size: var(--text-md);
  font-weight: 700;
}

.share-row-act {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.tour-picker {
  margin-bottom: var(--space-3);
}

.tour-picker > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 650;
}

.picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 12px;
  max-height: 260px;
  overflow: auto;
  margin: var(--space-2) 0;
  padding: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.me-device { margin-bottom: 4px; }

/* The notifications switch reads as on when this browser is subscribed. */
.me-push[hidden] { display: none; }
.me-push.is-on { color: var(--accent); }

@media (max-width: 720px) {
  .share-row { grid-template-columns: minmax(0, 1fr) auto; }
  .share-row-act { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
  .hbars li { grid-template-columns: minmax(80px, 42%) 1fr auto; }
}

/* ---------------------------------------------------------- attention */
.attention li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
}

.attention li:first-child { padding-top: 0; border-top: 0; }
.attention li:last-child { padding-bottom: 0; }

.attention .level {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
}

.attention .level.warn { background: var(--amber); }
.attention .level.bad { background: var(--red); }
.attention .level.ok { background: var(--accent); }

.attention small {
  display: block;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ history */
.activity-list {
  margin-top: var(--space-3);
}

.activity-list li {
  display: grid;
  grid-template-columns: 124px minmax(0, 1fr);
  gap: 4px var(--space-4);
  padding: 11px 0;
  border-top: 1px solid var(--line);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.activity-list li:first-child { padding-top: 0; border-top: 0; }
.activity-list li:last-child { padding-bottom: 0; }

.activity-when {
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  line-height: 1.75;
  white-space: nowrap;
}

.activity-reason {
  grid-column: 2;
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.activity-failed .activity-line strong,
.activity-failed .activity-reason {
  color: var(--red-ink);
}

/* ---------------------------------------------------------- watermark */
.watermark-grid {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  gap: 6px;
  width: max-content;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-sunk);
}

.watermark-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  cursor: pointer;
}

/* The radio is kept for the form and the keyboard; the cell is what you see.
   It used to be a viewport-wide box because the label was not positioned. */
.watermark-cell input {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.watermark-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-muted);
}

.watermark-cell.is-chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.watermark-cell.is-chosen .watermark-dot { background: var(--accent); }

.watermark-cell:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.watermark-preview {
  margin: var(--space-3) 0;
}

.watermark-preview img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: repeating-conic-gradient(var(--checker-dark) 0% 25%, var(--checker-light) 0% 50%) 50% / 16px 16px;
}

.watermark-preview figcaption { margin-top: 6px; }

code.pin {
  display: inline-block;
  margin-top: 6px;
  padding: 10px 13px;
  background: var(--surface);
  font-size: var(--text-md);
  letter-spacing: 0.12em;
}

/* ----------------------------------------------------- upload dialog */
.upload-dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: min(90vh, 820px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-dialog);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-overlay);
}

.upload-dialog::backdrop {
  background: var(--scrim);
  backdrop-filter: blur(3px);
}

.upload-panel {
  display: grid;
  gap: 14px;
  padding: clamp(20px, 5vw, 28px);
}

.upload-panel h2 {
  font-size: var(--text-lg);
  font-weight: 680;
  letter-spacing: -0.025em;
}

.dialog-heading,
.progress-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.upload-panel > label:not(.drop):not(.replace-confirm) {
  margin-bottom: -8px;
}

.drop {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: var(--space-5) var(--space-4);
  border: 1.5px dashed var(--line-hover);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.drop:hover,
.drop:focus-within {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.drop b {
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 650;
}

.drop svg.i {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.drop input[type="file"] {
  width: 100%;
  max-width: 320px;
  margin-top: 6px;
  font-size: var(--text-xs);
}

.upload-panel [data-upload-size-preview] {
  padding: 10px 12px;
  border-radius: var(--radius-control);
  background: var(--surface-hover);
  line-height: 1.45;
}

.upload-panel .notice { margin: 0; }

.upload-progress {
  display: grid;
  gap: 8px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

.upload-progress progress {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-pill);
  appearance: none;
  background: var(--surface-sunk);
  color: var(--accent);
}

.upload-progress progress::-webkit-progress-bar { background: var(--surface-sunk); border-radius: var(--radius-pill); }
.upload-progress progress::-webkit-progress-value { background: var(--accent); border-radius: var(--radius-pill); transition: inline-size 240ms var(--ease); }
.upload-progress progress::-moz-progress-bar { background: var(--accent); }

.upload-progress .muted {
  min-height: 1.4em;
  overflow-wrap: anywhere;
  font-size: var(--text-xs);
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 6px;
}

.dialog-actions [disabled] {
  cursor: wait;
  opacity: 0.66;
}

/* ---- the upload as pages: progress strip on top, steps under it, one page at a time ---- */
.upload-dialog.wizard {
  width: min(720px, calc(100vw - 32px));
  max-height: min(92vh, 900px);
}

.upload-dialog.wizard .upload-panel {
  max-height: min(92vh, 900px);
  overflow-y: auto;
  gap: var(--space-4);
  padding-top: var(--space-4);
  overscroll-behavior: contain;
}

.wizard-steps {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.wizard-steps li {
  display: inline-flex;
  flex: 1 1 0;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-control);
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--line);
}

.wizard-steps li[aria-current="step"] {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}

.wizard-steps li.done { color: var(--ink); border-bottom-color: var(--accent-soft); }

.wizard-num {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-sunk);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.wizard-steps li[aria-current="step"] .wizard-num,
.wizard-steps li.done .wizard-num {
  background: var(--accent);
  color: var(--on-accent);
}

.wizard-page {
  display: grid;
  gap: var(--space-4);
}

.wizard-page h3 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 680;
  letter-spacing: -0.015em;
}

.wizard-group {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  border: 0;
}

.wizard-group legend {
  width: 100%;
  padding: var(--space-3) 0 var(--space-2);
  border-top: 1px solid var(--line);
  font-weight: 650;
}

.wizard-summary { margin: 0; }

.wizard-saved {
  flex: 1 1 auto;
  min-height: 1em;
  font-size: var(--text-xs);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface-soft);
  cursor: pointer;
}

.check-row input { margin-top: 3px; }
.check-row b { display: block; font-weight: 650; }
.check-row small { display: block; color: var(--ink-muted); font-size: var(--text-xs); }

.field-error { color: var(--red-ink); }

.card-picture-pick {
  display: grid;
  gap: var(--space-2);
}

.card-picture-preview {
  position: relative;
  max-width: 420px;
  margin: 0;
  aspect-ratio: 1200 / 630;
  background: var(--accent);
  color: #fff;
}

.card-picture-preview img { position: absolute; inset: 0; width: 100%; height: 100%; }

.card-picture-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  padding: var(--space-3);
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 600;
  background: linear-gradient(180deg, transparent, var(--scrim));
}

.card-picture-placeholder small { font-weight: 500; opacity: 0.85; }
.card-picture-preview.has-picture .card-picture-placeholder { display: none; }

.card-picture-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* The backup archive's search, and the answer to a pasted link. */
.archive-search { max-width: 640px; }
.found-card { border-color: var(--accent); }
.archive-count { justify-content: flex-start; margin: 0 0 var(--space-2); }

/* Previous versions: one row per kept folder, its restore folded under it. */
.version-list {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.version-row {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.version-row b { display: block; font-weight: 650; }
.version-row small { display: block; color: var(--ink-muted); font-size: var(--text-xs); }
.version-row .danger-zone { margin: 0; }

/* The question a close asks while an upload is unfinished: laid over the pages, inside the dialog. */
.wizard-ask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: var(--scrim);
  border-radius: inherit;
}

.wizard-ask-card {
  display: grid;
  gap: var(--space-3);
  width: min(440px, 100%);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.wizard-ask-card h3 { margin: 0; font-size: var(--text-base); font-weight: 680; }
.wizard-ask-card .dialog-actions { flex-wrap: wrap; margin-top: var(--space-2); }
.upload-dialog.wizard { position: relative; }

/* The upload, minimised: a pill in the corner while the person does something else. */
.upload-pill {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-overlay);
  cursor: pointer;
}

.upload-pill-bar {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 240ms var(--ease);
}

.upload-pill.is-error { border-color: var(--red-line); }

.upload-dialog[open] { animation: dialog-in 200ms var(--ease); }
.upload-dialog[open]::backdrop { animation: backdrop-in 200ms var(--ease); }

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
}

/* ------------------------------------------------------------- login */
.login-shell {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: var(--space-5) 16px;
}

.login-panel {
  display: grid;
  gap: var(--space-3);
  width: min(100%, 420px);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.login-panel h1 {
  margin-top: var(--space-2);
  font-size: var(--text-xl);
  font-weight: 680;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.login-panel .form-stack {
  display: grid;
  gap: 6px;
  margin-top: var(--space-2);
}

.login-panel .form-stack label { margin-top: var(--space-2); }

.login-panel .form-stack .button {
  width: 100%;
  margin-top: var(--space-3);
}

.login-panel .notice { margin: 0; }

.support-note { margin-top: var(--space-2); }

/* Sign in with Google: one wide button, and a quiet rule before the password form when both are offered. */
.button-google {
  justify-content: center;
  width: 100%;
  min-height: 46px;
  margin-top: var(--space-2);
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0 0;
  color: var(--ink-muted);
  font-size: var(--text-xs);
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.status-pill.status-warn {
  border-color: var(--amber-line);
  background: var(--amber-soft);
  color: var(--amber-ink);
}

/* ------------------------------------------------------------ motion */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 180ms;
  animation-timing-function: var(--ease);
}

.rail { view-transition-name: rail; }

/* ------------------------------------------------- reading room */
/* The administration list: a description is a sentence, and a sentence may take two lines. */
.admin-nav .row .sub { white-space: normal; line-height: 1.4; }
.admin-nav .row { padding-top: 12px; padding-bottom: 12px; }

/* The fields table: every row one line high. The tools stay on one line, the
   counts never break, and a long list of choices is cut at two lines. */
.tour-table.fields td { vertical-align: top; }
.tour-table.fields td.num,
.tour-table.fields .row-tools { white-space: nowrap; }
.tour-table.fields .row-tools { flex-wrap: nowrap; justify-content: flex-end; }
.tour-table.fields td small.choices {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

/* Long lists show a page and offer the next. */
.show-more-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  margin-top: var(--space-3);
}

.show-more-count { font-size: var(--text-xs); }
.table-card .show-more-bar { padding: 0 var(--space-4) var(--space-3); }
.chip.chip-more { border-style: dashed; color: var(--ink-muted); }

/* A tour that came back much smaller: amber, beside the drift flag's red. */
.flag.shrunk { color: var(--amber); }
/* The side column stacks the size and when a client last opened the tour. */
.row .side { flex-direction: column; align-items: flex-end; gap: 2px; }
.row .side .opened { color: var(--ink-faint); font-size: var(--text-xs); }

/* A list of names to act on: the switch beside each says where it stands and flips it. */
.switch {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  height: 30px;
  padding: 0 10px 0 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-muted);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 650;
  cursor: pointer;
}

.switch::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: transform var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.switch[aria-checked="true"] {
  flex-direction: row-reverse;
  padding: 0 4px 0 10px;
  border-color: var(--accent);
  color: var(--accent);
}

.switch[aria-checked="true"]::before { background: var(--accent); }

.undo-notice { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); align-items: center; }
.undo-notice form { margin: 0; }

/* The delivery kit's maker and the link form: a select, and a button that sits on the field's line. */
.kit-make { display: grid; gap: var(--space-2); max-width: 520px; }
.form-actions-end { align-self: end; margin: 0; }
.share-make h3 { font-size: var(--text-sm); font-weight: 680; }

/* The tour page's top on a phone: the way back, the name and the state stay put while the rest scrolls. */
.page-top { display: contents; }

/* A card that folds: closed, only its heading shows; open, the lede follows the heading as in any card. */
details.card:not([open]) > summary.card-summary { margin: 0; }
details.card[open] > summary.card-summary + .lede { margin-top: -8px; }
details.card > summary.card-summary + :not(.lede) { margin-top: 0; }

/* Roles: each a row with its rights as chips; a made one unfolds into its editor. */
.role-list { display: grid; gap: var(--space-2); }

.role-row {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.role-head { display: flex; flex-wrap: wrap; gap: 4px var(--space-2); align-items: baseline; margin-bottom: 6px; }
.role-head b { font-weight: 680; }
.role-head small { color: var(--ink-muted); font-size: var(--text-xs); }
.role-edit > summary { list-style: none; cursor: pointer; }
.role-edit > summary::-webkit-details-marker { display: none; }
.role-edit[open] > summary { margin-bottom: var(--space-3); }
.role-edit .inline-form { margin-top: var(--space-2); }
.perm-chips { display: flex; flex-wrap: wrap; gap: 4px; }

.perm-chip {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  font-weight: 600;
}

.perm-group { margin: 0; padding: 0; border: 0; }
.perm-group legend { padding: 0; color: var(--ink-muted); font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.02em; text-transform: uppercase; }
.perm-group + .perm-group { margin-top: var(--space-3); }

.perm-pick {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.perm-pick:last-child { border-bottom: 0; }
.perm-pick input { margin-top: 3px; }
.perm-pick b { display: block; font-weight: 650; }
.perm-pick small { color: var(--ink-muted); font-size: var(--text-xs); }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  :root { --rail: 72px; }

  .rail .brand-mark { justify-content: center; padding-right: 0; padding-left: 0; font-size: 0; }
  .rail nav a .l,
  .rail .me .link-button .l,
  .rail .who > div,
  .rail .theme .l { display: none; }
  .rail nav a,
  .rail .me .link-button { justify-content: center; padding: 0; }
  .rail .count { position: absolute; margin: -22px 0 0 26px; }
  .rail .who { justify-content: center; }
  .rail .theme { flex-direction: column; border-radius: var(--radius-control); }
  .rail .theme button { border-radius: var(--radius-control); }
  .rail .accents { display: none; }
  .rail .me .me-appearance { display: inline-flex; }
}

@media (max-width: 960px) {
  :root { --list: 320px; }

  .detail-inner { padding: var(--space-4) var(--space-4) 96px; }
  .head h1 { font-size: var(--text-xl); }
  .setting-row { grid-template-columns: minmax(0, 1fr) auto; }
  .setting-row dt { grid-column: 1 / -1; padding: 0; }
}

@media (max-width: 720px) {
  html, body { height: auto; min-height: 100%; }

  /* One pane at a time: the list, or the thing opened from it. */
  .app,
  .app.one-column {
    display: block;
    height: auto;
    min-height: 100vh;
    padding-bottom: var(--tabbar);
  }

  .app.no-tabs { padding-bottom: 0; }
  .rail { display: none; }
  .app.show-detail .pane,
  .app.show-list .detail { display: none; }
  .pane { min-height: calc(100vh - var(--tabbar)); border-right: 0; }
  .detail { overflow: visible; }
  .detail-inner { padding: var(--space-3) 16px 40px; }
  .only-phone { display: inline-grid; }

  .upload-dialog.wizard {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .upload-dialog.wizard .upload-panel { max-height: 100dvh; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); }
  .wizard-steps li { padding: 8px 4px; font-size: var(--text-xs); }
  .wizard-steps li span + * { display: none; }
  .upload-pill { bottom: calc(var(--tabbar) + 12px + env(safe-area-inset-bottom)); }

  .crumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: var(--space-3);
    color: var(--accent);
    font-size: var(--text-sm);
    font-weight: 650;
    text-decoration: none;
  }

  .head { grid-template-columns: 1fr; }
  .head .actions { justify-content: flex-start; }
  .facts { grid-template-columns: 1fr 1fr; }
  .facts > div { padding: 8px 12px; }
  .facts > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  /* Two figures a row, not one: a phone screen holds the numbers without scrolling past them. */
  .kpis { grid-template-columns: 1fr 1fr; gap: var(--space-2); }
  .kpi { padding: 10px 12px; }
  /* Tabs keep their whole names and scroll sideways when there are more than fit; the counts go. */
  .tabs { gap: 0; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding-inline: 16px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs [role="tab"] { flex: 0 0 auto; padding: 12px 10px 14px; font-size: var(--text-sm); white-space: nowrap; }
  .tabs [role="tab"] .n { display: none; }

  .button { min-height: 44px; }
  .button-small { min-height: 40px; }
  .row { padding: 14px 44px 14px 16px; }
  .row-plain { padding-right: 16px; }
  .chip { height: 34px; }
  .setting-act { justify-self: start; }
  .activity-list li { grid-template-columns: 1fr; gap: 2px; }
  .activity-when { order: -1; }
  .form-2 { grid-template-columns: 1fr; }

  /* Tables become labelled rows: the Actions column was off the edge otherwise. */
  .tour-table, .tour-table thead, .tour-table tbody, .tour-table tr, .tour-table th, .tour-table td { display: block; width: auto; }
  .tour-table thead { position: absolute; overflow: hidden; width: 1px; height: 1px; clip: rect(0, 0, 0, 0); }
  .tour-table tr { padding: var(--space-3) 16px; border-bottom: 1px solid var(--line); }
  .tour-table tbody tr:last-child { border-bottom: 0; }
  .tour-table td { display: grid; grid-template-columns: minmax(84px, 0.32fr) minmax(0, 1fr); gap: var(--space-3); padding: 5px 0; border-bottom: 0; }
  .tour-table td > * { justify-self: start; }
  .tour-table td > details { justify-self: stretch; }
  /* A cell's second line (a field's choices, a user's address) stays in the value column, not under the label. */
  .tour-table td > * ~ * { grid-column: 2; }
  .tour-table td::before { content: attr(data-label); color: var(--ink-muted); font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.02em; line-height: 1.9; }
  .tour-table td:first-child { display: block; padding-top: 0; font-size: var(--text-base); }
  .tour-table td:first-child::before { display: none; }
  .tour-table td.empty { display: none; }
  .tour-table td.empty:has(form) { display: block; padding-top: 6px; }
  .tour-table.compact td::before { display: none; }
  .tour-table.compact td { display: block; padding: 2px 0; }
  .tour-table tbody tr:hover { background: transparent; }
  /* A client's tour row: a long deadline pill wraps instead of running off the edge. */
  .client-tours .status-pill { white-space: normal; text-align: left; }

  /* The head actions move into the thumb bar, within reach of one hand. */
  .has-thumb .head .actions { display: none; }

  .thumb {
    position: fixed;
    right: 0;
    bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px));
    left: 0;
    z-index: 19;
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(to top, var(--paper) 70%, transparent);
  }

  .app.no-tabs ~ .thumb { bottom: env(safe-area-inset-bottom, 0px); padding-bottom: 14px; }
  .thumb .button, .thumb form { flex: 1; }
  .thumb form .button { width: 100%; }
  .thumb .button { min-height: 48px; font-size: var(--text-base); }
  .has-thumb .detail-inner { padding-bottom: 150px; }

  .tabbar {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: var(--surface);
  }

  .tabbar.tabs-2 { grid-template-columns: repeat(2, 1fr); }
  .tabbar.tabs-4 { grid-template-columns: repeat(4, 1fr); }
  .tabbar.tabs-5 { grid-template-columns: repeat(5, 1fr); padding-inline: 4px; }
  .tabbar.tabs-5 a { padding-inline: 2px; }
  .tabbar.tabs-6 { grid-template-columns: repeat(6, 1fr); padding-inline: 2px; }
  .tabbar.tabs-6 a { padding-inline: 0; letter-spacing: -0.01em; }

  .tabbar a {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px 4px;
    border-radius: var(--radius-control);
    color: var(--ink-muted);
    font-size: var(--text-xs);
    font-weight: 650;
    text-decoration: none;
  }

  .tabbar a[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent);
  }

  .tabbar svg.i { width: 20px; height: 20px; }

  .login-panel { padding: var(--space-4); }
}

@media (min-width: 721px) {
  .tabbar { display: none; }
}

/* Installed on a phone: no rubber-banding of the whole page, and the panes
   start below the status bar rather than under it. */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .pane-head { padding-top: calc(var(--space-4) + env(safe-area-inset-top, 0px)); }
  .detail-inner { padding-top: calc(var(--space-5) + env(safe-area-inset-top, 0px)); }
  .login-shell { padding-top: calc(var(--space-5) + env(safe-area-inset-top, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media (max-width: 720px) {
  /* The head stays while the page scrolls under it: back, the name, and what state the tour is in. */
  .page-top {
    position: sticky;
    top: 0;
    z-index: 18;
    display: block;
    margin: 0 -16px var(--space-3);
    padding: var(--space-2) 16px 10px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
  }

  .page-top .crumb { margin-bottom: 4px; }
  .page-top .head { margin-bottom: 0; }
  .page-top .head h1 { font-size: var(--text-lg); }
  .page-top .head .status { margin-top: 6px; }

  /* A table of numbers reads as facts in columns, not as a list of labels: the
     name across the top, then each figure with its label above it, side by side. */
  .tour-table.metrics tr { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 4px var(--space-2); }
  .tour-table.metrics td { display: block; padding: 0; }
  .tour-table.metrics td:first-child { grid-column: 1 / -1; padding-bottom: 4px; }
  .tour-table.metrics td::before { display: block; margin-bottom: 0; line-height: 1.5; }
  .tour-table.metrics td.num { text-align: left; }
  .tour-table.metrics td > * ~ * { grid-column: auto; }
  .tour-table.metrics td.empty { display: none; }
  .tour-table.metrics td.empty:has(form) { display: block; grid-column: 1 / -1; }
  .tour-table.metrics td small { display: inline; margin-left: 4px; }

  .tour-table.fields small.choices { display: none; }
  .tour-table.fields .row-tools { justify-content: flex-start; }
  .chips.wrap .chip { height: 32px; }
  .show-more-bar { justify-content: space-between; }
  .kit-make { max-width: none; }
}

/* ------------------------------------------------ a client's own people */
/* Staff side: the sections switched on for a client, and who can sign in. */
.cl-features,
.cl-people {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.cl-feature,
.cl-person {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  padding: var(--space-3);
}

.cl-feature + .cl-feature,
.cl-person + .cl-person { border-top: 1px solid var(--line); }

.cl-feature > div,
.cl-person-who {
  display: grid;
  flex: 1 1 240px;
  gap: 2px;
  min-width: 0;
}

.cl-person-who small { overflow-wrap: anywhere; }
.cl-person-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.card .cl-invite { margin-top: var(--space-3); background: var(--surface-soft); }
.card .cl-add h3 { margin: 0; color: var(--ink); }
.cl-see { margin-top: var(--space-3); }
.cl-features + .notice { margin-top: var(--space-3); }
.cl-share-ways { grid-template-columns: repeat(2, 1fr); }

/* Client side: a page of their own, with no rail and nothing of ours to find. */
.cl-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100%;
}

.cl-top {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.cl-me {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}

.cl-me > span { display: grid; text-align: right; line-height: 1.3; }
.cl-me .link-button { display: inline-flex; gap: 6px; align-items: center; }

.cl-body {
  display: grid;
  gap: var(--space-5);
  align-content: start;
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) var(--space-6);
}

.cl-hero h1 {
  font-size: var(--text-2xl);
  font-weight: 680;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.cl-hero .lede { margin-top: 6px; font-size: var(--text-base); }

.cl-section { display: grid; gap: var(--space-3); }

.cl-section-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: baseline;
  justify-content: space-between;
}

.cl-section-head h2 {
  font-size: var(--text-lg);
  font-weight: 680;
  letter-spacing: -0.02em;
}

.cl-empty {
  padding: var(--space-5);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
}

.cl-empty h2 { font-size: var(--text-md); font-weight: 680; }

/* Their own page: one address above the tours it holds. */
.cl-page {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(0, 1.4fr);
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
}

.cl-page > div:first-child { display: grid; gap: 2px; }
.cl-page .share-link { margin-top: 0; }
.cl-page .share-link input { background: var(--surface); }

.cl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: var(--space-4);
}

.cl-tour {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.cl-tour:hover { border-color: var(--line-hover); box-shadow: var(--shadow-raised); }

.cl-tour-picture {
  display: block;
  aspect-ratio: 16 / 10;
  background: var(--surface-sunk);
}

.cl-tour-picture img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cl-tour-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.cl-tour-body h3 { font-size: var(--text-base); font-weight: 680; line-height: 1.3; }
.cl-tour-body h3 a { color: var(--ink); text-decoration: none; }
.cl-tour-body h3 a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 0.18em; }
.cl-tour-link {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.cl-address {
  min-width: 0;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

/* Adding a colleague: one line on a wide screen, the button on the fields' baseline. */
.cl-add {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.cl-add h3 { font-size: var(--text-base); font-weight: 680; }

.cl-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto;
  gap: var(--space-3);
  align-items: end;
}

.cl-add-row.with-role { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(120px, auto) auto; }
.cl-add-row.single { grid-template-columns: minmax(0, 1fr) auto; }

.cl-tour-state {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}

.cl-ask { color: var(--accent); font-size: var(--text-xs); font-weight: 650; }

.cl-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--text-sm);
}

.cl-contact {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
}

.cl-contact a { color: var(--accent); font-weight: 650; }
.login-panel .cl-contact { margin-top: var(--space-2); }

/* The client's sections: a row of tabs under their name, one page each. */
.cl-tabs {
  display: flex;
  gap: var(--space-1);
  margin-top: var(--space-4);
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}

.cl-tabs a {
  flex: none;
  margin-bottom: -1px;
  padding: 10px var(--space-3);
  border-bottom: 2px solid transparent;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  font-weight: 650;
  text-decoration: none;
}

.cl-tabs a:hover { color: var(--ink); }
.cl-tabs a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--ink); }

.cl-fine { margin-top: var(--space-2); }
.cl-held { margin-top: var(--space-3); }

/* Their links: what each is, what it brought, and what they can do with it. */
.cl-link-make .muted { margin-bottom: var(--space-1); }

.cl-link-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--space-3);
}

.cl-links { display: grid; gap: var(--space-2); }

.cl-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.cl-link.off { background: var(--surface-soft); }
.cl-link.off .cl-link-main,
.cl-link.off .cl-link-stats { opacity: 0.65; }
.cl-link.fresh { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.cl-link-main { display: grid; gap: 2px; min-width: 0; }
.cl-link-main .share-code { margin-top: 2px; }
.cl-link-stats { display: grid; justify-items: end; line-height: 1.3; }
.cl-link-stats .num { font-size: var(--text-md); font-weight: 700; }
.cl-link-stats small { color: var(--ink-muted); font-size: var(--text-xs); }

.cl-link-act {
  display: flex;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  gap: var(--space-2);
  align-items: center;
}

.cl-link-act .button { display: inline-flex; gap: 6px; align-items: center; }

.cl-link-fresh {
  display: flex;
  grid-column: 1 / -1;
  gap: var(--space-4);
  align-items: center;
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.cl-link-fresh img {
  flex: none;
  width: 140px;
  height: 140px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

/* Access: each tour's state, and what the client may change about it. */
.cl-accesses,
.cl-requests { display: grid; gap: var(--space-2); }

.cl-access,
.cl-request {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.cl-access-main,
.cl-request-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
}

.cl-access-main b,
.cl-request-head b { margin-right: auto; }

.cl-access-act {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.cl-date-form { display: flex; gap: var(--space-2); align-items: center; }
.cl-date-form input { width: auto; min-height: 34px; }

.cl-ours {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.cl-ours a { color: var(--accent); font-weight: 650; }

/* Support: their words and ours, kept as written. */
.cl-message { white-space: pre-wrap; overflow-wrap: anywhere; }
.cl-request.done { background: var(--surface-soft); }

.cl-reply {
  display: grid;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.cl-answer { display: grid; gap: var(--space-2); }
.cl-answer .form-actions { margin: 0; }
.cl-done { margin-top: var(--space-3); }
.cl-done > summary { color: var(--ink-muted); font-size: var(--text-sm); font-weight: 650; cursor: pointer; }
.cl-done[open] > summary { margin-bottom: var(--space-2); }

/* Lead capture: which tours ask, what they say, and what came in. */
.cl-position { display: flex; gap: var(--space-2); align-items: center; margin: 0; }
.cl-position select { width: auto; min-height: 34px; padding-block: 0; font-size: var(--text-sm); }
.cl-lead-words .cl-add + .cl-add { margin-top: var(--space-3); }
.cl-hook-test { margin-top: var(--space-2); }
.cl-secret { margin-top: var(--space-3); }
.cl-secret > summary { color: var(--ink-muted); font-size: var(--text-sm); cursor: pointer; }
.cl-secret code { font-size: var(--text-xs); }
.cl-lead-bulk { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.cl-lead-words { margin-top: var(--space-3); }
.cl-lead-words > summary { color: var(--ink-muted); font-size: var(--text-sm); font-weight: 650; cursor: pointer; }
.cl-lead-words[open] > summary { margin-bottom: var(--space-2); }

.cl-lead-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  justify-content: space-between;
  margin: var(--space-4) 0 var(--space-2);
}

.cl-lead-head h3 { margin: 0; }
.cl-request a { color: var(--accent); font-weight: 600; }

/* A card's title with what acts on the whole card beside it. */
.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-3);
  align-items: center;
  justify-content: space-between;
}

.card-head h2 { margin: 0; }
.card-head .muted { margin-top: 2px; }
.card-head-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.card > .card-head + * { margin-top: var(--space-3); }

/* A setting that is changed now and then: folded under a plain summary. */
.fold {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--line);
}

.fold > summary { color: var(--accent); font-size: var(--text-sm); font-weight: 650; cursor: pointer; }
.fold[open] > summary { margin-bottom: var(--space-3); }
.inline-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2); align-items: center; }
.client-facts { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); margin-bottom: var(--space-3); }
.client-facts + .notice { margin-bottom: var(--space-3); }

/* Staff looking at what the client sees. */
.cl-preview {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: center;
  padding: var(--space-2) 16px;
  background: var(--amber-soft);
  color: var(--amber-ink);
  font-size: var(--text-sm);
  font-weight: 650;
}

@media (max-width: 720px) {
  .cl-top { padding: var(--space-3) 16px; }
  .cl-me > span { text-align: left; }
  .cl-body { gap: var(--space-4); padding: var(--space-4) 16px var(--space-5); }
  .cl-hero h1 { font-size: var(--text-xl); }
  .cl-page { grid-template-columns: 1fr; }
  .cl-add-row,
  .cl-add-row.with-role { grid-template-columns: 1fr; }
  .cl-link { grid-template-columns: 1fr; }
  .cl-link-stats { justify-items: start; }
  .cl-link-fresh { flex-direction: column; align-items: flex-start; }
  .cl-foot { padding: var(--space-4) 16px; }
}

/* Leads: one row each, so a page of them reads at a glance. */
.leads-card .card-head { padding: var(--space-2) var(--space-4) var(--space-3); }
.leads-card .card-head h2 { padding: 0; }
.leads-table td { vertical-align: top; }
.leads-table td b + .status-pill { margin-left: 6px; }
.leads-table .lead-message {
  display: -webkit-box;
  overflow: hidden;
  max-width: 44ch;
  margin-top: 2px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.leads-table .lead-reach { display: grid; gap: 2px; }
.leads-table .lead-reach a { color: var(--accent); font-weight: 600; white-space: nowrap; }
.leads-table .lead-when { white-space: nowrap; color: var(--ink-muted); }
.leads-table .lead-act { text-align: right; }

/* Newer and older, with where this page sits between them. */
.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line);
}
.pager > :last-child { justify-self: end; }
.pager .muted { font-size: var(--text-sm); }
.leads-card > .muted { padding: var(--space-3) var(--space-4); }
/* On a phone a lead is three short lines: who, how to reach them, which tour and when. */
@media (max-width: 720px) {
  .leads-table td { display: block; padding: 2px 0; }
  .leads-table td::before { display: none; }
  .leads-table td:first-child { padding-left: 0; }
  .leads-table td[data-label="Tour"], .leads-table .lead-when { display: inline; color: var(--ink-muted); font-size: var(--text-sm); }
  .leads-table td[data-label="Tour"] small { display: inline; }
  .leads-table td[data-label="Tour"] small::before { content: " · "; }
  .leads-table .lead-when::before { display: inline; content: " · "; }
  .leads-table .lead-reach { display: flex; flex-wrap: wrap; gap: 2px var(--space-3); }
  .leads-table .lead-act { padding-top: 4px; text-align: left; }
  .leads-table .lead-message { max-width: none; }
}
.leads-table .lead-act .link-button { min-height: 0; padding-block: 0; }
