/* ==========================================================================
   Escape Hunt Secure Sign design system
   ========================================================================== */
:root {
  --font: 'Work Sans Variable', 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --script: 'Great Vibes', 'Snell Roundhand', cursive;

  --bg: #f6f5f3;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --surface-3: #f1efec;
  --ink: #1c1c1c;
  --ink-2: #3d3d3d;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --line: #e7e4e0;
  --line-strong: #d4d0ca;

  /* Escape Hunt orange. The brand's own #fd6631 is used where nothing is written on it; buttons and
     links use a deeper shade of it so white text and orange text stay readable (WCAG AA). */
  --brand: #fd6631;
  --brand-dark: #1c1c1c;
  --accent: #cc4410;
  --accent-hover: #b93d0e;
  --accent-press: #a5360c;
  --accent-soft: #fff1ea;
  --accent-soft-2: #ffe0d1;
  --accent-ring: rgba(253, 102, 49, 0.32);
  --accent-ink: #ffffff;

  --ok: #067647;  --ok-soft: #ecfdf3;  --ok-line: #abefc6;
  --warn: #b54708; --warn-soft: #fffaeb; --warn-line: #fedf89;
  --bad: #b42318; --bad-soft: #fef3f2; --bad-line: #fecdca;
  --info: #175cd3; --info-soft: #eff8ff; --info-line: #b2ddff;

  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --shadow-xs: 0 1px 2px rgba(28, 28, 28, 0.05);
  --shadow-sm: 0 1px 3px rgba(28, 28, 28, 0.08), 0 1px 2px rgba(28, 28, 28, 0.04);
  --shadow-md: 0 10px 24px -8px rgba(28, 28, 28, 0.14), 0 2px 6px rgba(28, 28, 28, 0.05);
  --shadow-lg: 0 28px 56px -16px rgba(28, 28, 28, 0.28), 0 4px 12px rgba(28, 28, 28, 0.06);

  --header-h: 60px;
  --tabbar-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
  --chrome: rgba(255, 255, 255, 0.86);   /* translucent bars over scrolling content */
  --inverse: #1c1c1c;                    /* toasts, the signing guide */
  --inverse-ink: #ffffff;
}

/* Dark theme: follows the device, unless chosen on the Account page (stored on this device). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121212;
    --surface: #1c1c1c;
    --surface-2: #212121;
    --surface-3: #2a2a2a;
    --ink: #f5f5f4;
    --ink-2: #d6d4d1;
    --muted: #a3a09c;
    --faint: #75726e;
    --line: #2e2d2b;
    --line-strong: #3d3b38;

    --accent: #fd6631;
    --accent-hover: #ff7a4b;
    --accent-press: #e95a27;
    --accent-soft: rgba(253, 102, 49, 0.14);
    --accent-soft-2: rgba(253, 102, 49, 0.26);
    --accent-ring: rgba(253, 102, 49, 0.4);
    --accent-ink: #1c1c1c;

    --ok: #47cd89;  --ok-soft: rgba(71, 205, 137, 0.12);  --ok-line: rgba(71, 205, 137, 0.34);
    --warn: #fdb022; --warn-soft: rgba(253, 176, 34, 0.12); --warn-line: rgba(253, 176, 34, 0.34);
    --bad: #f97066; --bad-soft: rgba(249, 112, 102, 0.12); --bad-line: rgba(249, 112, 102, 0.34);
    --info: #53b1fd; --info-soft: rgba(83, 177, 253, 0.12); --info-line: rgba(83, 177, 253, 0.34);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 24px -8px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 28px 56px -16px rgba(0, 0, 0, 0.75), 0 4px 12px rgba(0, 0, 0, 0.4);

    --chrome: rgba(28, 28, 28, 0.88);
    --inverse: #2f2e2c;
    --inverse-ink: #ffffff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121212;
  --surface: #1c1c1c;
  --surface-2: #212121;
  --surface-3: #2a2a2a;
  --ink: #f5f5f4;
  --ink-2: #d6d4d1;
  --muted: #a3a09c;
  --faint: #75726e;
  --line: #2e2d2b;
  --line-strong: #3d3b38;

  --accent: #fd6631;
  --accent-hover: #ff7a4b;
  --accent-press: #e95a27;
  --accent-soft: rgba(253, 102, 49, 0.14);
  --accent-soft-2: rgba(253, 102, 49, 0.26);
  --accent-ring: rgba(253, 102, 49, 0.4);
  --accent-ink: #1c1c1c;

  --ok: #47cd89;  --ok-soft: rgba(71, 205, 137, 0.12);  --ok-line: rgba(71, 205, 137, 0.34);
  --warn: #fdb022; --warn-soft: rgba(253, 176, 34, 0.12); --warn-line: rgba(253, 176, 34, 0.34);
  --bad: #f97066; --bad-soft: rgba(249, 112, 102, 0.12); --bad-line: rgba(249, 112, 102, 0.34);
  --info: #53b1fd; --info-soft: rgba(83, 177, 253, 0.12); --info-line: rgba(83, 177, 253, 0.34);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 24px -8px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 28px 56px -16px rgba(0, 0, 0, 0.75), 0 4px 12px rgba(0, 0, 0, 0.4);

  --chrome: rgba(28, 28, 28, 0.88);
  --inverse: #2f2e2c;
  --inverse-ink: #ffffff;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11';
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -0.022em; }
h2 { font-size: 17px; line-height: 1.35; }
h3 { font-size: 15px; line-height: 1.4; }
p { margin: 0; text-wrap: pretty; }
h1, h2, .lede, .empty p, .dialog-head .sub { text-wrap: balance; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
img, svg { display: block; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
::selection { background: var(--accent-soft-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Utilities ---------- */
/* Small links to the privacy notice, on signing pages, the Verify page and Account */
.privacy-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line-strong); }
.privacy-link:hover { color: var(--accent); text-decoration-color: currentColor; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.xsmall { font-size: 12px; }
.strong { font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.nums { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0 !important; min-width: 0 !important; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.tight { gap: 6px; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 22px; }

/* ---------- App header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 28px;
  /* Escape Hunt's black bar, in both themes */
  background: var(--brand-dark);
  border-bottom: 1px solid #000;
  color: #fff;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); font-weight: 600; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; flex: none; }
.brand:hover { color: var(--ink); text-decoration: none; }
.app-header .brand, .app-header .brand:hover { color: #fff; }
.brand-logo { display: block; height: 26px; width: auto; }
.brand-divider { width: 1px; height: 22px; background: rgba(255, 255, 255, 0.3); }
/* On tablets the menu loses its icons, so the logo and name keep their room. */
@media (min-width: 721px) and (max-width: 1040px) { .app-header .nav a .icon { display: none; } }
@media (min-width: 721px) and (max-width: 900px) { .app-header .proto-tag, .app-header .user-button .user-name { display: none; } }
.nav { display: flex; gap: 2px; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: var(--r-sm);
  color: rgba(255, 255, 255, 0.68); font-size: 14px; font-weight: 550;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.nav a.active { color: #fff; background: rgba(255, 255, 255, 0.12); }
.nav a.active .icon { color: var(--brand); }
.nav a .icon { width: 17px; height: 17px; }
.header-end { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.proto-tag {
  font-size: 12px; font-weight: 550; color: var(--warn);
  background: var(--warn-soft); border: 1px solid var(--warn-line);
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}
.secure-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: rgba(255, 255, 255, 0.72); white-space: nowrap; }
.secure-tag .icon { width: 15px; height: 15px; color: #47cd89; }
.app-header .proto-tag { color: #fdb022; background: rgba(253, 176, 34, 0.12); border-color: rgba(253, 176, 34, 0.34); }
@media (max-width: 440px) { .secure-tag > span { display: none; } } /* the lock alone, beside the longer name */

/* User menu */
.user-menu { position: relative; }
.user-button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 8px 4px 4px; border-radius: 99px;
  border: 1px solid transparent; background: transparent; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 550; color: var(--ink);
}
.user-button:hover, .user-button[aria-expanded='true'] { background: var(--surface-3); }
.user-button .icon { width: 16px; height: 16px; color: var(--muted); }
.app-header .user-button { color: #fff; }
.app-header .user-button:hover, .app-header .user-button[aria-expanded='true'] { background: rgba(255, 255, 255, 0.1); }
.app-header .user-button .icon { color: rgba(255, 255, 255, 0.6); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-md);
}
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 7px; background: none;
  font: inherit; font-size: 14px; color: var(--ink-2); text-align: left; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.menu .icon { width: 17px; height: 17px; color: var(--muted); }

/* Avatar */
.avatar {
  --c: var(--accent);
  flex: none; display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
  color: color-mix(in srgb, var(--c) 82%, var(--ink));
  font-size: 12.5px; font-weight: 650; letter-spacing: 0.01em;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.xs { width: 18px; height: 18px; font-size: 8px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14.5px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -7px; }

/* Mobile tab bar (installed app feel on phones) */
.tabbar { display: none; }

/* ---------- Page layout ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 32px 28px 72px; }
.page.narrow { max-width: 760px; }
.page-header { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-header .lede { margin-top: 4px; color: var(--muted); }
.page-header .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; font-weight: 550; margin-bottom: 12px; }
.back-link:hover { color: var(--ink); text-decoration: none; }
.back-link .icon { width: 16px; height: 16px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.card + .card { margin-top: 20px; }
.card-pad { padding: 22px 24px; }
.card-header { display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.card-header .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-body { padding: 20px 24px; }
.card-footer { padding: 14px 24px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.section-title { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }

/* ---------- Icons ---------- */
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Buttons ---------- */
.btn {
  --h: 38px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 15px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1; white-space: nowrap;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs); cursor: pointer; text-decoration: none;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, color 0.12s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); box-shadow: 0 1px 2px rgba(28, 28, 28, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.btn-primary:hover { color: var(--accent-ink); background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }
.btn-danger { color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { color: var(--bad); background: var(--bad-soft); }
.btn-danger-solid { color: #fff; background: #d92d20; border-color: #d92d20; }
.btn-danger-solid:hover { color: #fff; background: #b42318; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-link { height: auto; padding: 0; border: 0; background: none; box-shadow: none; color: var(--accent); font-weight: 550; }
.btn-link:hover { background: none; color: var(--accent-hover); text-decoration: underline; }
.btn-sm { --h: 32px; padding: 0 11px; font-size: 13px; }
.btn-lg { --h: 46px; padding: 0 20px; font-size: 15px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn-icon { width: var(--h); padding: 0; }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--spinner, var(--muted)) transparent var(--spinner, var(--muted)) transparent;
  animation: spin 0.7s linear infinite;
}
.btn-primary.loading::after, .btn-danger-solid.loading::after { --spinner: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: block; }
.field + .field { margin-top: 16px; }
.label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.label .opt { font-weight: 450; color: var(--faint); }
.help { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.field-error { font-size: 13px; color: var(--bad); margin-top: 6px; }
input[type=text], input[type=email], input[type=url], input[type=password], input[type=number], input[type=search], input[type=datetime-local], textarea, select {
  width: 100%; height: 40px; padding: 0 12px;
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.12s, box-shadow 0.12s;
  -webkit-appearance: none; appearance: none;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select {
  padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
input[aria-invalid='true'] { border-color: #f97066; }
input[readonly] { background: var(--surface-2); color: var(--muted); }
.input-sm { height: 34px !important; font-size: 14px !important; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14.5px; color: var(--ink-2); line-height: 1.45; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; cursor: pointer; }
@media (max-width: 720px) {
  input[type=text], input[type=email], input[type=url], input[type=password], input[type=number], input[type=search], input[type=datetime-local], textarea, select { font-size: 16px; } /* stops iOS zooming on focus */
}

/* ---------- Status pills ---------- */
.pill {
  --tone: var(--muted); --tone-bg: var(--surface-3);
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px 0 8px; border-radius: 99px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--tone); background: var(--tone-bg);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.no-dot::before { display: none; }
.pill.info { --tone: var(--info); --tone-bg: var(--info-soft); }
.pill.accent { --tone: var(--accent); --tone-bg: var(--accent-soft); }
.pill.ok { --tone: var(--ok); --tone-bg: var(--ok-soft); }
.pill.warn { --tone: var(--warn); --tone-bg: var(--warn-soft); }
.pill.bad { --tone: var(--bad); --tone-bg: var(--bad-soft); }

/* ---------- Notices ---------- */
.notice {
  --tone: var(--info); --tone-bg: var(--info-soft); --tone-line: var(--info-line);
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 15px; border-radius: var(--r);
  background: var(--tone-bg); border: 1px solid var(--tone-line);
  font-size: 14px; color: var(--ink-2); line-height: 1.5;
}
.notice > .icon { color: var(--tone); width: 19px; height: 19px; margin-top: 1px; }
.notice strong { color: var(--ink); }
.notice.ok { --tone: var(--ok); --tone-bg: var(--ok-soft); --tone-line: var(--ok-line); }
.notice.warn { --tone: var(--warn); --tone-bg: var(--warn-soft); --tone-line: var(--warn-line); }
.notice.bad { --tone: var(--bad); --tone-bg: var(--bad-soft); --tone-line: var(--bad-line); }
.notice .notice-body { flex: 1; min-width: 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
th:first-child { padding-left: 24px; } th:last-child { padding-right: 24px; }
td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td:first-child { padding-left: 24px; } td:last-child { padding-right: 24px; }
tbody tr:last-child td { border-bottom: 0; }
.kv { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 0; }
.kv > div { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.kv .k { color: var(--muted); padding-right: 16px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 10px 12px; margin-bottom: -1px;
  font: inherit; font-size: 14px; font-weight: 550; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab .count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-3); padding: 1px 7px; border-radius: 99px; }
.tab.active .count { color: var(--accent); background: var(--accent-soft); }
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 9px; }
.segmented button {
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted);
  padding: 6px 14px; border: 0; border-radius: 7px; background: none; cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- Empty and loading states ---------- */
.empty { text-align: center; padding: 56px 24px; }
.empty .empty-icon {
  width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 14px;
  display: grid; place-items: center; color: var(--accent);
  background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-soft-2);
}
.empty .empty-icon .icon { width: 24px; height: 24px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 400px; margin: 0 auto 20px; }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--line) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.loading-block { display: grid; place-items: center; gap: 12px; padding: 64px 0; color: var(--muted); font-size: 14px; }

/* ---------- Progress ---------- */
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s ease; }
.progress.ok > span { background: #17b26a; }

/* ---------- Dropzone ---------- */
.dropzone {
  display: block; position: relative; cursor: pointer; text-align: center;
  padding: 36px 24px; border-radius: var(--r-lg);
  border: 1.5px dashed var(--line-strong); background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .dz-icon { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.dropzone .dz-title { font-weight: 600; color: var(--ink); }
.dropzone .dz-title span { color: var(--accent); }
.dropzone .dz-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.file-chip .file-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--bad-soft); color: var(--bad); flex: none; }

/* ---------- Dialogs ---------- */
dialog.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 0; border-radius: var(--r-xl);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  overflow: auto;
}
dialog.dialog.wide { width: min(680px, calc(100vw - 32px)); }
dialog.dialog::backdrop { background: rgba(28, 28, 28, 0.48); backdrop-filter: blur(3px); }
dialog.dialog[open] { animation: dialog-in 0.18s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dialog-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px 0; }
.dialog-head h2 { font-size: 18px; }
.dialog-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.dialog-head .tone-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.dialog-head .tone-icon.bad { background: var(--bad-soft); color: var(--bad); }
.dialog-head .tone-icon.ok { background: var(--ok-soft); color: var(--ok); }
.dialog-close { margin: -6px -8px 0 auto; }
.dialog-body { padding: 18px 24px 4px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 24px 22px; flex-wrap: wrap-reverse; }
@media (max-width: 560px) {
  dialog.dialog, dialog.dialog.wide {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: calc(100dvh - 24px); padding-bottom: var(--safe-bottom);
  }
  dialog.dialog[open] { animation: sheet-in 0.22s ease-out; }
  .dialog-foot .btn { flex: 1; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0.6; } }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--r);
  background: var(--inverse); color: var(--inverse-ink); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toast-in 0.2s ease-out;
}
.toast .icon { width: 18px; height: 18px; color: #75e0a7; }
.toast.bad .icon { color: #fda29b; }
.toast.out { opacity: 0; transform: translateY(6px); transition: all 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ---------- PDF pages and fields (shared) ---------- */
.doc { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 28px 20px 96px; }
.page-sheet { position: relative; width: 100%; background: #fff; border-radius: 2px; box-shadow: 0 1px 3px rgba(28, 28, 28, 0.1), 0 8px 24px -6px rgba(28, 28, 28, 0.12); }
.page-sheet canvas { display: block; width: 100%; height: 100%; border-radius: 2px; }
.page-sheet .overlay { position: absolute; inset: 0; }
.page-sheet .page-num { position: absolute; left: 0; right: 0; bottom: -20px; text-align: center; font-size: 11.5px; color: var(--faint); font-weight: 500; }
.f {
  --c: var(--accent);
  position: absolute; container-type: size;
  display: flex; align-items: center; gap: 4px; padding: 0 5px;
  border: 1.5px solid var(--c); border-radius: 4px;
  background: color-mix(in srgb, var(--c) 13%, rgba(255, 255, 255, 0.6));
  color: color-mix(in srgb, var(--c) 78%, black);
  font-size: 12px; font-weight: 650; line-height: 1;
  overflow: hidden; white-space: nowrap; user-select: none; -webkit-user-select: none;
}
/* Sized against the field box itself (children can use its container units; the box can't). */
.f > .f-label { font-size: clamp(6px, 58cqh, 13px); overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.f > .icon { width: clamp(7px, 60cqh, 15px); height: clamp(7px, 60cqh, 15px); stroke-width: 2.2; pointer-events: none; flex: none; }
@container (max-width: 40px) { .f > .icon + .f-label { display: none; } }

/* ---------- Auth pages ---------- */
.auth-shell {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 16px;
  /* Escape Hunt's dark backdrop with a warm glow, in both themes */
  background:
    radial-gradient(900px 420px at 50% -100px, rgba(253, 102, 49, 0.2), transparent 70%),
    #141414;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; text-align: center; color: #fff; }
.auth-brand .brand-logo { height: 46px; }
.auth-brand .product { font-size: 13px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255, 255, 255, 0.78); }
.auth-shell .auth-card { box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6); }
.auth-card { width: 100%; max-width: 420px; padding: 30px 32px 32px; }
.auth-card h1 { font-size: 22px; text-align: center; }
.auth-card .lede { text-align: center; color: var(--muted); margin: 6px 0 24px; font-size: 14.5px; }
.auth-foot { margin-top: 24px; font-size: 13px; color: rgba(255, 255, 255, 0.62); text-align: center; display: flex; align-items: center; gap: 6px; }
.auth-foot .icon { width: 15px; height: 15px; color: #47cd89; }
.auth-foot a { color: rgba(255, 255, 255, 0.85); }
.strength { display: flex; gap: 4px; margin-top: 8px; }
.strength span { flex: 1; height: 4px; border-radius: 99px; background: var(--surface-3); transition: background 0.2s; }
.strength[data-score='1'] span:nth-child(-n+1) { background: #f04438; }
.strength[data-score='2'] span:nth-child(-n+2) { background: #f79009; }
.strength[data-score='3'] span:nth-child(-n+3) { background: #17b26a; }
.strength[data-score='4'] span { background: #079455; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-header { padding: 0 20px; gap: 18px; }
  .page { padding: 24px 20px 64px; }
}
@media (max-width: 720px) {
  :root { --header-h: 56px; }
  body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
  .app-header { padding: 0 16px; }
  .app-header .nav, .app-header .proto-tag { display: none; }
  .user-button .user-name, .user-button .chev { display: none; }
  .user-button { padding: 2px; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: var(--chrome); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--muted); }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar a:hover { text-decoration: none; }
  .page { padding: 20px 16px 40px; }
  .page-header { margin-bottom: 18px; }
  .page-header .actions { margin-left: 0; width: 100%; }
  h1 { font-size: 23px; }
  .card-header, .card-body { padding-left: 18px; padding-right: 18px; }
  .card-pad { padding: 18px; }
  th:first-child, td:first-child { padding-left: 18px; } th:last-child, td:last-child { padding-right: 18px; }
  .kv { grid-template-columns: 1fr; }
  .kv > div { border-bottom: 0; padding: 0; }
  .kv .k { padding-top: 12px; font-size: 12.5px; }
  .kv .v { padding-bottom: 12px; border-bottom: 1px solid var(--line) !important; }
  .kv .v:last-child { border-bottom: 0 !important; }
  .auth-card { padding: 24px 20px; }
  .doc { padding: 16px 10px 120px; gap: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Two-step verification ---------- */
.auth-icon {
  width: 52px; height: 52px; margin: 0 auto 16px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
  box-shadow: 0 0 0 6px rgba(253, 102, 49, 0.06);
}
.auth-icon.ok { background: var(--ok-soft); color: var(--ok); box-shadow: 0 0 0 6px rgba(6, 118, 71, 0.06); }
.auth-icon.warn { background: var(--warn-soft); color: var(--warn); box-shadow: 0 0 0 6px rgba(181, 71, 8, 0.06); }
.auth-icon.bad { background: var(--bad-soft); color: var(--bad); box-shadow: 0 0 0 6px rgba(180, 35, 24, 0.06); }
.auth-actions { display: grid; gap: 8px; margin-top: 22px; }
.auth-card .step-error:not(:empty) { margin-top: 16px; }
.dialog-body .step-error:not(:empty) { margin-top: 16px; }
.signing-in-as { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.signing-in-as strong { color: var(--ink-2); font-weight: 600; }

input.code-input[type=text] {
  height: 58px; padding: 0 12px 0 calc(12px + 0.42em);
  font-size: 28px; font-weight: 600; letter-spacing: 0.42em; text-align: center;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
input.code-input[type=text]::placeholder { color: var(--line-strong); }
input.code-input.recovery[type=text] { font-family: var(--mono); font-size: 20px; font-weight: 500; letter-spacing: 0.08em; padding-left: 12px; }
.setup-steps input.code-input[type=text] { height: 52px; font-size: 24px; }

.code-links { display: flex; justify-content: center; gap: 6px 20px; flex-wrap: wrap; margin-top: 18px; }
.lost-phone { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); text-align: center; }
.lost-phone summary { cursor: pointer; font-weight: 550; color: var(--ink-2); list-style: none; }
.lost-phone summary::-webkit-details-marker { display: none; }
.lost-phone summary::after { content: ' ›'; color: var(--faint); }
.lost-phone[open] summary::after { content: ''; }
.lost-phone p { margin: 8px 0 0; line-height: 1.55; text-align: left; }

.setup-steps { list-style: none; counter-reset: setup; margin: 4px 0 0; padding: 0; display: grid; gap: 22px; }
.setup-steps > li { counter-increment: setup; position: relative; padding-left: 40px; min-width: 0; }
.setup-steps > li::before {
  content: counter(setup); position: absolute; left: 0; top: -2px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700;
}
.setup-step-title { display: block; font-size: 14.5px; font-weight: 600; color: var(--ink); line-height: 1.4; }
.qr-block { display: flex; align-items: center; gap: 18px; margin-top: 12px; flex-wrap: wrap; }
.qr { width: 148px; height: 148px; padding: 10px; flex: none; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-xs); }
.setup-key { flex: 1 1 170px; min-width: 0; }
.key-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.setup-key-value { font-size: 13px; line-height: 1.6; letter-spacing: 0.04em; padding: 4px 8px; word-break: break-all; color: var(--ink); }
.qr-details { margin-top: 12px; font-size: 13px; color: var(--muted); }
.qr-details summary { cursor: pointer; }

.recovery-codes {
  list-style: none; margin: 16px 0 14px; padding: 16px 18px;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--mono); font-size: 15px; letter-spacing: 0.05em; color: var(--ink); text-align: center;
}
.recovery-codes li { white-space: nowrap; }

.why-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.why-list li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--ink-2); line-height: 1.5; }
.why-list .icon { width: 18px; height: 18px; color: var(--accent); flex: none; margin-top: 2px; }
.auth-card .setup-steps { margin-top: 0; }

@media (max-width: 560px) {
  .setup-steps > li { padding-left: 36px; }
  .qr-block { gap: 12px; }
  .recovery-codes { gap: 10px 12px; padding: 14px 12px; font-size: 14px; }
}

/* Small tag beside a name: "Admin", a template role such as "Client", "Shared". */
.role-tag { flex: none; font-size: 11px; font-weight: 650; letter-spacing: 0.02em; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 1px 6px; }

/* "or" between two ways of doing something */
.or-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 14px; font-size: 12.5px; color: var(--faint); font-weight: 550; text-transform: uppercase; letter-spacing: 0.04em; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.file-list { display: grid; gap: 8px; max-height: 260px; overflow-y: auto; }

/* Break between documents in an envelope with several */
.doc-num { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 650; }
.doc-break { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 900px; padding: 4px 2px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); min-width: 0; }
.doc-break .muted { font-weight: 450; margin-left: auto; white-space: nowrap; }
.doc-break .doc-num { background: var(--accent-soft); color: var(--accent); }
.doc-break:not(:first-child) { margin-top: 18px; }

/* Larger segmented choice with icons (Account → Appearance) */
.segmented.lg { gap: 4px; padding: 4px; border-radius: var(--r); flex-wrap: wrap; }
.segmented.lg button { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: var(--r-sm); font-size: 14px; font-weight: 550; }
.segmented.lg button .icon { width: 16px; height: 16px; }
.segmented button:hover { color: var(--ink); }
@media (max-width: 560px) { .segmented.lg { display: flex; } .segmented.lg button { flex: 1 1 auto; justify-content: center; } }

/* ---------- Single sign-on on the sign-in page ---------- */
.auth-alternatives { display: grid; gap: 10px; }
.sso-btn .icon { width: 18px; height: 18px; }
.role-tag.neutral { color: var(--ink-2); background: var(--surface-3); }
.check.is-disabled { cursor: default; opacity: 0.55; }
.check.is-disabled input { cursor: default; }

/* A button that's just an icon (it carries an aria-label). */
.btn.icon-only { width: 32px; padding: 0; justify-content: center; flex: none; }

/* Envelopes: administrators' "Mine / Everyone's" switch, and whose envelope each row is. */
.scope-switch button { height: 32px; padding: 0 12px; font-size: 13.5px; font-weight: 550; }
.env-owner { color: var(--ink-2); font-weight: 550; }
.owner-tag { display: inline-flex; align-items: center; gap: 6px; }

/* When to send: now, or later */
.send-when { margin-top: 18px; }
.send-when .label { display: block; }
.send-when-at { margin-top: 10px; display: grid; gap: 6px; max-width: 320px; }
