:root {
  --sidebar: #171717;
  --sidebar-hover: #242424;
  --canvas: #f7f7f5;
  --surface: #ffffff;
  --ink: #20201f;
  --muted: #73736f;
  --line: #e2e2de;
  --line-strong: #cecec8;
  --accent: #20201f;
  --success: #24825c;
  --warning: #a16207;
  --danger: #bd4639;
  --danger-soft: #fff1ef;
  --shadow: 0 12px 36px rgba(23, 23, 23, .10);
  --sans: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SFMono-Regular", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: light; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 100; padding: 10px 14px; color: white; background: var(--sidebar); }
.skip-link:focus { top: 16px; }
.noscript { padding: 12px 20px; color: white; background: var(--danger); text-align: center; }

.brand-lockup { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-lockup > span:last-child { display: grid; gap: 1px; }
.brand-lockup b { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.brand-lockup small { color: inherit; font: 9px var(--mono); letter-spacing: .09em; opacity: .55; }
.brand-mark { display: grid; width: 37px; height: 37px; place-items: center; border: 1px solid currentColor; border-radius: 11px; font: 650 14px var(--mono); }
.eyebrow { margin: 0; font: 10px var(--mono); letter-spacing: .14em; }
.state-dot { display: inline-block; width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #8c8c87; box-shadow: 0 0 0 3px rgba(140, 140, 135, .12); }
.state-dot.success { background: var(--success); box-shadow: 0 0 0 3px rgba(36, 130, 92, .12); }
.state-dot.warning { background: var(--warning); box-shadow: 0 0 0 3px rgba(161, 98, 7, .12); }
.state-dot.danger { background: var(--danger); box-shadow: 0 0 0 3px rgba(189, 70, 57, .12); }

.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(0, 1.12fr) minmax(390px, .88fr); }
.login-brand { position: relative; display: flex; overflow: hidden; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 42px clamp(36px, 6vw, 92px); color: #f5f5f2; background: var(--sidebar); }
.login-brand::before { content: "C"; position: absolute; right: -5vw; bottom: -14vw; color: transparent; font: 650 clamp(300px, 42vw, 650px)/1 var(--sans); -webkit-text-stroke: 1px rgba(255, 255, 255, .08); transform: rotate(-8deg); }
.login-brand > * { position: relative; z-index: 1; }
.login-statement { max-width: 760px; margin: auto 0; padding: 12vh 0 8vh; }
.login-statement .eyebrow { color: #a7a7a0; }
.login-statement h1 { max-width: 720px; margin: 22px 0 24px; font-size: clamp(50px, 5vw, 76px); font-weight: 590; line-height: .99; letter-spacing: -.058em; }
.login-statement > p:last-child { max-width: 630px; margin: 0; color: #b9b9b3; font-size: clamp(15px, 1.45vw, 20px); line-height: 1.78; }
.trust-list { display: flex; flex-wrap: wrap; gap: 18px 28px; color: #cfcfca; font-size: 12px; }
.trust-list span { display: inline-flex; align-items: center; gap: 8px; }
.trust-list i { width: 6px; height: 6px; border-radius: 50%; background: #9d9d96; }

.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 6vw, 92px); background: var(--surface); }
.live-line { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px; margin-bottom: 46px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.live-line b { font-size: 13px; }
.live-line small { color: var(--muted); font: 9px var(--mono); }
.login-form { display: grid; gap: 17px; }
.form-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.form-heading span { font-size: 24px; font-weight: 630; letter-spacing: -.035em; }
.form-heading small { color: var(--muted); font-size: 10px; }
label { display: grid; gap: 8px; color: #494945; font-size: 12px; font-weight: 590; }
input, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 9px; outline: none; color: var(--ink); background: var(--surface); transition: border-color .16s ease, box-shadow .16s ease; }
input { min-height: 50px; padding: 0 14px; }
input:focus, textarea:focus { border-color: #7d7d78; box-shadow: 0 0 0 3px rgba(32, 32, 31, .08); }
.primary-button { display: inline-flex; min-height: 50px; align-items: center; justify-content: space-between; gap: 20px; border: 0; border-radius: 9px; padding: 0 17px; color: white; background: var(--accent); font-weight: 630; transition: transform .16s ease, opacity .16s ease; }
.primary-button:hover:not(:disabled) { transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .42; }
.form-message { min-height: 18px; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--success); }
.login-boundary { margin-top: 38px; padding-top: 15px; border-top: 1px solid var(--line); }
.login-boundary b { font-size: 11px; }
.login-boundary p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.7; }

.workspace { display: grid; min-height: 100vh; grid-template-columns: 276px minmax(0, 1fr); background: var(--canvas); }
.sidebar { position: sticky; top: 0; z-index: 30; display: flex; height: 100vh; min-width: 0; flex-direction: column; padding: 18px 12px 14px; color: #eeeeea; background: var(--sidebar); }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 7px 18px; }
.brand-lockup.compact .brand-mark { width: 34px; height: 34px; border-color: #5d5d59; }
.brand-lockup.compact b { font-size: 14px; }
.sidebar-close { display: none; color: #d2d2cd; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; border: 0; border-radius: 8px; color: var(--ink); background: transparent; }
.icon-button:hover { background: rgba(127, 127, 120, .13); }
.new-task-button { display: grid; min-height: 43px; grid-template-columns: 22px 1fr auto; align-items: center; border: 1px solid #3b3b38; border-radius: 9px; padding: 0 11px; color: #f2f2ef; background: #242422; text-align: left; font-size: 12px; }
.new-task-button:hover { background: #2d2d2a; }
.new-task-button span { font-size: 17px; font-weight: 300; }
.new-task-button kbd { color: #898983; font: 9px var(--mono); }
.history { min-height: 0; flex: 1; margin-top: 22px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 9px 8px; color: #868680; }
.history-heading h2 { margin: 0; font-size: 10px; font-weight: 550; text-transform: uppercase; letter-spacing: .08em; }
.history-heading span { font: 9px var(--mono); }
.task-list { display: grid; overflow-y: auto; max-height: calc(100vh - 220px); gap: 3px; margin: 0; padding: 0; list-style: none; scrollbar-width: thin; }
.task-list-empty { padding: 16px 10px; color: #757570; font-size: 11px; }
.task-item { display: grid; width: 100%; gap: 5px; border: 0; border-radius: 8px; padding: 9px 10px; color: #c9c9c4; background: transparent; text-align: left; }
.task-item:hover { background: var(--sidebar-hover); }
.task-item.active { color: #fff; background: #30302d; }
.task-item-top { display: flex; min-width: 0; align-items: center; gap: 7px; }
.task-item b { overflow: hidden; min-width: 0; flex: 1; font-size: 11px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.task-item small { color: #777771; font: 8px var(--mono); }
.task-status { flex: 0 0 auto; color: #85857f; font: 8px var(--mono); font-style: normal; }
.task-status.completed { color: #75b99b; }
.task-status.queued, .task-status.running { color: #c79a59; }
.task-status.blocked { color: #df877e; }
.sidebar-foot { display: flex; align-items: center; gap: 10px; padding: 13px 7px 0; border-top: 1px solid #30302e; }
.identity { display: flex; min-width: 0; flex: 1; align-items: center; gap: 9px; }
.identity > span { display: grid; width: 31px; height: 31px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #20201f; background: #dbdbd5; font: 650 9px var(--mono); }
.identity div { display: grid; min-width: 0; gap: 2px; }
.identity b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.identity small { color: #7f7f79; font: 8px var(--mono); }
.logout-button { border: 0; padding: 7px; color: #92928c; background: transparent; font-size: 10px; }
.logout-button:hover { color: white; }
.sidebar-backdrop { display: none; }

.thread-shell { display: grid; min-width: 0; min-height: 100vh; grid-template-rows: auto auto minmax(0, 1fr) auto; }
.thread-header { position: sticky; top: 0; z-index: 15; display: grid; min-height: 68px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 10px 22px; border-bottom: 1px solid var(--line); background: rgba(247, 247, 245, .92); backdrop-filter: blur(16px); }
.thread-heading { min-width: 0; }
.thread-heading h1 { overflow: hidden; margin: 0; font-size: 14px; font-weight: 610; text-overflow: ellipsis; white-space: nowrap; }
.thread-heading small { color: var(--muted); font-size: 9px; }
.mobile-menu { display: none; }
.worker-pill { display: inline-flex; min-height: 34px; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 99px; padding: 0 12px; color: #5d5d59; background: var(--surface); font-size: 10px; }
.worker-pill:hover { border-color: var(--line-strong); }
.worker-banner { display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 12px; margin: 12px 22px 0; border: 1px solid #f0c5c0; border-radius: 10px; padding: 11px 13px; color: #71342e; background: var(--danger-soft); }
.worker-banner b { font-size: 11px; }
.worker-banner p { margin: 2px 0 0; color: #9a5b54; font-size: 9px; }
.worker-banner button { border: 0; padding: 7px 8px; color: #8c4038; background: transparent; font-size: 9px; text-decoration: underline; text-underline-offset: 3px; }

.conversation { display: grid; overflow-y: auto; min-height: 0; align-items: center; padding: 48px clamp(22px, 7vw, 96px) 28px; }
.empty-state { width: min(720px, 100%); margin: auto; text-align: center; }
.empty-mark { display: grid; width: 54px; height: 54px; margin: 0 auto 24px; place-items: center; border: 1px solid #bdbdb7; border-radius: 17px; color: #51514d; background: var(--surface); box-shadow: 0 8px 24px rgba(23, 23, 23, .06); font: 650 18px var(--mono); }
.empty-state h2 { margin: 0; font-size: clamp(25px, 3vw, 36px); font-weight: 560; letter-spacing: -.045em; }
.empty-state > p { max-width: 580px; margin: 13px auto 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.starter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 30px; }
.starter-grid button { min-height: 64px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; color: #5d5d58; background: rgba(255, 255, 255, .55); font-size: 10px; text-align: left; }
.starter-grid button:hover { border-color: var(--line-strong); background: var(--surface); }
.message-list { width: min(820px, 100%); margin: 0 auto auto; }
.message { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 13px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.message:first-child { padding-top: 0; }
.message:last-child { border-bottom: 0; }
.message-avatar { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--line-strong); border-radius: 9px; color: #4d4d49; background: var(--surface); font: 620 10px var(--mono); }
.message.assistant .message-avatar { color: white; background: var(--sidebar); }
.message-content { min-width: 0; }
.message-heading { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.message-heading b { font-size: 11px; }
.message-heading small { color: var(--muted); font: 8px var(--mono); }
.message-body { color: #30302e; font-size: 13px; line-height: 1.78; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-body.queued, .message-body.running { color: var(--warning); }
.message-body.blocked { color: var(--danger); }

.composer-dock { position: sticky; bottom: 0; z-index: 10; padding: 14px clamp(22px, 7vw, 96px) max(18px, env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(247, 247, 245, 0), var(--canvas) 24%); }
.composer-form { width: min(820px, 100%); margin: 0 auto; }
.composer-box { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 15px; background: var(--surface); box-shadow: 0 10px 32px rgba(23, 23, 23, .09); }
.composer-box:focus-within { border-color: #979791; box-shadow: 0 10px 34px rgba(23, 23, 23, .12), 0 0 0 3px rgba(32, 32, 31, .05); }
.composer-box textarea { display: block; min-height: 76px; max-height: 220px; border: 0; border-radius: 0; padding: 15px 16px 7px; resize: vertical; font-size: 13px; line-height: 1.6; box-shadow: none; }
.composer-box textarea:focus { box-shadow: none; }
.composer-toolbar { display: flex; min-height: 47px; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 8px 12px; }
.composer-context { display: flex; min-width: 0; align-items: center; gap: 6px; }
.context-chip { border: 1px solid var(--line); border-radius: 99px; padding: 4px 7px; color: #6c6c67; font: 8px var(--mono); }
.title-preview { overflow: hidden; max-width: min(46vw, 380px); color: #8a8a84; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.send-button { display: grid; width: 33px; height: 33px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 9px; color: white; background: var(--accent); font-size: 18px; }
.send-button:disabled { cursor: not-allowed; color: #aaa9a4; background: #e4e4df; }
.composer-meta { display: flex; justify-content: space-between; gap: 16px; padding: 7px 5px 0; color: #8b8b85; font: 8px var(--mono); }
.composer-message { min-height: 15px; padding: 3px 5px 0; font-size: 9px; }

@media (max-width: 880px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 54vh; padding: 28px; }
  .login-statement { padding: 10vh 0 7vh; }
  .login-statement h1 { font-size: clamp(46px, 10vw, 74px); }
  .login-panel { padding: 42px 28px 52px; }
  .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .starter-grid { grid-template-columns: 1fr; }
  .starter-grid button { min-height: 48px; text-align: center; }
}

@media (max-width: 680px) {
  .login-brand { min-height: 440px; }
  .login-statement { padding: 56px 0 38px; }
  .login-statement h1 { margin-top: 15px; font-size: 43px; }
  .login-statement > p:last-child { font-size: 14px; }
  .trust-list { gap: 10px 17px; }
  .login-panel { padding: 32px 20px 42px; }
  .live-line { margin-bottom: 32px; }
  .form-heading { align-items: start; flex-direction: column; gap: 4px; }

  .workspace { display: block; overflow-x: hidden; }
  .sidebar { position: fixed; left: 0; width: min(86vw, 304px); transform: translateX(-104%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; border: 0; background: rgba(0, 0, 0, .38); }
  .sidebar-open .sidebar-backdrop { display: block; }
  .thread-shell { min-height: 100dvh; }
  .thread-header { min-height: 60px; grid-template-columns: 36px minmax(0, 1fr) auto; padding: 8px 11px; }
  .mobile-menu { display: grid; }
  .thread-heading h1 { font-size: 12px; }
  .thread-heading small { display: none; }
  .worker-pill { min-height: 32px; padding: 0 10px; }
  .worker-pill span:last-child { max-width: 82px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .worker-banner { grid-template-columns: 10px 1fr; margin: 9px 11px 0; }
  .worker-banner button { display: none; }
  .conversation { padding: 36px 16px 20px; }
  .empty-state > p { font-size: 11px; }
  .starter-grid { margin-top: 22px; }
  .message { grid-template-columns: 27px minmax(0, 1fr); gap: 10px; padding: 18px 0; }
  .message-avatar { width: 27px; height: 27px; }
  .message-body { font-size: 12px; }
  .composer-dock { padding: 11px 11px max(14px, env(safe-area-inset-bottom)); }
  .composer-box { border-radius: 13px; }
  .composer-box textarea { min-height: 68px; padding: 13px 13px 5px; }
  .title-preview { display: none; }
  .composer-meta span:first-child { max-width: 58vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .composer-meta span:last-child { font-size: 0; }
  .composer-meta span:last-child b { font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
