:root {
  /* The Tandem palette (brand/README.md), shared with the desktop app. */
  --bg: #faf9f6;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --text: #1c1a17;
  --muted: #64605a;
  --border: #e4e0d8;
  --accent: #c2461a;
  --accent-text: #ffffff;
  --ok: #2d7449;
  --warn: #7f6000;
  --danger: #b4234a;
  --agent: #6650c2;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19;
    --surface: #252421;
    --surface-2: #2e2c29;
    --text: #eeebe4;
    --muted: #a39f95;
    --border: #33312d;
    --accent: #f07a45;
    --accent-text: #1c1b19;
    --ok: #6bc08e;
    --warn: #d8b64e;
    --danger: #ef7f98;
    --agent: #a99beb;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; width: 100%; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; }
.notice { color: var(--warn); border: 1px solid var(--warn); border-radius: var(--radius); padding: 8px 12px; }
.count:empty { display: none; }
.count { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }

.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.top select { width: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand img { border-radius: 5px; }
.spacer { flex: 1; }

.login { max-width: 420px; margin: 12vh auto; padding: 0 16px; }
.login form { display: flex; gap: 8px; }
.login form input { flex: 1; }
.login form.stack, .stack { flex-direction: column; display: flex; gap: 8px; }
.login details { margin: 16px 0; }
.login .links { display: flex; gap: 16px; }
.login .invite-card { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin: 12px 0; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 16px 0; }
.filters { display: flex; gap: 6px; }
.filters select { width: auto; padding: 3px 6px; font-size: 13px; }
.load { display: flex; gap: 8px; flex-wrap: wrap; }
.load .pill { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 12px; }
.load .pill.full { border-color: var(--danger); color: var(--danger); }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; padding: 12px 16px 24px; overflow-x: auto; align-items: start; }
.col { background: var(--surface-2); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.col h3 { margin: 2px 4px 8px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; cursor: pointer; }
.card:hover { border-color: var(--accent); }
.card .num { color: var(--muted); font-size: 12px; }
.card .title { font-weight: 600; margin: 2px 0 4px; overflow-wrap: anywhere; }
.meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.card .progress { font-size: 12px; margin-top: 4px; color: var(--muted); overflow-wrap: anywhere; }
.badge { border-radius: 4px; padding: 0 5px; font-size: 11px; border: 1px solid var(--border); }
.badge.high { color: var(--danger); border-color: var(--danger); }
.badge.medium { color: var(--warn); border-color: var(--warn); }
.badge.low { color: var(--ok); border-color: var(--ok); }
.who.agent { color: var(--agent); }

.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); background: var(--surface); border-left: 1px solid var(--border); padding: 12px 16px; overflow-y: auto; z-index: 10; box-shadow: -4px 0 16px rgba(0,0,0,.08); }
.panel.wide { width: min(620px, 100vw); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.panel-head h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.panel h3 { font-size: 13px; color: var(--muted); margin: 18px 0 6px; text-transform: none; }
.panel .item { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; margin-bottom: 8px; }
.panel .item .opts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.spec dt { font-size: 12px; color: var(--muted); margin-top: 10px; }
.spec dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }
.history { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.history li { padding: 4px 0; border-bottom: 1px dashed var(--border); overflow-wrap: anywhere; }
.check { display: flex; gap: 6px; }
.check .mark.pass { color: var(--ok); }
.check .mark.fail { color: var(--danger); }
.messages { list-style: none; padding: 0; margin: 0 0 8px; font-size: 13px; }
.messages li { padding: 6px 8px; margin-bottom: 6px; border-left: 3px solid var(--agent); background: var(--surface-2); border-radius: 0 6px 6px 0; }
.messages .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.messages .ghost, .message-form .ghost { padding: 0 6px; font-size: 12px; }
.message-form { display: grid; gap: 6px; }
.message-form .row-between { gap: 8px; align-items: center; }
.message-form label.inline { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.message-form select { width: auto; max-width: 200px; }
.hint { font-size: 12px; }
.guidelines { white-space: pre-wrap; background: var(--surface-2); padding: 8px; border-radius: 6px; font-size: 12px; }

dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); width: min(640px, calc(100vw - 32px)); padding: 16px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin-top: 0; }
dialog label { display: block; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
dialog label > input, dialog label > textarea, dialog label > select { margin-top: 2px; color: var(--text); font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 140px; }

@media (max-width: 640px) {
  .board { grid-auto-flow: row; grid-auto-columns: auto; }
  .top { gap: 6px; }
}

.secret { background: var(--surface-2); border: 1px dashed var(--warn); border-radius: 6px; padding: 8px; margin: 8px 0; }
.secret code, pre.snippet { display: block; white-space: pre-wrap; word-break: break-all; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.team-code .code { font: 600 16px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.08em; }
pre.snippet { background: var(--surface-2); padding: 8px; border-radius: 6px; margin: 6px 0; }
.copyable { display: flex; gap: 6px; align-items: center; }
.copyable pre.snippet { flex: 1; min-width: 0; background: var(--surface); }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 6px 0; }
.inline-form input, .inline-form select { flex: 1; min-width: 120px; width: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list td { padding: 5px 4px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.small { font-size: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 1px 4px 1px 10px; font-size: 12px; }
.chip button { padding: 0 6px; line-height: 1.2; }
details summary { cursor: pointer; color: var(--muted); margin-top: 8px; }

/* Joining a project with an agent, and who is online */
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 10px 16px 0; padding: 10px 12px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--surface); }
.panel .banner { margin: 8px 0; }
.agents-strip { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 16px 0; }
.agents-strip:empty { display: none; }
.agents-strip .pill { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 12px; color: var(--agent); }
.agents-strip .pill.paused { color: var(--muted); }
.pill-toggle { border: 0; background: none; padding: 0 0 0 6px; font-size: 11px; cursor: pointer; color: inherit; }
.auto-claim { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-right: 4px; }
.auto-claim .switch button { padding: 2px 10px; font-size: 12px; }
.switch button.on.off { background: var(--warn); color: #fff; }
.auto-claim-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.agents-strip .pill.add { border-style: dashed; color: var(--muted); cursor: pointer; font: inherit; font-size: 12px; }
.agents-strip .pill.add:hover { color: var(--agent); border-color: var(--agent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--border); vertical-align: middle; }
.dot.on { background: var(--ok); }
.warn { color: var(--warn); font-size: 12px; }
dialog.join .existing { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* View switch and the project's 2D world */
.switch { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.switch button { border: 0; border-radius: 0; padding: 3px 12px; font-size: 13px; background: var(--surface); }
.switch button.on { background: var(--accent); color: var(--accent-text); }
.world { padding: 10px 16px 24px; }
.world-stage { position: relative; max-width: 1280px; }
.world-canvas { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); border: 1px solid var(--border); background: #e3dccd; }
.world-tip { position: absolute; transform: translate(-50%, calc(-100% - 6px)); background: var(--text); color: var(--bg); font-size: 12px; padding: 3px 8px; border-radius: 4px; pointer-events: none; white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.world-legend { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
/* On phones the world keeps a readable size and scrolls sideways. */
@media (max-width: 700px) { .world { overflow-x: auto; } .world-stage { min-width: 640px; } }
.agent-chip { border: 1px solid var(--border); border-radius: 14px; padding: 2px 10px; font-size: 12px; color: var(--agent); }
.agent-chip.selected { border-color: var(--accent); }
.dot.state-working { background: #2fbf71; }
.dot.state-waiting { background: #e9b43a; }
.dot.state-idle { background: #6aa8f0; }
.dot.state-paused { background: #a08cf5; }
.dot.state-offline { background: var(--border); }
.state.working { color: var(--ok); }
.state.waiting { color: var(--warn); }
.state.offline { color: var(--muted); }
.record { padding: 3px 0; border-bottom: 1px dashed var(--border); font-size: 13px; overflow-wrap: anywhere; }
.record code { font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* Notifications */
dialog.notify { width: min(560px, calc(100vw - 32px)); }
dialog.notify h3 { font-size: 13px; color: var(--muted); margin: 18px 0 6px; }
dialog.notify .item { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; margin-bottom: 8px; }
dialog.notify .opts { display: flex; gap: 6px; flex-wrap: wrap; }
.checks label.check { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--text); font-size: 14px; }
.checks input[type="checkbox"] { width: auto; margin: 0; }
.flash { color: var(--ok); }
.switch.small { margin-bottom: 8px; }
/* Project doc */
.doc { max-width: 880px; margin: 0 auto; padding: 8px 16px 40px; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.doc-head h2 { margin: 0 0 2px; font-size: 20px; }
.doc-head .actions { margin-top: 0; }
.doc-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 12px 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.doc-facts dt { color: var(--muted); }
.doc-facts dd { margin: 0; overflow-wrap: anywhere; }
.doc > h3 { font-size: 15px; margin: 24px 0 8px; }
.md { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px; overflow-wrap: anywhere; }
.md p { white-space: pre-wrap; }
.md h2, .md h3, .md h4, .md h5, .md h6 { margin: 16px 0 6px; }
.md h2 { font-size: 18px; } .md h3 { font-size: 16px; } .md h4, .md h5, .md h6 { font-size: 14px; }
.md code { font: 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.md pre { background: var(--surface-2); padding: 10px; border-radius: 6px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 8px 0; padding: 0 12px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.doc-edit label { display: block; margin-top: 10px; }
textarea.mono { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin-top: 2px; }
.doc-edit input:disabled { color: var(--muted); background: var(--surface-2); }
