:root {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --text: #1b1c1e;
  --muted: #62646a;
  --border: #dcdbd5;
  --accent: #d6361f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe5e1;
  --ok: #1f7a4a;
  --ok-soft: #e1f3e8;
  --warn: #9a5b00;
  --warn-soft: #fdf0d9;
  --danger: #b3261e;
  --focus: #2f6fde;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 2px 8px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #1a1b1e;
    --surface-2: #222328;
    --text: #ececea;
    --muted: #a0a2a8;
    --border: #303137;
    --accent: #ff5a3c;
    --accent-ink: #160604;
    --accent-soft: #3a1a14;
    --ok: #5bd08e;
    --ok-soft: #13301f;
    --warn: #f1b54a;
    --warn-soft: #332508;
    --danger: #ff6b61;
    --focus: #7aa7ff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

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

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: 0.01em; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 5px; flex: none;
  background: conic-gradient(var(--text) 0 25%, var(--surface) 0 50%, var(--text) 0 75%, var(--surface) 0) 0 0 / 11px 11px;
  border: 2px solid var(--accent);
}
.nav { display: flex; align-items: center; gap: 16px; }
.nav form { margin: 0; }

main { padding-top: 24px; padding-bottom: 48px; }
.footer { color: var(--muted); font-size: 14px; padding-bottom: 32px; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.02em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.hero { padding: 16px 0 24px; }
.hero-small { padding-top: 4px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; font-weight: 600; color: var(--accent); margin: 0 0 8px; }
.lede { font-size: 18px; color: var(--muted); margin: 0; max-width: 62ch; }

.callout {
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 24px;
}
.callout h2 { font-size: 22px; }
.callout p { margin: 0 0 12px; max-width: 70ch; }
.callout ul { margin: 0; padding-left: 20px; }
.callout li { margin-bottom: 6px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 420px; margin: 40px auto; }
.card h2 { display: flex; align-items: center; gap: 10px; }
.num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--text); color: var(--bg); font-size: 14px; flex: none;
}
.section-intro { color: var(--muted); margin: -4px 0 18px; max-width: 70ch; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.field-wide { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid { grid-template-columns: minmax(0, 1fr); } }

label, legend { display: block; font-weight: 600; margin-bottom: 4px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.help { margin: 0 0 6px; font-size: 14px; color: var(--muted); }
.req { color: var(--accent); }

input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 64px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.7; font-style: italic; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }
input[type="file"] { font: inherit; max-width: 100%; }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin: 0; }
.checks .check { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; }
.checks .check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.consent { align-items: flex-start; font-weight: 500; }
.consent input { margin-top: 3px; }

.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.meter {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px 12px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.meter-static { position: static; border: 0; padding: 0; box-shadow: none; margin-bottom: 12px; }
.meter-text { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 14px; margin-bottom: 6px; }
.meter-text strong { font-size: 18px; }
.meter-msg { color: var(--muted); }
.meter-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width 0.3s ease; }

.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; }
.w-100 { width: 100%; }

.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--border); }
.finish .actions { margin-top: 20px; }
.cf-turnstile { margin-top: 18px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 600;
  padding: 10px 18px; min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

.small { font-size: 14px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.flash { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; border: 1px solid; }
.flash ul { margin: 6px 0 0; padding-left: 20px; }
.flash p { margin: 6px 0 0; }
.flash-ok { background: var(--ok-soft); border-color: var(--ok); }
.flash-warn { background: var(--warn-soft); border-color: var(--warn); }
.file-note { font-size: 14px; margin: 6px 0 0; color: var(--muted); }
.file-note.bad { color: var(--danger); font-weight: 600; }

.badge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); text-transform: none; vertical-align: middle; white-space: nowrap;
}
.badge-new, .badge-reply { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.badge-need_info, .badge-draft { background: var(--warn-soft); border-color: var(--warn); }
.badge-in_progress, .badge-testing { background: var(--surface-2); border-color: var(--focus); }
.badge-on_server { background: var(--ok-soft); border-color: var(--ok); }
.badge-archived { color: var(--muted); }

.detail-section { margin-bottom: 20px; }
.detail-section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
dl { display: grid; grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
dt { font-weight: 600; }
dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) { dl { grid-template-columns: minmax(0, 1fr); } dd { margin-bottom: 8px; } }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }
.file { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); color: var(--text); text-decoration: none; }
.file-image img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.file-audio, .file-doc { padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; overflow-wrap: anywhere; }
.file-audio { grid-column: span 2; }
.file-audio audio { width: 100%; }
.doc-icon { font-weight: 800; color: var(--accent); }

.thread { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.msg { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; background: var(--surface-2); max-width: 88%; }
.msg-member { align-self: flex-end; }
.msg-admin, .msg-claude { align-self: flex-start; border-left: 3px solid var(--accent); }
.msg-draft { border-style: dashed; max-width: 100%; width: 100%; }
.msg-head { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; font-size: 14px; margin-bottom: 6px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.reply label { margin-top: 12px; }
.reply input[type="file"] { margin-top: 4px; }

.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-head h1 { margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters a { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); text-decoration: none; color: var(--text); font-size: 14px; }
.filters a[aria-current="page"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.pct { font-variant-numeric: tabular-nums; font-weight: 700; }
h2 .pct { font-size: 14px; color: var(--muted); }

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
@media (max-width: 820px) { .admin-grid { grid-template-columns: minmax(0, 1fr); } }
body:has(.admin-grid) .wrap { max-width: 1200px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-form select { flex: 1 1 100%; }
.plain { list-style: none; padding: 0; margin: 0 0 12px; }
.plain li { margin-bottom: 8px; }
.danger-zone { border-color: var(--danger); }
code { font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
