:root{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Noto Sans SC",sans-serif;color:#111827;background:#f7f8fa;line-height:1.45}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden}
[hidden]{display:none!important}
h1,h2,p{margin:0}
button,input,textarea{font:inherit}
button{border:0;cursor:pointer}
.eyebrow,.nav-label{font-size:.68rem;letter-spacing:.08em;color:#8b95a5;font-weight:700;text-transform:uppercase}
.muted{color:#8b95a5;font-size:.8rem}
.login{max-width:380px;margin:16vh auto;padding:28px}
.login h1{font-size:1.8rem;margin:8px 0}
.intro{color:#6b7280;margin-bottom:16px}
label{display:block;font-weight:600;font-size:.88rem;margin:12px 0}
input,textarea{width:100%;border:1px solid #d8dee8;border-radius:10px;padding:12px;font-size:16px;background:#fff;color:inherit}
input:focus,textarea:focus{outline:none;border-color:#3b82f6}
.login button,.send,#newChat,#projectSave{background:#2563eb;color:#fff;border-radius:10px;font-weight:700;padding:10px 14px;min-height:40px}
.form-message{display:block;min-height:1.1em;margin-top:8px;color:#2563eb;font-size:.85rem}
.error{color:#dc2626!important}

.hub{display:flex;height:100dvh;max-height:100dvh;overflow:hidden}
.sidebar{width:280px;flex:0 0 280px;background:#fff;border-right:1px solid #eceff3;display:flex;flex-direction:column;padding:12px 10px 10px;z-index:20}
.side-head{display:flex;flex-direction:column;gap:8px}
#newChat{width:100%}
.side-scroll{flex:1;overflow:auto;min-height:0}
.nav-label{margin:14px 8px 6px}
.nav-list{display:flex;flex-direction:column;gap:2px}
.nav-item,.nav-link,.text-btn{width:100%;text-align:left;background:transparent;color:#111827;font-weight:550;padding:8px 10px;min-height:36px;border-radius:8px}
.nav-item{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;line-height:1.3;max-height:none;word-break:normal}
.nav-item.active,.nav-link.active{background:#eef4ff;color:#1d4ed8}
.logout{margin-top:8px}
.backdrop{position:fixed;inset:0;background:#11182755;z-index:15}

.main{flex:1;min-width:0;display:flex;flex-direction:column;height:100%;overflow:hidden;background:#f7f8fa}
.topbar{display:flex;align-items:center;gap:8px;padding:8px 10px;background:#fff;border-bottom:1px solid #eceff3;flex-shrink:0;min-height:48px}
.top-title{flex:1;min-width:0;font-size:1rem;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.icon-btn{flex:0 0 36px;width:36px;height:36px;min-height:36px;padding:0;border-radius:8px;background:transparent;color:#111827;font-size:18px;line-height:1;white-space:nowrap}
.more-wrap{position:relative;flex:0 0 36px}
.more-menu{position:absolute;right:0;top:40px;background:#fff;border:1px solid #eceff3;border-radius:10px;min-width:128px;padding:4px;z-index:30;box-shadow:0 8px 24px #11182714}
.more-menu button{display:block;width:100%;text-align:left;background:transparent;padding:10px 12px;border-radius:8px;min-height:40px;white-space:nowrap}
.danger-text{color:#dc2626}

.view{display:none;flex-direction:column;flex:1;min-height:0;overflow:hidden}
.view:not([hidden]){display:flex}
.messages{flex:1;overflow:auto;padding:14px 12px 8px;display:flex;flex-direction:column;gap:10px;-webkit-overflow-scrolling:touch}
.msg{max-width:min(720px,92%);padding:8px 2px;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}
.msg.user{align-self:flex-end;background:#2563eb;color:#fff;padding:10px 12px;border-radius:16px 16px 4px 16px}
.msg.assistant{align-self:flex-start}
.msg-tools{margin-top:6px}
.copy-btn{min-height:40px;min-width:64px;padding:8px 12px;border-radius:8px;background:#eef2f7;color:#374151;font-size:.8rem;font-weight:600}
.copy-btn.copied{background:#ecfdf3;color:#15803d}
.msg time{display:block;margin-top:4px;color:#9aa3b2;font-size:.72rem}
.msg.user time{color:#dbeafe}
.job{font-size:.78rem;color:#6b7280;margin-top:6px}
.job.running{color:#2563eb}
.job.success{color:#15803d}
.job.failed{color:#dc2626}
details{margin-top:6px}
summary{cursor:pointer;color:#2563eb;font-size:.8rem}
pre{white-space:pre-wrap;overflow-wrap:anywhere;background:#f3f4f6;padding:8px;border-radius:8px;font-size:.74rem;max-height:220px;overflow:auto}

.composer{flex-shrink:0;display:flex;gap:8px;align-items:flex-end;flex-wrap:wrap;padding:8px 10px calc(10px + env(safe-area-inset-bottom));background:#fff;border-top:1px solid #eceff3}
.composer textarea{flex:1;min-width:0;min-height:40px;max-height:120px;resize:none;padding:10px 12px;line-height:1.35}
.send{flex:0 0 auto;white-space:nowrap;min-width:64px}
.model-btn{flex:0 0 auto;min-height:40px;min-width:108px;padding:8px 12px;border-radius:10px;background:#eef2f7;color:#1f2937;font-size:.8rem;font-weight:700;white-space:nowrap}
.choice-row{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0 12px}
.choice{min-height:40px;min-width:64px;padding:8px 12px;border-radius:10px;background:#eef2f7;color:#1f2937;font-weight:650}
.choice.active{background:#2563eb;color:#fff}

.panel{margin:16px;background:#fff;border:1px solid #eceff3;border-radius:12px;padding:16px;overflow:auto}
.guard-actions{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
.danger-btn{background:#dc2626;color:#fff;border-radius:10px;font-weight:700;padding:10px 14px;min-height:40px}
.guard-alerts{display:flex;flex-wrap:wrap;gap:6px;margin:8px 0}
.guard-pill{font-size:.72rem;font-weight:700;padding:4px 8px;border-radius:999px;background:#f3f4f6}
.guard-pill.warn{background:#fff7ed;color:#c2410c}
.guard-pill.block{background:#fef2f2;color:#b91c1c}
.guard-pill.ok{background:#ecfdf3;color:#15803d}
.online{font-size:.72rem;background:#ecfdf3;color:#15803d;padding:3px 8px;border-radius:999px;margin-left:6px}
.online i{display:inline-block;width:7px;height:7px;border-radius:50%;background:#22c55e;margin-right:4px}
.metrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:12px 0}
.metrics div{padding:10px;border-radius:10px;background:#f3f4f6}
.metrics small{display:block;color:#8b95a5;font-size:.72rem}
.task-list{padding:12px;overflow:auto;display:flex;flex-direction:column;gap:8px}
.task-card{background:#fff;border:1px solid #eceff3;border-radius:12px;padding:12px}
.empty{color:#8b95a5;padding:8px}
dialog{border:1px solid #eceff3;border-radius:12px;padding:18px;width:min(400px,calc(100vw - 24px));max-height:calc(100dvh - 32px);overflow:auto;margin:auto}
dialog::backdrop{background:#11182755}
dialog menu{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap;padding:0;margin-top:12px}
dialog menu button{flex:0 1 auto;width:auto;min-width:84px;text-align:center}
dialog menu .text-btn{width:auto;min-width:84px;min-height:40px;padding:10px 14px;text-align:center}

@media(max-width:820px){
  .sidebar{position:fixed;left:0;top:0;height:100dvh;transform:translateX(-105%);transition:transform .18s ease}
  .sidebar.open{transform:none}
  .icon-btn{display:inline-flex;align-items:center;justify-content:center}
  dialog{padding:16px}
}
@media(min-width:821px){
  #menuToggle{display:none}
  .messages,.composer{padding-left:24px;padding-right:24px}
}
@media(prefers-color-scheme:dark){
  :root{color:#e5e7eb;background:#0f141c}
  .login,.sidebar,.topbar,.composer,.panel,.task-card,.more-menu,dialog,.msg.assistant{background:#151b24;border-color:#2a3342}
  .copy-btn,.model-btn,.choice{background:#1e2937;color:#e5e7eb}
  input,textarea,pre,.metrics div{background:#0f141c;color:#e5e7eb;border-color:#334155}
  .nav-item.active,.nav-link.active{background:#1e3a5f;color:#bfdbfe}
  .msg.user{background:#1d4ed8}
}
