/* ===================================================================
 * THEME TOKENS
 *
 * Every colour that depends on the theme is a variable, including the ones
 * used in inline styles from JavaScript — a CSS variable resolves at use
 * time, so `style="color:var(--text-2)"` recolours itself when the palette
 * changes, with no JS involved.
 *
 * The dark palette below is the app as the field has always seen it. The
 * light palette lives in ONE media query at the foot of this file and
 * applies only at desktop width. Phones and tablets never see it.
 * =================================================================== */
:root {
  --bg: #121212; --surface: #1e1e1e; --surface2: #2a2a2a; --border: #3a3a3a;
  --green: #45C95A; --green-d: #15402B; --text: #fff; --muted: #999; --danger: #e57373;
  /* chrome */
  --topbar: #181818; --topbar-line: #262626;
  /* text ramp, brightest to dimmest */
  --text-2: #ddd; --text-3: #ccc; --text-4: #bbb;
  /* separators and inert fills */
  --hairline: #2a2a2a; --hairline-2: #242424; --fill: #333;
  /* status tints */
  --ok-bg: #1f3d2e; --ok-fg: #8fd3b0; --warn-bg: #3a3a1f; --warn-fg: #e6d27a;
  --info-bg: #1f2a3a; --info-fg: #8fb6e6;
  /* a button's own label: white on the dark theme, ink on the light one */
  --btn-face: #fff;
  --card-shadow: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }
/* The screen is a fixed width. Anything wider scrolls inside its own strip
   rather than dragging the whole page sideways. */
html, body { overflow-x: hidden; max-width: 100%; }
body { padding-bottom: env(safe-area-inset-bottom); }

.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--topbar); border-bottom: 1px solid var(--topbar-line);
}
.brand { font-size: 18px; font-weight: 800; flex: 1; text-align: center; }
.brand span { color: var(--green); }
.icon-btn { background: none; border: none; color: var(--text); font-size: 26px; line-height: 1; width: 40px; height: 40px; border-radius: 8px; }
.icon-btn:active { background: var(--surface2); }

#app { padding: 14px; max-width: 900px; margin: 0 auto; }

h1 { font-size: 22px; margin: 4px 0 2px; }
h2 { font-size: 17px; color: var(--green); margin: 18px 0 8px; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: none; border-radius: 10px; padding: 12px 16px; font-size: 15px; font-weight: 700; color: var(--btn-face); background: var(--surface2); cursor: pointer; }
.btn:active { opacity: .85; }
.btn-green { background: var(--green); color: #fff; }
.btn-ghost { background: var(--surface2); border: 1px solid var(--border); color: var(--text-2); }
.btn-outline { background: transparent; border: 1px solid var(--green); color: var(--green); }
.btn-danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.spacer { height: 10px; }

.card { background: var(--surface); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
/* user-select off so a long-press starts multi-select instead of the
   browser's text-selection / callout menu. */
.list-card { display: flex; align-items: center; gap: 12px; background: var(--surface2); border-radius: 12px; padding: 14px; margin-bottom: 10px; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.list-card .accent { width: 4px; align-self: stretch; background: var(--green); border-radius: 3px; margin: -14px 0 -14px -14px; }
.list-card .grow { flex: 1; }
.list-card .title { font-size: 16px; font-weight: 700; }
.list-card .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; background: var(--green-d); color: var(--green); }
.chip-gc { background: #3a2f15; color: #f4b400; }

label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; font-size: 13px; color: var(--text-3); font-weight: 600; margin-bottom: 4px; }
input, textarea, select {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px; color: var(--text); font-size: 16px; font-family: inherit;
}
textarea { min-height: 78px; resize: vertical; }
.inline { display: flex; gap: 8px; align-items: center; }
.switch-row { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }

.tabbar {
  display: flex; gap: 6px; margin: 6px 0 14px;
  flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
  scroll-snap-type: x proximity;
  /* Bleed to the screen edges so a scrolled tab isn't clipped mid-word. */
  padding: 2px 14px; margin-left: -14px; margin-right: -14px;
}
.tabbar::-webkit-scrollbar { height: 4px; }
.tabbar::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 4px; }
.tabbar .tab {
  flex: 0 0 auto; scroll-snap-align: start;
  text-align: center; padding: 10px 16px; border-radius: 10px;
  background: var(--surface2); color: var(--text-4); font-weight: 700; font-size: 14px;
  white-space: nowrap;
}
.tabbar .tab.active { background: var(--green); color: #fff; }
.tabbar .tab:active { opacity: .8; }

/* Anything clickable that isn't a <button> still has to behave like one:
   a pointer cursor, and no text-selection I-beam when you hover or drag
   across it. Tabs, list rows and the small ✕ controls are all plain divs. */
.tab,
.list-card,
.list-card .grow,
.x,
.photo,
.rollup-row[data-click],
label.inline,
.ro-note span {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* Checkbox and radio labels: the whole row should feel tappable — but a text
   field inside one still gets a text cursor. */
label.inline { cursor: pointer; }
input[type="checkbox"], input[type="radio"] { cursor: pointer; }
label.inline input[type="text"], label.inline input:not([type]), label.inline textarea { cursor: text; user-select: auto; }
.ptp-yn label, .chk-grid label, .switch-row label { cursor: pointer; -webkit-user-select: none; user-select: none; }
/* Text the user may genuinely want to copy stays selectable. */
.ro-v, .hint, .muted, .sub, textarea, input { -webkit-user-select: auto; user-select: auto; }

.note-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.note-row .num { color: var(--muted); font-weight: 700; padding-top: 11px; width: 22px; }
.note-row .x { color: var(--danger); font-size: 18px; padding: 10px 4px 0; }

.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; background: var(--fill); }
.photo img { width: 100%; height: 130px; object-fit: cover; display: block; }
.photo .del { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 50%; width: 26px; height: 26px; border: none; font-size: 14px; }

.labor-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr .6fr 28px; gap: 6px; margin-bottom: 6px; align-items: center; }
.labor-row input, .labor-row select { padding: 9px; font-size: 14px; }
.labor-row .x { color: var(--danger); text-align: center; font-size: 18px; }
.labor-head { display: grid; grid-template-columns: 1.3fr 1fr 1fr .6fr 28px; gap: 6px; font-size: 11px; color: var(--muted); margin-bottom: 4px; padding: 0 2px; }

/* The only live signature surface in the app is the one inside the Sign modal.
   A captured signature is shown as a flat image — nothing to smudge. */
.sig-pad { width: 100%; height: 180px; background: #fff; border-radius: 10px; touch-action: none; display: block; }
.sig-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sig-done { margin: 6px 0 2px; background: #fff; border-radius: 8px; padding: 6px; text-align: center; pointer-events: none; user-select: none; }
.sig-done img { max-height: 56px; max-width: 100%; display: inline-block; }

.rollup-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--hairline); }
.rollup-row .h { color: var(--green); font-weight: 800; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 42px; }

.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
/* A dialog never grows past the screen. Anything taller scrolls inside
 * itself — on a phone, on an iPad, and with the keyboard up — so nothing can
 * end up above the top edge or below the bottom where it cannot be reached.
 * dvh follows the browser's own chrome as it hides and shows; vh is the
 * fallback where dvh is not understood. */
.modal { background: var(--surface); border-radius: 14px; padding: 18px; width: 100%; max-width: 440px;
  max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px);
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal h3 { margin: 0 0 12px; }
/* Cancel and Save stay on screen while the middle of a long dialog scrolls
 * under them. The negative offset and matching padding cover the dialog's
 * own bottom padding, so no content shows through beneath the row. */
.modal-actions { display: flex; justify-content: flex-end; gap: 16px; align-items: center; margin-top: 16px;
  position: sticky; bottom: -18px; background: var(--surface); padding: 10px 0 18px; }
.link { color: var(--green); font-weight: 700; background: none; border: none; font-size: 15px; }
.link-muted { color: var(--muted); background: none; border: none; font-size: 15px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000; color: #fff; padding: 12px 18px; border-radius: 24px; font-size: 14px; z-index: 100; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: .95; }

/* Header account button: just the initial, always round, never truncated text.
   Tap it for the account screen (status, sync, password, sign out). */
.who { background: none; border: none; padding: 0; flex: none; cursor: pointer; position: relative; }
.who .dot { width: 32px; height: 32px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.who .vtag { position: absolute; right: -2px; bottom: -2px; width: 14px; height: 14px; border-radius: 50%; background: #f4b400; color: #1a1a1a; font-size: 9px; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 2px solid var(--topbar); }
.who:active .dot { opacity: .8; }

/* Account screen */
.acct-head { display: flex; align-items: center; gap: 14px; }
.acct-head .big-dot { width: 56px; height: 56px; border-radius: 50%; background: var(--green); color: #fff; font-weight: 800; font-size: 24px; display: flex; align-items: center; justify-content: center; flex: none; }
.acct-head .em { font-size: 14px; color: var(--text-2); word-break: break-all; line-height: 1.35; }

.gate { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto; }
.gate-box { width: 100%; max-width: 420px; text-align: center; padding-top: 30px; }
.gate-brand { font-size: 28px; font-weight: 800; margin-bottom: 18px; }
.gate-brand span { color: var(--green); }
.gate-msg { color: var(--text-2); font-size: 15px; margin: 8px 0; }
.gate-hint { color: var(--muted); font-size: 13px; }
.gate-hint code { background: var(--surface2); padding: 2px 6px; border-radius: 4px; color: #eee; }
#clerk-signin { margin-top: 10px; display: flex; justify-content: center; }

.rate-row { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 2px; font-size: 13px; color: var(--text-2); }

/* PTP: yes/no question rows and the permit / PPE checkbox grids */
.ptp-q { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--hairline); }
.ptp-q:last-child { border-bottom: none; }
.ptp-qt { flex: 1; font-size: 13.5px; line-height: 1.4; }
.ptp-qt b { color: var(--green); margin-right: 4px; }
.ptp-yn { display: flex; gap: 10px; flex: none; padding-top: 1px; }
.ptp-yn label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-3); }
.ptp-yn input { width: auto; }
.chk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.chk-grid label { font-size: 13px; color: var(--text-2); align-items: flex-start; }
@media (max-width: 420px) { .chk-grid { grid-template-columns: 1fr; } }

/* Read-only finished-document view */
.ro-row { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--hairline); }
.ro-row:last-child { border-bottom: none; }
.ro-k { width: 40%; color: var(--muted); font-size: 13px; font-weight: 600; }
.ro-v { flex: 1; font-size: 14px; white-space: pre-wrap; }
.ro-note { display: flex; gap: 8px; padding: 6px 0; font-size: 14px; }
.ro-note span { color: var(--green); font-weight: 700; }
.ro-cap { font-size: 12px; color: var(--muted); padding: 6px; text-align: center; }

/* Inline PDF preview (bottom of every saved/finished document) */
#pdfprev-wrap { margin-top: 14px; }
.pdfprev { background: var(--topbar); border-radius: 12px; padding: 10px; }
.pdfpage { display: block; width: 100%; height: auto; background: #fff; border-radius: 6px; margin: 0 0 10px; box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.pdfpage:last-child { margin-bottom: 0; }

/* Custom form upload (📐 Custom Forms) */
.dropzone { border: 2px dashed #3a3a3a; border-radius: 14px; padding: 26px 14px; text-align: center; margin-top: 12px; transition: border-color .15s, background .15s; }
.dropzone.drag { border-color: var(--green); background: #16241b; }
.fc-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 760px) { .fc-split { grid-template-columns: 1fr; } }

/* Hover hints. Desktop only — attachTips() never binds on a touch device,
   and the native title is parked in data-tip so tooltips can't double up. */
.tip {
  position: fixed; z-index: 300; pointer-events: none;
  background: #f4f4f4; color: #161616;
  font-size: 12.5px; font-weight: 600; line-height: 1.3;
  padding: 6px 9px; border-radius: 7px; max-width: 240px;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(2px); transition: opacity .12s, transform .12s;
}
.tip.show { opacity: 1; transform: translateY(0); }

/* ---- v105: a Viewer changes nothing. The server refuses their writes;
 * this keeps the screen honest about it. ---- */
body.role-viewer #new-project, body.role-viewer #app .btn-green, body.role-viewer #app .btn-danger,
body.role-viewer #app [data-del], body.role-viewer #app [data-del-person], body.role-viewer #app [data-menu],
body.role-viewer #app .icon-btn[title="Delete"], body.role-viewer #app [data-rm] { display: none !important; }
body.role-viewer #app input:not([data-nav]), body.role-viewer #app textarea, body.role-viewer #app select:not([data-nav]) { pointer-events: none; opacity: .8; }

/* ===================================================================
 * THE PERSON PAGE, AT THREE SIZES
 *
 * One set of cards, three shapes. The phone keeps exactly what it had —
 * a single column of cards, thumb-sized, nothing rearranged — because
 * that is what the field uses all day. A tablet gets two columns where
 * there is room. A desktop gets the wide layout: details on the left,
 * access on the right, and Customize Access as a side panel instead of a
 * dialog floating in the middle of a 27-inch screen.
 * =================================================================== */
.person-page { display: block; }
.person-head { display: flex; align-items: center; gap: 14px; }
.person-head .avatar { width: 54px; height: 54px; border-radius: 50%; background: #3a3a3a; color: #e8e8e8;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; flex: none; }
.person-head .grow { flex: 1; min-width: 0; }
.person-head h1 { font-size: 21px; }
.person-contact { display: none; font-size: 13px; text-align: right; }
.card-h { margin: 0 0 6px; font-size: 15px; }
.person-cols { display: block; }
.field-grid { display: block; }
.dist-grid { display: block; }
.person-actions { display: block; }
.person-actions .btn { margin-bottom: 10px; }

/* --- tablet: two columns where the width allows, cards stay cards --- */
@media (min-width: 760px) {
  .person-contact { display: block; }
  .field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
  .dist-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
  .person-actions { display: flex; gap: 12px; }
  .person-actions .btn { margin-bottom: 0; }
}

/* --- desktop: details and access side by side --- */
@media (min-width: 1100px) {
  .person-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
  .person-side { position: sticky; top: 12px; }
  .field-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ===================================================================
 * A DIALOG THAT IS REALLY A PANEL
 *
 * Long, settings-shaped dialogs (Customize Access) read badly as a small
 * box in the middle of a big screen. Marked `drawer`, the same dialog is:
 *   phone   — the centred, height-capped dialog every other one uses
 *   tablet  — a sheet that slides up from the bottom, thumb-reachable
 *   desktop — a full-height panel down the right-hand side
 * It is the same element with the same contents; only where it sits
 * changes, so there is one implementation and one set of handlers.
 * =================================================================== */
@media (min-width: 760px) and (max-width: 1099px) {
  .modal-back.drawer { align-items: flex-end; padding: 0; }
  .modal-back.drawer > .modal { max-width: 100%; border-radius: 18px 18px 0 0; max-height: 88vh; max-height: 88dvh; padding: 18px 20px; }
  .modal-back.drawer > .modal::before { content: ''; display: block; width: 44px; height: 4px; border-radius: 2px;
    background: #4a4a4a; margin: -6px auto 12px; }
}
@media (min-width: 1100px) {
  .modal-back.drawer { align-items: stretch; justify-content: flex-end; padding: 0; }
  .modal-back.drawer > .modal { max-width: 470px; width: 470px; height: 100%; max-height: 100%;
    border-radius: 0; padding: 22px 24px; }
  .modal-back.drawer > .modal .modal-actions { bottom: -22px; padding: 12px 0 22px; }
}

/* --- Customize access: rows of one control each, readable at any width --- */
.cfg-sec { border-top: 1px solid var(--hairline); padding: 12px 0 4px; }
.cfg-sec:first-child { border-top: 0; padding-top: 0; }
.cfg-sec-h { font-weight: 800; font-size: 13.5px; margin: 0 0 6px; }
.cfg-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--hairline-2); }
.cfg-row:last-child { border-bottom: 0; }
.cfg-row-t { flex: 1; min-width: 0; }
.cfg-row select { width: auto; flex: none; max-width: 48%; font-size: 12.5px; margin: 0; }
.cfg-pick { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 3px 0; }

/* --- App access card: the summary the admin reads first --- */
.acc-rows { border-top: 1px solid var(--hairline); margin-top: 8px; }
.acc-row { display: flex; gap: 10px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--hairline-2); }
.acc-k { color: var(--muted); font-size: 12.5px; flex: none; min-width: 42%; }
.acc-v { font-size: 13px; font-weight: 600; text-align: right; flex: 1; }
.acc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.acc-chips .chip { font-size: 11.5px; }

/* The rail and breadcrumb do not exist below desktop width — the topbar is
 * the navigation there. Declared BEFORE the media query so the desktop rules
 * win on source order; a media query adds no specificity of its own. */
.rail, .crumb { display: none; }

/* ===================================================================
 * THE DESKTOP SHELL
 *
 * Above 1100px the app stops being a phone screen stretched wide and
 * becomes a desktop application: a fixed left rail of navigation, a
 * breadcrumb, and a wide content column on a light background.
 *
 * Everything below 1100px is untouched — the phone and the iPad keep the
 * dark, single-column, thumb-reachable app the field already uses. That is
 * the whole point: this is a second presentation of the same screens, not
 * a replacement for the first.
 * =================================================================== */
@media (min-width: 1100px) {
  :root {
    --bg: #f4f6f7; --surface: #ffffff; --surface2: #eef1f3; --border: #d9dfe3;
    --text: #0e1a13; --muted: #64736b; --danger: #b3382c;
    --topbar: #ffffff; --topbar-line: #e4e9ec;
    --text-2: #2f3d36; --text-3: #47564e; --text-4: #5a685f;
    --hairline: #e7ecef; --hairline-2: #eef1f3; --fill: #dde4e8;
    --green: #1f9d4d; --green-d: #e6f4ec;
    --ok-bg: #e6f4ec; --ok-fg: #14683a; --warn-bg: #fdf3d8; --warn-fg: #8a5b0c;
    --info-bg: #e5edf8; --info-fg: #1f4f8f;
    --btn-face: #16241c;
    --card-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  }

  /* The rail is fixed; the page is pushed over to clear it. */
  body { padding-left: 220px; }
  .topbar { display: none; }

  .rail {
    position: fixed; inset: 0 auto 0 0; width: 220px; z-index: 30;
    background: #0e1a13; color: #e8efea; display: flex; flex-direction: column;
  }
  .rail-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 22px; }
  .rail-brand .mark { width: 30px; height: 30px; flex: none; }
  .rail-brand b { font-size: 15px; font-weight: 800; letter-spacing: .02em; line-height: 1.1; }
  .rail-brand b span { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .22em; color: #8fd3b0; }
  .rail-nav { flex: 1; overflow-y: auto; padding: 0 10px; }
  .rail-nav a {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; margin-bottom: 2px;
    border-radius: 8px; color: #b8c7bf; font-size: 14px; font-weight: 600;
    text-decoration: none; cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  }
  .rail-nav a .ic { width: 18px; text-align: center; flex: none; font-size: 15px; }
  .rail-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
  .rail-nav a.on { background: rgba(255,255,255,.10); color: #fff; }
  .rail-foot {
    display: flex; align-items: center; gap: 10px; padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.10); cursor: pointer;
    background: none; border-left: 0; border-right: 0; border-bottom: 0; color: inherit; font: inherit; text-align: left;
  }
  .rail-foot .av {
    width: 32px; height: 32px; border-radius: 50%; flex: none; background: var(--green);
    color: #fff; font-weight: 800; font-size: 12.5px; display: flex; align-items: center; justify-content: center;
  }
  .rail-foot .nm { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; line-height: 1.25; }
  .rail-foot .nm span { display: block; font-size: 11.5px; font-weight: 600; color: #8fa89a; }

  .crumb {
    display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted);
    padding: 16px 32px 0; max-width: 1180px; margin: 0; font-weight: 600;
  }
  .crumb a { color: var(--muted); text-decoration: none; cursor: pointer; }
  .crumb a:hover { color: var(--text); text-decoration: underline; }
  .crumb .sep { opacity: .55; }
  .crumb b { color: var(--text); font-weight: 700; }

  /* Left-aligned against the rail, not centred in what is left over — a
   * column floating in the middle of a wide screen reads as a mistake. */
  #app { max-width: 1180px; margin: 0; padding: 10px 32px 48px; }

  /* Settings is in the rail. The button that used to be the only way in is
   * redundant here, so it steps aside — on a phone it is still the way in.
   * Hidden, not removed: everything that looks for it still finds it. */
  #go-hub { display: none; }
  #app > .row:empty, #app > .row:has(> #go-hub:only-child) { display: none; }

  /* On the dark theme a green heading reads as a section marker. On white it
   * reads as a link. Headings become ink; green stays on what is actionable. */
  h2, .card-h { color: var(--text); }
  h1 { font-size: 26px; }
  .card { padding: 18px 20px; border-radius: 12px; box-shadow: var(--card-shadow); border: 1px solid var(--border); }
  .card-h { font-size: 15.5px; font-weight: 800; }

  /* Explanatory text gets a readable measure. A sentence running the full
   * 1180px is hard to track back to the start of the next line. */
  #app > .muted, #app > p, .card > .muted, .card-h + .muted { max-width: 88ch; }

  /* A page-level action is a button, not a banner. Full width is right under
   * a thumb and absurd across 1180px, so block buttons that sit directly on
   * the page get their natural size back. Inside a card or a dialog they
   * keep filling their container, which is what they are for. */
  #app > .btn-block, #app > .row > .btn { width: auto; min-width: 190px; }
  #app > .row { justify-content: flex-start; gap: 10px; }
  #app > .row > .btn { flex: none; }

  /* A button needs an edge on white — a pale fill alone has none. */
  .btn { border: 1px solid var(--border); }
  .btn-green { border-color: var(--green); }
  .btn-ghost { background: var(--surface); }
  input, select, textarea { background: var(--surface); border-color: var(--border); }
}
