:root {
  --primary: #0073ea;
  --primary-hover: #0060b9;
  --primary-soft: #cce5ff;
  --bg: #eceff8;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --hover: #dcdfec;
  --row-hover: #f5f6f8;
  --text: #323338;
  --muted: #676879;
  --border: #d0d4e4;
  --border-light: #e6e9ef;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 4px 8px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --danger: #d83a52;
  --agent: #a25ddc;
  --on-color: #ffffff;
  --sidebar-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #0073ea;
    --primary-hover: #1f8bff;
    --primary-soft: #133774;
    --bg: #181b34;
    --surface: #30324e;
    --surface-2: #292f4c;
    --hover: #4b4e69;
    --row-hover: #393b53;
    --text: #d5d8df;
    --muted: #9699a6;
    --border: #4b4e69;
    --border-light: #3d3f5b;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary-hover: #1f8bff;
  --primary-soft: #133774;
  --bg: #181b34;
  --surface: #30324e;
  --surface-2: #292f4c;
  --hover: #4b4e69;
  --row-hover: #393b53;
  --text: #d5d8df;
  --muted: #9699a6;
  --border: #4b4e69;
  --border-light: #3d3f5b;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Figtree, 'Roboto', -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; }
code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
pre { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; background: var(--surface-2); padding: 10px 12px; border-radius: 6px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
pre code { background: none; padding: 0; }
.boot { height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { transform: scale(0.9); opacity: 0.6; } }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
.hidden { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: 4px; border: 0; cursor: pointer;
  background: var(--primary); color: #fff; font-weight: 500; white-space: nowrap;
  transition: background 0.1s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--hover); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); }
.btn.agent { background: var(--agent); }
.btn.agent:hover { background: #8b45c6; }
.btn.lg { height: 40px; padding: 0 20px; font-size: 15px; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 4px;
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.split { display: inline-flex; }
.split .btn:first-child { border-radius: 4px 0 0 4px; }
.split .btn:last-child { border-radius: 0 4px 4px 0; border-left: 1px solid rgba(255,255,255,0.35); padding: 0 8px; }
.input, select.input, textarea.input {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); outline: none;
}
textarea.input { height: auto; min-height: 90px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.input:hover { border-color: var(--text); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
[data-theme="dark"] .seg button.on, :root:not([data-theme="light"]) .seg button.on { color: var(--text); }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 500px at 10% 0%, rgba(162, 93, 220, 0.18), transparent),
              radial-gradient(900px 500px at 100% 100%, rgba(0, 200, 117, 0.15), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 12px; padding: 36px 32px; box-shadow: var(--shadow-sm); }
.auth-card .brand { margin-bottom: 22px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); }
.auth-card .btn { width: 100%; margin-top: 6px; }
.error-box { background: #ffe6e9; color: #bb3354; border-radius: 4px; padding: 8px 12px; margin-bottom: 14px; font-size: 13px; }

/* ---------- shell ---------- */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: -0.02em; }
.brand img { width: 30px; height: 30px; }
.brand small { font-weight: 400; color: var(--muted); font-size: 13px; letter-spacing: 0; margin-left: 2px; }
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; grid-template-rows: 56px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 18px; }
.topbar .search { position: relative; width: 340px; max-width: 40vw; margin-left: 24px; }
.topbar .search .input { height: 32px; padding-left: 32px; background: var(--surface); border-color: transparent; border-radius: 16px; }
.topbar .search svg { position: absolute; left: 10px; top: 8px; color: var(--muted); }
.search-results { position: absolute; top: 38px; left: 0; right: 0; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); z-index: 50; max-height: 420px; overflow: auto; padding: 6px; }
.search-results .res { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 4px; cursor: pointer; }
.search-results .res:hover { background: var(--row-hover); }
.agent-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 14px; background: var(--surface); font-size: 13px; cursor: pointer; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c4c4c4; display: inline-block; flex: none; }
.dot.on { background: #00c875; box-shadow: 0 0 0 3px rgba(0, 200, 117, 0.25); }
.dot.busy { background: #fdab3d; animation: pulse 1s infinite; }
.menu-toggle { display: none; }

.sidebar { padding: 8px 10px 16px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 6px; color: var(--text); cursor: pointer; font-size: 14px; }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.on { background: var(--primary-soft); }
.nav-item svg { flex: none; color: var(--muted); }
.nav-item.on svg { color: var(--primary); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--muted); }
.nav-section { margin: 16px 10px 6px; font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.ws-badge { width: 22px; height: 22px; border-radius: 5px; background: linear-gradient(135deg, #a25ddc, #0073ea); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.sidebar .spacer { flex: 1; }
.main { background: var(--surface); border-top-left-radius: 16px; overflow: auto; position: relative; min-width: 0; }
.page { padding: 26px 32px 60px; max-width: 1500px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; letter-spacing: -0.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-light); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); border-radius: 4px 4px 0 0; }
.tabs button:hover { background: var(--row-hover); color: var(--text); }
.tabs button.on { border-bottom-color: var(--primary); color: var(--text); font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar .input { width: 220px; height: 32px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 4px; border: 0; background: transparent; cursor: pointer; color: var(--text); }
.chip:hover { background: var(--hover); }
.chip.on { background: var(--primary-soft); }

/* ---------- avatars & pills ---------- */
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 600; flex: none; user-select: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 10px; }
.avatar.lg { width: 36px; height: 36px; font-size: 14px; }
.avatar.nobody { background: transparent; border: 1px dashed var(--border); color: var(--muted); }
.avatar { align-self: center; overflow: hidden; }
.avatar.agent { background: #a25ddc; }
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 11px; color: var(--on-color); font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.outline { background: transparent !important; border: 1px solid var(--border); color: var(--text); }
.role-admin { background: #0073ea; } .role-developer { background: #00c875; } .role-reporter { background: #fdab3d; } .role-agent { background: #a25ddc; }

/* ---------- board table ---------- */
.group { margin-bottom: 36px; }
.group-head { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.group-head .caret { cursor: pointer; transition: transform 0.15s; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; }
.group-head .caret:hover { background: var(--hover); }
.group.collapsed .caret { transform: rotate(-90deg); }
.group-head h2 { font-size: 18px; font-weight: 600; }
.group-head .n { color: var(--muted); font-size: 13px; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.table-wrap { overflow-x: auto; }
.table th { font-weight: 400; color: var(--muted); font-size: 13px; height: 36px; border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light); border-right: 1px solid var(--border-light); text-align: center; background: var(--surface); }
.table th:first-child { border-left: 6px solid var(--gc); border-top-left-radius: 6px; text-align: left; padding-left: 14px; }
.table th:last-child { border-top-right-radius: 6px; }
.table td { height: 40px; border-bottom: 1px solid var(--border-light); border-right: 1px solid var(--border-light); padding: 0; text-align: center; background: var(--surface); }
.table td:first-child { border-left: 6px solid var(--gc); text-align: left; }
.table tr:hover td { background: var(--row-hover); }
.table tr.selected td { background: var(--primary-soft); }
.table tr.add td { border-bottom-left-radius: 6px; }
.cell-title { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 14px; height: 40px; cursor: pointer; min-width: 0; }
.cell-title .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.cell-title .id { color: var(--muted); font-size: 12px; flex: none; }
.cell-title .bubble { color: var(--muted); display: inline-flex; align-items: center; gap: 3px; font-size: 12px; flex: none; padding: 2px 4px; border-radius: 4px; }
.cell-title .bubble.has { color: var(--primary); }
.cell-title:hover .bubble { background: var(--hover); }
.fill { height: 40px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 13px; cursor: pointer; padding: 0 6px; position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fill.ro { cursor: default; }
.fill:not(.ro):hover::after { content: ''; position: absolute; top: 0; right: 0; border-width: 0 10px 10px 0; border-style: solid; border-color: transparent rgba(0,0,0,0.25) transparent transparent; }
.fill.light { color: var(--text); }
.fill.plain { color: var(--text); background: transparent; }
.fill.running { background-image: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.35) 50%, rgba(255,255,255,0) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.add-row input { border: 1px solid transparent; background: transparent; height: 32px; width: 100%; padding: 0 12px; outline: none; border-radius: 4px; }
.add-row input:hover { border-color: var(--border); }
.add-row input:focus { border-color: var(--primary); background: var(--surface); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty img { width: 64px; opacity: 0.8; margin-bottom: 12px; }

/* ---------- kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kcol { flex: 0 0 280px; background: var(--surface-2); border-radius: 8px; padding: 0 0 8px; min-height: 120px; }
.kcol-head { height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; color: #fff; font-weight: 600; border-radius: 8px 8px 0 0; }
.kcol.drop { outline: 2px dashed var(--primary); outline-offset: -2px; }
.kcards { padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.kcard { background: var(--surface); border-radius: 6px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.12); cursor: pointer; border-left: 4px solid var(--gc); }
.kcard:hover { box-shadow: var(--shadow-sm); }
.kcard .t { font-weight: 500; margin-bottom: 8px; line-height: 1.35; }
.kcard .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------- popover / modal / drawer ---------- */
.popover { position: fixed; z-index: 1000; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 8px; min-width: 180px; max-height: 60vh; overflow: auto; }
.pick-list { display: flex; flex-direction: column; gap: 6px; padding: 4px; }
.pick-list .opt { height: 32px; border-radius: 2px; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 13px; border: 0; padding: 0 12px; min-width: 160px; }
.pick-list .opt:hover { opacity: 0.85; }
.pick-list .opt.plain { color: var(--text); background: transparent; justify-content: flex-start; gap: 8px; }
.pick-list .opt.plain:hover { background: var(--row-hover); opacity: 1; }
.pick-list .opt.cur { outline: 2px solid var(--text); outline-offset: 1px; }
.menu { display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 8px 12px; border-radius: 4px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--row-hover); }
.menu hr { border: 0; border-top: 1px solid var(--border-light); margin: 6px 0; }
.menu .desc { display: block; font-size: 12px; color: var(--muted); }

.overlay { position: fixed; inset: 0; background: rgba(41, 47, 76, 0.6); z-index: 500; display: grid; place-items: center; padding: 16px; animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 8px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow); animation: rise 0.18s ease-out; }
.modal.wide { max-width: 920px; }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.modal-head { display: flex; align-items: center; padding: 20px 24px 8px; gap: 12px; }
.modal-head h2 { font-size: 22px; flex: 1; }
.modal-body { padding: 8px 24px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 20px; }

.drawer-back { position: fixed; inset: 0; z-index: 400; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--surface); z-index: 401; box-shadow: -8px 0 30px rgba(0,0,0,0.18); display: flex; flex-direction: column; }
.drawer.opening { animation: slide 0.2s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { padding: 16px 20px 0; }
.drawer-head .top { display: flex; align-items: flex-start; gap: 8px; }
.title-edit { flex: 1; font-size: 22px; font-weight: 600; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; margin-left: -7px; background: transparent; outline: none; min-width: 0; resize: none; line-height: 1.3; overflow: hidden; }
.title-edit:not([readonly]):hover { border-color: var(--border); }
.title-edit:focus { border-color: var(--primary); }
.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; margin: 10px 0 12px; }
.prop { display: flex; flex-direction: column; gap: 3px; }
.prop > span { font-size: 12px; color: var(--muted); }
.prop .fill { height: 30px; border-radius: 4px; font-size: 13px; }
.prop .fill.plain { justify-content: flex-start; gap: 6px; border: 1px solid var(--border-light); padding: 0 8px; }
.drawer .tabs { margin: 0 20px; }
.drawer-body { flex: 1; overflow: auto; padding: 4px 20px 16px; }
.drawer-foot { border-top: 1px solid var(--border-light); padding: 12px 20px 16px; }

/* ---------- chat ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg .bubble-box { flex: 1; min-width: 0; border: 1px solid var(--border-light); border-radius: 8px; padding: 10px 14px; background: var(--surface); }
.msg.agent .bubble-box { border-color: rgba(162, 93, 220, 0.45); background: linear-gradient(0deg, rgba(162, 93, 220, 0.06), rgba(162, 93, 220, 0.06)), var(--surface); }
.msg.desc .bubble-box { background: var(--surface-2); border-color: transparent; }
.msg .who { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.msg .who b { font-weight: 600; }
.msg .who .when { color: var(--muted); font-size: 12px; }
.msg .who .del { margin-left: auto; opacity: 0; }
.msg:hover .who .del { opacity: 1; }
.md { line-height: 1.55; word-wrap: break-word; }
.md p { margin: 0 0 6px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 6px; padding-left: 20px; }
.md h3, .md h4 { font-size: 14px; margin: 8px 0 4px; }
.sys { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; padding-left: 38px; }
.sys::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--border); flex: none; }
.sys b, .sys strong { color: var(--text); font-weight: 600; }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att-img { width: 150px; height: 110px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border-light); cursor: zoom-in; background: var(--surface-2); }
.att-img img, .att-img video { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-file { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border-light); border-radius: 6px; max-width: 280px; color: var(--text); }
.att-file:hover { background: var(--row-hover); text-decoration: none; }
.att-file .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ext { display: inline-grid; place-items: center; min-width: 34px; height: 34px; padding: 0 4px; border-radius: 6px; font-size: 10px; font-weight: 700; color: #fff; background: #579bfc; text-transform: uppercase; }
.composer { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); transition: border-color 0.1s; }
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.composer.drag { border-color: var(--agent); box-shadow: 0 0 0 2px var(--agent); }
.composer textarea { width: 100%; border: 0; outline: none; resize: none; padding: 10px 12px; min-height: 64px; max-height: 240px; background: transparent; line-height: 1.5; }
.composer .pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.composer .pending .p { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 4px; padding: 3px 4px 3px 8px; font-size: 12px; max-width: 220px; }
.composer .pending .p img { width: 26px; height: 26px; object-fit: cover; border-radius: 3px; }
.composer .pending .p span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer .bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--border-light); }
.progress { height: 3px; background: var(--primary); width: 0; transition: width 0.2s; border-radius: 2px; }

/* ---------- agent activity ---------- */
.job { border: 1px solid var(--border-light); border-radius: 8px; margin: 10px 0; overflow: hidden; }
.job-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); flex-wrap: wrap; }
.logs { max-height: 420px; overflow: auto; padding: 8px 12px; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.log { display: flex; gap: 8px; align-items: baseline; }
.log .k { flex: none; width: 16px; text-align: center; }
.log.tool .v { font-family: ui-monospace, Menlo, monospace; color: var(--muted); word-break: break-all; }
.log.error .v { color: var(--danger); white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; }
.log.text .v { min-width: 0; }
.log.info .v { color: var(--agent); font-weight: 500; }

/* ---------- cards / home ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat { border: 1px solid var(--border-light); border-radius: 8px; padding: 16px 18px; cursor: pointer; transition: box-shadow 0.15s; position: relative; overflow: hidden; }
.stat:hover { box-shadow: var(--shadow-sm); }
.stat::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c); }
.stat .v { font-size: 30px; font-weight: 700; margin-top: 4px; }
.stat .l { color: var(--muted); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 30px; }
.quick button { display: flex; gap: 14px; align-items: center; text-align: left; border: 1px solid var(--border-light); background: var(--surface); border-radius: 10px; padding: 16px; cursor: pointer; transition: all 0.15s; }
.quick button:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); border-color: var(--border); }
.quick .ico { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.quick b { display: block; font-size: 15px; margin-bottom: 2px; }
.quick span { color: var(--muted); font-size: 13px; }
.panel { border: 1px solid var(--border-light); border-radius: 8px; padding: 6px 0; }
.panel h3 { font-size: 16px; padding: 10px 16px 8px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; }
.list-row:hover { background: var(--row-hover); }
.list-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }

/* ---------- assets ---------- */
.dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 22px; text-align: center; color: var(--muted); margin-bottom: 20px; cursor: pointer; transition: all 0.15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.asset { border: 1px solid var(--border-light); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--surface); transition: box-shadow 0.15s, transform 0.15s; }
.asset:hover { box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.asset .thumb { height: 140px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; background-image: linear-gradient(45deg, var(--border-light) 25%, transparent 25%), linear-gradient(-45deg, var(--border-light) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--border-light) 75%), linear-gradient(-45deg, transparent 75%, var(--border-light) 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.asset .thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.asset .thumb .big-ext { width: 64px; height: 64px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; text-transform: uppercase; }
.asset .info { padding: 10px 12px; }
.asset .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 6px; }
.asset .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.asset-preview { background: var(--surface-2); border-radius: 8px; min-height: 260px; display: grid; place-items: center; overflow: hidden; margin-bottom: 16px; }
.asset-preview img { max-width: 100%; max-height: 60vh; }
.asset-preview .model-view { position: relative; width: 100%; height: 440px; display: flex; flex-direction: column; }
.model-view canvas { flex: 1; min-height: 0; width: 100%; display: block; cursor: grab; touch-action: none; }
.model-view canvas:active { cursor: grabbing; }
.model-status { position: absolute; top: 10px; left: 12px; font-size: 12px; color: var(--muted); background: var(--surface); border-radius: 6px; padding: 3px 8px; opacity: 0.9; pointer-events: none; }
.model-status.error { color: var(--danger); position: static; margin: auto; }
.model-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--border-light); background: var(--surface); }
.model-bar select.input { width: auto; max-width: 260px; padding-top: 4px; padding-bottom: 4px; }
.model-bar .muted:first-child { margin-right: auto; }
.asset .thumb .model-thumb { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.asset .thumb .model-thumb img { width: 100%; height: 100%; object-fit: contain; }
.model-thumb.working .big-ext { animation: thumb-pulse 1s ease-in-out infinite alternate; }
@keyframes thumb-pulse { from { opacity: 0.45; } to { opacity: 1; } }
.anim-badge { position: absolute; right: 8px; top: 8px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 2px 7px; }
@media (max-width: 640px) { .asset-preview .model-view { height: 340px; } }
.tag { display: inline-block; background: var(--surface-2); border-radius: 4px; padding: 1px 6px; font-size: 12px; color: var(--muted); }

/* ---------- misc ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 2000; display: grid; place-items: center; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 4px; }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #323338; color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: var(--shadow); animation: rise 0.2s; font-size: 14px; }
.toast.ok { background: #00854d; }
.toast.err { background: #d83a52; }
.card-box { border: 1px solid var(--border-light); border-radius: 8px; padding: 18px 20px; margin-bottom: 20px; }
.card-box h3 { font-size: 16px; margin-bottom: 12px; }
.simple-table { width: 100%; border-collapse: collapse; }
.simple-table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px; border-bottom: 1px solid var(--border-light); }
.simple-table td { padding: 8px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
.copy-box { display: flex; gap: 6px; margin-top: 8px; }
.copy-box input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.color-swatches { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; }
.color-swatches button { width: 26px; height: 26px; border-radius: 4px; border: 0; cursor: pointer; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 56px; left: 0; bottom: 0; width: var(--sidebar-w); background: var(--bg); z-index: 300; transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--shadow); }
  .shell.nav-open .sidebar { transform: none; }
  .menu-toggle { display: inline-grid; }
  .main { border-top-left-radius: 0; }
  .page { padding: 18px 16px 60px; }
  .topbar .search { margin-left: 0; flex: 1; max-width: none; width: auto; }
  .topbar .brand small, .agent-chip .lbl { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .table { min-width: 860px; }
}

/* ---------- games ---------- */
.game-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.nav-item .count { display: inline-flex; align-items: center; gap: 6px; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #cab641; color: #fff; font-size: 11px; font-weight: 700; margin-left: 6px; }
.game-icon { display: inline-grid; place-items: center; border-radius: 10px; color: #fff; font-weight: 700; flex: none; letter-spacing: -0.02em; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-bottom: 30px; }
.game-card { display: flex; flex-direction: column; gap: 10px; text-align: left; border: 1px solid var(--border-light); border-top: 4px solid var(--gc, var(--border)); background: var(--surface); border-radius: 10px; padding: 16px; color: var(--text); cursor: pointer; transition: box-shadow 0.15s, transform 0.15s; font: inherit; }
.game-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); text-decoration: none; }
.game-card b { font-size: 16px; }
.game-card .desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.game-card.add { align-items: center; justify-content: center; border-style: dashed; border-top-width: 1px; color: var(--muted); min-height: 150px; gap: 6px; }
.game-card.add b { color: var(--text); font-size: 15px; }
.section-title { font-size: 18px; margin: 8px 0 12px; display: flex; align-items: center; gap: 8px; }
.home-section { margin-bottom: 28px; }
.game-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; flex-wrap: wrap; }
.game-head h1 { font-size: 28px; letter-spacing: -0.01em; }
.game-head p { margin: 6px 0 0; color: var(--muted); max-width: 820px; line-height: 1.5; }
.rules { border: 1px solid var(--border-light); border-left: 4px solid var(--agent); border-radius: 8px; padding: 0 16px; margin-bottom: 16px; background: var(--surface); }
.rules summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; padding: 12px 0; flex-wrap: wrap; }
.rules summary::-webkit-details-marker { display: none; }
.rules summary svg { color: var(--agent); }
.rules[open] { padding-bottom: 14px; }
.ask-box { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color 0.15s, box-shadow 0.15s; }
.ask-box:focus-within { border-color: var(--agent); box-shadow: 0 0 0 1px var(--agent), var(--shadow-sm); }
.ask-box.drag { border-color: var(--agent); box-shadow: 0 0 0 3px rgba(162, 93, 220, 0.3); }
.ask-box textarea { width: 100%; border: 0; outline: none; resize: none; background: transparent; font-size: 15px; line-height: 1.5; min-height: 72px; }
.ask-box .pending { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-box .pending .p { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 4px; padding: 3px 4px 3px 8px; font-size: 12px; max-width: 220px; }
.ask-box .pending .p img { width: 26px; height: 26px; object-fit: cover; border-radius: 3px; }
.ask-box .pending .p span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700; margin-left: 6px; }
.tab-count.warn { background: #cab641; color: #fff; }
.tab-count.ask { background: #ff642e; color: #fff; }
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-card { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border-light); border-left: 4px solid var(--gc, var(--border)); border-radius: 8px; background: var(--surface); cursor: pointer; transition: box-shadow 0.12s; flex-wrap: wrap; }
.item-card:hover { box-shadow: var(--shadow-sm); }
.item-card.selected { background: var(--primary-soft); }
.item-card .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 700px) { .item-card .t { white-space: normal; } }

/* ---------- asset library ---------- */
.upload-box .dropzone { margin-bottom: 0; padding: 16px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border-light); margin: 0 4px; }
.asset-section { margin-bottom: 30px; }
.asset .thumb { height: 130px; }
.asset .meta .folder { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.src.repo { background: rgba(0, 115, 234, 0.12); color: var(--primary); }
.src.upload { background: rgba(162, 93, 220, 0.15); color: #7e3bb5; }
.pack-nav { margin: -4px 0 14px; }
.pack-nav .crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 8px; }
.pack-nav .crumb { background: none; border: 0; padding: 2px 4px; border-radius: 4px; color: var(--primary); cursor: pointer; font: inherit; font-weight: 600; }
.pack-nav .crumb.on { color: var(--text); cursor: default; }
.pack-nav .crumb:not(.on):hover { background: var(--surface-2); }
.pack-nav .folders { display: flex; flex-wrap: wrap; gap: 6px; max-height: 168px; overflow-y: auto; }
.pack-nav .folders .chip { display: inline-flex; align-items: center; gap: 5px; }
.tag-editor { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-editor .input { padding-top: 3px; padding-bottom: 3px; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; background: rgba(0, 115, 234, 0.1); color: var(--primary); border-radius: 12px; padding: 2px 4px 2px 9px; font-size: 12px; font-weight: 600; }
.tag-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 4px; border-radius: 8px; }
.tag-chip button:hover { background: rgba(0, 115, 234, 0.18); }
.tag-chip.inherited { background: var(--surface-2); color: var(--muted); padding-right: 9px; }
.src.library { background: rgba(3, 127, 76, 0.13); color: #037f4c; }

.item-card .item-main { flex: 1 1 220px; min-width: 0; }
@media (max-width: 700px) {
  .rules summary .muted { display: none; }
  .topbar .search { display: none; }
  .game-head h1 { font-size: 24px; }
}

/* ---------- play here: the game next to the work ---------- */
.play-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(380px, 1fr); height: 100%; }
.play-pane { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--border-light); background: #11131f; border-top-left-radius: 16px; overflow: hidden; }
.play-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border-light); flex-wrap: wrap; font-size: 13px; }
.play-bar .seg button { padding: 3px 9px; font-size: 12px; }
.play-status { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--text); }
.play-status code { font-size: 11.5px; }
.play-stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; position: relative; }
.game-frame { border: 0; background: #000; display: block; transform-origin: center center; }
.work-pane { overflow: auto; padding: 20px 22px 60px; min-width: 0; }
.work-pane .game-head { margin-bottom: 14px; }
.work-pane .game-head h1 { font-size: 22px; }
.work-pane .item-card .pill { min-width: 0 !important; }
@media (max-width: 1100px) {
  .play-layout { grid-template-columns: 1fr; grid-template-rows: auto auto; height: auto; }
  .play-pane { border-right: 0; border-radius: 0; }
  .play-stage { height: 56vw; min-height: 260px; }
  .work-pane { overflow: visible; }
}
.work-pane .item-card { flex-wrap: nowrap; }
.work-pane .item-card .item-main { flex-basis: 120px; }
.work-pane .item-card > .pill:first-child { display: none; }

/* ---------- game console + screenshot ---------- */
.console-btn { position: relative; }
.console-btn .badge { margin-left: 2px; }
.badge.err { background: #e2445c; }
.badge.warn { background: #fdab3d; }
.play-stage.flash::after { content: ''; position: absolute; inset: 0; background: #fff; opacity: 0.6; animation: flash 0.35s ease-out forwards; pointer-events: none; }
@keyframes flash { to { opacity: 0; } }
.play-console { height: 220px; display: flex; flex-direction: column; background: #161826; color: #d5d8df; border-top: 1px solid #2c2f45; font-size: 12.5px; }
.console-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid #2c2f45; background: #1c1f30; }
.console-head .muted { color: #9699a6; }
.console-head .btn.ghost, .console-head .icon-btn { color: #d5d8df; }
.console-head .btn.ghost:hover, .console-head .icon-btn:hover { background: #2c2f45; }
.console-list { flex: 1; overflow: auto; font-family: ui-monospace, Menlo, monospace; padding: 4px 0; }
.c-line { display: flex; gap: 10px; padding: 3px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); align-items: baseline; }
.c-line .c-time { color: #6b6f85; flex: none; }
.c-line .c-kind { flex: none; width: 64px; text-transform: uppercase; font-size: 10.5px; font-weight: 700; }
.c-line.error .c-kind, .c-line.resource .c-kind, .c-line.network .c-kind { color: #ff6b81; }
.c-line.warn .c-kind { color: #fdab3d; }
.c-line.info .c-kind { color: #579bfc; }
.c-line .c-msg, .c-line details { min-width: 0; word-break: break-word; white-space: pre-wrap; flex: 1; }
.c-line details summary { cursor: pointer; }
.c-line pre { background: #0f111b; color: #b8bccc; margin: 4px 0; }

/* ---------- agent progress + branch ---------- */
.live-step { font-size: 12.5px; color: var(--agent); margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-step::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--agent); margin-right: 6px; animation: pulse 1s infinite; vertical-align: middle; }
.branch-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; padding: 8px 10px; border: 1px solid var(--border-light); border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.branch-bar svg { color: var(--muted); }
.diff { font-family: ui-monospace, Menlo, monospace; font-size: 12px; border: 1px solid var(--border-light); border-radius: 6px; overflow: auto; max-height: 60vh; }
.d-line { white-space: pre; padding: 0 10px; min-height: 17px; }
.d-add { background: rgba(0, 200, 117, 0.14); }
.d-del { background: rgba(226, 68, 92, 0.14); }
.d-hunk { color: var(--primary); background: var(--surface-2); }
.d-head { font-weight: 700; background: var(--surface-2); margin-top: 6px; border-top: 1px solid var(--border-light); }
.d-file { color: var(--muted); }

/* ---------- simple task panel ---------- */
.meta-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; margin: 2px 0 4px; }
.status-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.status-chip::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--sc); }
.status-chip.click { cursor: pointer; border-radius: 4px; padding: 1px 6px; margin: -1px -6px; }
.status-chip.click:hover { background: var(--hover); }
.meta-line .muted.small { margin-left: auto; }
.tabs.light { margin-bottom: 4px; }
.tabs.light button { padding: 6px 10px; font-size: 13px; }
.branch-bar code { font-size: 11.5px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- merge state + Friday main ---------- */
.merge { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; color: var(--muted); }
.merge.ok { color: #00a35c; }
.merge.warn { color: #d97706; }
.merge.busy { color: var(--agent); }
.merge .spinner { width: 12px; height: 12px; }
.commit-list { display: flex; flex-direction: column; margin-top: 4px; }
.commit { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--border-light); font-size: 13px; }
.commit .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.test-tools { gap: 6px; }
.test-go { height: 28px; width: 210px; font-size: 12.5px; padding: 0 6px; }

.model-chip { font-size: 11.5px; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.model-chip.quick { background: rgba(253, 171, 61, 0.18); color: #b86e00; }
button.model-chip { border: 0; font: inherit; font-size: 11.5px; cursor: pointer; }
button.model-chip:hover { filter: brightness(0.95); text-decoration: underline; }

/* ---------- the agent asks you ---------- */
.question-card { margin: 10px 20px 4px; padding: 12px 14px; border-radius: 10px; background: rgba(255, 100, 46, 0.08); border: 1px solid rgba(255, 100, 46, 0.45); }
.question-card .q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: #d9480f; }
.question-card .q-text { margin-bottom: 10px; font-size: 14.5px; }

.memory-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; max-height: 280px; overflow: auto; }
.memory { display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; border-radius: 6px; background: var(--surface-2); font-size: 13px; line-height: 1.45; }

/* Play options: URL parameters for the game (mode.json testOptions) */
.play-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 8px 12px; border-bottom: 1px solid var(--border-light); background: var(--surface); }
.play-options .opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.play-options .opt > span { color: var(--muted); font-weight: 600; }
.play-options select.input, .play-options input.input { padding-top: 4px; padding-bottom: 4px; width: auto; }
.play-query { font-size: 12px; background: rgba(162, 93, 220, 0.14); color: #7e3bb5; border-radius: 6px; padding: 2px 6px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.composer-warn { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 6px; border-radius: 8px; background: rgba(253, 171, 61, 0.18); color: #8a5300; font-size: 13px; font-weight: 600; }
.play-bar .theme-sel { width: auto; padding: 3px 8px; font-size: 12px; font-weight: 600; }

/* Games outside the platform: set apart, dashed, open in a new tab */
.nav-item.external { color: var(--muted); }
.game-card.external { border-style: dashed; border-top-style: solid; background: transparent; }
.github-bar { margin: 0 0 16px; }

/* The full release test before a Push: a running line with spinner, clock and the test's last output line */
.release-run { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.release-run .release-step { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
