
  :root{
    --bg:#0e0e11; --rail:#121215; --side:#141417; --panel:#18181c; --panel-2:#1d1d22;
    --border:#2a2a31; --border-soft:#222228;
    --text:#ececf1; --muted:#9a9aa6; --dim:#6e6e7a;
    --accent:#ea7a4f; --accent-2:#f08a5d; --ok:#3ecf8e; --warn:#f2c14e; --live:#ef4444;
    --code-bg:#24242b;
  }
  *{box-sizing:border-box;margin:0;padding:0}
  html,body{height:100%}
  body{background:var(--bg);color:var(--text);font:14px/1.5 Inter,system-ui,sans-serif;display:flex;overflow:hidden}
  button{font:inherit;color:inherit;background:none;border:0;cursor:pointer}
  code,.mono{font-family:"JetBrains Mono",monospace}
  svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

  /* icon rail */
  .rail{width:40px;background:var(--rail);border-right:1px solid var(--border-soft);display:flex;flex-direction:column;align-items:center;padding:12px 0;gap:18px;color:var(--muted)}
  .rail button:hover{color:var(--text)}
  .rail .spacer{flex:1}

  /* sidebar */
  .side{width:290px;background:var(--side);border-right:1px solid var(--border-soft);display:flex;flex-direction:column;padding:14px 12px}
  .brand{display:flex;align-items:center;gap:10px;font-weight:700;font-size:15px;padding:2px 4px 14px}
  .brand-mark{width:30px;height:30px;border-radius:8px;background:linear-gradient(135deg,var(--accent-2),#d9603a);display:grid;place-items:center;color:#fff}
  .brand-mark svg{width:16px;height:16px}
  .new-chat{background:var(--accent);color:#fff;font-weight:600;border-radius:10px;height:42px;display:flex;align-items:center;justify-content:center;gap:8px;transition:background .15s}
  .new-chat:hover{background:var(--accent-2)}
  .search{margin-top:10px;display:flex;align-items:center;gap:10px;height:38px;padding:0 12px;border:1px solid var(--border);border-radius:10px;background:var(--panel);color:var(--muted)}
  .search input{flex:1;background:none;border:0;outline:0;color:var(--text);font:inherit}
  .tabs{margin-top:10px;display:grid;grid-template-columns:1fr 1fr;padding:4px;border:1px solid var(--border);border-radius:10px;background:var(--panel)}
  .tabs button{height:30px;border-radius:7px;font-size:13px;font-weight:500;color:var(--muted)}
  .tabs button.active{background:var(--panel-2);color:var(--text);font-weight:600}
  .list{flex:1;overflow-y:auto;margin-top:14px;padding-right:2px}
  .list::-webkit-scrollbar{width:6px}.list::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
  .group{font-size:11px;font-weight:600;letter-spacing:.08em;color:var(--dim);padding:10px 10px 6px}
  .item{display:flex;align-items:center;gap:8px;padding:9px 10px;border-radius:8px;color:#d4d4dc;cursor:pointer;font-size:14px}
  .item:hover{background:var(--panel)}
  .item.active{background:var(--panel-2)}
  .item span{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .item .pin{color:var(--dim);width:14px;height:14px}
  .dot{width:7px;height:7px;border-radius:50%;background:var(--accent);flex:none}
  .spin{width:12px;height:12px;border:2px solid var(--accent);border-right-color:transparent;border-radius:50%;animation:sp .9s linear infinite;flex:none}
  @keyframes sp{to{transform:rotate(360deg)}}

  .usage{border:1px solid var(--border);background:var(--panel);border-radius:10px;padding:12px;margin-top:10px}
  .usage-head{display:flex;justify-content:space-between;font-weight:600;font-size:13px;margin-bottom:8px}
  .usage-head small{color:var(--muted);font-weight:500}
  .meter{display:grid;grid-template-columns:62px 1fr 34px;align-items:center;gap:8px;font-size:12.5px;color:var(--muted);margin-top:4px}
  .meter b{font-weight:500;text-align:right;color:var(--text)}
  .bar{height:5px;background:#2b2b33;border-radius:3px;overflow:hidden}
  .bar i{display:block;height:100%;border-radius:3px}
  .user{display:flex;align-items:center;gap:10px;padding:14px 6px 2px;margin-top:10px;border-top:1px solid var(--border-soft)}
  .avatar{width:34px;height:34px;border-radius:50%;background:#2a2a35;display:grid;place-items:center;font-weight:600}
  .user .who{flex:1;line-height:1.25}
  .user .who b{display:block;font-weight:600}
  .user .who small{color:var(--muted);font-size:12px}

  /* main */
  .main{flex:1;display:flex;flex-direction:column;min-width:0}
  .topbar{display:flex;align-items:flex-start;justify-content:space-between;padding:12px 16px 12px;border-bottom:1px solid var(--border-soft)}
  .topbar h1{font-size:15px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .chips{display:flex;gap:6px;margin-top:6px}
  .chip{font-size:12px;padding:2px 8px;border-radius:6px;border:1px solid var(--border);color:#cfcfd8;background:var(--panel)}
  .chip.accent{border-color:#6b3a26;color:var(--accent-2);background:#2a1a13}
  .top-actions{display:flex;align-items:center;gap:18px;color:var(--muted);padding-top:6px}
  .live{width:8px;height:8px;border-radius:50%;background:var(--live);box-shadow:0 0 8px var(--live)}

  .scroll{flex:1;overflow-y:auto}
  .scroll::-webkit-scrollbar{width:8px}.scroll::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}
  .thread{max-width:740px;margin:0 auto;padding:28px 0 24px}
  .tool{display:flex;align-items:center;gap:10px;border:1px solid var(--border);background:var(--panel);border-radius:8px;padding:9px 12px;margin-bottom:8px;font-size:13px}
  .tool svg.ic{width:15px;height:15px;color:var(--muted)}
  .tool b{font-weight:600}
  .tool code{flex:1;color:var(--muted);font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .tool .chk{color:var(--ok);width:16px;height:16px}

  .msg{margin-top:20px;font-size:15px;line-height:1.6}
  .msg p{margin:0 0 14px}
  .msg ol,.msg ul{padding-left:22px;margin:0 0 14px}
  .msg li{margin-bottom:6px}
  .msg strong{font-weight:700}
  .msg code{background:var(--code-bg);border:1px solid #30303a;border-radius:5px;padding:1px 6px;font-size:13px;font-weight:500}
  .meta{display:flex;align-items:center;gap:6px;color:var(--muted);font-size:13px;margin-top:22px}
  .meta .dot{background:var(--ok);width:6px;height:6px}

  .composer-wrap{padding:0 16px 10px}
  .composer{max-width:820px;margin:0 auto;border:1px solid var(--border);background:var(--panel);border-radius:14px;padding:12px 14px 10px}
  .composer textarea{width:100%;background:none;border:0;outline:0;resize:none;color:var(--text);font:15px/1.5 Inter,sans-serif;min-height:26px;max-height:200px}
  .composer textarea::placeholder{color:var(--muted)}
  .composer-row{display:flex;align-items:center;gap:14px;margin-top:6px;color:var(--muted);font-size:12.5px}
  .composer-row .hint{flex:1}
  .send{width:36px;height:36px;border-radius:9px;background:#2a2a31;display:grid;place-items:center;color:var(--muted);transition:.15s}
  .send.ready{background:var(--accent);color:#fff}
  .footnote{text-align:center;color:var(--muted);font-size:12.5px;margin-top:10px}

  @media (max-width:900px){.side,.rail{display:none}.thread{padding:20px 16px}}

/* ---- live app additions ---- */
.item .acts{display:none;gap:4px}
.item:hover .acts{display:flex}
.item .acts button{color:var(--dim);padding:0 2px}.item .acts button:hover{color:var(--text)}
.item .acts svg{width:14px;height:14px}
.chip select{background:none;border:0;color:inherit;font:inherit;outline:0;cursor:pointer}
.chip select option{background:var(--panel)}
.chip.root{border-color:#6b2626;color:#ff8a8a;background:#2a1313}
.chip.box{border-color:#26506b;color:#8ac8ff;background:#13202a}
.ububble{margin:22px 0 0 auto;max-width:80%;width:fit-content;background:var(--panel-2);border:1px solid var(--border);border-radius:12px;padding:10px 14px;white-space:pre-wrap;font-size:15px}
.ububble small{display:block;color:var(--dim);font-size:11px;margin-bottom:2px}
.msg pre{background:var(--code-bg);border:1px solid #30303a;border-radius:8px;padding:12px;overflow-x:auto;margin:0 0 14px}
.msg pre code{background:none;border:0;padding:0}
.msg a{color:var(--accent-2)}
.msg h1,.msg h2,.msg h3{font-size:16px;margin:16px 0 8px}
.msg table{border-collapse:collapse;margin:0 0 14px}.msg td,.msg th{border:1px solid var(--border);padding:4px 8px}
.tool .x{color:var(--live);width:16px;height:16px}
.tool .spin{width:13px;height:13px}
.tools{margin-top:18px}
.err{margin-top:16px;border:1px solid #6b2626;background:#2a1313;color:#ffb4b4;border-radius:8px;padding:10px 12px;font-size:13px;white-space:pre-wrap}
.meta.bad .dot{background:var(--live)}
.thinking{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px;margin-top:18px}
.empty{color:var(--muted);text-align:center;margin-top:18vh}
.empty h2{color:var(--text);font-size:22px;margin-bottom:6px}
.send.stop{background:#3a1d1d;color:#ff8a8a}
.menu{position:absolute;bottom:64px;left:12px;right:12px;background:var(--panel-2);border:1px solid var(--border);border-radius:10px;padding:6px;display:none;z-index:5}
.menu.open{display:block}
.menu button{display:block;width:100%;text-align:left;padding:8px 10px;border-radius:6px}.menu button:hover{background:var(--panel)}
.side{position:relative}
.modal-bg{position:fixed;inset:0;background:#000a;display:none;align-items:center;justify-content:center;z-index:10;padding:16px}
.modal-bg.open{display:flex}
.modal{background:var(--side);border:1px solid var(--border);border-radius:14px;width:640px;max-width:100%;max-height:88vh;overflow-y:auto;padding:20px}
.modal h2{font-size:17px;margin-bottom:4px}.modal h3{font-size:13px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin:22px 0 8px}
.modal p.sub{color:var(--muted);font-size:13px}
.row{display:flex;gap:8px;align-items:center;padding:8px 0;border-bottom:1px solid var(--border-soft);font-size:14px}
.row .grow{flex:1;min-width:0}
.row small{color:var(--muted)}
.field{background:var(--panel);border:1px solid var(--border);border-radius:8px;color:var(--text);font:inherit;padding:8px 10px;outline:0;min-width:0}
.field:focus{border-color:var(--accent)}
.btn{background:var(--accent);color:#fff;border-radius:8px;padding:8px 14px;font-weight:600}
.btn.ghost{background:var(--panel);border:1px solid var(--border);color:var(--text);font-weight:500}
.btn.danger{background:#3a1d1d;color:#ff8a8a}
.btn.sm{padding:4px 10px;font-size:12.5px}
.formrow{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}.formrow .field{flex:1}
.note{font-size:12.5px;color:var(--muted);margin-top:6px}
.toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:var(--panel-2);border:1px solid var(--border);padding:10px 16px;border-radius:10px;z-index:20;display:none}
/* login */
.login-wrap{flex:1;display:grid;place-items:center;padding:16px}
.login{width:360px;max-width:100%;background:var(--side);border:1px solid var(--border);border-radius:16px;padding:28px}
.login .brand{justify-content:center;padding-bottom:20px}
.login label{display:block;font-size:13px;color:var(--muted);margin:12px 0 6px}
.login .field{width:100%}
.login .btn{width:100%;margin-top:18px;height:42px}
.login .err{display:none}
@media (max-width:900px){.side.open{display:flex;position:fixed;inset:0 auto 0 0;z-index:9;width:290px}.mtoggle{display:inline-flex!important}}
.mtoggle{display:none;color:var(--muted);margin-right:10px}

.live-tag{display:inline-flex;align-items:center;gap:4px;margin-left:6px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;color:var(--ok)}
.live-tag i{width:6px;height:6px;border-radius:50%;background:var(--ok);animation:pulse 1.2s ease-in-out infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.25}}
.bar i{transition:width .6s ease}

.usage-sub{font-size:11.5px;color:var(--dim);margin-top:6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
