:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --panel-2: #efece4;
  --ink: #1d1b18;
  --ink-2: #6b665c;
  --line: #e2ddd2;
  --accent: #e8572a;
  --accent-ink: #ffffff;
  --claude: #c96442;
  --claude-bg: #fbeee6;
  --dev: #2f6fd6;
  --ok: #2e8b57;
  --warn: #b7791f;
  --bad: #c53030;
  --radius: 12px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --panel: #1d1c19;
    --panel-2: #262420;
    --ink: #f1ede4;
    --ink-2: #a39d90;
    --line: #34312b;
    --claude-bg: #2c211c;
    --dev: #6ea1ff;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--ink-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
input, textarea, select {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 10px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

/* ---------- centered card pages (welcome, join, admin login) */
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; width: min(420px, 100%);
}
.card h1 { margin: 0 0 6px; font-size: 22px; }
.card form { display: grid; gap: 10px; margin-top: 18px; }
.logo { font-weight: 800; letter-spacing: -.02em; }
.logo span { color: var(--accent); }
.error { color: var(--bad); font-size: 14px; min-height: 1.2em; }

/* ---------- chat layout */
.app { display: grid; grid-template-columns: 220px 1fr 320px; height: 100%; }
.sidebar { background: var(--panel-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar header { padding: 16px; }
.channels { list-style: none; margin: 0; padding: 0 8px; overflow: auto; flex: 1; }
.channels button {
  width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px;
  display: flex; justify-content: space-between; gap: 8px;
}
.channels button.active { background: var(--panel); font-weight: 600; }
.channels .unread { background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 11px; padding: 0 7px; }
.sidebar footer { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 0; font-size: 17px; }
.topbar .blurb { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play { text-decoration: none; background: var(--accent); color: var(--accent-ink); padding: 6px 12px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.menu-btn, .board-btn { display: none; }

.log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 2px; }
.msg { padding: 4px 10px; border-radius: 10px; max-width: 760px; }
.msg .who { font-weight: 650; font-size: 13px; }
.msg .when { color: var(--ink-2); font-size: 12px; margin-left: 6px; font-weight: 400; }
.msg .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.claude { background: var(--claude-bg); margin: 4px 0; }
.msg.claude .who { color: var(--claude); }
.msg.admin .who { color: var(--dev); }
.tag { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; }
.msg.cont .who { display: none; }
.msg { position: relative; }
.file-btn { position: absolute; top: 2px; right: 6px; font-size: 11px; padding: 1px 8px; opacity: 0; }
.msg:hover .file-btn, .file-btn:focus, .file-btn:disabled { opacity: 1; }
@media (hover: none) { .file-btn { position: static; opacity: .8; margin-top: 2px; } }
.typing { color: var(--ink-2); font-size: 13px; padding: 0 16px 6px; min-height: 22px; }
.empty { margin: auto; text-align: center; color: var(--ink-2); max-width: 360px; }

.composer { display: flex; gap: 8px; padding: 12px 16px 16px; }
.composer textarea { resize: none; height: 44px; max-height: 160px; }

.board { border-left: 1px solid var(--line); background: var(--panel); overflow: auto; padding: 16px; }
.board h3 { margin: 0 0 4px; font-size: 15px; }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.item .title { font-weight: 600; }
.item .meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.item .detail { margin-top: 6px; font-size: 13px; color: var(--ink-2); white-space: pre-wrap; display: none; }
.item.open .detail { display: block; }
.chip { font-size: 11px; border-radius: 99px; padding: 1px 8px; background: var(--panel-2); color: var(--ink-2); white-space: nowrap; }
.chip.s-building, .chip.s-shipping, .chip.s-ship_requested { background: #fdf1d8; color: var(--warn); }
.chip.s-ready { background: #e0edff; color: var(--dev); }
.chip.s-shipped { background: #e1f3e8; color: var(--ok); }
.chip.s-failed, .chip.s-ship_failed { background: #fde2e2; color: var(--bad); }
.chip.s-rejected { text-decoration: line-through; }
@media (prefers-color-scheme: dark) {
  .chip.s-building, .chip.s-shipping, .chip.s-ship_requested { background: #3a2e12; }
  .chip.s-ready { background: #1a2a45; }
  .chip.s-shipped { background: #16301f; }
  .chip.s-failed, .chip.s-ship_failed { background: #3d1a1a; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar, .board { position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  .board { inset: 0 0 0 auto; transform: translateX(100%); }
  body.show-sidebar .sidebar, body.show-board .board { transform: none; box-shadow: 0 0 40px #0004; }
  .menu-btn, .board-btn { display: inline-block; }
  .topbar .blurb { display: none; }
  .topbar h2 { flex: 1; }
}

/* ---------- admin */
.admin { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
.admin h1 { margin: 0; font-size: 22px; }
.admin section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.admin section h2 { margin: 0 0 10px; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input { flex: 1; min-width: 140px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-weight: 500; }
code, pre { font-family: var(--mono); font-size: 12px; }
pre { background: var(--panel-2); padding: 8px; border-radius: 8px; overflow: auto; white-space: pre-wrap; max-height: 260px; margin: 6px 0 0; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 6px; }
.status-dot.on { background: var(--ok); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs button.active { background: var(--ink); color: var(--bg); }
.aitem { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-top: 10px; }
.aitem .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
@media (max-width: 600px) { .hide-sm { display: none; } }
