:root {
  --bg: #0b0a14;
  --bg2: #131122;
  --card: #171529;
  --line: #2a2745;
  --text: #e8e6f5;
  --muted: #8f8ab0;
  --accent: #8b5cf6;
  --accent2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb7185;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #251f4a 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.65 "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}
.shell { max-width: 1080px; margin: 0 auto; padding: 18px; min-height: 100%; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 16px; }
.brand { display: flex; gap: 12px; align-items: center; }
.mask { font-size: 30px; filter: drop-shadow(0 0 12px #8b5cf688); }
.brand h1 { font-size: 20px; letter-spacing: .5px; }
.sub { color: var(--muted); font-size: 12px; }
.status { color: var(--muted); font-size: 13px; }
.status.live { color: var(--ok); }
.status.reconnecting { color: var(--warn); }

.main { display: grid; grid-template-columns: 1fr 270px; gap: 16px; flex: 1; min-height: 0; }
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.feed { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.hello { color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.hello b { color: var(--text); }
.hints { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { background: #241f3d; color: #cfc8f0; border: 1px solid var(--line); padding: 6px 11px; border-radius: 999px; cursor: pointer; font-size: 12.5px; }
.chip:hover { border-color: var(--accent); }

.msg { max-width: 86%; padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, #6d3df0, #8b5cf6); color: #fff; border-bottom-right-radius: 6px; }
.msg.muse { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.tool { align-self: stretch; background: #12101f; border: 1px dashed var(--line); border-radius: 10px; font-size: 12.8px; }
.tool summary { cursor: pointer; padding: 7px 12px; color: #b7aef0; }
.tool summary .fn { color: var(--accent2); font-weight: 600; }
.tool .body { padding: 6px 12px 10px; color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.tool.err { border-color: #5a2340; }
.tool.err summary { color: var(--err); }
.badge-run { align-self: flex-start; color: var(--accent2); font-size: 12px; padding: 4px 10px; border: 1px solid #214a54; border-radius: 999px; background: #10222a; }
.badge-spin { display: inline-block; width: 1em; height: 1em; border: 2px solid #22d3ee; border-top-color: transparent; border-radius: 50%; margin-right: 6px; vertical-align: -2px; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.errorline { align-self: stretch; color: var(--err); background: #211021; border: 1px solid #4a2340; border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; }

#approvalZone:empty { display: none; }
.appr { position: sticky; bottom: 0; margin: 0 14px 10px; background: #1d1830; border: 1px solid var(--warn); border-radius: 14px; padding: 12px 14px; }
.appr h3 { font-size: 13.5px; color: var(--warn); margin-bottom: 4px; }
.appr .who { color: var(--muted); font-size: 12.5px; }
.appr .args { background: #120e22; border-radius: 8px; padding: 8px 10px; font: 12px ui-monospace, monospace; color: #cfd6ff; overflow-x: auto; margin: 8px 0; white-space: pre-wrap; word-break: break-all; }
.appr .btns { display: flex; gap: 10px; }
.appr .btns button { border-radius: 8px; padding: 7px 18px; cursor: pointer; border: 1px solid var(--line); font-size: 13px; }
.appr .yes { background: #16382c; color: var(--ok); border-color: #1f5b43; }
.appr .no { background: #381626; color: var(--err); border-color: #5b2140; }
.appr button:disabled { opacity: .45; cursor: default; }
.appr.resolved { opacity: .6; border-style: dashed; }

.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: var(--bg2); }
.composer textarea {
  flex: 1; resize: none; max-height: 160px; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px; font: inherit; outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
#sendBtn { border: none; width: 42px; border-radius: 12px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: 17px; cursor: pointer; }
#sendBtn:disabled { opacity: .4; }

.side { display: flex; flex-direction: column; gap: 14px; min-height: 0; overflow-y: auto; }
.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px; }
.panel h2 { font-size: 13px; color: #cfc8f0; margin-bottom: 8px; letter-spacing: 1px; }
.panel ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.panel .empty { color: var(--muted); font-size: 12px; }
.files a { color: var(--accent2); text-decoration: none; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.files a:hover { text-decoration: underline; }
.files .sz { color: var(--muted); font-size: 11px; }
.memories li { font-size: 12.5px; color: var(--text); }
.meta p { font-size: 11.5px; color: var(--muted); }
.meta .tip { font-size: 11px; margin-top: 6px; }

@media (max-width: 820px) {
  .main { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .panel { flex: 1 1 45%; }
}
@media (prefers-reduced-motion: reduce) { .badge-spin { animation-duration: 3s; } }
