/* contact.morais.co + helpdesk.morais.co/rladmin/ — shared stylesheet
   Every color, radius, spacing and shadow is a token. Components never use raw values. */

/* ---------- 1. Tokens: light (default) ---------- */
:root {
  color-scheme: light;
  --bg: #f6f3ed;
  --surface: #fffdf9;
  --surface-2: #f1ede5;
  --surface-3: #e8e3d9;
  --ink: #1f1d1a;
  --ink-2: #47433c;
  --muted: #5f5a52;
  --line: #e2dcd1;
  --line-strong: #8f8678;
  --house: #2f5d50;
  --on-accent: #ffffff;
  --ok: #2e6b3f;      --ok-bg: #e3efe4;
  --warn: #8a5a00;    --warn-bg: #f8ecd2;
  --danger: #a8321f;  --danger-bg: #f7e1db;
  --note-bg: #fbf2d3; --note-line: #d9bd62; --note-ink: #5c4a10;
  --overlay: rgb(31 29 26 / 0.06);
  --shadow-1: 0 1px 2px rgb(31 29 26 / 0.05), 0 4px 14px rgb(31 29 26 / 0.05);
  --shadow-2: 0 2px 4px rgb(31 29 26 / 0.06), 0 12px 32px rgb(31 29 26 / 0.09);

  /* Accent: the site's accent if the page declares one, else the house accent */
  --accent: var(--site, var(--house));
  --accent-soft: color-mix(in oklab, var(--accent) 9%, var(--surface));
  --accent-line: color-mix(in oklab, var(--accent) 30%, var(--line));
  --accent-hover: color-mix(in oklab, var(--accent) 86%, var(--ink));
  --focus: var(--accent);

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --font-serif: "Iowan Old Style", Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;

  --t-xs: 0.8125rem;  /* 13 */
  --t-sm: 0.875rem;   /* 14 */
  --t-base: 1rem;     /* 16 */
  --t-md: 1.125rem;   /* 18 */
  --t-lg: 1.375rem;   /* 22 */
  --t-xl: 1.75rem;    /* 28 */
  --t-2xl: clamp(2rem, 1.4rem + 2.6vw, 2.5rem); /* 32-40 */
  --t-ref: clamp(2.5rem, 1.6rem + 4vw, 3.5rem); /* 40-56 */
  --lh-tight: 1.2;
  --lh: 1.55;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-pill: 999px;
  --ring: 3px;
  --tap: 44px;
  --dur: 180ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
/* Per-site accent: accents.css sets --site-l / --site-d on [data-site]. */
[data-site] { --site: var(--site-l); }

/* ---------- 2. Tokens: dark (system preference, until the visitor chooses) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141311; --surface: #1c1b18; --surface-2: #25231f; --surface-3: #302d28;
    --ink: #ece8e1; --ink-2: #cdc7bd; --muted: #a8a196;
    --line: #36332d; --line-strong: #7a7366;
    --house: #8cc4b2; --on-accent: #141311;
    --ok: #8fd19e; --ok-bg: #1f3325;
    --warn: #f0c46a; --warn-bg: #3a2e14;
    --danger: #f19a87; --danger-bg: #3d211b;
    --note-bg: #2e2714; --note-line: #7a6626; --note-ink: #f0dc9a;
    --overlay: rgb(255 255 255 / 0.05);
    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 14px rgb(0 0 0 / 0.25);
    --shadow-2: 0 2px 4px rgb(0 0 0 / 0.45), 0 12px 32px rgb(0 0 0 / 0.4);
    --accent-soft: color-mix(in oklab, var(--accent) 12%, var(--surface));
  }
  :root:not([data-theme="light"]) [data-site],
  :root:not([data-theme="light"])[data-site] { --site: var(--site-d); }
}
/* ---------- 3. Tokens: dark (chosen) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141311; --surface: #1c1b18; --surface-2: #25231f; --surface-3: #302d28;
  --ink: #ece8e1; --ink-2: #cdc7bd; --muted: #a8a196;
  --line: #36332d; --line-strong: #7a7366;
  --house: #8cc4b2; --on-accent: #141311;
  --ok: #8fd19e; --ok-bg: #1f3325;
  --warn: #f0c46a; --warn-bg: #3a2e14;
  --danger: #f19a87; --danger-bg: #3d211b;
  --note-bg: #2e2714; --note-line: #7a6626; --note-ink: #f0dc9a;
  --overlay: rgb(255 255 255 / 0.05);
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 14px rgb(0 0 0 / 0.25);
  --shadow-2: 0 2px 4px rgb(0 0 0 / 0.45), 0 12px 32px rgb(0 0 0 / 0.4);
  --accent-soft: color-mix(in oklab, var(--accent) 12%, var(--surface));
}
:root[data-theme="dark"] [data-site],
:root[data-theme="dark"][data-site] { --site: var(--site-d); }

@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0ms; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- 4. 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;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: var(--t-base); line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
h1, h2, h3 { margin: 0; line-height: var(--lh-tight); text-wrap: balance; font-weight: 600; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
svg { flex: none; }
:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: color-mix(in oklab, var(--accent) 25%, transparent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s-4); top: -100px; z-index: 50; background: var(--surface); color: var(--ink); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); box-shadow: var(--shadow-2); }
.skip:focus { top: var(--s-4); }
.js-only { display: none !important; }
.js .js-only { display: revert !important; }
.js .nojs-only { display: none !important; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.serif { font-family: var(--font-serif); }

/* ---------- 5. Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 48px; padding: 0 var(--s-5); border-radius: var(--r-md);
  border: 1px solid transparent; font: inherit; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; text-align: center;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); text-decoration: none; }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--overlay); color: var(--ink); text-decoration: none; }
.btn-danger { background: var(--surface); border-color: var(--line-strong); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); text-decoration: none; }
.btn-sm { min-height: var(--tap); padding: 0 var(--s-4); font-size: var(--t-sm); }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { cursor: not-allowed; background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.btn[aria-busy="true"] { cursor: progress; background: var(--accent); color: var(--on-accent); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); cursor: pointer; padding: 0;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.theme-form { display: contents; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}

.langs { display: flex; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); overflow: hidden; }
.langs a {
  display: grid; place-items: center; min-width: var(--tap); height: var(--tap); padding: 0 var(--s-3);
  font-size: var(--t-sm); font-weight: 600; letter-spacing: 0.02em; color: var(--ink-2); text-decoration: none;
}
.langs a:hover { background: var(--overlay); color: var(--ink); }
.langs a[aria-current="true"] { background: var(--ink); color: var(--surface); }
.langs a:focus-visible { outline-offset: -3px; border-radius: var(--r-pill); }

/* ---------- 6. Forms ---------- */
.form { display: grid; gap: var(--s-5); }
.row-2 { display: grid; gap: var(--s-5); }
@media (min-width: 640px) { .row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.field { display: grid; gap: var(--s-2); align-content: start; }
.field > label, .label { font-weight: 600; font-size: var(--t-sm); color: var(--ink); }
.label-note { font-weight: 400; color: var(--muted); }
.hint { font-size: var(--t-sm); color: var(--muted); }
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: var(--s-3) 14px;
  font: inherit; font-size: var(--t-base); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:hover, .textarea:hover, .select:hover { border-color: var(--muted); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 var(--ring) color-mix(in oklab, var(--focus) 35%, transparent);
}
.textarea { min-height: 220px; resize: vertical; line-height: var(--lh); }
.select { appearance: none; padding-right: 40px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input[disabled], .textarea[disabled] { background: var(--surface-2); color: var(--muted); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; padding: 11px 13px; }
.field-error { display: flex; gap: var(--s-2); align-items: flex-start; font-size: var(--t-sm); font-weight: 600; color: var(--danger); }
.field-error .icon { width: 18px; height: 18px; margin-top: 1px; }
.field-foot { display: flex; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; font-size: var(--t-sm); color: var(--muted); }
.counter { margin-left: auto; font-variant-numeric: tabular-nums; }
.counter.is-near { color: var(--warn); font-weight: 600; }
.counter.is-over { color: var(--danger); font-weight: 600; }
.check { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--s-3); align-items: start; min-height: var(--tap); padding: var(--s-2) 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); cursor: pointer; }
.check-text { font-weight: 600; font-size: var(--t-sm); }
.fine { font-size: var(--t-sm); color: var(--muted); }
.form-actions { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.form-actions .btn { flex: 1 1 100%; }
@media (min-width: 520px) { .form-actions .btn { flex: 0 0 auto; } }
.hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.error-summary { display: grid; gap: var(--s-2); padding: var(--s-4); border-radius: var(--r-md); background: var(--danger-bg); color: var(--ink); border: 1px solid color-mix(in oklab, var(--danger) 40%, transparent); }
.error-summary h2 { font-size: var(--t-base); color: var(--danger); display: flex; gap: var(--s-2); align-items: center; }
.error-summary ul { margin: 0; padding-left: var(--s-6); font-size: var(--t-sm); }
.error-summary a { color: var(--ink); font-weight: 600; }

/* switch (a button posting a form; aria-pressed carries state) */
.switch { position: relative; width: 52px; height: var(--tap); border: 0; background: transparent; padding: 0; cursor: pointer; display: inline-grid; place-items: center; }
.switch::before { content: ""; width: 44px; height: 26px; border-radius: var(--r-pill); background: var(--surface-3); border: 1px solid var(--line-strong); transition: background-color var(--dur) var(--ease); }
.switch::after { content: ""; position: absolute; left: 7px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-1); transition: transform var(--dur) var(--ease); }
.switch[aria-pressed="true"]::before { background: var(--ok); border-color: var(--ok); }
.switch[aria-pressed="true"]::after { transform: translateX(18px); }

/* ---------- 7. Badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--t-xs); font-weight: 650; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-open { color: var(--ok); background: var(--ok-bg); }
.badge-waiting { color: var(--warn); background: var(--warn-bg); }
.badge-closed { color: var(--ink-2); background: var(--surface-3); }
.badge-spam { color: var(--danger); background: var(--danger-bg); }
.lang { display: inline-grid; place-items: center; min-width: 44px; padding: 1px 6px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.site-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--site, var(--house)); box-shadow: 0 0 0 2px var(--surface); }
.swatch { display: inline-block; width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--site, var(--house)); border: 1px solid var(--line); }
.site-tag { display: inline-flex; align-items: center; gap: var(--s-2); white-space: nowrap; min-width: 0; }

/* ---------- 8. Notices ---------- */
.notice { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); }
.notice .icon { margin-top: 2px; }
.notice-body { display: grid; gap: var(--s-2); min-width: 0; }
.notice-title { font-weight: 650; }
.notice-ok { background: var(--ok-bg); border-color: color-mix(in oklab, var(--ok) 35%, transparent); }
.notice-ok > .icon { color: var(--ok); }
.notice-warn { background: var(--warn-bg); border-color: color-mix(in oklab, var(--warn) 35%, transparent); }
.notice-warn > .icon { color: var(--warn); }
.notice-danger { background: var(--danger-bg); border-color: color-mix(in oklab, var(--danger) 35%, transparent); }
.notice-danger > .icon { color: var(--danger); }
.notice-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-1); }

/* ---------- 9. Thread (shared by public ticket page and rladmin) ---------- */
.thread { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4); }
.msg { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: var(--s-4) var(--s-5) var(--s-5); display: grid; gap: var(--s-3); animation: rise 320ms var(--ease) both; }
.msg-head { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); font-size: var(--t-xs); font-weight: 700; }
.who { font-weight: 650; }
.who-role { font-size: var(--t-sm); color: var(--muted); }
.msg-time { margin-left: auto; font-size: var(--t-sm); color: var(--muted); white-space: nowrap; }
.msg-body { display: grid; gap: var(--s-3); max-width: 68ch; overflow-wrap: anywhere; }
.msg-staff { background: var(--accent-soft); border-color: var(--accent-line); }
.msg-staff .avatar { background: var(--accent); color: var(--on-accent); }
.msg-note { background: var(--note-bg); border: 1px dashed var(--note-line); }
.msg-note .avatar { background: var(--note-line); color: var(--note-bg); }
.note-label { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--note-ink); }
.msg-new { box-shadow: 0 0 0 var(--ring) color-mix(in oklab, var(--accent) 30%, transparent); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================================================
   PUBLIC  (contact.morais.co)
   ============================================================ */
.public { display: flex; flex-direction: column; padding: 0 var(--s-4) var(--s-5); }
.shell { width: 100%; max-width: 680px; margin: 0 auto; display: flex; flex-direction: column; flex: 1; }
.pagebar { display: flex; align-items: center; gap: var(--s-2) var(--s-3); flex-wrap: wrap; padding: var(--s-3) 0 var(--s-4); }
.backlink { display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap); padding-right: var(--s-2); color: var(--ink-2); font-size: var(--t-sm); font-weight: 600; text-decoration: none; }
.backlink:hover { color: var(--ink); text-decoration: underline; }
.wordmark { font-family: var(--font-serif); font-size: var(--t-md); font-weight: 600; color: var(--ink); text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }
.controls { display: flex; align-items: center; gap: var(--s-2); margin-left: auto; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: inset 0 4px 0 var(--accent), var(--shadow-1);
  padding: var(--s-6) var(--s-5) var(--s-5);
  animation: rise 360ms var(--ease) both;
}
@media (min-width: 640px) { .card { padding: var(--s-7) var(--s-7) var(--s-7); } }
.card-plain { box-shadow: var(--shadow-1); }
.letter-head { display: grid; gap: var(--s-2); margin-bottom: var(--s-6); }
.eyebrow { font-size: var(--t-sm); font-weight: 600; color: var(--muted); letter-spacing: 0.01em; }
.site-name { font-family: var(--font-serif); font-size: var(--t-2xl); font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.lede { font-size: var(--t-md); color: var(--ink-2); max-width: 46ch; }
.center { text-align: center; justify-items: center; }
.done-mark { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); margin-bottom: var(--s-2); }
.done-mark .icon { width: 30px; height: 30px; stroke-width: 2; }
.ref-block { display: grid; gap: var(--s-1); justify-items: center; padding: var(--s-5); margin: var(--s-5) 0; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.ref-label { font-size: var(--t-sm); font-weight: 600; color: var(--muted); }
.ref { font-family: var(--font-mono); font-size: var(--t-ref); font-weight: 600; letter-spacing: 0.04em; line-height: 1.1; color: var(--ink); }
.stack { display: grid; gap: var(--s-4); }
.stack-sm { display: grid; gap: var(--s-2); }
.actions-center { display: flex; gap: var(--s-3); flex-wrap: wrap; justify-content: center; }
.actions-center .btn { flex: 1 1 220px; max-width: 320px; }
.ticket-head { display: grid; gap: var(--s-3); margin-bottom: var(--s-5); padding-bottom: var(--s-5); border-bottom: 1px solid var(--line); }
.ticket-meta { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; font-size: var(--t-sm); color: var(--muted); }
.ticket-subject { font-family: var(--font-serif); font-size: var(--t-xl); font-weight: 600; }
.ticket-head + .notice { margin-bottom: var(--s-5); }
fieldset.modes { border: 0; border-bottom: 1px solid var(--line); margin: 0; min-width: 0; }
.reply-box { margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--line); }
.reply-box .textarea { min-height: 160px; }
.section-title { font-size: var(--t-md); font-weight: 650; }
.site-foot { margin-top: auto; padding-top: var(--s-6); display: flex; gap: var(--s-2) var(--s-4); flex-wrap: wrap; justify-content: center; font-size: var(--t-sm); color: var(--muted); }
.site-foot a { color: var(--muted); display: inline-flex; align-items: center; min-height: var(--tap); }
.site-foot a:hover { color: var(--ink); }
.status-art { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); margin-bottom: var(--s-2); }
.status-art .icon { width: 28px; height: 28px; }

/* ============================================================
   STAFF  (helpdesk.morais.co/rladmin/)
   ============================================================ */
.admin { font-size: 0.9375rem; }
.app { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100dvh; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.sidebar {
  position: fixed; z-index: 20; inset: auto 0 0 0;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.side-brand, .subnav, .side-foot { display: none; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.nav-link {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; padding: var(--s-1); color: var(--muted); font-size: 0.75rem; font-weight: 600; text-decoration: none;
}
.nav-link:hover { color: var(--ink); background: var(--overlay); }
.nav-link[aria-current="page"] { color: var(--ink); }
.nav-link[aria-current="page"] .icon { color: var(--house); }
.nav-link .count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--house); color: var(--on-accent); font-size: 0.6875rem; line-height: 18px; text-align: center; font-family: var(--font-mono); }
.nav-link .count.is-quiet { display: none; }
@media (min-width: 960px) {
  .app { grid-template-columns: 248px minmax(0, 1fr); padding-bottom: 0; }
  .sidebar { position: sticky; top: 0; inset: auto; height: 100dvh; display: flex; flex-direction: column; gap: var(--s-5); padding: var(--s-5) var(--s-3); border-top: 0; border-right: 1px solid var(--line); overflow-y: auto; }
  .side-brand { display: grid; gap: 2px; padding: 0 var(--s-3); text-decoration: none; color: var(--ink); }
  .side-brand b { font-family: var(--font-serif); font-size: var(--t-md); }
  .side-brand span { font-size: var(--t-xs); color: var(--muted); font-family: var(--font-mono); }
  .nav { display: grid; grid-template-columns: none; gap: 2px; }
  .nav-link { flex-direction: row; justify-content: flex-start; gap: var(--s-3); min-height: var(--tap); padding: 0 var(--s-3); border-radius: var(--r-md); font-size: var(--t-sm); color: var(--ink-2); }
  .nav-link[aria-current="page"] { background: var(--surface-2); }
  .nav-link .count, .nav-link .count.is-quiet { display: inline; position: static; margin-left: auto; min-width: 0; height: auto; padding: 0; background: none; color: var(--muted); font-size: var(--t-xs); line-height: inherit; }
  .subnav { display: grid; gap: 2px; list-style: none; margin: 2px 0 var(--s-2); padding: 0 0 0 30px; }
  .subnav a { display: flex; align-items: center; gap: var(--s-2); min-height: 36px; padding: 0 var(--s-3); border-radius: var(--r-sm); color: var(--ink-2); font-size: var(--t-sm); text-decoration: none; }
  .subnav a:hover { background: var(--overlay); color: var(--ink); }
  .subnav a[aria-current="page"] { color: var(--ink); font-weight: 650; background: var(--overlay); }
  .subnav .count { margin-left: auto; font-family: var(--font-mono); font-size: var(--t-xs); color: var(--muted); }
  .side-foot { display: grid; gap: var(--s-2); margin-top: auto; padding: var(--s-4) var(--s-3) 0; border-top: 1px solid var(--line); font-size: var(--t-sm); }
  .side-user { display: flex; align-items: center; gap: var(--s-2); }
}
.main { min-width: 0; padding: var(--s-4); container-type: inline-size; }
@media (min-width: 960px) { .main { padding: var(--s-6) var(--s-6) var(--s-7); } }
.main-inner { max-width: 1320px; margin: 0 auto; display: grid; gap: var(--s-5); }
.topbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.page-title { font-family: var(--font-serif); font-size: var(--t-xl); font-weight: 600; margin-right: auto; }
.page-title .muted { font-family: var(--font-sans); font-size: var(--t-base); font-weight: 500; }
.search { position: relative; flex: 1 1 240px; max-width: 400px; }
.search .icon { position: absolute; left: 14px; top: 50%; margin-top: -10px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 44px; min-height: var(--tap); }
.tabs { display: flex; gap: var(--s-1); flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs a { display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--tap); padding: 0 var(--s-3); margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--ink-2); font-weight: 600; font-size: var(--t-sm); text-decoration: none; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .count { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--muted); }
.filters { display: flex; gap: var(--s-3); flex-wrap: wrap; align-items: end; }
.filters .field { flex: 1 1 160px; max-width: 240px; gap: var(--s-1); }
.filters .field > label { font-size: var(--t-xs); color: var(--muted); }
.filters .select { min-height: var(--tap); padding-top: 8px; padding-bottom: 8px; font-size: var(--t-sm); }
.filter-chips { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; font-size: var(--t-sm); color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 6px 0 12px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink); font-weight: 600; text-decoration: none; }
.chip:hover { background: var(--surface-3); color: var(--ink); }

/* ticket list */
.tlist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; container-type: inline-size; }
.tlist > li + li { border-top: 1px solid var(--line); }
.trow {
  position: relative; display: grid; gap: 4px var(--s-3); align-items: center; padding: var(--s-3) var(--s-4);
  grid-template-columns: 10px auto minmax(0, 1fr) auto;
  grid-template-areas: "dot ref . time" "dot subj subj subj" "dot meta meta meta";
  transition: background-color var(--dur) var(--ease);
}
.trow:hover { background: var(--overlay); }
.trow-sel { grid-area: sel; display: none; }
.has-select .trow { grid-template-columns: 44px 10px auto minmax(0, 1fr) auto; grid-template-areas: "sel dot ref . time" "sel dot subj subj subj" "sel dot meta meta meta"; }
.has-select .trow-sel { display: grid; place-items: center; width: var(--tap); height: var(--tap); position: relative; z-index: 2; }
.trow-sel input { width: 20px; height: 20px; accent-color: var(--house); }
.unread { grid-area: dot; align-self: start; margin-top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--house); }
.unread.is-read { background: transparent; }
.trow-ref { grid-area: ref; font-family: var(--font-mono); font-size: var(--t-sm); color: var(--muted); }
.trow-subj { grid-area: subj; display: grid; gap: 2px; min-width: 0; }
.trow-subj a { color: var(--ink); text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow-subj a::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.trow-subj a:focus-visible { outline: none; }
.trow:has(.trow-subj a:focus-visible) { outline: var(--ring) solid var(--focus); outline-offset: -3px; }
.is-unread .trow-subj a { font-weight: 700; }
.snippet { font-size: var(--t-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow-meta { grid-area: meta; display: flex; gap: var(--s-2) var(--s-3); align-items: center; flex-wrap: wrap; font-size: var(--t-sm); color: var(--ink-2); }
.trow-time { grid-area: time; font-size: var(--t-sm); color: var(--muted); white-space: nowrap; text-align: right; }
.trow-visitor { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@container (min-width: 980px) {
  .trow { grid-template-columns: 10px 72px minmax(0, 1fr) 168px 150px 56px 150px 76px; grid-template-areas: "dot ref subj site visitor lang status time"; min-height: 64px; }
  .has-select .trow { grid-template-columns: 44px 10px 72px minmax(0, 1fr) 168px 150px 56px 150px 76px; grid-template-areas: "sel dot ref subj site visitor lang status time"; }
  .unread { align-self: center; margin-top: 0; }
  .trow-meta { display: contents; }
  .trow-meta .site-tag { grid-area: site; }
  .trow-meta .trow-visitor { grid-area: visitor; }
  .trow-meta .lang { grid-area: lang; }
  .trow-meta .badge { grid-area: status; justify-self: start; }
  .tlist-head { display: grid !important; }
}
.tlist-head { display: none; grid-template-columns: 10px 72px minmax(0, 1fr) 168px 150px 56px 150px 76px; gap: var(--s-3); padding: var(--s-2) var(--s-4); font-size: var(--t-xs); font-weight: 600; color: var(--muted); background: var(--surface-2); }
.has-select .tlist-head { grid-template-columns: 44px 10px 72px minmax(0, 1fr) 168px 150px 56px 150px 76px; }
.tlist-head span:last-child { text-align: right; }
.list-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; font-size: var(--t-sm); color: var(--muted); }
.bulkbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.bulkbar .check { padding: 0 var(--s-2); }
.bulkbar .spacer { flex: 1; }

.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-3); padding: var(--s-8) var(--s-5); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--surface); }
.empty h2 { font-family: var(--font-serif); font-size: var(--t-lg); }
.empty p { color: var(--muted); max-width: 40ch; }

/* ticket detail */
.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-sm); }
.crumbs a { display: inline-flex; align-items: center; gap: var(--s-1); min-height: var(--tap); color: var(--ink-2); font-weight: 600; text-decoration: none; }
.crumbs a:hover { color: var(--ink); text-decoration: underline; }
.detail { display: grid; gap: var(--s-5); grid-template-columns: minmax(0, 1fr); align-items: start; }
.detail-head { display: grid; gap: var(--s-2); }
.detail-head h1 { font-family: var(--font-serif); font-size: var(--t-xl); }
.detail-main { display: grid; gap: var(--s-5); min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-4) var(--s-5); display: grid; gap: var(--s-4); }
.panel dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s-3) var(--s-5); }
.panel dt { font-size: var(--t-xs); font-weight: 600; color: var(--muted); }
.panel dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.panel-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; padding-top: var(--s-4); border-top: 1px solid var(--line); }
.status-form { display: flex; gap: var(--s-2); align-items: end; flex-wrap: wrap; }
.status-form .field { flex: 1 1 180px; }
.status-form .select { min-height: var(--tap); }
@container (min-width: 1000px) {
  .detail { grid-template-columns: minmax(0, 1fr) 320px; }
  .detail-side { position: sticky; top: var(--s-6); order: 2; }
  .panel dl { grid-template-columns: minmax(0, 1fr); }
  .panel-actions .btn { flex: 1 1 100%; }
}
.composer { border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.composer:focus-within { border-color: var(--house); }
.modes { display: flex; gap: var(--s-1); padding: var(--s-2); border-bottom: 1px solid var(--line); }
.modes input { position: absolute; opacity: 0; pointer-events: none; }
.modes label { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-4); border-radius: var(--r-md); font-weight: 600; font-size: var(--t-sm); color: var(--ink-2); cursor: pointer; }
.modes label:hover { background: var(--overlay); color: var(--ink); }
.modes input:checked + label { background: var(--ink); color: var(--surface); }
.modes input:focus-visible + label { outline: var(--ring) solid var(--focus); outline-offset: 2px; }
.composer .textarea { border: 0; border-radius: 0; min-height: 180px; background: transparent; box-shadow: none; }
.composer .textarea:focus-visible { box-shadow: none; }
.composer-foot { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); }
.composer-hint { display: flex; gap: var(--s-2); align-items: center; font-size: var(--t-sm); color: var(--muted); margin-right: auto; min-width: 0; }
.for-note { display: none !important; }
.composer:has(#mode-note:checked) { background: var(--note-bg); border-color: var(--note-line); border-style: dashed; }
.composer:has(#mode-note:checked) .for-reply { display: none !important; }
.composer:has(#mode-note:checked) .for-note { display: inline-flex !important; }
.composer:has(#mode-note:checked) .composer-hint { color: var(--note-ink); }
.composer:has(#mode-note:checked) .modes input:checked + label { background: var(--note-ink); color: var(--note-bg); }
.composer:has(#mode-note:checked) .btn-primary { background: var(--note-ink); color: var(--note-bg); }

/* tables (sites) */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th { text-align: left; font-size: var(--t-xs); font-weight: 600; color: var(--muted); background: var(--surface-2); padding: var(--s-2) var(--s-4); }
.table td { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: var(--overlay); }
.table .num { text-align: right; font-family: var(--font-mono); }
.site-cell { display: flex; align-items: center; gap: var(--s-3); }
.site-cell a { font-weight: 650; color: var(--ink); text-decoration: none; }
.site-cell a:hover { text-decoration: underline; }
.site-cell .slug { display: block; font-family: var(--font-mono); font-size: var(--t-xs); color: var(--muted); }
.is-inactive td { color: var(--muted); }
@container (max-width: 760px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: var(--s-3) var(--s-4); border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-1) var(--s-3); }
  .table tr:first-child { border-top: 0; }
  .table td { border: 0; padding: 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
  .table .num { text-align: left; }
  .table td.cell-switch { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
}
.edit-grid { display: grid; gap: var(--s-5); grid-template-columns: minmax(0, 1fr); }
@container (min-width: 820px) { .edit-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .edit-grid .span-2 { grid-column: 1 / -1; } }
.color-row { display: flex; gap: var(--s-3); align-items: center; }
.color-row input[type="color"] { width: 56px; height: 48px; padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); cursor: pointer; }
.color-row .input { flex: 1; font-family: var(--font-mono); }
.preview-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-3); }
.preview-tile { display: grid; gap: var(--s-3); padding: var(--s-4); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); box-shadow: inset 0 4px 0 var(--accent); }
.preview-tile .btn { min-height: 40px; pointer-events: none; }
.preview-tile .pt-cap { font-size: var(--t-xs); color: var(--muted); font-weight: 600; }
.preview-tile[data-preview="dark"] { --surface: #1c1b18; --line: #36332d; --muted: #a8a196; --ink: #ece8e1; --on-accent: #141311; --accent: var(--site-d, #8cc4b2); color: var(--ink); }
.preview-tile[data-preview="light"] { --surface: #fffdf9; --line: #e2dcd1; --muted: #5f5a52; --ink: #1f1d1a; --on-accent: #ffffff; --accent: var(--site-l, #2f5d50); color: var(--ink); }
.contrast-ok { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); font-weight: 600; color: var(--ok); }
.form-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); display: grid; gap: var(--s-5); }
@media (min-width: 960px) { .form-card { padding: var(--s-6); } }
.form-card h2 { font-size: var(--t-md); }
.form-card-head { display: grid; gap: var(--s-1); }
.cards-2 { display: grid; gap: var(--s-5); grid-template-columns: minmax(0, 1fr); }
@container (min-width: 900px) { .cards-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.toast { animation: rise 320ms var(--ease) both; }

/* login */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-5) var(--s-4); }
.login-card { width: 100%; max-width: 420px; display: grid; gap: var(--s-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-6) var(--s-5); box-shadow: var(--shadow-2); }
@media (min-width: 520px) { .login-card { padding: var(--s-7) var(--s-6); } }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.login-top .side-brand { display: grid; gap: 2px; padding: 0; text-decoration: none; color: var(--ink); }
.login-top .side-brand b { font-family: var(--font-serif); font-size: var(--t-md); }
.login-top .side-brand span { font-size: var(--t-xs); color: var(--muted); font-family: var(--font-mono); }

/* privacy page */
.prose { display: grid; gap: var(--s-3); max-width: 64ch; }
.prose h2 { font-size: var(--t-md); font-weight: 650; margin-top: var(--s-4); }
.prose ul { margin: 0; padding-left: var(--s-5); display: grid; gap: var(--s-1); }
.prose li::marker { color: var(--muted); }
.updated { font-size: var(--t-sm); color: var(--muted); }
