:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1d1d1b;
  --muted: #6b6a65;
  --line: #e3e1da;
  --accent: #1f5fd1;
  --warn: #b3261e;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); }
header.top { display: flex; align-items: baseline; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--card); }
header.top h1 { font-size: 20px; margin: 0; letter-spacing: 0.04em; }
header.top .sub { color: var(--muted); font-size: 14px; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 24px 48px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.card h2 { font-size: 16px; margin: 0 0 10px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 3px; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; width: 100%; background: #fff; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
button { font: inherit; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; margin-top: 10px; }
button.ghost { background: #fff; color: var(--accent); }
.err { color: var(--warn); font-size: 13px; min-height: 1em; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
pre { background: #f1f0eb; padding: 8px 10px; border-radius: 6px; white-space: pre-wrap; word-break: break-all; margin: 6px 0; }
.small { font-size: 13px; color: var(--muted); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.pill { font-size: 11px; padding: 1px 6px; border-radius: 9px; background: #eceae3; color: var(--muted); margin-left: 4px; }
details summary { cursor: pointer; font-size: 14px; margin: 6px 0; }

/* room viewer */
.viewer { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .viewer { grid-template-columns: 1fr; } }
.stage { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.stage canvas { width: 100%; height: auto; display: block; }
.hud { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 0 4px 6px; font-variant-numeric: tabular-nums; }
.hud b { color: var(--ink); }
.overlay { position: absolute; left: 8%; right: 8%; top: 22%; background: rgba(40, 40, 40, 0.92); color: #eee; border-radius: 8px; padding: 14px 18px; text-align: center; font-size: 14px; line-height: 1.5; }
.overlay h3 { color: #ffd84a; margin: 0 0 6px; font-size: 18px; }
.overlay.hidden { display: none; }
.feed { font-size: 13px; max-height: 220px; overflow: auto; }
.feed div { padding: 2px 0; border-bottom: 1px dashed var(--line); }
.thinking { color: #b26b00; }

/* AI programs */
.prog { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal[hidden] { display: none; }
.modalbox { background: var(--card); border-radius: 10px; padding: 16px 18px; width: min(900px, 94vw); max-height: 88vh; overflow: auto; }
.codehead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.codehead button { margin: 0; }
pre.code { white-space: pre; word-break: normal; overflow: auto; font-size: 12.5px; line-height: 1.45; }
pre.code .add { background: #e3f6e6; color: #1b6b2b; display: inline-block; min-width: 100%; }
pre.code .del { background: #fbe4e2; color: #9b2c23; display: inline-block; min-width: 100%; }

.feed.chat div { padding: 3px 0; }
