@font-face { font-family: "Inter Tight"; src: url(/fonts/intertight.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url(/fonts/jbmono.woff2) format("woff2"); font-weight: 100 800; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url(/fonts/is-italic.woff2) format("woff2"); font-style: italic; font-weight: 400; font-display: swap; }

:root {
  --bg: #F5F2EA;
  --panel: #FFFFFF;
  --side: #EFEBE1;
  --ink: #16140F;
  --dim: rgba(22, 20, 15, .66);
  --faint: rgba(22, 20, 15, .44);
  --line: rgba(22, 20, 15, .09);
  --line-2: rgba(22, 20, 15, .16);
  --solar: #F2541B;
  --gold: #C9780A;
  --cyan: #0E9F84;
  --rose: #E0245A;
  --ion: #3B55E6;
  --code: #F1EDE3;
  --sans: "Inter Tight", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Instrument Serif", "Songti SC", serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --w: 760px;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.65 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; }
::selection { background: rgba(242, 84, 27, .2); }

.app { display: grid; grid-template-columns: 272px 1fr; height: 100dvh; }

/* ───── sidebar */
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 10px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand b { color: var(--solar); font-weight: 700; }
.new-chat { margin: 6px 14px 10px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel); display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: 14px; transition: border-color .2s, transform .2s var(--ease); }
.new-chat:hover { border-color: var(--ink); }
.new-chat span:first-child { color: var(--solar); font-size: 16px; line-height: 1; }
.convs { flex: 1; overflow-y: auto; padding: 4px 8px 12px; min-height: 0; }
.convs .grp { font-size: 11.5px; color: var(--faint); padding: 12px 10px 4px; letter-spacing: .02em; }
.conv { text-decoration: none; display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: left; font-size: 13.5px; color: var(--dim); position: relative; }
.conv:hover { background: rgba(22, 20, 15, .05); color: var(--ink); }
.conv.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 0 var(--line); }
.conv .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .del { opacity: 0; font-size: 12px; color: var(--faint); padding: 2px 4px; border-radius: 6px; }
.conv:hover .del { opacity: 1; }
.conv .del:hover { color: var(--rose); }
.side-foot { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.bal { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.bal .k { font-size: 12px; color: var(--faint); display: block; line-height: 1.2; }
.bal b { font: 700 18px/1.2 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.bal.low b { color: var(--rose); }
.topup { font-size: 12.5px; font-weight: 600; text-decoration: none; padding: 6px 12px; border-radius: 99px; background: var(--ink); color: #fff; }
.pref { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--dim); cursor: pointer; }
.pref input { accent-color: var(--solar); }
.me { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--faint); }
.me .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { color: var(--dim); font-size: 12.5px; }
.link-btn:hover { color: var(--ink); }

/* ───── main */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); min-height: 54px; }
.title { flex: 1; margin: 0; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { font: 500 11.5px/1 var(--mono); color: var(--dim); border: 1px solid var(--line-2); border-radius: 99px; padding: 6px 10px; white-space: nowrap; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 16px; }
.icon-btn:hover { background: rgba(22, 20, 15, .06); }
.only-mobile { display: none; }

.thread { flex: 1; overflow-y: auto; padding: 28px 24px 24px; scroll-behavior: smooth; }
.thread > * { max-width: var(--w); margin-left: auto; margin-right: auto; }

/* ───── hero */
.hero { padding: clamp(24px, 8vh, 90px) 0 20px; }
.eyebrow { margin: 0 0 14px; color: var(--solar); font: 600 12px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.hero h2 { margin: 0; font: 750 clamp(28px, 4vw, 42px)/1.12 var(--sans); letter-spacing: -.035em; }
.hero h2 em { font: italic 400 1.08em/1 var(--serif); color: var(--solar); letter-spacing: -.01em; }
body.zh .hero h2 em { font: inherit; font-style: normal; color: var(--solar); }
.hero .sub { color: var(--dim); margin: 16px 0 26px; max-width: 40em; font-size: 15.5px; }
.examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ex { text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); transition: border-color .2s, transform .25s var(--ease), box-shadow .25s; display: flex; flex-direction: column; gap: 4px; }
.ex:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: 0 14px 40px -24px rgba(22, 20, 15, .35); }
.ex .tag { font: 600 11px/1 var(--mono); color: var(--solar); letter-spacing: .04em; }
.ex .q { font-size: 14px; color: var(--ink); line-height: 1.5; }
.fine { color: var(--faint); font-size: 12.5px; margin: 18px 0 0; }

/* ───── messages */
.turn { margin-bottom: 30px; }
.msg-user { display: flex; justify-content: flex-end; margin-bottom: 18px; }
.msg-user .bubble { background: var(--ink); color: #FBF9F4; padding: 11px 16px; border-radius: 18px 18px 4px 18px; max-width: 82%; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.msg-ai { display: flex; flex-direction: column; gap: 8px; }
.steps { display: flex; flex-direction: column; gap: 6px; }
.step { border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, .6); font-size: 13px; overflow: hidden; }
.step > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 9px; padding: 8px 12px; color: var(--dim); }
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { color: var(--ink); }
.step .ico { width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; flex: none; background: rgba(22, 20, 15, .06); }
.step.run .ico { background: rgba(242, 84, 27, .12); color: var(--solar); }
.step.think .ico { background: rgba(59, 85, 230, .1); color: var(--ion); }
.step .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step .lbl code { font: 500 12px/1 var(--mono); color: var(--ink); }
.step .meta { font: 500 11.5px/1 var(--mono); color: var(--faint); white-space: nowrap; }
.step .meta .cost { color: var(--gold); }
.step .st { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); flex: none; }
.step.ok .st { background: var(--cyan); }
.step.err .st { background: var(--rose); }
.step.live .st { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.step .body { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; }
.step .body .k { font: 600 10.5px/1 var(--mono); color: var(--faint); letter-spacing: .06em; text-transform: uppercase; }
.step pre { margin: 0; max-height: 320px; overflow: auto; font: 12px/1.55 var(--mono); background: var(--code); border-radius: 8px; padding: 10px; white-space: pre-wrap; word-break: break-word; }
.step.think .body { color: var(--dim); white-space: pre-wrap; font-size: 13px; max-height: 320px; overflow: auto; }

.answer { font-size: 15.5px; line-height: 1.75; word-break: break-word; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p { margin: 0 0 .8em; }
.answer h1, .answer h2, .answer h3, .answer h4 { margin: 1.3em 0 .5em; line-height: 1.3; letter-spacing: -.02em; }
.answer h1 { font-size: 1.35em; } .answer h2 { font-size: 1.2em; } .answer h3 { font-size: 1.07em; } .answer h4 { font-size: 1em; }
.answer ul, .answer ol { margin: 0 0 .9em; padding-left: 1.4em; }
.answer li { margin: .2em 0; }
.answer a { color: var(--ion); text-decoration: none; border-bottom: 1px solid rgba(59, 85, 230, .3); word-break: break-all; }
.answer a:hover { border-color: var(--ion); }
.answer code { font: 13px/1.4 var(--mono); background: var(--code); padding: .1em .35em; border-radius: 5px; }
.answer pre { background: var(--code); border-radius: 10px; padding: 12px 14px; overflow: auto; }
.answer pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; }
.answer blockquote { margin: 0 0 .9em; padding: .2em 0 .2em 1em; border-left: 3px solid var(--line-2); color: var(--dim); }
.answer hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.answer strong { font-weight: 650; }
.tbl { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.answer table { border-collapse: collapse; width: 100%; font-size: 13.5px; line-height: 1.5; }
.answer th, .answer td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.answer th { font-weight: 600; background: rgba(22, 20, 15, .03); white-space: nowrap; }
.answer tr:last-child td { border-bottom: 0; }
.answer td.num, .answer th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cursor::after { content: ""; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -.12em; background: var(--solar); animation: pulse .9s infinite; border-radius: 1px; }

.foot { display: flex; align-items: center; gap: 4px; color: var(--faint); font-size: 12px; margin-top: 2px; }
.foot .cost { font-family: var(--mono); font-size: 11.5px; margin-right: auto; }
.foot button { padding: 5px 7px; border-radius: 8px; color: var(--faint); font-size: 13px; line-height: 1; }
.foot button:hover { background: rgba(22, 20, 15, .06); color: var(--ink); }
.foot button.on { color: var(--solar); }
.err-box { border: 1px solid rgba(224, 36, 90, .3); background: rgba(224, 36, 90, .06); color: var(--rose); padding: 10px 14px; border-radius: 12px; font-size: 13.5px; }
.err-box a { color: inherit; font-weight: 600; }
.working { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 13px; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--solar); animation: bounce 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ───── composer */
.composer { padding: 10px 24px max(16px, env(safe-area-inset-bottom)); }
.composer .box { max-width: var(--w); margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 18px; padding: 8px 8px 8px 16px; box-shadow: 0 18px 50px -30px rgba(22, 20, 15, .4); transition: border-color .2s, box-shadow .2s; }
.composer .box:focus-within { border-color: rgba(242, 84, 27, .55); box-shadow: 0 0 0 4px rgba(242, 84, 27, .1), 0 18px 50px -30px rgba(22, 20, 15, .4); }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: none; font: 15px/1.55 var(--sans); color: var(--ink); max-height: 220px; padding: 7px 0; }
.composer textarea::placeholder { color: var(--faint); }
.send, .stop { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.send { background: var(--solar); color: #fff; transition: opacity .2s, transform .2s var(--ease); }
.send:disabled { opacity: .3; cursor: default; }
.send:not(:disabled):hover { transform: translateY(-1px); }
.stop { background: var(--ink); }
.stop span { width: 11px; height: 11px; background: #fff; border-radius: 2px; }
.hint { max-width: var(--w); margin: 8px auto 0; text-align: center; color: var(--faint); font-size: 11.5px; }

/* ───── gate + toast */
.gate { position: fixed; inset: 0; background: rgba(245, 242, 234, .72); backdrop-filter: blur(8px); display: grid; place-items: center; z-index: 40; padding: 16px; }
.gate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 32px 28px 22px; max-width: 380px; width: 100%; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 40px 120px -40px rgba(22, 20, 15, .45); }
.gate-card h2 { margin: 6px 0 0; font-size: 21px; letter-spacing: -.02em; }
.gate-card p { margin: 0 0 8px; color: var(--dim); font-size: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 12px 22px; border-radius: 99px; font-weight: 600; text-decoration: none; font-size: 14.5px; width: 100%; }
.btn.primary { background: linear-gradient(135deg, #FF8A4C, var(--solar)); color: #fff; box-shadow: 0 14px 40px -14px rgba(242, 84, 27, .8); }
.toast { position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 99px; font-size: 13px; z-index: 50; }

/* ───── mobile */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 30; transform: translateX(-102%); transition: transform .35s var(--ease); }
  .side.open { transform: none; box-shadow: 30px 0 80px -30px rgba(22, 20, 15, .4); }
  .scrim { position: fixed; inset: 0; background: rgba(22, 20, 15, .25); z-index: 25; }
  .only-mobile { display: grid; }
  .top { padding: 10px 16px; }
  .thread { padding: 20px 16px 16px; }
  .composer { padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }
  .examples { grid-template-columns: 1fr; }
  .chip { display: none; }
  .msg-user .bubble { max-width: 92%; }
  .conv .del { opacity: 1; }
}
