/* Codex Web — layout and components on the Strata token system. */

*{box-sizing:border-box}
[hidden]{display:none!important}
html,body{height:100%}
body{
  margin:0;
  background:var(--st-bg);
  color:var(--st-ink);
  font-family:var(--st-font);
  font-size:var(--st-fs-base);
  line-height:var(--st-lh-body);
  -webkit-font-smoothing:antialiased;
}
::selection{background:var(--st-accent-tint);color:var(--st-ink)}
button,input,textarea{font:inherit;color:inherit}
button{cursor:pointer;border:0;background:none}
:focus-visible{outline:2px solid var(--st-focus);outline-offset:2px;border-radius:6px}
.ic{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}

/* scrollbars */
*{scrollbar-width:thin;scrollbar-color:var(--st-line) transparent}
*::-webkit-scrollbar{width:10px;height:10px}
*::-webkit-scrollbar-thumb{background:var(--st-line);border-radius:99px;border:3px solid transparent;background-clip:content-box}
*::-webkit-scrollbar-track{background:transparent}

.app{height:100dvh;display:flex;flex-direction:column;overflow:hidden}

/* top bar */
.topbar{
  flex:0 0 auto;height:60px;display:flex;align-items:center;gap:var(--st-s-3);
  padding:0 var(--st-s-4);background:var(--st-surface);border-bottom:1px solid var(--st-line);
}
.brand{font-size:var(--st-fs-lg);font-weight:var(--st-fw-bold);letter-spacing:-.01em}
.brand span{color:var(--st-accent-text);font-weight:var(--st-fw-medium)}
.topbar-right{margin-left:auto;display:flex;align-items:center;gap:var(--st-s-2)}
.topbar-right{flex:0 0 auto}
.icon-btn{
  width:40px;height:40px;display:inline-flex;align-items:center;justify-content:center;
  border-radius:var(--st-r-sm);color:var(--st-icon);transition:background var(--st-dur) var(--st-ease);
}
.icon-btn:hover{background:var(--st-surface-2)}
.status-pill{
  display:inline-flex;align-items:center;gap:var(--st-s-2);height:32px;padding:0 12px;
  border-radius:var(--st-r-pill);background:var(--st-surface-2);border:1px solid var(--st-line-soft);
  font-size:var(--st-fs-sm);color:var(--st-ink-soft);white-space:nowrap;
}
.status-pill .dot{width:8px;height:8px;border-radius:50%;background:var(--st-ink-muted)}
.status-pill.busy .dot{background:var(--st-accent)}
@keyframes pulse{50%{opacity:.35}}

/* layout */
.layout{flex:1;display:flex;min-height:0}
.sidebar{
  flex:0 0 280px;display:flex;flex-direction:column;min-height:0;
  background:var(--st-surface);border-right:1px solid var(--st-line);
}
.sidebar-top{padding:var(--st-s-3);display:flex;flex-direction:column;gap:var(--st-s-2)}
.new-btn{
  display:flex;align-items:center;justify-content:center;gap:var(--st-s-2);
  height:42px;border-radius:var(--st-r-sm);background:var(--st-accent-btn);color:var(--st-accent-ink);
  font-weight:var(--st-fw-medium);transition:background var(--st-dur) var(--st-ease);
}
.new-btn:hover{background:var(--st-accent-btn-hover)}
.search-box{
  display:flex;align-items:center;gap:var(--st-s-2);height:40px;padding:0 12px;
  background:var(--st-surface-2);border:1px solid var(--st-line-soft);border-radius:var(--st-r-sm);
  color:var(--st-ink-muted);
}
.search-box .ic{width:17px;height:17px;flex:0 0 auto}
.search-box input{flex:1;min-width:0;border:0;background:none;outline:none;font-size:var(--st-fs-md)}
.search-box input::placeholder{color:var(--st-ink-muted)}

.chat-list{flex:1;overflow-y:auto;padding:var(--st-s-2) var(--st-s-3) var(--st-s-4)}
.group-label{
  padding:var(--st-s-3) var(--st-s-2) var(--st-s-1);font-size:var(--st-fs-xs);
  color:var(--st-ink-muted);text-transform:uppercase;letter-spacing:.04em;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.chat-row{
  display:block;width:100%;text-align:left;padding:10px 12px;border-radius:var(--st-r-sm);
  border:1px solid transparent;transition:background var(--st-dur) var(--st-ease);
}
.chat-row:hover{background:var(--st-surface-2)}
.chat-row.active{background:var(--st-accent-tint);border-color:var(--st-accent-tint)}
.chat-row .t{
  display:block;font-size:var(--st-fs-md);color:var(--st-ink-soft);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.chat-row.active .t{color:var(--st-ink);font-weight:var(--st-fw-medium)}
.chat-row .m{display:block;font-size:var(--st-fs-xs);color:var(--st-ink-muted);margin-top:2px}
.sidebar-foot{
  flex:0 0 auto;padding:var(--st-s-3);border-top:1px solid var(--st-line-soft);
  display:flex;flex-direction:column;gap:2px;
}
.link-btn{align-self:flex-start;color:var(--st-accent-text);font-size:var(--st-fs-sm);padding:6px 0}
.foot-note{font-size:var(--st-fs-xs);color:var(--st-ink-muted)}
.backdrop{display:none}

/* chat */
.chat{flex:1;display:flex;flex-direction:column;min-width:0;min-height:0;background:var(--st-bg)}
.chat-head{
  flex:0 0 auto;display:flex;align-items:center;gap:var(--st-s-3);
  padding:var(--st-s-3) var(--st-s-6);border-bottom:1px solid var(--st-line-soft);
  background:color-mix(in srgb, var(--st-bg) 88%, transparent);backdrop-filter:blur(8px);
}
.chat-title{margin:0;font-size:var(--st-fs-lg);font-weight:var(--st-fw-bold);letter-spacing:-.01em;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-meta{font-size:var(--st-fs-xs);color:var(--st-ink-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-title-wrap{min-width:0;flex:1}

.messages{flex:1;overflow-y:auto;padding:var(--st-s-6) var(--st-s-6) var(--st-s-8)}
.messages-inner{max-width:820px;margin:0 auto;display:flex;flex-direction:column;gap:var(--st-s-6)}
.msg{animation:rise var(--st-dur) var(--st-ease) both}
@keyframes rise{from{opacity:0;transform:translateY(6px)}}
.msg-head{display:flex;align-items:baseline;gap:var(--st-s-2);margin-bottom:var(--st-s-1)}
.msg-who{font-size:var(--st-fs-sm);font-weight:var(--st-fw-bold);color:var(--st-ink)}
.msg-time{font-size:var(--st-fs-xs);color:var(--st-ink-muted)}
.msg-body{color:var(--st-ink-soft);max-width:72ch;overflow-wrap:anywhere}
.msg.user .msg-body{
  display:inline-block;background:var(--st-surface);border:1px solid var(--st-line);
  border-radius:var(--st-r-md);padding:12px 16px;max-width:min(72ch,100%);
}
.msg.user{align-self:flex-end;max-width:min(72ch,100%)}
.msg.user .msg-head{justify-content:flex-end}
.msg.assistant .msg-body{padding:2px 0}
.system-note{
  align-self:center;max-width:min(72ch,100%);padding:7px 11px;border:1px solid var(--st-line);
  border-radius:999px;background:var(--st-surface-2);color:var(--st-ink-muted);
  font-size:var(--st-fs-xs);text-align:center;
}
.msg.reasoning{align-self:stretch}
.reasoning-panel{
  border:1px solid var(--st-line);border-radius:var(--st-r-sm);background:var(--st-surface-2);
  overflow:hidden;
}
.reasoning-panel summary{
  display:flex;align-items:center;justify-content:space-between;gap:var(--st-s-3);
  padding:9px 12px;cursor:pointer;color:var(--st-ink-muted);font-size:var(--st-fs-sm);
  font-weight:var(--st-fw-medium);list-style:none;
}
.reasoning-panel summary::-webkit-details-marker{display:none}
.reasoning-panel summary::before{
  content:"›";display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;
  margin-right:6px;border:1px solid var(--st-line);border-radius:50%;line-height:1;
  transition:transform var(--st-dur) var(--st-ease);
}
.reasoning-panel[open] summary::before{transform:rotate(90deg)}
.reasoning-panel summary span{margin-right:auto}
.reasoning-panel summary small{font-size:var(--st-fs-xs);color:var(--st-ink-muted)}
.reasoning-body{
  padding:0 14px 12px 38px;color:var(--st-ink-muted);font-size:var(--st-fs-sm);
  border-top:1px solid var(--st-line-soft);
}
.reasoning-body p{margin:.7em 0 0}

/* markdown */
.msg-body p{margin:0 0 .8em}
.msg-body p:last-child{margin-bottom:0}
.msg-body h1,.msg-body h2,.msg-body h3{line-height:1.3;margin:1.2em 0 .5em;letter-spacing:-.01em}
.msg-body h1{font-size:1.25em}.msg-body h2{font-size:1.15em}.msg-body h3{font-size:1.05em}
.msg-body ul,.msg-body ol{margin:.2em 0 .9em;padding-left:1.4em}
.msg-body li{margin:.15em 0}
.msg-body code{
  font-family:var(--st-font-mono);font-size:.88em;background:var(--st-code-bg);color:var(--st-code-ink);
  padding:.12em .38em;border-radius:5px;
}
.msg-body pre{
  background:var(--st-code-bg);color:var(--st-code-ink);border-radius:var(--st-r-sm);
  padding:14px 16px;overflow-x:auto;margin:.6em 0 1em;font-size:var(--st-fs-sm);
}
.msg-body pre code{background:none;padding:0;color:inherit}
.msg-body a{color:var(--st-info-text);text-underline-offset:2px}
.msg-body blockquote{
  margin:.6em 0;padding:2px 0 2px 14px;border-left:1px solid var(--st-line);color:var(--st-ink-muted);
}
.msg-body hr{border:0;border-top:1px solid var(--st-line);margin:1.2em 0}

.empty{height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--st-s-3);color:var(--st-ink-muted)}
.empty-mark{width:56px;height:56px;border-radius:var(--st-r-md);background:var(--st-surface);border:1px solid var(--st-line);
  display:flex;align-items:center;justify-content:center;color:var(--st-accent-text);box-shadow:var(--st-sh-card)}
.empty-mark .ic{width:26px;height:26px}
.empty p{margin:0;font-size:var(--st-fs-md)}

.thinking{display:inline-flex;align-items:center;gap:8px;color:var(--st-ink-muted);font-size:var(--st-fs-sm)}
.thinking i{width:7px;height:7px;border-radius:50%;background:var(--st-accent)}

/* composer */
.composer{
  flex:0 0 auto;position:relative;margin:0 auto var(--st-s-5);width:min(820px,calc(100% - 32px));
  background:var(--st-surface);border:1px solid var(--st-line);border-radius:var(--st-r-md);
  box-shadow:var(--st-sh-card);padding:10px 12px 8px;
}
.composer:focus-within{border-color:var(--st-focus)}
.composer textarea{
  width:100%;border:0;outline:none;resize:none;background:none;min-height:26px;max-height:200px;
  line-height:1.5;padding:6px 6px 2px;
}
.composer textarea::placeholder{color:var(--st-ink-muted)}
.composer-actions{display:flex;align-items:center;gap:var(--st-s-2);min-height:40px}
.composer-actions{flex-wrap:nowrap;min-width:0}
.hint{flex:1;min-width:0;font-size:var(--st-fs-xs);color:var(--st-ink-muted);padding-left:6px;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.send-btn{
  width:42px;height:42px;border-radius:var(--st-r-sm);background:var(--st-accent-btn);color:var(--st-accent-ink);
  display:inline-flex;align-items:center;justify-content:center;transition:background var(--st-dur) var(--st-ease);
}
.send-btn:hover{background:var(--st-accent-btn-hover)}
.send-btn:disabled{opacity:.45;cursor:default}
.send-btn.stop{background:var(--st-danger)}
.send-btn.stop:hover{background:var(--st-danger-text)}

/* gate */
.gate{
  position:fixed;inset:0;background:rgba(14,17,19,.45);display:flex;align-items:center;justify-content:center;
  padding:var(--st-s-4);z-index:20;
}
.gate[hidden]{display:none}
.gate-card{
  width:min(400px,100%);background:var(--st-surface);border:1px solid var(--st-line);border-radius:var(--st-r-md);
  box-shadow:var(--st-sh-pop);padding:var(--st-s-6);display:flex;flex-direction:column;gap:var(--st-s-3);
}
.gate-card h2{margin:0;font-size:var(--st-fs-xl);letter-spacing:-.01em}
.gate-card p{margin:0;font-size:var(--st-fs-sm);color:var(--st-ink-muted)}
.gate-card code{font-family:var(--st-font-mono);background:var(--st-surface-2);padding:1px 5px;border-radius:4px}
.gate-card input{
  height:44px;border:1px solid var(--st-line);border-radius:var(--st-r-sm);padding:0 12px;background:var(--st-surface-2);
}
.gate-card .primary{
  height:44px;border-radius:var(--st-r-sm);background:var(--st-accent-btn);color:var(--st-accent-ink);font-weight:var(--st-fw-medium);
}
.gate-card .primary:hover{background:var(--st-accent-btn-hover)}
.gate-error{color:var(--st-danger-text)!important}

/* responsive */
.only-mobile{display:none}
@media (max-width:900px){
  .only-mobile{display:inline-flex}
  .sidebar{
    position:fixed;top:60px;bottom:0;left:0;width:min(320px,86vw);z-index:15;
    transform:translateX(-102%);transition:transform .22s var(--st-ease);box-shadow:var(--st-sh-pop);
  }
  .sidebar.open{transform:none}
  .backdrop{display:block;position:fixed;inset:60px 0 0;background:rgba(14,17,19,.4);z-index:14;opacity:0;pointer-events:none;transition:opacity .2s}
  .backdrop.show{opacity:1;pointer-events:auto}
  .messages{padding:var(--st-s-4) var(--st-s-4) var(--st-s-6)}
  .chat-head{padding:var(--st-s-3) var(--st-s-4)}
  .composer{width:calc(100% - 24px);margin-bottom:max(var(--st-s-3),env(safe-area-inset-bottom))}
  .status-pill{padding:0 10px}
  .brand{font-size:var(--st-fs-base)}
}
