:root {
  --bg: #f5f6f8; --panel: #fff; --panel-2: #f9fafb; --text: #171b24; --muted: #687083; --line: #e4e7ec; --line-2: #eef0f3;
  --accent: #2f6fde; --accent-hover: #255fc4; --accent-soft: #e9f0fd; --accent-text: #fff;
  --ok: #18834a; --ok-soft: #e6f5ec; --warn: #a86f00; --warn-soft: #fdf3dc; --bad: #c8312f; --bad-soft: #fcebea;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05); --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
  --radius: 12px; --radius-sm: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1217; --panel: #171b22; --panel-2: #1c212a; --text: #e7eaf0; --muted: #949cad; --line: #2a303b; --line-2: #222832;
    --accent: #5b8ff0; --accent-hover: #74a1f3; --accent-soft: #1d2a45; --accent-text: #fff;
    --ok: #4cc283; --ok-soft: #15291f; --warn: #e2ad45; --warn-soft: #2d2412; --bad: #f06b68; --bad-soft: #321a1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--panel-2); border: 1px solid var(--line-2); padding: 1px 5px; border-radius: 5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 22px; margin: 0; letter-spacing: -.015em; }
h3 { font-size: 15px; margin: 18px 0 8px; }

/* ── controls ─────────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--accent-text);
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, opacity .12s; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.secondary { background: var(--panel); color: var(--text); border-color: var(--line); box-shadow: var(--shadow); }
button.secondary:hover { background: var(--panel-2); border-color: var(--muted); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { background: var(--panel-2); color: var(--text); }
button.danger { background: var(--bad); }
button.danger:hover { background: var(--bad); opacity: .9; }
button.danger-text { color: var(--bad); }
button.danger-text:hover { background: var(--bad-soft); color: var(--bad); }
button.link { background: none; color: var(--accent); padding: 0; border: 0; }
button.sm { padding: 5px 10px; font-size: 12.5px; }
button.block { width: 100%; justify-content: center; }
button:disabled, button:disabled:hover { opacity: .5; cursor: default; background: var(--accent); }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 10px; width: 100%; transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { background: var(--panel-2); color: var(--muted); }
textarea { font-family: var(--mono); font-size: 12.5px; line-height: 1.55; resize: vertical; }
textarea.prose { font-family: inherit; font-size: inherit; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; cursor: pointer; }
label { display: block; margin: 12px 0; font-weight: 500; font-size: 13px; }
label > input, label > textarea, label > select { margin-top: 5px; font-weight: 400; font-size: 14px; }
label.check { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; font-size: 14px; }
label.check > input { margin: 0; }
.w-xs { width: 90px; } .w-sm { max-width: 140px; } .w-md { max-width: 220px; }
.grow { flex: 1; min-width: 160px; } .grow-2 { flex: 2; min-width: 200px; }

/* ── layout ───────────────────────────────────────────────────────────── */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; } td .row.tight { flex-wrap: nowrap; } .row.end { justify-content: flex-end; flex-wrap: nowrap; }
.row.options { gap: 20px; margin: 4px 0 8px; }
.row.actions { margin-top: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card, .table-wrap + .card, .card + .table-wrap { margin-top: 16px; }
.card.flush { padding: 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.pad { padding: 10px; margin: 0; }

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--panel); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--text); padding: 4px 8px 18px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.logo-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-weight: 700; font-size: 14px;
  color: #fff; background: linear-gradient(135deg, #3b82f6, #6d4ae8); box-shadow: 0 2px 6px rgba(59, 130, 246, .35);
}
.logo-mark.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 20px; margin-bottom: 14px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a {
  display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 8px 10px; border-radius: var(--radius-sm);
  font-weight: 500; transition: background .12s, color .12s;
}
#nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
#nav a.active { background: var(--accent-soft); color: var(--accent); }
#nav svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me { display: flex; align-items: center; gap: 8px; min-width: 0; }
.me-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px;
}
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

.view { padding: 32px 36px 48px; max-width: 1280px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; max-width: 720px; }
.page-head h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.cols > .card + .card, .grid > .card + .card { margin-top: 0; }
.stat .stat-label { color: var(--muted); font-size: 12.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 14px 0 4px; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.callout { padding: 10px 12px; border-radius: var(--radius-sm); margin: 10px 0 0; }
.callout.bad { background: var(--bad-soft); color: var(--bad); }

.split { display: grid; grid-template-columns: 290px 1fr; gap: 16px; align-items: start; }
.list { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
.list a { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); }
.list a:hover { background: var(--panel-2); text-decoration: none; }
.list a.active { background: var(--accent-soft); }
.list a.active .strong, .list a.active .mono { color: var(--accent); }

/* ── tables ───────────────────────────────────────────────────────────── */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--panel-2); }
tr.clickable { cursor: pointer; } tbody tr:hover { background: var(--panel-2); }
td a.strong { color: var(--text); }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 500;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); vertical-align: middle;
}
.pill.ok, .pill.bad, .pill.warn, .pill.accent { border-color: transparent; }
.pill.ok::before, .pill.bad::before, .pill.warn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.accent { color: var(--accent); background: var(--accent-soft); }
.page-head h2 .pill { font-size: 12.5px; }

/* ── run timeline ─────────────────────────────────────────────────────── */
.events { display: flex; flex-direction: column; gap: 6px; }
.ev { border-left: 3px solid var(--line); padding: 6px 12px; white-space: pre-wrap; word-break: break-word; background: var(--panel-2); border-radius: 0 6px 6px 0; }
.ev.user { border-color: var(--accent); } .ev.text { border-color: var(--ok); }
.ev.tool_call { color: var(--muted); font-family: var(--mono); font-size: 12px; background: transparent; }
.ev.tool_result { color: var(--muted); font-size: 12px; max-height: 140px; overflow: auto; background: transparent; }
.ev.err { border-color: var(--bad); color: var(--bad); } .ev.outcome { border-color: var(--warn); }
.report { white-space: pre-wrap; line-height: 1.6; }
.feedback { padding: 8px 0; border-bottom: 1px solid var(--line-2); }

/* ── timeline headlines ──────────────────────────────────────────────── */
.tl { position: relative; display: flex; flex-direction: column; }
.tl::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 2px; background: var(--line-2); }
.tl-item > summary {
  position: relative; display: flex; align-items: baseline; gap: 10px; padding: 7px 8px 7px 24px; border-radius: var(--radius-sm);
  cursor: pointer; list-style: none; min-width: 0;
}
.tl-item > summary::-webkit-details-marker { display: none; }
.tl-item > summary:hover { background: var(--panel-2); }
.tl-item[data-flat] > summary { cursor: default; } .tl-item[data-flat] > summary:hover { background: none; }
.tl-dot { position: absolute; left: 0; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--panel); border: 2px solid var(--line); }
.tl-item.user .tl-dot { border-color: var(--accent); background: var(--accent); }
.tl-item.text .tl-dot { border-color: var(--ok); }
.tl-item.outcome .tl-dot { border-color: var(--warn); }
.tl-item.err .tl-dot { border-color: var(--bad); }
.tl-item.tools .tl-dot { width: 8px; height: 8px; left: 2px; top: 14px; border-width: 0; background: var(--line); }
.tl-who { flex: none; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); width: 48px; }
.tl-head { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item.user .tl-head { font-weight: 600; }
.tl-item.tools .tl-head { color: var(--muted); font-size: 13px; flex: none; }
.tl-sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item[open] > summary .tl-head { white-space: normal; }
.tl-body { margin: 2px 0 10px 24px; padding: 12px 14px; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
.tool > summary { cursor: pointer; padding: 4px 0; font-size: 12.5px; }
.tool.err > summary { color: var(--bad); }
.tool pre { margin: 4px 0 8px; max-height: 260px; overflow: auto; font-size: 12px; white-space: pre-wrap; word-break: break-word; background: var(--panel); padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line-2); }

/* ── before & after ──────────────────────────────────────────────────── */
.snap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.snap-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.snap-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.snap-pics { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.snap-pic { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
.snap-pic:hover { text-decoration: none; color: var(--text); }
.snap-pic img {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); transition: border-color .12s, transform .12s;
}
.snap-pic:hover img { border-color: var(--accent); transform: translateY(-1px); }
.snap-empty { display: grid; place-items: center; aspect-ratio: 8 / 3; border: 1px dashed var(--line); border-radius: var(--radius-sm); }
a.secondary-btn { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); align-self: flex-start; }
a.secondary-btn:hover { background: var(--panel-2); border-color: var(--muted); }
a.secondary-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── knowledge base ──────────────────────────────────────────────────── */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px 16px; margin: 0 0 16px;
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--panel); cursor: pointer; text-align: center;
  font-weight: 400; transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 28px; height: 28px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#kb-progress { color: var(--accent); font-weight: 500; }
.card.kb-doc { padding: 14px 16px; margin-top: 10px; }
.kb-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.kb-icon { display: grid; place-items: center; min-width: 52px; height: 40px; padding: 0 6px; border-radius: 8px; background: var(--bad-soft);
  color: var(--bad); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
.kb-meta { display: flex; flex-direction: column; min-width: 0; }
.kb-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-text { margin: 12px 0 0; max-height: 420px; overflow: auto; white-space: pre-wrap; font-size: 12.5px; background: var(--panel-2);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 12px; }
a.ghost-btn { background: transparent; color: var(--muted); padding: 5px 10px; font-size: 12.5px; }
a.ghost-btn:hover { background: var(--panel-2); color: var(--text); }
@media (max-width: 860px) { .kb-head { grid-template-columns: auto 1fr; } .kb-head .row { grid-column: 1 / -1; justify-content: flex-start; } }

/* ── feedback chat ───────────────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 420px; overflow-y: auto; padding: 4px 2px 12px; }
.chat-empty { text-align: center; padding: 18px 0 8px; }
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 82%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg .avatar { flex: none; }
.bubble { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 14px 14px 14px 4px; padding: 9px 13px; min-width: 0; }
.msg.mine .bubble { background: var(--accent-soft); border-color: transparent; border-radius: 14px 14px 4px 14px; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.msg-rating { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; }
.msg-text { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.stars { letter-spacing: 1px; font-size: 15px; line-height: 1; color: var(--line); }
.stars .on { color: #f5a524; } .stars.low .on { color: var(--bad); }

.msg-actions { margin-top: 6px; }
.msg-actions .ghost { padding: 3px 8px; margin-left: -8px; color: var(--accent); }
/* proposed lesson under a feedback item */
.lesson-box { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--panel); }
.lesson-box.pending { border-color: var(--warn); background: var(--warn-soft); }
.lesson-box.approved { border-color: var(--ok); }
.lesson-box.rejected { opacity: .7; }
.lesson-box-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.lesson-box textarea { font-size: 14px; background: var(--panel); }
.lesson-box .md ul { margin: 0; }
.msg .lesson-box { min-width: min(520px, 70vw); }

/* memory page */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 18px; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.mem-items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.card.mem-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: start; padding: 14px 16px; margin-top: 0; }
.mem-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 12.5px; }
.mem-body { min-width: 0; padding-top: 2px; }
.mem-body textarea { font-size: 14px; }
.mem-actions { display: flex; gap: 4px; align-items: center; }
@media (max-width: 860px) { .card.mem-item { grid-template-columns: 28px 1fr; } .mem-actions { grid-column: 2; } }
.fb-item { padding: 16px 18px; }
.fb-item-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.fb-item .msg-text { margin-top: 8px; }
.fb-item .mk-lesson { margin-top: 8px; margin-left: -8px; color: var(--accent); }

.composer { border-top: 1px solid var(--line-2); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.composer-top { gap: 12px; }
.star-pick { display: inline-flex; gap: 2px; }
.star-pick .star {
  background: none; border: 0; padding: 0 2px; font-size: 28px; line-height: 1; color: var(--line); cursor: pointer;
  transition: transform .1s, color .1s;
}
.star-pick .star:hover { background: none; transform: scale(1.15); }
.star-pick .star.on { color: #f5a524; }
.composer #fb-reason { max-width: 340px; }
.composer-input {
  display: flex; align-items: flex-end; gap: 8px; border: 1px solid var(--line); border-radius: 22px; padding: 5px 5px 5px 14px;
  background: var(--panel); transition: border-color .12s, box-shadow .12s;
}
.composer-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-input textarea { border: 0; box-shadow: none; padding: 7px 0; resize: none; font-family: inherit; font-size: 14px; background: transparent; }
.composer-input textarea:focus { box-shadow: none; }
.composer-input button { border-radius: 18px; padding: 7px 16px; }
.composer-note { margin: 0; }

/* ── rendered markdown ───────────────────────────────────────────────── */
.md { line-height: 1.6; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md .md-table { margin: 0 0 12px; }
.md h3, .md h4, .md h5, .md h6 { margin: 18px 0 8px; line-height: 1.3; }
.md h3 { font-size: 17px; } .md h4 { font-size: 15px; } .md h5, .md h6 { font-size: 14px; }
.md ul, .md ol { padding-left: 22px; } .md li { margin: 3px 0; }
.md blockquote { padding: 2px 14px; border-left: 3px solid var(--line); color: var(--muted); }
.md pre { background: var(--panel-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 10px 12px; overflow: auto; }
.md pre code { background: none; border: 0; padding: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.md-table { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.md-table table { font-size: 13px; }
.md-table th, .md-table td { padding: 7px 12px; white-space: nowrap; }
.md-table th { text-transform: none; letter-spacing: 0; font-size: 12.5px; }

/* ── states ───────────────────────────────────────────────────────────── */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 48px 24px;
  border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); background: var(--panel);
}
.empty b { color: var(--text); font-size: 15px; }
.empty span { max-width: 460px; }
.empty.bad b { color: var(--bad); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; }
.view.busy { opacity: .55; pointer-events: none; transition: opacity .15s .1s; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 10; max-width: 420px; background: var(--text); color: var(--bg);
  padding: 11px 16px 11px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); border-left: 4px solid var(--ok);
  animation: rise .18s ease-out;
}
.toast.bad { border-left-color: var(--bad); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* ── roles, nav sections, meter ───────────────────────────────────────── */
body:not(.is-admin) [data-admin] { display: none !important; }
.nav-section { margin: 16px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
a.pill:hover { text-decoration: none; border-color: var(--muted); }
.meter { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; margin: -4px 0 8px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ── dialog ───────────────────────────────────────────────────────────── */
.dialog {
  width: min(480px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 14px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg); animation: rise .18s ease-out;
}
.dialog::backdrop { background: rgba(10, 14, 22, .45); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; }
.dialog-head h3 { margin: 0; font-size: 16px; }
.dialog-body { padding: 4px 20px 0; }
.dialog-body .row label { margin: 12px 0; }
.dialog-body .stack { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 4px; }
.dialog-note { justify-content: space-between; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; margin-top: 8px; background: var(--panel-2); border-top: 1px solid var(--line-2); }

/* ── login ────────────────────────────────────────────────────────────── */
.login {
  display: grid; place-items: center; min-height: 100vh; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}
.login-card { width: 100%; max-width: 380px; padding: 32px; box-shadow: var(--shadow-lg); }
.login-card > p.muted { margin: 0 0 18px; }
.login-card button { margin-top: 8px; padding: 10px 14px; }

/* ── small screens ────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; } .brand span:last-child { display: none; }
  #nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  #nav a { padding: 7px 10px; white-space: nowrap; }
  #nav a span { display: none; } #nav a.active span { display: inline; }
  .sidebar-foot { margin: 0; padding: 0; border: 0; } .me-name { display: none; }
  .view { padding: 20px 16px 40px; }
  .split { grid-template-columns: 1fr; } .list { position: static; max-height: 260px; }
  .cols { grid-template-columns: 1fr; }
}
