:root {
  --bg: #f7f6f2; --side: #efede6; --panel: #ffffff; --text: #23221f; --muted: #75736b; --line: #e2dfd5;
  --accent: #2f6fb3; --accent-ink: #ffffff; --user: #e9e6dd; --hover: #e6e3da; --err: #b3261e; --code: #f3f1ea;
  --serif: "Noto Serif", Georgia, serif; --sans: Inter, system-ui, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1f1e1c; --side: #181816; --panel: #2a2926; --text: #ecebe6; --muted: #a3a198; --line: #383632;
    --accent: #6ea8e8; --accent-ink: #0f1720; --user: #34332f; --hover: #2c2b28; --err: #f28b82; --code: #262522; }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); }
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.serif { font-family: var(--serif); font-weight: 400; }
.muted { color: var(--muted); }
.small { font-size: 13px; } .tiny { font-size: 12px; } .center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err { color: var(--err); font-size: 14px; min-height: 20px; }
.primary { background: var(--accent); color: var(--accent-ink); border-radius: 10px; padding: 10px 16px; font-weight: 500; }
.primary:disabled { opacity: .6; cursor: default; }
.ghost { border: 1px solid var(--line); border-radius: 8px; padding: 5px 12px; background: var(--panel); }
.wide { width: 100%; }
.icon { width: 34px; height: 34px; border-radius: 8px; display: inline-grid; place-items: center; color: var(--muted); font-size: 16px; }
.icon:hover { background: var(--hover); color: var(--text); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.brand.big { font-size: 20px; justify-content: center; }
.logo { width: 24px; height: 24px; border-radius: 7px; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 21h13a4 4 0 0 0 .4-8 6 6 0 0 0-11.5-1.2A4.6 4.6 0 0 0 9 21z' fill='white'/%3E%3C/svg%3E") center/100%; }

/* ---------- auth ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-card h1 { font-size: 34px; margin: 28px 0 4px; }
.auth-card form { text-align: left; margin-top: 24px; display: grid; gap: 12px; }
.auth-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-card input[type=email], .auth-card input[type=password] { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 15px; }
.auth-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { grid-template-columns: auto 1fr !important; align-items: start; }

/* ---------- layout ---------- */
.app { display: flex; height: 100dvh; }
.sidebar { width: 272px; flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px; gap: 6px; }
.side-top { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 8px; }
.new-chat { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 10px; font-weight: 500; }
.new-chat span { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 14px; }
.new-chat:hover { background: var(--hover); }
.side-label { font-size: 12px; color: var(--muted); padding: 10px 10px 2px; }
.conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.conv { display: flex; align-items: center; border-radius: 8px; }
.conv a { flex: 1; min-width: 0; padding: 7px 10px; color: var(--text); text-decoration: none; font-size: 14px; }
.conv:hover, .conv.active { background: var(--hover); }
.conv .icon { width: 28px; height: 28px; opacity: 0; font-size: 14px; }
.conv:hover .icon, .conv.active .icon { opacity: 1; }
.side-bottom { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 8px; }
.plan-box { font-size: 13px; padding: 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.plan-box b { font-weight: 600; }
.plan-box button { margin-top: 8px; width: 100%; padding: 7px; font-size: 13px; }
.user-row { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 0 2px; }
.user-row span.ellipsis { flex: 1; min-width: 0; }
.avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 600; font-size: 13px; text-transform: uppercase; }
.scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 52px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 14px; }
.model-pick { position: relative; }
.model-btn { padding: 6px 10px; border-radius: 8px; font-weight: 500; }
.model-btn:hover { background: var(--hover); }
.menu { position: absolute; top: 40px; left: 0; z-index: 20; min-width: 260px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 8px 30px rgb(0 0 0 / .12); }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; }
.menu button:hover, .menu button[aria-selected=true] { background: var(--hover); }
.menu small { display: block; color: var(--muted); }
.warm { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.warm::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #d9a400; animation: pulse 1.2s infinite; }
.warm.ready::before { background: #2e9d57; animation: none; }
@keyframes pulse { 50% { opacity: .3; } }
.upgrade-top { margin-left: auto; }

.scroll { flex: 1; overflow-y: auto; }
.empty { max-width: 760px; margin: 18vh auto 0; padding: 0 16px; text-align: center; }
.empty h2 { font-size: 38px; margin: 0 0 6px; }
.msgs { max-width: 760px; margin: 0 auto; padding: 8px 16px 24px; }
.msg { margin: 18px 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--user); border-radius: 16px; padding: 9px 14px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.user img { display: block; max-width: 220px; max-height: 160px; border-radius: 10px; margin-bottom: 6px; }
.msg.ai .body { font-family: var(--serif); font-size: 16px; line-height: 1.7; word-wrap: break-word; }
.msg.ai .body p { margin: 0 0 12px; }
.msg.ai .body :is(h1,h2,h3) { font-family: var(--sans); font-weight: 600; line-height: 1.3; margin: 18px 0 8px; }
.msg.ai .body h1 { font-size: 20px; } .msg.ai .body h2 { font-size: 18px; } .msg.ai .body h3 { font-size: 16px; }
.msg.ai .body :is(ul,ol) { padding-left: 22px; margin: 0 0 12px; }
.msg.ai .body code { font: 13.5px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; background: var(--code); padding: 1px 5px; border-radius: 5px; }
.msg.ai .body pre { position: relative; background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; overflow-x: auto; }
.msg.ai .body pre code { background: none; padding: 0; }
.msg.ai .body table { border-collapse: collapse; margin: 0 0 12px; font-family: var(--sans); font-size: 14px; display: block; overflow-x: auto; }
.msg.ai .body :is(th,td) { border: 1px solid var(--line); padding: 6px 10px; }
.msg.ai .body blockquote { margin: 0 0 12px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.copy-code { position: absolute; top: 6px; right: 6px; font: 12px var(--sans); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); }
.actions { display: flex; gap: 2px; margin-top: 2px; }
.actions .icon { width: 30px; height: 30px; font-size: 14px; }
.meta { font: 12px var(--sans); color: var(--muted); align-self: center; margin-left: 6px; }
.cursor::after { content: "▍"; animation: pulse 1s infinite; color: var(--muted); }
.err-msg { color: var(--err); font-family: var(--sans); font-size: 14px; }

.composer-wrap { flex: none; padding: 0 16px 10px; }
.composer { max-width: 760px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 10px 10px 8px 14px; box-shadow: 0 2px 12px rgb(0 0 0 / .04); }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.composer textarea { width: 100%; border: 0; outline: 0; resize: none; background: transparent; max-height: 220px; font-size: 15px; padding: 4px 0; }
.composer-row { display: flex; align-items: center; gap: 6px; }
.hint { margin-right: auto; }
.send { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 18px; font-weight: 600; }
.send:disabled { opacity: .4; cursor: default; }
.send.stop { font-size: 12px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumbs:not(:empty) { margin-bottom: 6px; }
.thumbs img { height: 60px; border-radius: 8px; cursor: pointer; border: 1px solid var(--line); }
.limit-bar { max-width: 760px; margin: 0 auto 8px; font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
.limit-bar button { margin-left: auto; padding: 5px 10px; font-size: 13px; }

.dlg { border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(420px, calc(100vw - 32px)); background: var(--panel); color: var(--text); }
.dlg::backdrop { background: rgb(0 0 0 / .35); }
.dlg h3 { font-size: 26px; margin: 0; }
.dlg-x { position: absolute; top: 12px; right: 12px; margin: 0; }
.price { font-size: 28px; font-weight: 600; margin: 6px 0 10px; }
.price .muted { font-size: 15px; font-weight: 400; }
.perks { padding-left: 20px; margin: 0 0 16px; }
.perks li { margin: 4px 0; }
.pay-state { font-size: 14px; min-height: 0; margin-bottom: 10px; }
.pay-state:empty { display: none; }

@media (max-width: 760px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .sidebar.open + .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / .3); }
  .hint { visibility: hidden; }
  .empty { margin-top: 12vh; }
  .empty h2 { font-size: 30px; }
}
@media (min-width: 761px) { .only-mobile { display: none; } }

.admin-link { display: block; margin-top: 8px; font-weight: 500; text-decoration: none; }

/* ---------- dots ---------- */
.nav-dots { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; font-size: 14px; }
.nav-dots:hover, .nav-dots.active { background: var(--hover); }
.nav-dots small { color: var(--muted); font-size: 12px; }
.dot-ico { color: var(--accent); margin-right: 6px; }
.nav-dots .dot-ico { width: 22px; text-align: center; margin: 0; }
.dots-view { flex: 1; overflow-y: auto; }
.dots-wrap { max-width: 900px; margin: 0 auto; padding: 8px 20px 48px; }
.dots-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 16px; }
.dots-head h2 { font-size: 30px; margin: 0 0 4px; }
.dots-head p { margin: 0; max-width: 560px; }
.dot-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dot-actions .ghost { padding: 9px 14px; font-size: 14px; }
.ghost.danger { color: var(--err); }
.back { font-size: 14px; text-decoration: none; }
.dot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 14px; }
.dot-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; text-align: left; display: block; width: 100%; }
button.dot-card { display: grid; gap: 6px; margin: 0; cursor: pointer; }
button.dot-card:hover { border-color: var(--accent); }
.dot-title { font-weight: 600; font-size: 16px; }
.dot-empty { grid-column: 1 / -1; padding: 24px; text-align: center; border: 1px dashed var(--line); border-radius: 14px; }
.upsell { border-color: var(--accent); }
.upsell .primary { margin-top: 4px; }
.pill { display: inline-block; font-size: 12px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); }
.pill.on, .pill.ok { color: #1e7d3c; border-color: #1e7d3c; }
.pill.ask { color: #9a6200; border-color: #c98a1a; }
.pill.bad { color: var(--err); border-color: var(--err); }
.pill.run { color: var(--accent); border-color: var(--accent); }
.goal { font-size: 15px; }
.ask-box { border-color: #c98a1a; }
.ask-box p { margin: 6px 0 10px; font-weight: 500; }
.reply { display: flex; gap: 8px; margin-top: 8px; }
.reply input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: inherit; }
.reply .primary, .reply .ghost { padding: 8px 14px; }
.report { font-size: 15px; }
.report > :first-child { margin-top: 6px; }
.dot-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.run-item { border-top: 1px solid var(--line); }
.run-item:first-of-type { border-top: 0; }
.run-item > button { width: 100%; text-align: left; padding: 8px 0; font-size: 13.5px; }
.run-body { display: none; padding: 0 0 8px; }
.run-item.open .run-body { display: block; }
.step { display: flex; gap: 10px; padding: 5px 0; font-size: 14px; align-items: flex-start; }
.step > span:first-child { width: 20px; flex: none; text-align: center; }
.step .muted { word-break: break-all; }
.notes { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.notes li { margin: 3px 0; }
.msgline { font-size: 13.5px; padding: 4px 0; }
.msgline.dot b { color: var(--accent); }
.live { border-color: var(--accent); }
.spin { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dot-dlg { width: min(520px, calc(100vw - 32px)); }
.dot-form { display: grid; gap: 12px; margin-top: 12px; }
.dot-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.dot-form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.dot-form input:not([type=checkbox]), .dot-form textarea, .dot-form select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font: inherit; color: var(--text); resize: vertical; }
@media (max-width: 760px) {
  .dot-cols { grid-template-columns: 1fr; }
  .dots-wrap { padding: 4px 16px 40px; }
  .dots-head h2 { font-size: 24px; }
}

.shot { margin: 8px 0 10px; }
.shot img { width: 100%; max-height: 420px; object-fit: cover; object-position: top; border: 1px solid var(--line); border-radius: 10px; display: block; }
.shot figcaption { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
