/* 颜色、字号、间距照 Paseo（packages/app/src/styles/theme.ts）：默认暗色，系统是浅色时用浅色 */
:root {
  --surface0: #181b1a; --surface1: #1e2120; --surface2: #272a29; --surface3: #434645;
  --sidebar: #141716; --sidebar-hover: #1c1f1e; --sidebar-selected: #232726;
  --border: #252b2a; --border-accent: #2f3534;
  --text: #fafafa; --muted: #a1a5a4; --faint: #717574;
  --accent: #20744a; --accent-bright: #7ccba0; --danger: #f7796d; --warn: #db932e; --ok: #35c264; --running: #5caaf6;
  --user-bubble: #434645;
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--surface0);
}
@media (prefers-color-scheme: light) {
  :root {
    --surface0: #ffffff; --surface1: #fafafa; --surface2: #f4f4f5; --surface3: #e4e4e7;
    --sidebar: #f4f4f5; --sidebar-hover: #ebebed; --sidebar-selected: #e4e4e7;
    --border: #e4e4e7; --border-accent: #d4d4d8;
    --text: #1a1a1e; --muted: #71717a; --faint: #a1a1aa;
    --accent-bright: #20744a; --danger: #c64f43; --warn: #b37824; --ok: #299f51; --running: #268ae0;
    --user-bubble: #e4e4e7;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .secret { font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.empty { color: var(--muted); padding: 12px 0; }

/* ---- 骨架：左侧栏 + 主区 ---- */
.shell { display: flex; height: 100vh; }
.sidebar { width: 300px; flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.side-brand { height: 48px; display: flex; align-items: baseline; gap: 8px; padding: 14px 16px 0; font-weight: 600; font-size: 15px; }
.side-nav { display: flex; flex-direction: column; padding: 4px 8px 8px; border-bottom: 1px solid var(--border); }
.nav-row { display: flex; align-items: center; min-height: 32px; padding: 6px 8px; border-radius: 8px; color: var(--text); opacity: .76; }
.nav-row:hover { background: var(--sidebar-hover); opacity: 1; text-decoration: none; }
.nav-row.active { background: var(--sidebar-selected); opacity: 1; }
.side-section { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; color: var(--muted); font-size: 12px; }
.icon-button { font: inherit; font-size: 12px; background: none; border: 1px solid transparent; color: var(--faint); border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.icon-button:hover { color: var(--text); background: var(--sidebar-hover); }
.icon-button.on { color: var(--accent-bright); border-color: var(--border-accent); }
.tree { flex: 1; overflow-y: auto; padding: 2px 8px 12px; }
.tree-empty { color: var(--muted); padding: 8px; font-size: 13px; }
.tree-group { margin-bottom: 6px; }
.tree button { font: inherit; color: inherit; background: none; border: none; width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 8px; border-radius: 8px; }
.tree-emp { min-height: 34px; padding: 6px 8px; font-weight: 600; }
.tree-proj { min-height: 32px; padding: 6px 8px 6px 20px; color: var(--muted); }
.tree-sess { min-height: 32px; padding: 6px 12px 6px 30px; opacity: .76; }
.tree-sess.archived { opacity: .45; }
.tree-sess .muted { flex-shrink: 0; }
.tree-more, .tree-none { min-height: 28px; padding: 4px 12px 4px 46px; color: var(--faint); font-size: 12px; }
.tree button:hover { background: var(--sidebar-hover); opacity: 1; }
.tree-sess.selected { background: var(--sidebar-selected); opacity: 1; }
.chev { width: 10px; color: var(--faint); font-size: 10px; transition: transform .1s; }
.chev.closed { transform: rotate(-90deg); }
.avatar { width: 20px; height: 20px; border-radius: 50%; background: var(--surface3); color: var(--text); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; }
.count { color: var(--faint); font-size: 12px; font-weight: 400; }
.badge { width: 16px; height: 16px; border-radius: 4px; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 600; flex-shrink: 0; vertical-align: middle; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.none { background: transparent; }
.dot.running { background: var(--running); box-shadow: 0 0 0 3px color-mix(in srgb, var(--running) 25%, transparent); }
.dot.failed { background: var(--danger); }
.side-footer { border-top: 1px solid var(--border); padding: 10px 16px; display: flex; gap: 12px; align-items: center; font-size: 13px; }
.side-footer .who { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; min-width: 0; overflow-y: auto; background: var(--surface0); }

/* ---- 普通页面 ---- */
.page-head { position: sticky; top: 0; z-index: 1; height: 48px; display: flex; align-items: center; padding: 0 24px; background: var(--surface0); border-bottom: 1px solid var(--border); }
.page-head h1 { font-size: 15px; font-weight: 600; margin: 0; }
.page-body { max-width: 1100px; margin: 0 auto; padding: 20px 24px 48px; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
section { margin-top: 24px; }
.card { background: var(--surface1); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.card.narrow { max-width: 420px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid .card { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat strong { font-size: 20px; font-weight: 600; }
.list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface1); }
.list-row { font: inherit; color: inherit; background: none; border: none; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 10px 14px; text-align: left; cursor: pointer; width: 100%; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface2); }
.list-row .time { width: 72px; text-align: right; }
.hit-row { align-items: flex-start; }
.snippet { color: var(--muted); font-size: 13px; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search-input { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr:last-child td { border-bottom: none; }
td.actions { white-space: nowrap; text-align: right; }

button, .button { font: inherit; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-accent); background: var(--surface2); color: var(--text); cursor: pointer; display: inline-block; }
button:hover, .button:hover { border-color: var(--surface3); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.1); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; padding: 2px 6px; color: var(--accent-bright); }
button.link.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--border-accent); border-radius: 8px; background: var(--surface2); color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { width: 100%; min-height: 60px; }
label { display: block; }
label > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
form.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--surface2); border: 1px solid var(--border-accent); color: var(--muted); font-weight: 400; }
.tag.small { padding: 0 6px; font-size: 11px; }
.tag.ok { color: var(--ok); border-color: currentColor; }
.tag.warn { color: var(--warn); border-color: currentColor; }
.tag.bad { color: var(--danger); border-color: currentColor; }

.notice { border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid var(--border-accent); background: var(--surface1); }
.notice.error { border-color: var(--danger); color: var(--danger); }
.notice.success { border-color: var(--accent); }
.notice .close { float: right; }
.secret { background: var(--surface2); padding: 2px 6px; border-radius: 4px; user-select: all; word-break: break-all; }
pre.doc { white-space: pre-wrap; word-break: break-word; background: var(--surface2); padding: 14px; border-radius: 8px; max-height: 70vh; overflow: auto; font-size: 13px; }

/* ---- 登录 ---- */
.login { max-width: 380px; margin: 14vh auto; padding: 0 16px; }
.login-brand { text-align: center; font-size: 22px; font-weight: 600; margin-bottom: 20px; }
.login .card { padding: 24px; }
.login input { width: 100%; }
.login form button[type=submit] { width: 100%; margin-top: 4px; }

/* ---- 会话记录：照 Paseo 的聊天界面 ---- */
.session { min-height: 100%; display: flex; flex-direction: column; }
.session-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 12px; padding: 8px 24px; min-height: 52px; background: var(--surface0); border-bottom: 1px solid var(--border); }
.session-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.transcript-wrap { width: 100%; max-width: 820px; margin: 0 auto; padding: 16px 16px 64px; }
.transcript { display: flex; flex-direction: column; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; margin: 16px 0; }
.msg-user .bubble { max-width: 85%; background: var(--user-bubble); border-radius: 16px 2px 16px 16px; padding: 12px 16px; font-size: 15px; line-height: 21px; white-space: pre-wrap; word-break: break-word; }
.stamp { color: var(--faint); font-size: 12px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg-user:hover .stamp { opacity: 1; }
.msg-assistant { padding: 12px 0; font-size: 15px; line-height: 21px; word-break: break-word; }
.markdown p { margin: 0 0 12px; }
.markdown > :last-child { margin-bottom: 0; }
.markdown .md-h1 { font-size: 22px; font-weight: 700; margin: 16px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown .md-h2 { font-size: 18px; font-weight: 600; margin: 14px 0 8px; }
.markdown .md-h3 { font-size: 16px; font-weight: 600; margin: 12px 0 6px; }
.markdown code { background: var(--surface2); border-radius: 6px; padding: 2px 4px; font-size: 12.5px; }
.markdown pre { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow-x: auto; margin: 0 0 12px; }
.markdown pre code { background: none; padding: 0; font-size: 12.5px; line-height: 18px; }
.markdown ul, .markdown ol { margin: 0 0 12px; padding-left: 22px; }
.markdown li { margin: 2px 0; }
.markdown blockquote { margin: 0 0 12px; padding: 4px 12px; background: var(--surface1); border-left: 3px solid var(--surface3); border-radius: 4px; color: var(--muted); }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md-table { overflow-x: auto; margin: 0 0 12px; }
.md-table table { font-size: 13.5px; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 6px 10px; }
.md-table th { background: var(--surface1); color: var(--text); }
.tool { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; color: var(--muted); font-size: 14px; min-height: 30px; }
.tool:hover { background: var(--surface1); }
.tool-icon { width: 14px; color: var(--faint); text-align: center; }
.tool-name { color: var(--text); opacity: .8; white-space: nowrap; }
.tool-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 12.5px; color: var(--faint); }
.thought { margin: 2px 0; }
.thought summary { cursor: pointer; padding: 4px 8px; border-radius: 8px; color: var(--muted); font-size: 14px; list-style: none; }
.thought summary::before { content: "✦ "; color: var(--faint); }
.thought summary:hover { background: var(--surface1); }
.thought-body { margin: 4px 8px 8px 22px; padding: 8px 12px; border-left: 2px solid var(--border-accent); color: var(--muted); font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.hit { animation: hit 2.4s ease-out; border-radius: 8px; }
@keyframes hit { from { background: color-mix(in srgb, var(--accent) 35%, transparent); } to { background: transparent; } }

@media (max-width: 760px) {
  .sidebar { width: 240px; }
  .page-body, .transcript-wrap { padding-left: 12px; padding-right: 12px; }
}
