:root {
  color-scheme: light;
  --ink: #161616;
  --muted: #61615e;
  --line: #dededb;
  --paper: #f8f8f6;
  --white: #fff;
  --rail: #151515;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --column: 780px;
  --gutter: clamp(20px, 4vw, 40px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, select, textarea { font: inherit; color: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.app {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--rail);
  color: #f5f5f3;
}

.side-top { padding: 28px 20px 30px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 700 21px/1 var(--mono);
  letter-spacing: .12em;
  margin-bottom: 32px;
}

.mark {
  position: relative;
  display: inline-block;
  flex: 0 0 20px;
  height: 21px;
}

.mark::before, .mark::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border: 1px solid currentColor;
}

.mark::after { left: 5px; top: 5px; background: var(--rail); }

.new {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #555;
  border-radius: 3px;
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.new:hover { background: #292929; }
.side-label { color: #a9a9a7; font-size: 12px; padding: 0 24px 8px; }
.sessions { min-height: 0; overflow: auto; padding: 0 12px 20px; }

.session {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 8px;
  border-left: 2px solid transparent;
  color: #bcbcb9;
}

.session:hover, .session:focus-within, .session[data-active="1"] { background: #272727; color: #fff; }
.session[data-active="1"] { border-left-color: #e8e8e4; }
.session-label, .session-del { border: 0; background: transparent; }

.session-label {
  flex: 1;
  min-width: 0;
  padding: 9px 4px 9px 10px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.session-status { font-size: 11px; white-space: nowrap; }
.session-del { padding: 2px 6px; color: #aaa; }
.session-del:hover { color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.top {
  display: flex;
  flex: 0 0 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}

#apiBtn { margin-inline-start: auto; }

#modelSel, .ghost, .copy {
  border: 1px solid #cececa;
  border-radius: 3px;
  background: transparent;
  padding: 6px 11px;
  font-size: 13px;
}

#modelSel, #apiBtn { font-family: var(--mono); }
#modelSel { min-height: 38px; }
#modelSel:hover, .ghost:hover, .copy:hover { background: #ecece9; }
.menu, .side-backdrop { display: none; }

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 32px var(--gutter) 18px;
  scrollbar-gutter: stable both-edges;
}

.empty, .msg {
  width: min(100%, var(--column));
  margin-inline: auto;
}

.empty { padding-top: clamp(26px, 11vh, 112px); }
.slogan { color: var(--muted); font-size: 14px; margin: 0 0 10px; }

.empty h1 {
  font-size: clamp(32px, 5.4vw, 72px);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -.035em;
  margin: 0 0 clamp(26px, 6vh, 56px);
}

.empty h1 span { color: #62625f; }
.samples { max-width: 490px; border-top: 1px solid var(--line); }

.sample {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 10px 2px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}

.sample::after { content: "↗" / ""; color: var(--muted); }
.sample:hover { background: #efefed; }
.msg { margin-bottom: 26px; }
.msg.user { display: flex; justify-content: flex-end; }

.bubble-user, .bubble-answer {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble-user {
  max-width: 84%;
  background: #eaeae7;
  padding: 10px 15px;
  border-radius: 3px;
}

.bubble-answer { font-size: 17px; }
.stopped { font-size: 13px; color: var(--muted); }

.think {
  margin-bottom: 14px;
  border-left: 1px solid #c5c5c1;
}

.think-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.think-head:hover { color: var(--ink); }
.think-time { font: 12px var(--mono); }
.chev { line-height: 1; }
.think[data-open="1"] .chev { transform: rotate(90deg); }
.think[data-open="0"] .think-body { display: none; }

.think-body {
  padding: 3px 12px 8px;
  color: var(--muted);
  line-height: 1.85;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 280px;
  overflow: auto;
}

.caret {
  display: inline-block;
  width: 6px;
  height: 12px;
  margin-inline-start: 3px;
  background: currentColor;
  animation: blink 1s steps(1) infinite;
}

.caret.hidden { display: none; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .caret { animation: none; } }

.msg-tools { margin-top: 8px; }
.tool { padding: 2px 0; border: 0; background: none; color: var(--muted); font-size: 12px; }
.tool:hover { text-decoration: underline; }

.composer {
  width: 100%;
  padding: 0 var(--gutter) 15px;
}

.box, .hint { width: min(100%, var(--column)); margin-inline: auto; }

.box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 57px;
  border: 1px solid #c9c9c5;
  border-radius: 4px;
  padding: 8px;
  background: var(--white);
}

.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.box:focus-within { border-color: var(--ink); }

#input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  max-height: 200px;
  border: 0;
  outline: 0;
  resize: none;
  padding: 7px 8px;
  background: transparent;
}

.send {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--ink);
  border-radius: 3px;
  background: var(--ink);
  color: var(--white);
  white-space: nowrap;
  font-size: 13px;
}

.send:hover { background: #353535; }
.send[data-mode="stop"] { background: var(--white); color: var(--ink); }
.hint { margin-top: 7px; color: var(--muted); font: 11px/1.5 var(--mono); }

.drawer {
  width: min(600px, 100%);
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0 0 0 auto;
  padding: 24px clamp(16px, 4vw, 32px);
  border: 0;
  border-left: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
}

.drawer::backdrop { background: #0006; }
.drawer-head, .code-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.drawer-head h2 { margin: 0; font-size: 19px; }
.drawer-sec { margin-top: 24px; }
.drawer-sec h3 { margin: 0 0 7px; color: var(--muted); font-size: 13px; }
.code-row, pre { border: 1px solid var(--line); background: var(--white); padding: 10px 12px; }
.code-row code { overflow-wrap: anywhere; font: 12px var(--mono); }
.copy { white-space: nowrap; }
pre { margin: 0 0 7px; overflow-x: auto; font: 12px/1.7 var(--mono); }

@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .top { flex-basis: 54px; }
  .thread { padding-top: 22px; scrollbar-gutter: auto; }

  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(264px, 85vw);
    z-index: 2;
    visibility: hidden;
  }

  .side.open { visibility: visible; }

  .side.open + .side-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1;
    border: 0;
    background: #0006;
  }

  .menu { display: inline-block; }
}

/* First-use layout */
.empty { padding-top: clamp(4px, 5vh, 48px); }
.hero-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 700 18px/1 var(--mono);
  letter-spacing: .14em;
  margin-bottom: 13px;
}
.hero-brand .mark::after { background: var(--paper); }
.empty h1 { margin-bottom: clamp(20px, 3vh, 32px); }
#homeComposer .composer { padding: 0; }
#chatComposer:empty { display: none; }
.suggestions { margin-top: 20px; }
.suggestions-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.suggestions-head h2 { font-size: 13px; font-weight: 600; margin: 0; }
.suggestions-head button { text-decoration: underline; text-underline-offset: 3px; padding: 4px 0 4px 12px; }
.samples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 22px; max-width: none; }
.sample { min-width: 0; }
.specs { display: flex; flex-wrap: wrap; align-items: baseline; margin-top: 24px; row-gap: 5px; }
.specs > * + * { border-left: 1px solid var(--line); margin-left: 14px; padding-left: 14px; }
.specs strong { font-weight: 650; font-size: 17px; }
.specs span { color: var(--muted); font-size: 13px; }
.product-nav { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 14px; }
.product-nav a, .standalone-top a, .about a { color: inherit; text-underline-offset: 3px; }
.product-nav a { color: var(--muted); font-size: 12px; }
.message-model { font: 600 12px/1.5 var(--mono); margin-bottom: 7px; }
.drawer-sec p, .drawer-sec dd { margin: 0 0 10px; }
.drawer-sec dt { font-weight: 600; overflow-wrap: anywhere; }
.api-traits { color: var(--muted); font: 12px/1.6 var(--mono); }
.standalone-top { height: 64px; }
.about { width: min(100%, 770px); padding: 35px var(--gutter); margin: auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 720px) {
  .empty { padding-top: 8px; }
  .box { flex-direction: column; align-items: stretch; }
  #input { flex: auto; width: 100%; }
  .samples { grid-template-columns: minmax(0, 1fr); }
  .sample:nth-child(n+5) { display: none; }
}

.notice { color: var(--ink); }
.notice:empty { display: none; }
