/* 一隅空间 platform styles. Brand: deep pine ink + vermilion seal. */
:root {
  --ink: #16312c;
  --ink-2: #24463f;
  --ink-soft: #4a5f5a;
  --mist: #eef2f0;
  --mist-2: #e2e9e6;
  --paper: #ffffff;
  --line: #cdd9d4;
  --line-strong: #9fb2ac;
  --seal: #b8342a;
  --seal-dark: #952a21;
  --seal-tint: #f7e3e0;
  --gold: #e9a23b;
  /* Focus ring: at least 3:1 against white, --mist and the ink header/hero. */
  --focus: #c96a00;
  --ok: #2b6e47;
  --ok-tint: #e1f0e6;
  --warn: #8a5300;
  --warn-tint: #fbefd9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(22, 49, 44, 0.06), 0 10px 30px rgba(22, 49, 44, 0.08);
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Noto Serif SC", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 64px;
  /* Notches and rounded corners in landscape (0 where there are none, or without viewport-fit=cover). */
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --gutter: max(16px, var(--safe-l), var(--safe-r));
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.3; margin: 0 0 0.5em; letter-spacing: 0.02em; }
h1, h2 { font-family: var(--serif); font-weight: 700; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--seal); text-underline-offset: 3px; }
a:hover { color: var(--seal-dark); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

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

.container { width: min(1120px, 100% - 2 * var(--gutter)); margin-inline: auto; }
.narrow { width: min(760px, 100% - 2 * var(--gutter)); }
.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: max(12px, var(--safe-l)); top: -48px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; color: #fff; }
.text-link { font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.linklike { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- seal & brand ---------- */
.seal { flex: none; display: block; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; letter-spacing: 0.08em; }
.brand-domain { font-size: 0.75rem; color: var(--ink-soft); letter-spacing: 0.03em; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font-weight: 600; font-size: 0.975rem; line-height: 1.2; letter-spacing: 0.02em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
/* a link styled as a button cannot be disabled: aria-disabled also stops its clicks (the poster's Save) */
.btn[aria-disabled="true"] { pointer-events: none; }
.btn-seal { background: var(--seal); color: #fff; }
.btn-seal:hover { background: var(--seal-dark); color: #fff; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-2); color: #fff; }
.btn-outline { background: var(--paper); color: var(--ink); border-color: var(--line-strong); }
.btn-outline:hover { border-color: var(--ink); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--mist); color: var(--ink); }
.btn-sm { min-height: 40px; padding: 0 14px; font-size: 0.9rem; }
.btn-xs { min-height: 34px; padding: 0 10px; font-size: 0.85rem; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn.danger { color: var(--seal); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--mist); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- header & footer ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, 0.96); border-bottom: 1px solid var(--line); }
@supports (backdrop-filter: blur(8px)) { .site-header { background: rgba(255, 255, 255, 0.86); backdrop-filter: blur(8px); } }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: var(--header-h); }
.header-nav { display: flex; align-items: center; gap: 4px 18px; flex-wrap: wrap; justify-content: flex-end; }
.header-nav > a:not(.btn), .header-nav > .linklike { color: var(--ink); text-decoration: none; font-size: 0.95rem; padding: 10px 0; }
.header-nav > a:not(.btn):hover, .header-nav > .linklike:hover { color: var(--seal); }
.lang-switch { font-size: 0.875rem !important; color: var(--ink-soft) !important; }
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .header-nav { gap: 4px 12px; }
  .brand-domain { display: none; }
}

.site-footer { background: var(--ink); color: rgba(255, 255, 255, 0.82); padding: 40px 0 32px; font-size: 0.9rem; }
.footer-inner { display: grid; gap: 16px; }
.footer-brand { display: flex; align-items: center; gap: 10px; font-family: var(--serif); color: #fff; letter-spacing: 0.06em; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer-links a { color: #fff; text-decoration: none; padding: 6px 0; }
.footer-links a:hover { text-decoration: underline; color: #fff; }
.footer-legal { margin: 0; font-size: 0.8rem; color: rgba(255, 255, 255, 0.66); }

/* ---------- shared bits (the home page has its own stylesheet, home.css) ---------- */
.bracket { color: var(--seal); font-family: var(--serif); }

/* ---------- forms ---------- */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-row { display: grid; gap: 18px; }
@media (min-width: 640px) { .field-row { grid-template-columns: 1fr 1fr; } }
label, .label { font-weight: 600; font-size: 0.95rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="date"], input[type="number"], textarea, select {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--paper); font-size: 16px; line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 96px; }
/* Text-like fields swap the outline for a ring; checkboxes and radios keep :focus-visible. */
input:not([type="checkbox"]):not([type="radio"]):focus, textarea:focus, select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 2px var(--focus); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--seal); }
.hint { margin: 0; font-size: 0.85rem; color: var(--ink-soft); line-height: 1.6; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 0.9rem; line-height: 1.6; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; accent-color: var(--seal); }
.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice-col { display: grid; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: center; min-height: 48px; padding: 8px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font-weight: 400; cursor: pointer; background: var(--paper); }
.choice input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--seal); }
.choice:has(input:checked) { border-color: var(--ink); background: var(--mist); }
/* Where :has() works, ring the whole option box instead of the small native control. */
@supports selector(:has(a)) {
  .choice:has(input:focus-visible), .theme-option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
  .choice input:focus-visible, .theme-option input:focus-visible { outline: none; }
}
.form-error { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--seal-tint); color: var(--seal-dark); font-size: 0.925rem; }
.field-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.auth-wrap { min-height: calc(100vh - var(--header-h) - 200px); display: grid; place-items: center; padding: 48px var(--gutter) 64px; background: var(--mist); }
.auth-card { width: min(460px, 100%); background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 24px; }
@media (min-width: 520px) { .auth-card { padding: 40px 36px; } }
.auth-card h1 { font-size: 1.7rem; letter-spacing: 0.06em; }
.auth-card.center { text-align: center; }
.auth-card.center .seal { margin: 0 auto 16px; }

/* ---------- paper skin: the pages one click from home (apply, sign in, their follow-ups, the legal pages) ---------- */
/* The home page's ivory: warm paper, ink, brass hairlines, a display serif for headings, square ink buttons. */
body.is-paper {
  --ink: #1b1814; --ink-2: #4a433a; --ink-soft: #675e51; --mist: #ece5d8; --mist-2: #e4dccd;
  --line: rgba(27, 24, 20, 0.18); --line-strong: rgba(27, 24, 20, 0.42); --focus: #a08154;
  --display: "Didot", "Bodoni 72", "Bodoni MT", "Iowan Old Style", "Hoefler Text", Georgia, "Songti SC", "STSong", serif;
  background: #f4efe5; color: var(--ink);
}
.is-paper .site-header { background: rgba(244, 239, 229, 0.92); border-bottom-color: rgba(27, 24, 20, 0.14); }
.is-paper .brand-name { font-family: var(--display); font-weight: 400; font-size: 1.4rem; letter-spacing: 0.005em; }
.is-paper .brand-domain { color: var(--ink-soft); }
.is-paper .header-nav > a:not(.btn), .is-paper .header-nav > .linklike { color: var(--ink-2); }
.is-paper .header-nav .btn-primary { background: transparent; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 0; }
.is-paper .header-nav .btn-primary:hover { background: var(--ink); color: #f4efe5; border-color: var(--ink); }
.is-paper .auth-wrap { background: transparent; }
.is-paper .auth-card {
  background: #fbf8f2; border-radius: 0;
  box-shadow: 0 0 0 1px rgba(27, 24, 20, 0.08), 0 24px 48px -28px rgba(43, 32, 15, 0.42), 0 60px 90px -60px rgba(43, 32, 15, 0.35);
}
.is-paper h1, .is-paper h2 { font-family: var(--display); font-weight: 400; letter-spacing: 0; color: var(--ink); }
:lang(zh-CN) .is-paper h1, :lang(zh-CN) .is-paper h2 { letter-spacing: 0.06em; }
.is-paper .auth-card h1 { font-size: 2rem; letter-spacing: 0; }
.is-paper .btn-primary, .is-paper .btn-seal { background: var(--ink); color: #f4efe5; border-radius: 0; }
.is-paper .btn-primary:hover, .is-paper .btn-seal:hover { background: #2e2922; color: #f4efe5; }
.is-paper main a:not(.btn) { color: var(--ink); text-decoration-color: #a08154; }
.is-paper main a:not(.btn):hover { color: var(--ink-2); }
.is-paper input[type="text"], .is-paper input[type="email"], .is-paper input[type="password"], .is-paper textarea { border-radius: 0; background: #fffdf9; }
.is-paper .site-footer { background: #16130f; color: #b4ab9b; }
.is-paper .footer-brand { color: #f1eadd; }
.is-paper .footer-links a { color: #f1eadd; }
.is-paper .footer-legal { color: #b4ab9b; }
.auth-alt { margin: 20px 0 0; text-align: center; font-size: 0.925rem; }
.form-done { text-align: center; display: grid; justify-items: center; gap: 4px; }
.form-done .seal { margin-bottom: 10px; }
.review-note { background: var(--mist); padding: 12px 14px; border-radius: var(--radius-sm); text-align: left; }

/* ---------- legal ---------- */
.legal { padding: 48px 0 72px; }
.legal h1 { font-size: 2rem; }
.legal h2 { font-size: 1.3rem; margin-top: 2em; }
.legal h3 { margin-top: 1.4em; }
.legal li { margin-bottom: 0.4em; }
.legal-summary { background: var(--mist); padding: 16px 20px; border-radius: var(--radius); }

/* ---------- setup ---------- */
.setup { padding: 40px 0 72px; }
.setup h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); letter-spacing: 0.06em; }
.lead-dark { color: var(--ink-soft); font-size: 1.05rem; }
.setup-form { gap: 28px; margin-top: 28px; }
.setup-step { border: 0; padding: 24px 20px; margin: 0; background: var(--mist); border-radius: var(--radius); display: grid; gap: 18px; min-width: 0; }
@media (min-width: 640px) { .setup-step { padding: 28px; } }
.setup-step legend { float: left; width: 100%; padding: 0; font-family: var(--serif); font-weight: 700; font-size: 1.3rem; letter-spacing: 0.06em; margin-bottom: 4px; }
.setup-step legend + * { clear: both; }
.address-input { display: flex; align-items: stretch; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--paper); overflow: hidden; }
.address-input:focus-within { border-color: var(--ink); box-shadow: 0 0 0 2px var(--focus); }
.address-input input { border: 0; box-shadow: none !important; min-width: 0; flex: 1; padding-inline: 4px; }
.address-scheme, .address-suffix { display: flex; align-items: center; padding: 0 10px; color: var(--ink-soft); font-size: 0.95rem; white-space: nowrap; background: var(--mist-2); }
.address-scheme { padding-right: 6px; background: transparent; }
@media (max-width: 420px) { .address-scheme { display: none; } .address-suffix { font-size: 0.85rem; padding: 0 8px; } }
.sub-status { margin: 0; min-height: 1.5em; font-size: 0.9rem; font-weight: 600; }
.sub-status.ok { color: var(--ok); }
.sub-status.bad { color: var(--seal); }

.theme-pick { display: grid; gap: 10px; }
@media (min-width: 640px) { .theme-pick { grid-template-columns: 1fr 1fr; } }
.theme-option { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; font-weight: 400; min-width: 0; }
.theme-option input { margin: 4px 0 0; width: 18px; height: 18px; flex: none; accent-color: var(--seal); }
.theme-option:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.theme-option-swatch { width: 44px; height: 44px; flex: none; border-radius: 8px; background: radial-gradient(circle at 72% 70%, var(--sw-accent) 0 9px, transparent 10px), linear-gradient(var(--sw-bg), var(--sw-bg)); border: 1px solid rgba(0, 0, 0, 0.08); }
.theme-option-body { display: grid; gap: 2px; min-width: 0; }
.theme-option-name { font-weight: 700; font-family: var(--serif); letter-spacing: 0.04em; }
.theme-option-desc { font-size: 0.875rem; color: var(--ink-soft); line-height: 1.55; }

/* ---------- badges, notices, toast ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; background: var(--mist-2); color: var(--ink); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge-live, .badge-approved { background: var(--ok-tint); color: var(--ok); }
.badge-unpublished, .badge-pending { background: var(--warn-tint); color: var(--warn); }
.badge-draft { background: var(--mist-2); color: var(--ink-soft); }
.badge-rejected, .badge-suspended { background: var(--seal-tint); color: var(--seal-dark); }
.badge-ink { background: var(--ink); color: #fff; }
.badge-ink::before { display: none; }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); }
.notice-warn { background: var(--warn-tint); color: var(--warn); }
/* The toast stays rendered (a live region a screen reader already knows about) and is only
   visually hidden between messages. While a modal dialog is open it lives inside that dialog. */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 1000; max-width: min(520px, 100% - 2 * var(--gutter)); padding: 12px 18px; border-radius: var(--radius-sm); background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 0.95rem; line-height: 1.6; transition: opacity 0.2s, transform 0.2s; }
.toast:not(.is-shown) { opacity: 0; transform: translate(-50%, 8px); pointer-events: none; }
.toast.is-error { background: var(--seal-dark); }

/* ---------- dialogs ---------- */
.dialog { width: min(520px, calc(100% - 24px)); max-height: calc(100vh - 32px); border: 0; border-radius: var(--radius); padding: 0; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3); color: var(--ink); }
.dialog-wide { width: min(760px, 100% - 2 * max(12px, var(--safe-l), var(--safe-r))); }
.dialog::backdrop { background: rgba(10, 24, 21, 0.55); }
.dialog > .form { padding: 24px 20px; }
@media (min-width: 520px) { .dialog > .form { padding: 28px; } }
.dialog h2 { font-size: 1.35rem; margin: 0; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.copy-box { display: flex; gap: 8px; }
.copy-box input { flex: 1; min-width: 0; font-size: 0.85rem; }

/* ---------- dashboard ---------- */
body.is-dash { height: 100vh; height: 100dvh; overflow: hidden; background: var(--mist); }
body.is-dash main { height: 100%; }
.dash { height: 100%; display: flex; flex-direction: column; }
.dash-top { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dash-brand { display: flex; }
.dash-site { min-width: 0; flex: 1; }
.dash-title { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 1.05rem; letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-address { margin: 0; display: flex; align-items: center; gap: 2px; font-size: 0.85rem; min-width: 0; }
.dash-address a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-address .icon-btn { width: 32px; height: 32px; }
.dash-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 720px) {
  .dash-top { gap: 8px; }
  .dash-top > .badge { order: 3; }
  .dash-actions { order: 4; flex: 1 1 100%; justify-content: flex-end; }
}
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 190px; display: grid; padding: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.menu-list > * { display: block; width: 100%; text-align: left; padding: 10px 12px; min-height: 44px; border: 0; background: none; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; cursor: pointer; font-size: 0.95rem; }
.menu-list > *:hover { background: var(--mist); color: var(--ink); }
/* whose account this is (the address bar only says /app): a line, not a button */
.menu-list > .menu-who { display: grid; gap: 2px; min-height: 0; margin: 0 0 4px; padding: 8px 12px 10px; border-bottom: 1px solid var(--line); border-radius: 0; cursor: default; font-size: 0.8rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.menu-list > .menu-who:hover { background: none; color: var(--ink-soft); }
.menu-who strong { font-size: 0.9rem; font-weight: 600; color: var(--ink); }

.dash-tabs { display: none; }
.dash-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 420px) 1fr; }
@media (max-width: 900px) {
  .dash-tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--paper); border-bottom: 1px solid var(--line); }
  .dash-tabs button { min-height: 44px; border: 0; background: none; font-weight: 600; color: var(--ink-soft); border-bottom: 3px solid transparent; cursor: pointer; }
  .dash-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--seal); }
  .dash-tabs button:focus-visible { outline-offset: -3px; }
  .dash-body { grid-template-columns: 1fr; }
  .dash-body[data-active="chat"] .preview { display: none; }
  .dash-body[data-active="preview"] .chat { display: none; }
}

.chat { display: flex; flex-direction: column; min-height: 0; background: var(--paper); border-right: 1px solid var(--line); }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 16px 8px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.msg { max-width: 92%; display: grid; gap: 6px; }
.msg-user { align-self: flex-end; }
.msg-ai { align-self: flex-start; }
.msg-who { font-size: 0.75rem; color: var(--ink-soft); letter-spacing: 0.04em; }
.msg-user .msg-who { text-align: right; }
.msg-body { padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; font-size: 0.95rem; }
.msg-user .msg-body { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.msg-ai .msg-body { background: var(--mist); border-bottom-left-radius: 4px; }
.msg-ai.is-error .msg-body { background: var(--seal-tint); color: var(--seal-dark); }
.msg-steps { display: grid; gap: 4px; font-size: 0.8rem; color: var(--ink-soft); padding-left: 4px; }
.msg-step { display: flex; gap: 8px; align-items: baseline; }
.msg-step::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); transform: translateY(-1px); }
.msg-step.is-done::before { background: var(--ok); }
.msg-step.is-error::before { background: var(--seal); }
.msg-step.is-working::before { background: var(--gold); animation: pulse 1s ease-in-out infinite; }
.msg-progress { font-size: 0.85rem; color: var(--ink-soft); font-style: normal; border-left: 2px solid var(--line); margin-left: 3px; padding: 2px 0 2px 10px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft); animation: pulse 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.msg-note { align-self: center; font-size: 0.8rem; color: var(--ink-soft); }

.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px 10px; }
.chip { border: 1.5px solid var(--line); background: var(--paper); border-radius: 12px 12px 12px 4px; padding: 7px 12px; font-size: 0.85rem; line-height: 1.5; text-align: left; cursor: pointer; color: var(--ink); min-height: 40px; }
.chip:hover { border-color: var(--ink); }
.chat-form { border-top: 1px solid var(--line); padding: 12px 16px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 8px; background: var(--paper); }
.chat-form textarea { min-height: 76px; max-height: 40vh; }
.chat-form-row { display: flex; align-items: center; gap: 8px; }
.chat-form-row .quota { flex: 1; text-align: right; font-size: 0.8rem; color: var(--ink-soft); }
.chat-attachments { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.8rem; color: var(--ink-soft); }
.chat-attachments span { background: var(--mist); padding: 2px 8px; border-radius: 4px; }
.ai-label { margin: 0; font-size: 0.75rem; color: var(--ink-soft); }

.preview { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.preview-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--paper); border-bottom: 1px solid var(--line); }
.preview-label { font-size: 0.85rem; font-weight: 600; margin-right: auto; padding-left: 4px; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { border: 0; background: var(--paper); padding: 0 12px; min-height: 36px; font-size: 0.85rem; cursor: pointer; color: var(--ink-soft); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg button:focus-visible { outline-offset: -3px; } /* .seg clips anything outside */
.preview-frame-wrap { flex: 1; min-height: 0; display: flex; justify-content: center; padding: 14px; overflow: auto; }
.preview-frame-wrap iframe { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; box-shadow: var(--shadow); transition: width 0.25s; }
.preview-frame-wrap[data-device="mobile"] iframe { width: 390px; max-width: 100%; height: min(100%, 844px); }
@media (max-width: 900px) { .preview-frame-wrap { padding: 0; } .preview-frame-wrap iframe { border-radius: 0; box-shadow: none; } .seg { display: none; } }
.preview-paused { margin: auto; width: min(420px, 100% - 32px); padding: 24px; text-align: center; background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); }
.preview-paused p { color: var(--ink-soft); font-size: 0.925rem; }

/* Landscape phones: keep edge content clear of the notch and rounded corners. The chat column is
   always on the left and the preview on the right; below 900px each one spans the full width. */
.dash-top { padding-left: max(12px, var(--safe-l)); padding-right: max(12px, var(--safe-r)); }
.dash-tabs { padding-left: var(--safe-l); padding-right: var(--safe-r); }
.chat-log, .chat-suggestions, .chat-form { padding-left: max(16px, var(--safe-l)); }
.preview-bar { padding-right: max(10px, var(--safe-r)); }
.preview-frame-wrap { padding-right: max(14px, var(--safe-r)); }
@media (max-width: 900px) {
  .chat-log, .chat-suggestions, .chat-form { padding-right: max(16px, var(--safe-r)); }
  .preview-bar { padding-left: max(10px, var(--safe-l)); }
  .preview-frame-wrap { padding-left: var(--safe-l); padding-right: var(--safe-r); }
}

.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.asset { display: grid; gap: 6px; font-size: 0.8rem; min-width: 0; }
.asset img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--mist); }
.asset-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.asset-actions { display: flex; gap: 4px; }
.asset-actions .btn { flex: 1; padding: 0 6px; }

/* ---------- admin ---------- */
/* The admin pages hold wide tables: their header, content and footer get more room than the 1120px of the rest */
body[data-page^="admin"] .container { width: min(1480px, 100% - 2 * var(--gutter)); }
.admin { padding: 36px 0 72px; }
.admin h2 { font-size: 1.35rem; margin-top: 40px; display: flex; align-items: center; gap: 10px; }
.count { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--seal); color: #fff; font-family: var(--sans); font-size: 0.85rem; }
.review-list { display: grid; gap: 14px; }
@media (min-width: 900px) { .review-list { grid-template-columns: 1fr 1fr; } }
.review-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 10px; min-width: 0; }
.review-card header { display: grid; gap: 2px; overflow-wrap: anywhere; }
.review-text { margin: 0; white-space: pre-wrap; background: var(--mist); padding: 10px 12px; border-radius: var(--radius-sm); overflow-wrap: anywhere; }
.review-actions { display: flex; gap: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: var(--mist); font-weight: 600; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table-num td:not(:first-child), .table-num th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; overflow-wrap: anywhere; }
.cell-sub { display: block; color: var(--ink-soft); font-size: 0.8rem; }
/* Admin users table: one Manage button per row that opens in place (the table scrolls sideways, so a floating
   menu would be clipped), its actions grouped, each with a line saying what it does */
.table-users .cell-dates .cell-sub { white-space: nowrap; }
.table-users .cell-note { max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-users .cell-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.manage-cell { width: 1%; }
.manage > summary { list-style: none; white-space: nowrap; }
.manage > summary::-webkit-details-marker { display: none; }
.manage[open] > summary { background: var(--mist); }
.manage-list { display: grid; gap: 8px; width: 15rem; margin-top: 10px; }
.manage-group { margin: 4px 0 -2px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.manage-group:empty { margin: 0; border-top: 1px solid var(--line); }
.manage-item { display: grid; justify-items: start; gap: 3px; }
.manage-item .cell-sub { font-size: 0.75rem; line-height: 1.4; }
/* One address's visits: a line per day, then that day's page loads */
.table-visits .row-day th { background: transparent; border-top: 2px solid var(--line); padding-top: 16px; white-space: normal; font-variant-numeric: tabular-nums; }
.table-visits tbody .row-day:first-child th { border-top: 0; }
.row-day-sub { margin-left: 12px; font-weight: 400; color: var(--ink-soft); }

/* Guestbook dialog: the visitors' messages, newest first, with the full address only the owner sees */
.gb-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 10px; max-height: min(52vh, 520px); overflow-y: auto; }
.gb-item { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; }
.gb-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin: 0; }
.gb-meta { font-size: 0.8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.gb-body { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.gb-actions { display: flex; flex-wrap: wrap; gap: 4px 12px; }

/* Holidays & special days dialog: a small stage where public/static/festive.js plays the effects, the holidays with
   their next dates, and the owner's own days (month, day, line, effect) */
.festive-stage { position: relative; overflow: hidden; height: 200px; margin: 4px 0 2px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, #f5f0e7, #e8e0d2); color: var(--ink-soft); font-size: 0.85rem; }
.festive-stage.is-site { height: min(420px, 60vh); place-items: stretch; background: var(--paper); }
.festive-stage.is-site > span { display: none; }
.festive-stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.festive-stage-actions { margin: 6px 0 0; }
.festive-h { margin: 14px 0 2px; font-size: 1rem; }
.festive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.festive-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.festive-name { min-width: 5.5em; font-weight: 600; }
.festive-when { flex: 1 1 14em; color: var(--ink-soft); font-size: 0.85rem; }
#dlg-festive [data-festive-holidays] li > .btn { margin-left: auto; }
.festive-day select, .festive-day input[type="text"] { width: auto; min-height: 40px; padding: 6px 10px; font-size: 15px; }
.festive-day input[type="text"] { flex: 1 1 12em; min-width: 0; }

/* Share poster dialog: choices on the left, the drawn poster on the right (below on a phone) */
.poster { display: grid; gap: 18px; }
@media (min-width: 760px) { .poster { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; } }
.poster-controls { display: grid; gap: 12px; min-width: 0; }
.poster-photos { display: grid; grid-template-columns: repeat(auto-fill, 72px); grid-auto-rows: 72px; gap: 6px; max-height: 236px; overflow-y: auto; padding: 2px; }
.poster-photo { width: 72px; height: 72px; padding: 0; display: grid; place-items: center; overflow: hidden; border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--mist); cursor: pointer; }
.poster-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster-photo[aria-checked="true"] { border-color: var(--seal); box-shadow: 0 0 0 2px var(--focus); }
.poster-none { padding: 4px; font-size: 0.75rem; line-height: 1.3; color: var(--ink-soft); text-align: center; }
.poster .choice-row { gap: 6px 18px; }
.poster-preview { margin: 0; display: grid; gap: 6px; align-content: start; }
.poster-preview img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--mist); }

/* Quiz dialog: one card per question, the right answer marked by the radio beside its choice */
.quiz-edit { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 12px; }
.quiz-edit__item { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.quiz-edit__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 0.9rem; }
.quiz-edit__opts { display: grid; gap: 6px; }
@media (min-width: 640px) { .quiz-edit__opts { grid-template-columns: 1fr 1fr; } }
.quiz-edit__opt { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.quiz-edit__opt input[type="radio"] { width: 20px; height: 20px; flex: none; margin: 0; accent-color: var(--seal); }
.quiz-edit__item input[type="text"] { min-height: 40px; padding: 7px 10px; font-size: 15px; }

/* Visitor footprints dialog: the places as the site will list them */
.fp-preview { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.fp-preview p { margin: 0; }
.fp-label { font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }
.fp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.fp-list li { display: inline-flex; gap: 6px; align-items: baseline; padding: 4px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.9rem; }
.fp-n { color: var(--ink-soft); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
