:root, :root[data-theme="dark"] {
  --bg: #262624;
  --sidebar: #1f1e1d;
  --surface: #30302e;
  --surface-2: #3a3a37;
  --surface-3: #454541;
  --input: #30302e;
  --border: #3e3e3a;
  --border-strong: #4d4d48;
  --text: #faf9f5;
  --text-2: #c3c1b8;
  --text-3: #9b998f;
  --blue: #3a8fe8;
  --blue-track: #24364a;
  --amber: #e0a33a;
  --amber-bg: rgba(224, 163, 58, .14);
  --danger: #e5675c;
  --user-bubble: #141413;
  --scrim: rgba(0, 0, 0, .55);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --code-bg: #1a1a19;
  --send-bg: #faf9f5;
  --send-fg: #1f1e1d;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #faf9f5;
  --sidebar: #f3f1ea;
  --surface: #ffffff;
  --surface-2: #efede5;
  --surface-3: #e4e1d7;
  --input: #ffffff;
  --border: #e3e0d6;
  --border-strong: #d2cec2;
  --text: #141413;
  --text-2: #3d3d3a;
  --text-3: #73726c;
  --blue: #2477d6;
  --blue-track: #dbe7f6;
  --amber: #a86b00;
  --amber-bg: rgba(200, 130, 0, .12);
  --danger: #c4372c;
  --user-bubble: #efede5;
  --scrim: rgba(20, 20, 19, .35);
  --shadow: 0 10px 40px rgba(20, 20, 19, .14);
  --code-bg: #f5f4ef;
  --send-bg: #141413;
  --send-fg: #faf9f5;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
.serif { font-family: Fraunces, "Iowan Old Style", Georgia, serif; font-variation-settings: "SOFT" 50; }
.muted { color: var(--text-3); }
.hidden { display: none !important; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- brand ---------- */
.mark { display: inline-block; width: 1em; height: .82em; background: currentColor; -webkit-mask: url(logo-mark.svg) center/contain no-repeat; mask: url(logo-mark.svg) center/contain no-repeat; }
.wordmark { display: inline-flex; align-items: center; gap: .32em; font-family: Fraunces, Georgia, serif; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; }
.wordmark .mark { width: 1.15em; height: .95em; }

/* ---------- layout ---------- */
#app { height: 100%; display: flex; }
.sidebar {
  width: 288px; flex: none; background: var(--sidebar); display: flex; flex-direction: column;
  border-right: 1px solid var(--border); height: 100%; transition: margin-left .2s ease;
}
.app.sb-collapsed .sidebar { margin-left: -288px; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 10px 18px; }
.sb-head .wordmark { font-size: 22px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 10px; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.sb-search { margin: 4px 12px 8px; display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 12px; padding: 0 12px; height: 42px; color: var(--text-3); }
.sb-search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); }
.sb-nav { padding: 2px 8px; }
.sb-item { width: 100%; display: flex; align-items: center; gap: 14px; padding: 9px 12px; border-radius: 10px; color: var(--text); text-align: left; }
.sb-item:hover { background: var(--surface-2); }
.sb-section { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; color: var(--text-3); font-size: 13.5px; }
.sb-list { flex: 1; overflow-y: auto; padding: 0 8px 8px; }
.chat-link { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-radius: 10px; color: var(--text); cursor: pointer; position: relative; }
.chat-link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-link:hover { background: var(--surface-2); }
.chat-link.active { background: var(--surface-3); }
.chat-link .more { opacity: 0; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); }
.chat-link:hover .more, .chat-link.active .more { opacity: 1; }
.chat-link .more:hover { background: var(--surface-3); }
.chat-link .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.sb-empty { padding: 8px 20px; color: var(--text-3); font-size: 14px; }
.sb-foot { border-top: 1px solid var(--border); padding: 10px; }
.user-btn { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 12px; text-align: left; }
.user-btn:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: #6f5bd8; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 14px; }
.user-btn .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.user-btn .nm small { color: var(--text-3); font-size: 14px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; position: relative; }
.topbar { height: 56px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 10px; }
.topbar .title-btn { display: flex; align-items: center; gap: 6px; max-width: min(60vw, 520px); padding: 6px 10px; border-radius: 10px; color: var(--text-2); }
.topbar .title-btn:hover { background: var(--surface-2); color: var(--text); }
.topbar .title-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.usage-ring { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; }
.usage-ring:hover { background: var(--surface-2); }

.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.thread { max-width: 780px; margin: 0 auto; padding: 8px 20px 24px; }
.composer-wrap { flex: none; padding: 0 16px calc(10px + env(safe-area-inset-bottom)); }
.composer-inner { max-width: 780px; margin: 0 auto; }
.notice { display: flex; align-items: center; gap: 12px; justify-content: space-between; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px 10px 16px; margin-bottom: 8px; font-size: 14px; color: var(--text-2); }
.notice.warn { border-color: rgba(224, 163, 58, .4); }
.composer { background: var(--input); border: 1px solid var(--border); border-radius: 22px; padding: 12px 12px 10px 16px; box-shadow: 0 2px 14px rgba(0, 0, 0, .12); }
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea { width: 100%; resize: none; border: 0; outline: 0; background: none; max-height: 40vh; min-height: 26px; line-height: 1.5; padding: 2px 0; font-size: 16px; display: block; }
.composer textarea::placeholder { color: var(--text-3); }
.comp-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.comp-row .spacer { flex: 1; }
.model-btn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 10px; color: var(--text-2); font-size: 14px; max-width: 70%; }
.model-btn:hover { background: var(--surface-2); color: var(--text); }
.model-btn .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn .eff { color: var(--text-3); }
.uc-chip { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: var(--amber-bg); color: var(--amber); font-weight: 600; }
.send-btn { width: 36px; height: 36px; border-radius: 11px; background: var(--send-bg); color: var(--send-fg); display: grid; place-items: center; transition: opacity .15s; }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn svg { stroke-width: 2.2; }
.disclaimer { text-align: center; font-size: 12px; color: var(--text-3); padding-top: 8px; }

/* empty state */
.hero { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; text-align: center; }
.hero h1 { font-family: Fraunces, Georgia, serif; font-weight: 400; font-size: clamp(28px, 5vw, 40px); line-height: 1.2; margin: 14px 0 6px; letter-spacing: -.01em; }
.hero .mark { font-size: 44px; color: var(--text); }
.hero p { color: var(--text-3); margin: 0; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 26px; max-width: 640px; }
.suggest button { border: 1px solid var(--border); border-radius: 12px; padding: 8px 14px; color: var(--text-2); font-size: 14px; }
.suggest button:hover { background: var(--surface); color: var(--text); }

/* messages */
.msg { margin: 18px 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--user-bubble); border-radius: 18px; padding: 10px 16px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.assistant .body { overflow-wrap: anywhere; }
.msg.assistant .body > :first-child { margin-top: 0; }
.msg.assistant .body > :last-child { margin-bottom: 0; }
.body p { margin: 0 0 .85em; }
.body h1, .body h2, .body h3, .body h4 { font-family: Fraunces, Georgia, serif; font-weight: 500; line-height: 1.3; margin: 1.2em 0 .5em; }
.body h1 { font-size: 1.5em; } .body h2 { font-size: 1.3em; } .body h3 { font-size: 1.12em; }
.body ul, .body ol { padding-left: 1.4em; margin: 0 0 .85em; }
.body li { margin: .25em 0; }
.body blockquote { margin: 0 0 .85em; padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.body a { color: var(--blue); }
.body hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.body table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; max-width: 100%; }
.body th, .body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.body th { background: var(--surface); font-weight: 600; }
.body :not(pre) > code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .88em; background: var(--surface-2); padding: .12em .38em; border-radius: 6px; }
.codeblock { margin: 0 0 1em; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.codeblock .cb-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; font-size: 12.5px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.codeblock .cb-copy { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 7px; font-size: 12.5px; color: var(--text-3); }
.codeblock .cb-copy:hover { background: var(--surface-2); color: var(--text); }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.codeblock code { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13.2px; line-height: 1.55; background: none !important; padding: 0 !important; }
.think { margin-bottom: 10px; }
.think-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 14px; padding: 2px 0; }
.think-btn:hover { color: var(--text-2); }
.think-btn svg { transition: transform .15s; width: 16px; height: 16px; }
.think.open .think-btn svg { transform: rotate(90deg); }
.think-body { display: none; margin-top: 6px; padding: 2px 0 2px 14px; border-left: 2px solid var(--border); color: var(--text-3); font-size: 14px; white-space: pre-wrap; max-height: 320px; overflow-y: auto; }
.think.open .think-body { display: block; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 8px; color: var(--text-3); }
.msg-actions .icon-btn { width: 32px; height: 32px; color: var(--text-3); }
.msg-actions .icon-btn svg { width: 17px; height: 17px; }
.msg-actions .lbl { font-size: 12.5px; margin-left: 8px; }
.msg .err { color: var(--danger); font-size: 14px; margin-top: 6px; }
.pulse { display: inline-block; font-size: 22px; color: var(--text-2); animation: pulse 1.2s ease-in-out infinite; margin-top: 6px; }
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.92); } 50% { opacity: 1; transform: scale(1); } }

/* ---------- overlays ---------- */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 50; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: var(--surface); border-radius: 22px 22px 0 0;
  max-height: 88vh; display: flex; flex-direction: column; animation: up .22s cubic-bezier(.2, .8, .2, 1); box-shadow: var(--shadow);
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet .handle { width: 42px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 10px auto 4px; flex: none; }
.sheet .sheet-body { overflow-y: auto; padding: 6px 0 12px; }
.popover { position: fixed; z-index: 51; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); max-height: min(78vh, 680px); display: flex; flex-direction: column; animation: fade .12s ease; }
.popover .sheet-body { overflow-y: auto; padding: 6px 0; }
.row { width: 100%; display: flex; align-items: center; gap: 14px; padding: 11px 20px; text-align: left; min-height: 46px; }
.popover .row { padding: 9px 16px; min-height: 40px; }
button.row:hover, .row.clickable:hover { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .grow .sub { display: block; font-size: 12.5px; color: var(--text-3); }
.row .check { color: var(--blue); width: 22px; height: 22px; stroke-width: 2.2; }
.row.disabled { color: var(--text-3); }
.row .logo { width: 20px; height: 20px; flex: none; object-fit: contain; }
.row .logo-mono { width: 20px; height: 20px; flex: none; background: currentColor; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 2px 8px; border-radius: 7px; background: var(--surface-2); color: var(--text-3); margin-left: 8px; vertical-align: 1px; white-space: nowrap; }
.badge.warn { background: var(--amber-bg); color: var(--amber); }
.badge svg { width: 13px; height: 13px; }
.sep { height: 1px; background: var(--border); margin: 6px 20px; }
.sec-title { padding: 12px 20px 4px; color: var(--text-3); font-size: 14px; }
.popover .sec-title { padding: 10px 16px 2px; }
.filter { margin: 6px 16px 4px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 10px; padding: 0 10px; height: 36px; color: var(--text-3); }
.filter input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font-size: 14px; }
.menu-email { padding: 8px 20px 10px; color: var(--text-3); font-size: 14px; }
.toggle { width: 46px; height: 28px; border-radius: 14px; background: var(--surface-3); position: relative; flex: none; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.toggle.on { background: var(--blue); }
.toggle.on::after { transform: translateX(18px); }

.modal { position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(680px, calc(100vw - 32px)); max-height: min(86vh, 760px); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: fade .15s ease; }
.modal.wide { width: min(1080px, calc(100vw - 32px)); }
.modal.narrow { width: min(440px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 8px 24px; }
.modal-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.modal-body { overflow-y: auto; padding: 8px 24px 24px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 6px 0 14px; scrollbar-width: none; }
.tab { padding: 8px 14px; border-radius: 10px; white-space: nowrap; color: var(--text-2); font-size: 15px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); }
.field { margin: 0 0 16px; }
.field label { display: block; font-size: 13.5px; color: var(--text-3); margin-bottom: 6px; }
.inp { width: 100%; height: 46px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); padding: 0 14px; outline: 0; font-size: 16px; }
.inp:focus { border-color: var(--blue); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: 12px; font-weight: 500; background: var(--surface-2); color: var(--text); }
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--send-bg); color: var(--send-fg); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.err-text { color: var(--danger); font-size: 14px; min-height: 20px; margin: 6px 0 0; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-2); }
.h-lg { font-size: 18px; font-weight: 600; margin: 4px 0 14px; }
.u-block { padding: 14px 0 16px; }
.u-block .u-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.u-block .u-title { font-size: 17px; }
.u-block .u-reset { color: var(--text-3); font-size: 14px; margin: 2px 0 12px; }
.u-bar-row { display: flex; align-items: center; gap: 16px; }
.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--blue-track); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--blue); border-radius: 3px; transition: width .3s; }
.bar.full > i { background: var(--danger); }
.u-pct { color: var(--text-2); font-size: 14.5px; min-width: 74px; text-align: right; }
.mini-usage .ml { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 20px; }
.mini-usage .ml + .bar { margin: 8px 20px 18px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { padding: 7px 14px; border-radius: 9px; color: var(--text-2); font-size: 14px; }
.seg button.on { background: var(--surface-2); color: var(--text); }

/* plans */
.plans { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.plan { border: 1px solid var(--border); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.plan.current { border-color: var(--blue); }
.plan.hl { border-color: var(--border-strong); background: var(--surface-2); }
.plan h3 { margin: 0; font-family: Fraunces, Georgia, serif; font-weight: 500; font-size: 24px; }
.plan .price { font-size: 30px; font-weight: 600; }
.plan .price small { font-size: 14px; color: var(--text-3); font-weight: 400; }
.plan ul { list-style: none; padding: 0; margin: 4px 0 8px; flex: 1; font-size: 14px; color: var(--text-2); }
.plan li { display: flex; gap: 8px; padding: 4px 0; }
.plan li svg { width: 16px; height: 16px; color: var(--blue); margin-top: 3px; stroke-width: 2.2; }
.testpay { display: flex; gap: 10px; align-items: flex-start; background: var(--amber-bg); color: var(--amber); border-radius: 12px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 16px; }
.card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--border); margin-bottom: 16px; }

/* auth */
.auth { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.auth-card { width: 100%; max-width: 400px; text-align: center; }
.auth-card .wordmark { font-size: 40px; }
.auth-card p.lead { color: var(--text-3); margin: 10px 0 28px; }
.auth-card .seg { margin-bottom: 18px; }
.auth-card form { text-align: left; }
.keybox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 10px 10px 10px 14px; font-family: "JetBrains Mono", monospace; font-size: 14px; word-break: break-all; margin: 12px 0 16px; }
.keybox span { flex: 1; }
.lang-switch { position: fixed; top: 14px; right: 14px; }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 12px; z-index: 80; font-size: 14px; animation: fade .15s ease; max-width: calc(100vw - 32px); }

/* ---------- mobile ---------- */
.only-mobile { display: none; }
@media (max-width: 820px) {
  .only-mobile { display: inline-grid; }
  .only-desktop { display: none !important; }
  .sidebar { position: fixed; inset: 0; width: 100%; z-index: 40; margin-left: 0 !important; transform: translateX(-100%); transition: transform .22s ease; border-right: 0; padding-top: env(safe-area-inset-top); }
  .app.sb-open .sidebar { transform: none; }
  .sb-head .wordmark { font-size: 26px; }
  .sb-search { height: 48px; margin: 6px 16px 10px; border-radius: 14px; font-size: 17px; }
  .sb-item { font-size: 17px; padding: 12px 16px; }
  .chat-link { font-size: 17px; padding: 12px 16px; }
  .chat-link .more { opacity: 1; }
  .thread { padding: 8px 16px 20px; }
  .composer-wrap { padding: 0 10px calc(8px + env(safe-area-inset-bottom)); }
  .plans { grid-template-columns: 1fr 1fr; }
  .modal { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 92vh; border-radius: 22px 22px 0 0; border: 0; animation: up .22s cubic-bezier(.2, .8, .2, 1); padding-bottom: env(safe-area-inset-bottom); }
  .modal.wide, .modal.narrow { width: 100%; }
  .modal-body { padding: 8px 18px 22px; }
  .modal-head { padding: 16px 12px 6px 18px; }
  .row { font-size: 17px; }
}
@media (max-width: 520px) {
  .plans { grid-template-columns: 1fr; }
  .card-row { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 821px) { .app:not(.sb-collapsed) #sb-open-btn { display: none; } }

/* ---------- attachments ---------- */
.attach-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); margin-left: -4px; }
.composer.drop { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-track); }
.att-row { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 10px; margin-left: -4px; scrollbar-width: thin; }
.chip { position: relative; flex: none; display: flex; align-items: center; gap: 10px; height: 64px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); padding: 0 34px 0 10px; max-width: 240px; }
.chip img { width: 64px; height: 64px; object-fit: cover; border-radius: 11px; margin-left: -10px; margin-right: -24px; }
.chip.uploading img { opacity: .5; }
.chip-ico { width: 38px; height: 38px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--text-2); }
.chip-name { min-width: 0; display: flex; flex-direction: column; font-size: 13px; line-height: 1.3; }
.chip-name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-name small { color: var(--text-3); }
.chip-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); color: var(--text); display: grid; place-items: center; }
.chip-x svg { width: 13px; height: 13px; stroke-width: 2.4; }
.spin { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 2.5px solid var(--text-3); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
.chip:not(:has(img)) .spin { left: auto; right: 30px; }
@keyframes spin { to { transform: rotate(360deg); } }
.user-col { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 85%; }
.user-col .bubble { max-width: 100%; }
.msg-atts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.att-img img { display: block; max-width: 220px; max-height: 220px; border-radius: 14px; border: 1px solid var(--border); object-fit: cover; }
.att-file { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; max-width: 280px; }
.att-file svg { color: var(--text-2); flex: none; }
.att-file span { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; line-height: 1.3; }
.att-file b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file small { color: var(--text-3); }
.filecard { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); margin: 0 0 1em; overflow: hidden; }
.fc-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; }
.fc-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--text-2); }
.fc-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.fc-name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-name small { color: var(--text-3); font-size: 12.5px; }
.fc-head .btn svg { width: 16px; height: 16px; }
.fc-code { display: none; margin: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; }
.filecard.open .fc-code { display: block; }
.fc-code pre { max-height: 420px; }
.cb-head > span:last-child { display: inline-flex; gap: 2px; }
@media (max-width: 520px) { .fc-head [data-toggle-code] span { display: none; } .att-img img { max-width: 160px; max-height: 160px; } }

/* compact profile menu */
.menu-profile { display: flex; align-items: center; gap: 12px; padding: 8px 18px 10px; }
.menu-profile .avatar { width: 38px; height: 38px; font-size: 15px; }
.mp-txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.mp-txt b { font-weight: 600; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-txt small { color: var(--text-3); font-size: 13px; }
.sheet-body.compact .row { font-size: 14.5px; min-height: 38px; padding: 7px 18px; gap: 12px; }
.sheet-body.compact .row svg.i { width: 18px; height: 18px; }
.sheet-body.compact .sep { margin: 4px 18px; }

/* effort button + slider popover */
.effort-btn { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 10px; color: var(--text-2); font-size: 14px; white-space: nowrap; }
.effort-btn:hover { background: var(--surface-2); color: var(--text); }
.eff-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.eff-bars i { width: 3px; border-radius: 1.5px; background: var(--surface-3); }
.eff-bars i:nth-child(1) { height: 5px; } .eff-bars i:nth-child(2) { height: 7px; } .eff-bars i:nth-child(3) { height: 9px; } .eff-bars i:nth-child(4) { height: 11px; } .eff-bars i:nth-child(5) { height: 14px; }
.eff-bars i.on { background: var(--text-2); }
.effort-btn:hover .eff-bars i.on { background: var(--text); }
.eff-pop { padding: 8px 16px 4px; }
.eff-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.eff-title { font-size: 13px; color: var(--text-3); }
.eff-val { font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; }
.eff-val .badge { font-weight: 400; }
.eff-desc { font-size: 13px; color: var(--text-3); margin: 2px 0 14px; min-height: 18px; }
.eff-slider { position: relative; height: 28px; margin: 0 6px; }
.eff-track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 2px; background: var(--surface-3); }
.eff-track > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--blue); transition: width .15s; }
.eff-dot { position: absolute; top: -3px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--surface); }
.eff-dot.locked { background: var(--border); }
.eff-slider input[type=range] { position: absolute; inset: 0; width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; touch-action: none; }
.eff-slider input[type=range]::-webkit-slider-runnable-track { height: 28px; background: transparent; }
.eff-slider input[type=range]::-moz-range-track { height: 28px; background: transparent; }
.eff-slider input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); border: 0; }
.eff-slider input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); border: 0; }
.eff-labels { display: flex; justify-content: space-between; margin: 6px -4px 0; }
.eff-labels button { flex: 1; font-size: 12px; color: var(--text-3); padding: 4px 0; display: inline-flex; align-items: center; justify-content: center; gap: 2px; }
.eff-labels button:first-child { justify-content: flex-start; } .eff-labels button:last-child { justify-content: flex-end; }
.eff-labels button.on { color: var(--text); font-weight: 600; }
.eff-labels button.locked { opacity: .6; }
.eff-labels svg { width: 11px; height: 11px; }
.eff-lock { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 12px; padding: 8px 10px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); font-size: 13px; }
.eff-pop .eff-uc { padding: 8px 0 !important; min-height: 0; font-size: 15px; }
@media (max-width: 420px) { .model-btn { max-width: 52%; } .effort-btn { padding: 6px 6px; } }

.eff-labels { position: relative; height: 26px; margin: 6px 6px 0; display: block; }
.eff-labels button { position: absolute; top: 0; transform: translateX(-50%); flex: none; white-space: nowrap; }
.eff-labels button:first-child { transform: none; margin-left: -6px; }
.eff-labels button:last-child { transform: translateX(-100%); margin-left: 6px; }
.eff-lock .btn { flex: none; white-space: nowrap; }

/* compact effort popover v2 + separate Ultracode button */
.eff-pop { padding: 10px 14px 8px; }
.eff-pop .eff-val { display: block; text-align: center; font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.uc-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 10px; color: var(--text-3); font-size: 13.5px; border: 1px solid transparent; }
.uc-btn svg { width: 17px; height: 17px; }
.uc-btn:hover { background: var(--surface-2); color: var(--text); }
.uc-btn.on { color: var(--amber); background: var(--amber-bg); border-color: rgba(224, 163, 58, .35); }
@media (max-width: 520px) { .uc-btn span { display: none; } .uc-btn { padding: 0 8px; } }

/* effort slider v3: wide pill track instead of a thin line */
.eff-pop .eff-slider { height: 22px; margin: 4px 0 6px; }
.eff-pop .eff-track { top: 0; height: 22px; border-radius: 11px; background: var(--surface-3); overflow: hidden; }
.eff-pop .eff-track > i { border-radius: 11px; background: var(--text); }
.eff-pop .eff-dot { top: 8px; width: 6px; height: 6px; margin-left: -3px; border: 0; background: var(--text-3); z-index: 1; }
.eff-pop .eff-dot.in { background: var(--bg); opacity: .45; }
.eff-pop .eff-dot.locked { background: var(--border-strong); }
.eff-pop .eff-slider input[type=range]::-webkit-slider-runnable-track { height: 22px; }
.eff-pop .eff-slider input[type=range]::-moz-range-track { height: 22px; }
.eff-pop .eff-slider input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: 0; background: var(--text); border: 3px solid var(--surface-3); box-shadow: 0 1px 4px rgba(0, 0, 0, .35); box-sizing: border-box; }
.eff-pop .eff-slider input[type=range]::-moz-range-thumb { width: 22px; height: 22px; background: var(--text); border: 3px solid var(--surface-3); box-shadow: 0 1px 4px rgba(0, 0, 0, .35); box-sizing: border-box; }

/* Ultracode stop on the effort slider */
.eff-pop.uc-on .eff-val, .sheet-body.uc-on .eff-val { color: var(--amber); }
.sheet-body.uc-on .eff-track > i { background: var(--amber); }
.sheet-body.uc-on .eff-slider input[type=range]::-webkit-slider-thumb { background: var(--amber); }
.sheet-body.uc-on .eff-slider input[type=range]::-moz-range-thumb { background: var(--amber); }
.effort-btn.uc { color: var(--amber); }
.effort-btn.uc .eff-bars i.on { background: var(--amber); }

/* ---------- Ultracode: purple effect ---------- */
:root { --uc1: #7c5cff; --uc2: #c27bff; --uc3: #5b8cff; --uc-glow: rgba(140, 92, 255, .55); }
@property --uc-ang { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes uc-shimmer { to { background-position: 200% 0; } }
@keyframes uc-spin { to { --uc-ang: 360deg; } }
@keyframes uc-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(140, 92, 255, .0), 0 0 14px 2px var(--uc-glow); } 50% { box-shadow: 0 0 0 4px rgba(140, 92, 255, .18), 0 0 22px 6px var(--uc-glow); } }
@keyframes uc-spark { 0% { transform: translate(-50%, -50%) scale(var(--s)); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0); opacity: 0; } }

/* label on top of the popover */
.sheet-body.uc-on .eff-val {
  color: transparent; background: linear-gradient(90deg, var(--uc3), var(--uc2), var(--uc1), var(--uc2), var(--uc3)); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; animation: uc-shimmer 2.4s linear infinite; letter-spacing: .02em;
}
/* track fill + thumb */
.sheet-body.uc-on .eff-track > i { background: linear-gradient(90deg, var(--uc3), var(--uc1), var(--uc2), var(--uc1), var(--uc3)); background-size: 200% 100%; animation: uc-shimmer 2.2s linear infinite; box-shadow: 0 0 16px var(--uc-glow); }
.sheet-body.uc-on .eff-track { overflow: visible; box-shadow: 0 0 18px rgba(140, 92, 255, .35); }
.sheet-body.uc-on .eff-dot.in { background: var(--bg); opacity: .5; }
.sheet-body.uc-on .eff-slider input[type=range]::-webkit-slider-thumb { background: #fff; border-color: var(--uc1); animation: uc-pulse 1.8s ease-in-out infinite; }
.sheet-body.uc-on .eff-slider input[type=range]::-moz-range-thumb { background: #fff; border-color: var(--uc1); box-shadow: 0 0 18px 4px var(--uc-glow); }
.popover:has(.uc-on) { border-color: rgba(140, 92, 255, .45); box-shadow: var(--shadow), 0 0 40px rgba(124, 92, 255, .22); transition: box-shadow .3s, border-color .3s; }

/* effort button in the composer */
.effort-btn.uc { color: transparent; }
.effort-btn.uc > span:last-child { background: linear-gradient(90deg, var(--uc3), var(--uc2), var(--uc1), var(--uc2), var(--uc3)); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; animation: uc-shimmer 2.4s linear infinite; font-weight: 600; }
.effort-btn.uc .eff-bars i.on { background: linear-gradient(180deg, var(--uc2), var(--uc1)); box-shadow: 0 0 6px var(--uc-glow); }

/* sparkle burst */
.uc-spark { position: fixed; z-index: 90; width: 7px; height: 7px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #fff 0 25%, var(--uc2) 45%, rgba(124, 92, 255, 0) 70%);
  animation: uc-spark .8s cubic-bezier(.2, .7, .3, 1) forwards; }
@media (prefers-reduced-motion: reduce) {
  .composer.uc, .effort-btn.uc > span:last-child, .sheet-body.uc-on .eff-val, .sheet-body.uc-on .eff-track > i, .sheet-body.uc-on .eff-slider input[type=range]::-webkit-slider-thumb { animation: none; }
}

.uc-spark { width: 11px; height: 11px; background: radial-gradient(circle, #fff 0 22%, #d9b8ff 38%, var(--uc1) 55%, rgba(124, 92, 255, 0) 72%); box-shadow: 0 0 10px rgba(170, 120, 255, .7); animation-duration: .95s; }

/* Ultracode bar v2: no full glow; purple wash fills right→left, shards drift right→left */
.sheet-body.uc-on .eff-track { overflow: hidden; box-shadow: none; }
.sheet-body.uc-on .eff-track > i { box-shadow: none; animation: none; background: var(--text); }
.eff-pop .uc-wash { position: absolute; inset: 0; border-radius: 11px; background: linear-gradient(90deg, var(--uc3), var(--uc1) 55%, var(--uc2)); transform: scaleX(0); transform-origin: right center; transition: transform .9s cubic-bezier(.65, 0, .35, 1); pointer-events: none; }
.sheet-body.uc-on .uc-wash { transform: scaleX(1); }
.eff-pop .uc-shards { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s ease .55s; }
.sheet-body.uc-on .uc-shards { opacity: 1; }
.uc-shards b { position: absolute; left: 100%; border-radius: 1px; background: linear-gradient(90deg, rgba(255, 255, 255, .95), rgba(216, 190, 255, .4));
  clip-path: polygon(0 50%, 30% 0, 100% 20%, 80% 100%, 15% 85%); animation-name: uc-shard; animation-timing-function: linear; animation-iteration-count: infinite; }
@keyframes uc-shard {
  0% { transform: translateX(0) rotate(var(--rot)); }
  100% { transform: translateX(-260px) rotate(calc(var(--rot) + 140deg)); }
}
.sheet-body.uc-on .eff-dot { z-index: 2; }
.popover:has(.uc-on) { box-shadow: var(--shadow); }
@media (prefers-reduced-motion: reduce) { .uc-shards b { animation: none; } .eff-pop .uc-wash { transition: none; } }

/* Ultracode bar v3: no purple wash; dense purple shards only over the last three stops */
.eff-pop .uc-wash { display: none; }
.eff-pop .uc-shards { left: calc(11px + .6 * (100% - 22px)); right: 0; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000); mask-image: linear-gradient(90deg, transparent, #000 22%, #000); transition: opacity .6s ease; }
.uc-shards b { background: var(--c); box-shadow: 0 0 4px var(--c); animation-name: uc-shard2; }
@keyframes uc-shard2 {
  0% { transform: translateX(0) rotate(var(--rot)); }
  100% { transform: translateX(-130px) rotate(calc(var(--rot) + 160deg)); }
}
.comp-row .effort-btn { margin-left: -10px; }

/* shards: purple on Ultracode, smaller and fewer blue ones on Max */
.uc-shards b { --c: hsl(calc(var(--base-h, 255) + var(--dh, 0)) 95% var(--l, 65%)); }
@keyframes uc-shard2 {
  0% { transform: translateX(0) rotate(var(--rot)) scale(var(--sc, 1)); }
  100% { transform: translateX(-130px) rotate(calc(var(--rot) + 160deg)) scale(var(--sc, 1)); }
}
.sheet-body.max-on .uc-shards { opacity: 1; --base-h: 200; --sc: .75;
  left: calc(11px + .4 * (100% - 22px)); right: calc(.2 * (100% - 22px)); }
.sheet-body.max-on .uc-shards b:nth-child(3n) { display: none; }
.sheet-body.max-on .eff-dot { z-index: 2; }

/* Max: blue shimmering label on the composer button */
.effort-btn.max > span:last-child { color: transparent; background: linear-gradient(90deg, #3b82f6, #60c5ff, #2f6bff, #60c5ff, #3b82f6); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; animation: uc-shimmer 2.4s linear infinite; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .effort-btn.max > span:last-child { animation: none; } }

/* thinking row (dots · headline · timer · chevron) */
.think-row { display: inline-flex; align-items: center; gap: 12px; max-width: 100%; padding: 4px 0; color: var(--text-3); font-size: 15px; text-align: left; }
.think-row:hover { color: var(--text-2); }
.think-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.think-time { flex: none; font-variant-numeric: tabular-nums; }
.think-chev { width: 16px !important; height: 16px !important; flex: none; transition: transform .15s; }
.think.open .think-chev { transform: rotate(90deg); }
.think-dots { position: relative; width: 18px; height: 18px; flex: none; }
.think-dots i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #e3825f; }
.think-dots i:nth-child(1) { left: 1px; top: 12px; } .think-dots i:nth-child(2) { left: 6.5px; top: 6.5px; } .think-dots i:nth-child(3) { left: 12px; top: 1px; }
.think-dots.anim i { animation: think-dot 1.2s ease-in-out infinite; }
.think-dots.anim i:nth-child(2) { animation-delay: .2s; } .think-dots.anim i:nth-child(3) { animation-delay: .4s; }
@keyframes think-dot { 0%, 100% { opacity: .35; transform: scale(.8); } 40% { opacity: 1; transform: scale(1.15); } }
.think-dots:not(.anim) i { opacity: .7; }
.think.open .think-body { margin-left: 8px; }

/* payment processing + success */
.pay-proc { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 34px 0 30px; }
.pay-spinner { width: 54px; height: 54px; border-radius: 50%; border: 4px solid var(--surface-3); border-top-color: var(--text); animation: spin .9s linear infinite; margin-bottom: 20px; }
.pay-proc-t { font-size: 18px; font-weight: 600; }
.pay-proc-s { font-size: 14px; margin-top: 4px; }
.pay-ok { text-align: center; padding: 4px 0 4px; }
.pay-ok h3 { margin: 14px 0 6px; font-size: 22px; font-family: Fraunces, Georgia, serif; font-weight: 500; }
.pay-ok p { margin: 0 0 22px; line-height: 1.6; }
.pay-check { width: 76px; height: 76px; margin: 6px auto 0; border-radius: 50%; background: rgba(52, 199, 89, .14); display: grid; place-items: center; animation: pay-pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.pay-check svg { width: 56px; height: 56px; fill: none; stroke: #34c759; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.pay-check circle { stroke-dasharray: 151; stroke-dashoffset: 151; animation: pay-draw .6s ease-out .1s forwards; }
.pay-check path { stroke-dasharray: 36; stroke-dashoffset: 36; animation: pay-draw .35s ease-out .55s forwards; }
@keyframes pay-draw { to { stroke-dashoffset: 0; } }
@keyframes pay-pop { from { transform: scale(.6); opacity: 0; } }

.think-logo { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; font-size: 20px; color: var(--text-2); }
.think-logo.anim { animation: pulse 1.2s ease-in-out infinite; color: var(--text); }

/* mono provider logos (OpenAI, xAI, Xiaomi) everywhere, not only in menu rows */
.logo-mono { display: inline-block; flex: none; width: 18px; height: 18px; background: currentColor; }
.model-btn .logo-mono { color: var(--text); }

/* ---------- desktop icon rail ---------- */
.rail { width: 60px; flex: none; height: 100%; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0; }
.app:not(.sb-collapsed) .rail { display: none !important; }
.rail-btn { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--text-2); }
.rail-btn:hover { background: var(--surface-2); color: var(--text); }
.rail-btn:first-child { margin-bottom: 8px; }
.rail-sp { flex: 1; }
.rail-avatar { padding: 4px; border-radius: 50%; margin-top: 6px; }
.rail-avatar:hover { background: var(--surface-2); }
.rail-avatar .avatar { width: 32px; height: 32px; font-size: 13px; }
@media (min-width: 821px) {
  #sb-open-btn { display: none !important; }
  .app.sb-collapsed .sidebar { margin-left: -288px; }
}
.rail { position: relative; z-index: 3; }
@media (min-width: 821px) { .sidebar { transition: margin-left .2s ease, visibility .2s; } .app.sb-collapsed .sidebar { visibility: hidden; } }

/* settings: tabs on the left on desktop */
.tab svg.i { display: none; }
@media (min-width: 821px) {
  .modal.settings-modal { width: min(900px, calc(100vw - 48px)); height: min(640px, 86vh); }
  .settings-modal .modal-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding-bottom: 0; }
  .settings-wrap { display: grid; grid-template-columns: 210px 1fr; gap: 28px; flex: 1; min-height: 0; }
  .settings-wrap .tabs { flex-direction: column; gap: 2px; padding: 4px 0 20px; overflow: visible; }
  .settings-wrap .tab { display: flex; align-items: center; gap: 12px; text-align: left; padding: 9px 12px; font-size: 15px; }
  .settings-wrap .tab svg.i { display: block; width: 18px; height: 18px; }
  .settings-pane { overflow-y: auto; padding: 2px 4px 24px 0; min-width: 0; }
}

.comp-ring { width: 34px; height: 34px; border-radius: 50%; }

/* usage pie next to send */
.comp-ring { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.comp-ring:hover { background: var(--surface-2); }
.pie { width: 15px; height: 15px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--text-3);
  background: conic-gradient(var(--text-2) calc(var(--p) * 1%), transparent 0); transition: background .3s; }
.comp-ring:hover .pie { box-shadow: inset 0 0 0 1.5px var(--text-2); }
.pie.high { background: conic-gradient(var(--amber) calc(var(--p) * 1%), transparent 0); box-shadow: inset 0 0 0 1.5px var(--amber); }
.pie.full { background: var(--danger); box-shadow: inset 0 0 0 1.5px var(--danger); }

.comp-ring { width: 34px; height: 34px; border-radius: 50%; }

/* compact usage popover */
.uq { padding: 4px 14px 6px; font-size: 13px; }
.uq-head { display: flex; justify-content: space-between; align-items: center; color: var(--text-3); margin-bottom: 8px; }
.uq-head button { color: var(--text-2); font-size: 12.5px; }
.uq-head button:hover { color: var(--text); }
.uq-row + .uq-row { margin-top: 10px; }
.uq-top { display: flex; justify-content: space-between; gap: 8px; }
.uq-top b { font-weight: 600; }
.uq .bar { height: 4px; margin: 5px 0 3px; }
.uq-reset { color: var(--text-3); font-size: 11.5px; }

.gen-row { margin-top: 4px; cursor: default; }
.gen-row:hover { color: var(--text-3); }

/* user button v2: compact, plan as a pill */
.sb-foot { padding: 8px; }
.user-btn { gap: 10px; padding: 6px 8px; border-radius: 10px; }
.ub-ava { width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff; background: linear-gradient(135deg, #6f5bd8, #3d8be8); }
.ub-txt { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.ub-txt b { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-pill { flex: none; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; border-radius: 5px; background: var(--surface-2); color: var(--text-3); }
.plan-pill.p-pro { background: rgba(58, 143, 232, .16); color: #6aaef5; }
.plan-pill.p-max { background: rgba(140, 92, 255, .18); color: #b49bff; }
.plan-pill.p-ultra { background: linear-gradient(90deg, rgba(255, 180, 60, .22), rgba(255, 110, 160, .22)); color: #ffc27a; }
:root[data-theme="light"] .plan-pill.p-pro { color: #2a6fc4; }
:root[data-theme="light"] .plan-pill.p-max { color: #6a46d8; }
:root[data-theme="light"] .plan-pill.p-ultra { color: #b86a00; }
.ub-more { width: 18px !important; height: 18px !important; color: var(--text-3); }
@media (max-width: 820px) { .ub-txt b { font-size: 16px; } .ub-ava { width: 32px; height: 32px; } }

/* user button v3: name on top, plan below */
.ub-ava { width: 32px; height: 32px; border-radius: 50%; background: #6f5bd8; font-size: 13.5px; }
.ub-txt { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.25; }
.ub-txt b { font-size: 14px; font-weight: 500; max-width: 100%; }
.ub-txt small { font-size: 12px; color: var(--text-3); }
@media (max-width: 820px) { .ub-txt b { font-size: 15px; } .ub-txt small { font-size: 13px; } .ub-ava { width: 34px; height: 34px; } }

@media (max-width: 820px) { .sidebar { height: 100dvh; } .sb-foot { padding: 10px 12px calc(22px + env(safe-area-inset-bottom)); } }

@media (max-width: 820px) { .sb-foot { border-top: 0; } .sb-foot .user-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 10px 12px; } }

/* ---------- phone composer like the Claude app ---------- */
.comp-meta { display: none; }
@media (max-width: 820px) {
  .composer.m-pill { border-radius: 26px; padding: 6px 6px 6px 8px; }
  .composer.m-pill .att-row { padding: 6px 4px 8px; margin-left: 0; }
  .composer.m-pill .comp-row { margin-top: 0; align-items: flex-end; gap: 6px; }
  .composer.m-pill .comp-row .spacer { display: none; }
  .composer.m-pill textarea { flex: 1; min-width: 0; width: auto; padding: 9px 2px; font-size: 16.5px; line-height: 1.4; min-height: 0; }
  .composer.m-pill .attach-btn { border: 0; width: 40px; height: 40px; margin: 0; color: var(--text-2); }
  .composer.m-pill .attach-btn svg { width: 24px; height: 24px; }
  .composer.m-pill .send-btn { width: 40px; height: 40px; border-radius: 50%; flex: none; }
  .composer.m-pill.is-empty .send-btn { display: none; }
  .comp-meta { display: flex; justify-content: flex-end; align-items: center; gap: 2px; padding: 8px 4px 2px; }
  .comp-meta .model-btn { max-width: 55%; font-size: 15px; color: var(--text); padding: 6px 6px; }
  .comp-meta .model-btn .logo, .comp-meta .model-btn .logo-mono, .comp-meta .model-btn svg.i { display: none; }
  .comp-meta .effort-btn { margin-left: 0 !important; font-size: 15px; color: var(--text-3); padding: 6px 8px; }
  .comp-meta .comp-ring { width: 34px; height: 34px; }
  .composer-wrap .disclaimer { display: none; }
}

@media (hover: none) { .comp-meta .model-btn:hover, .comp-meta .effort-btn:hover, .comp-meta .comp-ring:hover { background: none; } }

/* compact model picker on phones */
@media (max-width: 820px) {
  .sheet:has(.models-sheet) { max-height: 62vh; }
  .models-sheet { padding: 2px 0 8px; }
  .models-sheet .row { font-size: 15px; min-height: 0; padding: 9px 18px; gap: 12px; }
  .models-sheet .row .logo, .models-sheet .row .logo-mono { width: 18px; height: 18px; }
  .models-sheet .row .check { width: 18px; height: 18px; }
  .models-sheet .row .grow .sub { font-size: 11.5px; }
  .models-sheet .badge { font-size: 11px; padding: 1px 6px; }
  .models-sheet .sec-title { padding: 8px 18px 2px; font-size: 12.5px; }
  .models-sheet .sep { margin: 4px 18px; }
  .models-sheet .filter { margin: 4px 14px; height: 34px; }
}

/* greeting line */
.hero-title { display: flex; flex-direction: column; align-items: center; }
/* ---------- desktop: empty chat centred (greeting + box in the middle) ---------- */
@media (min-width: 821px) {
  .main.is-empty .scroll { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
  .main.is-empty #thread-wrap { min-height: 0 !important; }
  .main.is-empty .hero { min-height: 0; padding: 0 20px 26px; }
  .main.is-empty .hero-title { flex-direction: row; gap: 14px; }
  .main.is-empty .hero-title .mark { font-size: 34px; }
  .main.is-empty .hero-title h1 { margin: 0; font-size: clamp(28px, 3vw, 36px); }
  .main.is-empty .hero p, .main.is-empty .suggest { display: none; }
  .main.is-empty .composer-wrap { flex: 1 1 0; }
  .main.is-empty .composer textarea { min-height: 52px; }
  .main.is-empty .disclaimer { display: none; }
  .main.is-empty .comp-meta { display: flex; justify-content: flex-end; align-items: center; gap: 2px; padding: 8px 6px 0; }
  .main.is-empty .comp-meta .effort-btn { margin-left: 0; }
}

/* ---------- dark palette v2: darker neutral (#1b1b1b) ---------- */
:root, :root[data-theme="dark"] {
  --bg: #1b1b1b;
  --sidebar: #141414;
  --surface: #242424;
  --surface-2: #2d2d2d;
  --surface-3: #3a3a3a;
  --input: #242424;
  --border: #2f2f2f;
  --border-strong: #3e3e3e;
  --text: #f4f4f4;
  --text-2: #c6c6c6;
  --text-3: #9a9a9a;
  --user-bubble: #2a2a2a;
  --code-bg: #131313;
  --send-bg: #f4f4f4;
  --send-fg: #1b1b1b;
}
:root[data-theme="light"] { --user-bubble: #efede5; }

/* compact model picker on desktop */
@media (min-width: 821px) {
  .popover:has(.models-sheet) { max-height: min(440px, 70vh) !important; border-radius: 14px; }
  .popover .models-sheet { padding: 4px 0; }
  .popover .models-sheet .row { font-size: 13.5px; min-height: 0; padding: 6px 12px; gap: 10px; }
  .popover .models-sheet .row .logo, .popover .models-sheet .row .logo-mono { width: 16px; height: 16px; }
  .popover .models-sheet .row .check { width: 16px; height: 16px; }
  .popover .models-sheet .row .grow .sub { font-size: 11px; }
  .popover .models-sheet .badge { font-size: 10.5px; padding: 1px 6px; margin-left: 6px; }
  .popover .models-sheet .sec-title { padding: 8px 12px 2px; font-size: 12px; }
  .popover .models-sheet .sep { margin: 4px 12px; }
  .popover .models-sheet .filter { margin: 4px 10px; height: 30px; font-size: 13px; }
}

/* smaller profile menu on desktop */
@media (min-width: 821px) {
  .popover .sheet-body.compact { padding: 4px 0; }
  .popover .sheet-body.compact .menu-profile { padding: 6px 12px 8px; gap: 10px; }
  .popover .sheet-body.compact .menu-profile .avatar { width: 30px; height: 30px; font-size: 13px; }
  .popover .sheet-body.compact .mp-txt b { font-size: 13.5px; }
  .popover .sheet-body.compact .mp-txt small { font-size: 11.5px; }
  .popover .sheet-body.compact .row { font-size: 13px; padding: 5px 12px; min-height: 0; gap: 10px; }
  .popover .sheet-body.compact .row svg.i { width: 16px; height: 16px; }
  .popover .sheet-body.compact .row .muted { font-size: 12px; }
  .popover .sheet-body.compact .sep { margin: 3px 12px; }
}
@media (min-width: 821px) {
  .popover .sheet-body.compact .menu-profile { padding: 8px 14px 10px; gap: 11px; }
  .popover .sheet-body.compact .menu-profile .avatar { width: 34px; height: 34px; font-size: 14px; }
  .popover .sheet-body.compact .mp-txt b { font-size: 14.5px; }
  .popover .sheet-body.compact .mp-txt small { font-size: 12.5px; }
  .popover .sheet-body.compact .row { font-size: 14px; padding: 7px 14px; gap: 11px; }
  .popover .sheet-body.compact .row svg.i { width: 17px; height: 17px; }
  .popover .sheet-body.compact .row .muted { font-size: 13px; }
  .popover .sheet-body.compact .sep { margin: 4px 14px; }
}

/* ---------- plans page (full screen) ---------- */
.page { position: fixed; inset: 0; z-index: 52; background: var(--bg); overflow-y: auto; animation: fade .15s ease; }
.page-bar { position: sticky; top: 0; z-index: 2; height: 56px; display: flex; align-items: center; padding: 0 10px; background: var(--bg); border-bottom: 1px solid var(--border); }
.page-body { max-width: 1240px; margin: 0 auto; padding: 28px 16px 40px; }
.plans-title { font-family: Fraunces, Georgia, serif; font-weight: 400; text-align: center; font-size: clamp(30px, 5vw, 46px); line-height: 1.15; margin: 4px 0 30px; letter-spacing: -.01em; }
.pcards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }
.pcard-wrap { display: flex; flex-direction: column; }
.pcard-tab { margin: 0 22px -14px; padding: 9px 12px 22px; border-radius: 16px 16px 0 0; text-align: center; font-size: 14px; color: var(--blue); background: rgba(58, 143, 232, .14); }
.pcard { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 22px; overflow: hidden; }
.pcard.is-cur { border-color: rgba(58, 143, 232, .45); }
.pcard-top { padding: 26px 24px 22px; }
.plan-ico { width: 60px; height: 54px; color: var(--text); display: block; margin-bottom: 18px; }
.pcard h3 { margin: 0; font-size: 28px; font-weight: 500; }
.pcard-sub { color: var(--text-3); margin-top: 2px; font-size: 15.5px; }
.pcard-price { display: flex; align-items: center; gap: 12px; margin: 22px 0 20px; }
.pcard-price b { font-size: 46px; font-weight: 500; letter-spacing: -.02em; line-height: 1; }
.pcard-price span { color: var(--text-3); font-size: 13.5px; line-height: 1.35; }
.pcard-btn { width: 100%; height: 48px; border-radius: 12px; font-size: 16px; font-weight: 500; background: var(--surface-2); color: var(--text); }
.pcard-btn:hover { background: var(--surface-3); }
.pcard-btn.primary { background: var(--send-bg); color: var(--send-fg); }
.pcard-btn.primary:hover { opacity: .9; }
.pcard-note { text-align: center; color: var(--text-3); font-size: 13px; margin-top: 10px; }
.pcard-feat { border-top: 1px solid var(--border); padding: 20px 24px 24px; }
.pcard-head { color: var(--text-2); font-size: 15px; margin-bottom: 8px; }
.pcard-feat ul { list-style: none; margin: 0; padding: 0; }
.pcard-feat li { display: flex; gap: 12px; padding: 6px 0; color: var(--text-2); font-size: 15px; line-height: 1.4; }
.pcard-feat li svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--text-2); stroke-width: 2; }
.plans-foot { max-width: 720px; margin: 28px auto 0; text-align: center; color: var(--text-3); font-size: 13.5px; line-height: 1.6; }
@media (max-width: 1100px) { .pcards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .pcards { grid-template-columns: 1fr; gap: 26px; }
  .page-body { padding: 22px 14px 40px; }
  .pcard h3 { font-size: 30px; }
  .pcard-price b { font-size: 50px; }
}

/* current-plan tab sits above its card without pushing it down */
.pcard-wrap { position: relative; }
.pcard { z-index: 1; }
.pcard-tab { position: absolute; left: 22px; right: 22px; bottom: calc(100% - 16px); margin: 0; padding: 9px 12px 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcards { padding-top: 40px; }
@media (max-width: 640px) { .pcards { padding-top: 0; } .pcard-wrap.has-tab { margin-top: 40px; } }

/* rounded profile card in the sidebar on desktop too */
@media (min-width: 821px) { .sb-foot { border-top: 0; padding: 8px 10px 12px; } .sb-foot .user-btn { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 8px 10px; } .sb-foot .user-btn:hover { background: var(--surface-2); } }

.auth-link { display: block; margin: 14px auto 0; color: var(--text-3); font-size: 13.5px; }
.auth-link:hover { color: var(--text); }
.cred-form .field { max-width: 420px; }

/* ---------- plans: Free card + centred window on desktop ---------- */
.pcards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.pcard-btn:disabled { opacity: .55; cursor: default; }
@media (min-width: 821px) {
  .page.plans-page { inset: auto; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(1240px, calc(100vw - 48px)); max-height: calc(100vh - 48px);
    border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); }
  .plans-page .page-bar { height: 48px; border-radius: 20px 20px 0 0; }
  .plans-page .page-body { padding: 8px 20px 24px; }
  .plans-page .plans-title { font-size: 32px; margin: 0 0 6px; }
  .plans-page .pcards { gap: 12px; padding-top: 34px; }
  .plans-page .pcard { border-radius: 18px; }
  .plans-page .pcard-top { padding: 18px 18px 16px; }
  .plans-page .plan-ico { width: 44px; height: 40px; margin-bottom: 12px; }
  .plans-page .pcard h3 { font-size: 22px; }
  .plans-page .pcard-sub { font-size: 13.5px; min-height: 36px; }
  .plans-page .pcard-price { margin: 12px 0 14px; gap: 8px; }
  .plans-page .pcard-price b { font-size: 32px; }
  .plans-page .pcard-price span { font-size: 12px; }
  .plans-page .pcard-btn { height: 40px; font-size: 14.5px; border-radius: 10px; }
  .plans-page .pcard-note { font-size: 11.5px; }
  .plans-page .pcard-feat { padding: 14px 18px 18px; }
  .plans-page .pcard-head { font-size: 13.5px; }
  .plans-page .pcard-feat li { font-size: 13.5px; padding: 4px 0; gap: 9px; }
  .plans-page .pcard-feat li svg { width: 15px; height: 15px; }
  .plans-page .pcard-tab { font-size: 12.5px; padding: 7px 10px 22px; left: 14px; right: 14px; }
  .plans-page .plans-foot { margin-top: 18px; font-size: 12.5px; }
}
@media (min-width: 821px) and (max-width: 1150px) { .pcards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px) { .pcards { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .pcards { grid-template-columns: 1fr; } }

/* first three plans; Max / Ultra behind "All plans" */
.pcards:not(.all) .pcard-extra { display: none; }
.pcards:not(.all) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plans-more { text-align: center; margin-top: 18px; }
.plans-more button { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--border); color: var(--text-2); font-size: 14px; }
.plans-more button:hover { background: var(--surface); color: var(--text); }
.plans-more svg { width: 16px; height: 16px; }
@media (min-width: 821px) {
  .page.plans-page:not(.all) { width: min(900px, calc(100vw - 48px)); }
}
@media (max-width: 820px) { .pcards:not(.all) { grid-template-columns: 1fr; } }

/* desktop: Max and Ultra go to a second row, window keeps its width */
@media (min-width: 821px) { .pcards.all { grid-template-columns: repeat(3, minmax(0, 1fr)); } .page.plans-page.all { width: min(900px, calc(100vw - 48px)); } }

/* ---------- projects ---------- */
.main.no-composer .composer-wrap { display: none; }
.pj-page { max-width: 980px; margin: 0 auto; padding: 18px 22px 30px; }
.pj-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 22px; }
.pj-head h1, .pj-title-row h1 { font-family: Fraunces, Georgia, serif; font-weight: 400; font-size: 32px; margin: 0; }
.pj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pj-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); min-height: 130px; }
.pj-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.pj-ico { color: var(--text-2); margin-bottom: 6px; }
.pj-card b { font-size: 16px; font-weight: 600; }
.pj-desc { color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pj-card small { color: var(--text-3); font-size: 12.5px; margin-top: auto; padding-top: 8px; }
.pj-empty { text-align: center; color: var(--text-3); padding: 60px 20px; }
.pj-empty svg { width: 40px; height: 40px; }
.pj-back { color: var(--text-3); font-size: 14px; margin-bottom: 10px; }
.pj-back:hover { color: var(--text); }
.pj-title-row { display: flex; align-items: center; gap: 8px; }
.pj-sub { color: var(--text-2); margin: 6px 0 0; }
.pj-cols { display: grid; grid-template-columns: 1fr 320px; gap: 22px; margin-top: 22px; align-items: start; }
.pj-sec { color: var(--text-3); font-size: 13.5px; margin-bottom: 8px; }
.pj-chats { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.pj-chat { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.pj-chat:last-child { border-bottom: 0; }
.pj-chat:hover { background: var(--surface); }
.pj-chat span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-chat small { color: var(--text-3); flex: none; }
.pj-hint { font-size: 13.5px; margin: 0 0 10px; }
.pj-box { border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.pj-box-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 600; font-size: 14.5px; }
.pj-instr { font-size: 13.5px; white-space: pre-wrap; max-height: 160px; overflow: auto; color: var(--text-2); }
.pj-file { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.pj-file-ico { width: 32px; height: 32px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--text-2); }
.pj-file-ico svg { width: 17px; height: 17px; }
.pj-file-n { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; line-height: 1.3; }
.pj-file-n b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-file-n small { color: var(--text-3); }
.pj-file .icon-btn { width: 28px; height: 28px; }
.pj-ta { height: 150px; padding: 10px 12px; resize: vertical; font-size: 14.5px; line-height: 1.5; }
.tb-proj { display: inline-flex; align-items: center; gap: 5px; color: var(--text-3); margin-right: 4px; }
.tb-proj svg { width: 15px; height: 15px; }
@media (max-width: 820px) { .pj-cols { grid-template-columns: 1fr; } .pj-page { padding: 12px 14px 24px; } .pj-head h1, .pj-title-row h1 { font-size: 26px; } }

/* ---------- side panel (preview / folder) ---------- */
.side-panel { display: none; }
.app.panel-open .side-panel { display: flex; flex-direction: column; width: min(46vw, 760px); flex: none; height: 100%; border-left: 1px solid var(--border); background: var(--sidebar); }
.sp-head { height: 52px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--border); }
.sp-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.sp-title b { font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-title svg { width: 17px; height: 17px; flex: none; }
.sp-frame { flex: 1; width: 100%; border: 0; background: #fff; }
.fd-hint { padding: 8px 14px; font-size: 12.5px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.fd-tree { flex: 1; overflow: auto; padding: 6px 0 20px; }
.fd-row { width: 100%; display: flex; align-items: center; gap: 8px; padding: 5px 12px; font-size: 13.5px; color: var(--text-2); text-align: left; }
.fd-row:hover { background: var(--surface); color: var(--text); }
.fd-row svg { width: 16px; height: 16px; flex: none; }
.fd-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-dir { color: var(--text); }
.fd-row.picked { color: var(--blue); }
.app.panel-open:has(.side-panel) .side-panel { min-width: 300px; }
body:not(.has-folder) .fc-save { display: none !important; }
@media (max-width: 820px) {
  .app.panel-open .side-panel { position: fixed; inset: 0; width: 100%; z-index: 45; border-left: 0; padding-top: env(safe-area-inset-top); }
}

.tb-proj { flex: none; }

/* per-device preferences */
:root[data-fs="s"] .thread { font-size: 14px; }
:root[data-fs="l"] .thread { font-size: 17px; }
:root[data-cf="serif"] .msg.assistant .body { font-family: "Source Serif 4", Fraunces, Georgia, serif; font-size: 1.04em; }
@media (min-width: 821px) { :root.wide-chat .thread, :root.wide-chat .composer-inner { max-width: 1040px; } }
.kv-sub { font-size: 13px; }
.settings-pane .kv > div:first-child { min-width: 0; }
.toggle { border: 0; cursor: pointer; }

/* payment methods */
.pay-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.pay-m { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); text-align: left; min-height: 54px; }
.pay-m:hover:not(:disabled) { border-color: var(--border-strong); }
.pay-m.on { border-color: var(--blue); background: rgba(58, 143, 232, .08); }
.pay-m.off { opacity: .5; cursor: not-allowed; }
.pay-m-ico { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--text-2); }
.pay-m-ico svg { width: 18px; height: 18px; }
.pay-m-t { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pay-m-t b { font-weight: 500; font-size: 14px; }
.pay-m-t small { color: var(--text-3); font-size: 11.5px; }
.gift-inp { font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: .02em; font-size: 15px; }

/* ---------- checkout page (Stripe-like) ---------- */
.checkout-page .co-wrap { max-width: 1060px; margin: 0 auto; padding: 18px 24px 40px; display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 48px; align-items: start; }
.co-h { font-size: 24px; font-weight: 600; margin: 6px 0 20px; }
.co-periods { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 30px; }
.co-period { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 18px 18px 16px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--bg); }
.co-period.on { border-color: var(--blue); background: rgba(58, 143, 232, .07); }
.co-period b { font-weight: 500; font-size: 14.5px; margin-top: 12px; }
.co-period span { font-size: 14.5px; margin-top: 8px; }
.co-period small { color: var(--text-3); font-size: 13.5px; }
.co-radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--text-3); background: var(--surface-3); }
.co-period.on .co-radio { border-color: var(--blue); background: radial-gradient(circle, #9cc8f7 0 45%, transparent 50%); }
.co-save { position: absolute; top: 14px; right: 14px; font-style: normal; font-size: 12px; font-weight: 600; color: #8fbff2; background: rgba(58, 143, 232, .16); padding: 3px 8px; border-radius: 7px; }
.co-sec { font-size: 15px; font-weight: 600; margin: 6px 0 14px; }
.co-left .field label { font-size: 13.5px; font-weight: 600; color: var(--text); margin-bottom: 7px; }
.co-inp { height: 34px; border-radius: 6px; font-size: 14px; padding: 0 10px; background: var(--surface); border-color: var(--surface); }
select.co-inp { appearance: auto; }
.co-cardnum { position: relative; }
.co-cardnum .co-inp { padding-right: 140px; }
.co-brands { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; pointer-events: none; }
.co-brands i { font-style: normal; font-size: 9.5px; font-weight: 800; letter-spacing: .03em; padding: 3px 5px; border-radius: 3px; background: #fff; color: #1a1f71; }
.co-brands i:first-child { color: #0f754e; } .co-brands i:last-child { color: #eb001b; }
.co-card { border: 1px solid var(--border-strong); border-radius: 22px; background: var(--surface); padding: 30px 30px 26px; position: sticky; top: 16px; }
.co-plan { font-family: Fraunces, Georgia, serif; font-weight: 400; font-size: 28px; margin: 0 0 26px; }
.co-line { display: flex; justify-content: space-between; gap: 12px; color: var(--text-2); font-size: 14px; padding: 6px 0; }
.co-total { color: var(--text); font-weight: 600; padding-top: 14px; }
.co-note { display: flex; gap: 10px; align-items: flex-start; margin: 22px 0 20px; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: 12px; font-size: 13.5px; color: var(--text-2); }
.co-note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.co-agree { display: flex; gap: 12px; align-items: flex-start; font-size: 13.5px; color: var(--text-2); line-height: 1.5; cursor: pointer; margin-bottom: 22px; }
.co-agree input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--blue); }
.co-pay { height: 42px; }
.co-pay:disabled { background: var(--surface-2); color: var(--text-3); opacity: 1; }
.co-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; }
.co-err { text-align: center; }
.co-gift-link { display: flex; align-items: center; gap: 7px; margin: 6px auto 0; color: var(--text-3); font-size: 13.5px; }
.co-gift-link:hover { color: var(--text); }
.co-gift-link svg { width: 16px; height: 16px; }
.co-gift { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.co-gift .gift-inp { flex: 1; min-width: 0; height: 38px; font-size: 13px; }
.co-gift .btn { height: 38px; }
.co-gift .err-text { width: 100%; margin: 0; }
@media (max-width: 900px) {
  .checkout-page .co-wrap { grid-template-columns: 1fr; gap: 24px; padding: 12px 16px 32px; }
  .co-card { position: static; padding: 22px 20px; }
  .co-periods { gap: 10px; }
  .co-period { padding: 14px; }
}
@media (min-width: 821px) { .page.checkout-page { inset: 0; transform: none; width: auto; max-height: none; border: 0; border-radius: 0; } }
