:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #1b1a17;
  --muted: #5f5d57;
  --line: #e2e0d9;
  --accent: #8a6a1f;
  --accent-ink: #ffffff;
  --customer: #eef3ff;
  --staff: #ffffff;
  --warn: #9a3412;
  --ok: #166534;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1f1e1b;
    --ink: #f1efe9;
    --muted: #b4b0a6;
    --line: #34322d;
    --accent: #d8b25a;
    --accent-ink: #151412;
    --customer: #1f2a44;
    --staff: #1f1e1b;
    --warn: #fb923c;
    --ok: #4ade80;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 8px 14px; cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 8px 10px;
}
textarea { resize: vertical; min-height: 64px; }
input[type="checkbox"] { width: auto; margin-right: 6px; }
button.small { padding: 4px 10px; font-size: .85rem; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
header.top { border-bottom: 1px solid var(--line); background: var(--surface); }
header.top .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 10px; flex-wrap: wrap; }
header.top h1 { font-size: 1.15rem; margin: 0; }
header.top .by { color: var(--muted); font-size: .85rem; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 0; scrollbar-width: thin; }
nav.tabs button { white-space: nowrap; border-radius: 999px; padding: 6px 12px; font-size: .9rem; }
nav.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
main { padding: 16px 0 48px; }
section[hidden] { display: none; }
h2 { font-size: 1.05rem; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.notice { border-left: 3px solid var(--accent); padding: 8px 12px; background: var(--surface); margin: 10px 0; }
.badge { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--staff); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.customer { align-self: flex-end; background: var(--customer); }
.msg .meta { font-size: .78rem; color: var(--muted); margin-bottom: 4px; white-space: normal; }
.composer { display: flex; gap: 8px; margin-top: 14px; align-items: flex-end; }
.composer textarea { flex: 1; }
.options { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.options button.rec { border-color: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; vertical-align: top; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
tr.superseded td { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.table-scroll { overflow-x: auto; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.swatch { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.swatch .chip { height: 72px; }
.swatch .lbl { padding: 8px; font-size: .85rem; }
.font-sample { font-size: 1.4rem; margin: 4px 0; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.file img { width: 100%; height: 110px; object-fit: contain; background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 16px 16px; border-radius: 6px; }
pre.doc { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; font: .9rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } .msg { max-width: 100%; } }
.error { color: var(--warn); }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---------- round 4: shared views, admin detail, mobile ---------- */
.wrap-anywhere, .msg, td { overflow-wrap: anywhere; }
nav.tabs { flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
nav.tabs button { scroll-snap-align: start; flex: 0 0 auto; }
button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.detail-head { align-items: center; }
.detail-head h2 { margin: 0; }
.row { min-width: 0; }
.stack-form { display: grid; gap: 4px; }
.stack-form label { margin-top: 6px; }
.staff-form summary { cursor: pointer; font-weight: 600; }
.composer select { width: auto; }
.options .badge { font-size: .85rem; padding: 2px 10px; }

/* Tables become stacked cards on phones: each cell shows its column name (data-label). */
@media (max-width: 600px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr {
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
    padding: 8px 12px; margin: 0 0 10px;
  }
  table.stack td { border: 0; padding: 4px 0; }
  table.stack td::before {
    content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); font-weight: 600;
  }
  tr.superseded td { text-decoration: none; }
  tr.superseded { opacity: .7; }
  .composer { flex-wrap: wrap; }
  .composer textarea { flex-basis: 100%; }
  header.top h1 { font-size: 1.05rem; }
}
