  :root {
    --bg: #f6f7f9; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e5e7eb;
    --accent: #2563eb; --accent-text: #fff; --bubble: #eef2ff; --active: #e0e7ff;
    --ok: #15803d; --err: #b91c1c; --warn-bg: #fef3c7; --warn-text: #92400e; --input: #fff; --shade: rgba(15, 18, 24, .45);
  }
  @media (prefers-color-scheme: dark) {
    :root { --bg: #0f1218; --panel: #171b23; --text: #e5e7eb; --muted: #9ca3af; --line: #2a303b;
            --accent: #3b82f6; --bubble: #1e2433; --active: #1e293b; --ok: #4ade80; --err: #f87171;
            --warn-bg: #3a2f12; --warn-text: #fcd34d; --input: #0f1218; --shade: rgba(0, 0, 0, .6); }
  }
  * { box-sizing: border-box; }
  html, body { height: 100%; }
  body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text);
         display: flex; flex-direction: column; }
  header { padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--panel); display: flex; align-items: center; gap: 16px; min-height: 52px; flex-wrap: wrap; }
  header h1 { font-size: 16px; margin: 0; white-space: nowrap; }
  .status { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }
  .warn { background: var(--warn-bg); color: var(--warn-text); padding: 8px 16px; font-size: 13px; }
  section.view { flex: 1; min-height: 0; }
  .layout { display: grid; grid-template-columns: 270px 1fr; height: 100%; }
  aside { border-right: 1px solid var(--line); background: var(--panel); overflow-y: auto; }
  .bot-head { padding: 12px 16px 4px; font-weight: 600; border-top: 1px solid var(--line); }
  .bot-head:first-child { border-top: 0; }
  .bot-head small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
  .day { padding: 8px 16px 2px; font-weight: 600; color: var(--muted); font-size: 12px; }
  .chat { padding: 8px 16px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
  .chat-name { flex: 1; min-width: 0; }
  .chat-name b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-name small { display: block; overflow: hidden; text-overflow: ellipsis; }
  .new-badge { flex: none; font-size: 11px; line-height: 18px; padding: 0 8px; border-radius: 999px; background: var(--accent); color: var(--accent-text); white-space: nowrap; }
  .chat:hover, .chat.active { background: var(--active); }
  .chat small { color: var(--muted); white-space: nowrap; }
  main, .scroll { overflow-y: auto; height: 100%; padding: 16px; }
  .page { max-width: 1000px; margin: 0 auto; }
  .card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
  .card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
  .card-head h2 { margin: 0; font-size: 15px; }
  button { background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; }
  button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
  button.danger { background: transparent; color: var(--err); border: 1px solid var(--line); }
  button.sm { padding: 3px 9px; font-size: 13px; }
  button:disabled { opacity: .6; cursor: wait; }
  .nav { display: flex; gap: 4px; }
  .nav button { background: transparent; color: var(--muted); }
  .nav button.on { background: var(--active); color: var(--text); }
  .subnav { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
  .subnav button { background: transparent; color: var(--muted); border-radius: 0; border-bottom: 2px solid transparent; padding: 8px 14px; white-space: nowrap; }
  .subnav button.on { color: var(--accent); border-bottom-color: var(--accent); }
  .subnav .count { font-size: 12px; color: var(--muted); margin-left: 4px; }
  .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
  .chips button { background: transparent; color: var(--text); border: 1px solid var(--line); padding: 4px 12px; font-size: 13px; border-radius: 999px; }
  .chips button.on { background: var(--active); border-color: var(--accent); }
  .chips button.add { color: var(--accent); border-style: dashed; }
  .chips .off { color: var(--muted); text-decoration: line-through; }
  input, select, textarea { font: inherit; color: var(--text); background: var(--input); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; }
  textarea { font-family: ui-monospace, Consolas, monospace; font-size: 13px; min-height: 150px; resize: vertical; }
  input[type=checkbox] { width: auto; }
  label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
  label.check { display: flex; gap: 6px; align-items: center; color: var(--text); font-size: 14px; margin: 0; }
  .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
  .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .stack > * + * { margin-top: 12px; }
  .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
  .badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
  .msg { padding: 6px 10px; margin-bottom: 6px; background: var(--bubble); border-radius: 8px; overflow-wrap: anywhere; }
  .msg .meta { font-size: 12px; color: var(--muted); }
  .msg .from { font-weight: 600; color: var(--text); }
  .analysis table, table.data { border-collapse: collapse; width: 100%; }
  .analysis th, .analysis td, table.data th, table.data td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
  table.data th { background: var(--active); }
  .analysis h2 { font-size: 15px; margin: 16px 0 6px; }
  table.list { width: 100%; border-collapse: collapse; }
  table.list th, table.list td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; }
  table.list th { font-size: 12px; color: var(--muted); font-weight: 600; }
  .tbl-wrap { overflow-x: auto; }
  .ok { color: var(--ok); } .err { color: var(--err); } .muted, .empty { color: var(--muted); }
  .savebar { position: sticky; bottom: -16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-top: 16px;
             display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .overlay { position: fixed; inset: 0; background: var(--shade); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
  .overlay.solid { background: var(--bg); }
  .modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
  .modal.narrow { max-width: 380px; }
  .modal h2 { margin: 0 0 16px; font-size: 17px; }
  .modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
  .user-btn { background: transparent; color: var(--text); border: 1px solid var(--line); }
  .menu { position: absolute; right: 16px; top: 50px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; z-index: 5; min-width: 180px; }
  .menu button { display: block; width: 100%; text-align: left; background: transparent; color: var(--text); }
  .menu button:hover { background: var(--active); }
  .vars { display: flex; flex-wrap: wrap; gap: 6px; }
  .var { display: flex; flex-direction: column; align-items: flex-start; background: var(--bubble); color: var(--text);
         border: 1px dashed var(--accent); padding: 4px 10px; cursor: grab; text-align: left; max-width: 240px; }
  .var code { color: var(--accent); font-size: 13px; }
  .var span { font-size: 11px; color: var(--muted); line-height: 1.3; }
  .var-edit { font-size: 11px; color: var(--accent); margin-top: 2px; text-decoration: underline; }
  .var-add { border-style: dashed; background: transparent; }
  pre.preview { white-space: pre-wrap; background: var(--bubble); border-radius: 8px; padding: 10px; font-size: 12px; max-height: 260px; overflow: auto; margin: 0 0 12px; }
  .run { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
  .run.open { border-color: var(--accent); }
  .run-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 12px; cursor: pointer; }
  .run-head:hover { background: var(--active); }
  .run-body { padding: 0 12px 12px; }
  a.btn { display: inline-block; background: var(--accent); color: var(--accent-text); border-radius: 6px; padding: 6px 12px; text-decoration: none; }
  a.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
  .guide-step { display: flex; gap: 12px; align-items: flex-start; }
  .guide-num { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--active); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 600; }
  .run-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
  .run-no { min-width: 34px; font-weight: 600; color: var(--accent); }
  .run-time { font-weight: 700; font-size: 14px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
  [hidden] { display: none !important; }
  @media (max-width: 900px) {
    header { padding: 8px 16px; }
    .status { margin-left: 0; text-align: left; width: 100%; }
    .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    aside { max-height: 30vh; border-right: 0; border-bottom: 1px solid var(--line); }
  }
