/* GPT Mix — design tokens: "steel" (light) and "graphite" (dark). Rainbow ring logo is theme-independent. */
:root {
  --accent: #3B6FD4;
  --accent-2: #2F5BB0;
  --accent-grad: linear-gradient(135deg, #3B6FD4, #2F5BB0);
  --accent-soft: rgba(59, 111, 212, .12);
  --accent-ring: rgba(59, 111, 212, .22);
  --accent-ink: #ffffff;
  --bg: #FFFFFF;
  --bg-2: #F6F7F9;
  --bg-3: #ECEEF2;
  --ink: #15181E;
  --ink-2: #5F6673;
  --ink-3: #656C79;
  --line: #E3E6EC;
  --user-bubble: #E9EFFA;
  --danger: #D9363E;
  --ok: #1F9D5B;
  --tier-economy: #1F9D5B;
  --tier-standard: #3B6FD4;
  --tier-premium: #C7850A;
  --shadow: 0 10px 30px rgba(21, 24, 30, .10);
  --shadow-sm: 0 2px 8px rgba(21, 24, 30, .08);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --rainbow: conic-gradient(from 95deg, #ff3b30, #ff9500, #ffcc00, #8ed300, #34c759, #00c7be, #30b0ff, #5856d6, #af52de, #ff2d55, #ff3b30);
  --mix-grad: linear-gradient(90deg, #ff9500, #34c759 35%, #30b0ff 70%, #af52de);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #4D8DFF; --accent-2: #3B74E0; --accent-grad: linear-gradient(135deg, #4D8DFF, #3B74E0);
    --accent-soft: rgba(77, 141, 255, .16); --accent-ring: rgba(77, 141, 255, .28);
    --bg: #15171C; --bg-2: #1A1D23; --bg-3: #23272F; --ink: #F1F3F7; --ink-2: #A3AAB8; --ink-3: #8A919E;
    --line: #262A32; --user-bubble: #1F2A3F; --danger: #FF5A61; --ok: #3DD68C;
    --tier-economy: #3DD68C; --tier-standard: #4D8DFF; --tier-premium: #F5B400;
    --shadow: 0 12px 36px rgba(0, 0, 0, .5); --shadow-sm: 0 2px 8px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent: #4D8DFF; --accent-2: #3B74E0; --accent-grad: linear-gradient(135deg, #4D8DFF, #3B74E0);
  --accent-soft: rgba(77, 141, 255, .16); --accent-ring: rgba(77, 141, 255, .28);
  --bg: #15171C; --bg-2: #1A1D23; --bg-3: #23272F; --ink: #F1F3F7; --ink-2: #A3AAB8; --ink-3: #8A919E;
  --line: #262A32; --user-bubble: #1F2A3F; --danger: #FF5A61; --ok: #3DD68C;
  --tier-economy: #3DD68C; --tier-standard: #4D8DFF; --tier-premium: #F5B400;
  --shadow: 0 12px 36px rgba(0, 0, 0, .5); --shadow-sm: 0 2px 8px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.ico.sm { width: 16px; height: 16px; }

/* ---------- brand: rainbow ring (same in both themes) ---------- */
.ring { position: relative; width: 36px; height: 36px; border-radius: 50%; background: var(--rainbow); display: grid; place-items: center; flex: none; overflow: hidden; }
.ring::before { content: ""; position: absolute; inset: 19%; border-radius: 50%; background: #fff; }
.ring > svg, .ring > span { position: relative; z-index: 1; }
.ring > svg { width: 100%; height: 100%; display: block; }
.ring > svg path { fill: none; stroke: #111; stroke-width: 7.5; stroke-linecap: round; stroke-linejoin: round; }
.ring.small > svg path { stroke-width: 10; }
.ring > span { font-weight: 800; color: #111; letter-spacing: -.04em; line-height: 1; }
.ring.s28 { width: 28px; height: 28px; } .ring.s28 > span { font-size: 10px; }
.ring.s32 { width: 32px; height: 32px; } .ring.s32 > span { font-size: 11.5px; }
.ring.s36 { width: 36px; height: 36px; } .ring.s36 > span { font-size: 13px; }
.ring.s42 { width: 42px; height: 42px; } .ring.s42 > span { font-size: 15px; }
.ring.s96 { width: 96px; height: 96px; } .ring.s96 > span { font-size: 34px; }
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; color: var(--ink); text-decoration: none; }
.mix { background: var(--mix-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- auth ---------- */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(900px 500px at 15% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 28px 24px; box-shadow: var(--shadow); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand-sub { color: var(--ink-2); font-size: 13px; }
.tabs { display: flex; gap: 4px; background: var(--bg-3); padding: 4px; border-radius: 12px; margin-bottom: 18px; }
.tab { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; color: var(--ink-2); cursor: pointer; }
.tab.active { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }
.auth-form label { display: block; font-size: 13px; color: var(--ink-2); margin: 10px 0; }
.auth-form input { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: none; transition: border .15s, box-shadow .15s; }
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.hint { color: var(--ink-2); font-size: 13px; margin: 8px 0; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; }
code { font-family: var(--mono); background: var(--bg-3); padding: 1px 6px; border-radius: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; text-decoration: none; transition: filter .15s, background .15s; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: var(--accent-ink); font-weight: 600; width: 100%; margin-top: 6px; box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; width: 100%; margin-top: 8px; color: var(--ink-2); }
.btn.danger { color: var(--danger); }
.btn.wide { width: 100%; margin: 0; }
.btn:disabled { opacity: .6; cursor: default; }
.icon-btn { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 9px; cursor: pointer; color: var(--ink-2); display: grid; place-items: center; padding: 0; }
.icon-btn:hover { background: var(--bg-3); color: var(--ink); }
.icon-btn:disabled { opacity: .45; cursor: default; }

/* ---------- app layout ---------- */
.app { height: var(--vvh, 100dvh); display: grid; grid-template-columns: 280px 1fr; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 6px; }
.sidebar-top { display: flex; gap: 8px; padding: 8px 12px; align-items: center; }
.search { margin: 4px 12px 8px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: none; }
.search:focus { border-color: var(--accent); }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px; min-height: 0; }
.chat-item { display: flex; align-items: center; gap: 6px; padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--ink-2); }
.chat-item:hover { background: var(--bg-3); color: var(--ink); }
.chat-item.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.chat-item .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.chat-item .del { opacity: 0; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; padding: 2px; border-radius: 6px; display: grid; place-items: center; }
.chat-item:hover .del { opacity: 1; }
.chat-item .del:hover { color: var(--danger); background: var(--bg); }
.sidebar-bottom { border-top: 1px solid var(--line); padding: 10px 12px; }
.user-chip { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 8px; border-radius: 12px; cursor: pointer; text-align: left; }
.user-chip:hover { background: var(--bg-3); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-grad); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-balance { font-size: 12px; color: var(--ink-2); }
.gear { color: var(--ink-3); display: grid; }

.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--bg); }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.balance-pill { font-size: 13px; background: var(--bg-3); padding: 6px 10px; border-radius: 999px; color: var(--ink-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.balance-pill .ico { width: 14px; height: 14px; color: var(--accent); }

/* ---------- model picker (custom, tiers in colour) ---------- */
.model-picker { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.model-btn { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 7px 10px 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; font-weight: 600; }
.model-btn:hover { border-color: var(--ink-3); }
.model-btn .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-btn .chev { color: var(--ink-3); }
.tier-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--tier-color, var(--ink-3)); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--tier-color, var(--ink-3)) 22%, transparent); }
.tier-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; color: var(--tier-color); background: color-mix(in srgb, var(--tier-color) 14%, transparent); padding: 2px 8px; border-radius: 999px; }
.tier-economy { --tier-color: var(--tier-economy); } .tier-standard { --tier-color: var(--tier-standard); } .tier-premium { --tier-color: var(--tier-premium); }
.badge { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-pop { position: absolute; top: calc(100% + 8px); left: 0; z-index: 45; width: min(440px, calc(100vw - 28px)); max-height: min(70vh, 560px); overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 8px; }
.model-group { padding: 6px 8px 4px; }
.model-group-h { display: flex; align-items: center; gap: 8px; padding: 6px 4px 6px; font-size: 12px; color: var(--ink-2); }
.model-group-h .tier-tag { font-size: 11px; }
.model-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; color: var(--ink); border-left: 3px solid transparent; }
.model-item:hover { background: var(--bg-3); }
.model-item.active { background: var(--accent-soft); border-left-color: var(--tier-color); }
.model-item .mi-name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-item .mi-sub { font-size: 12px; color: var(--ink-2); display: flex; gap: 8px; flex-wrap: wrap; }
.model-item .mi-free { color: var(--ok); font-weight: 600; }
.model-item .chk { color: var(--accent); opacity: 0; } .model-item.active .chk { opacity: 1; }

/* ---------- messages ---------- */
.messages { flex: 1; overflow-y: auto; padding: 24px 16px 8px; scroll-behavior: smooth; }
.messages-inner, .msg { max-width: 820px; margin: 0 auto; }
.empty { max-width: 640px; margin: 9vh auto 0; text-align: center; color: var(--ink-2); }
.empty .ring { margin: 0 auto 16px; box-shadow: 0 12px 30px rgba(21,24,30,.12); }
.empty h1 { font-size: 28px; margin: 6px 0; color: var(--ink); letter-spacing: -.02em; }
.empty p { margin: 6px auto 18px; max-width: 520px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); cursor: pointer; font-size: 14px; transition: border .15s, background .15s, transform .1s; }
.chip:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.chip .em { font-size: 15px; line-height: 1; }
.msg { display: flex; gap: 12px; margin: 0 auto 18px; }
.msg.user { flex-direction: row-reverse; }
.msg > div:not(.ava) { min-width: 0; }
.msg .bubble { max-width: 100%; padding: 12px 16px; border-radius: 16px; background: var(--bg-2); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user-bubble); border-color: transparent; border-bottom-right-radius: 6px; max-width: 80%; white-space: pre-wrap; margin-left: auto; }
.msg.assistant .bubble { border-bottom-left-radius: 6px; width: 100%; }
.msg .meta { font-size: 11px; color: var(--ink-3); margin-top: 6px; display: flex; gap: 10px; }
.msg .ava { width: 30px; height: 30px; border-radius: 10px; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--bg-3); color: var(--ink-2); margin-top: 2px; }
.msg.user .ava { background: var(--accent-grad); color: #fff; }
.msg.assistant .ava { background: transparent; }
.msg.assistant .ava .ring { width: 30px; height: 30px; }
.bubble.md p { margin: 0 0 10px; } .bubble.md p:last-child { margin-bottom: 0; }
.bubble.md pre { background: var(--bg-3); padding: 12px; border-radius: 10px; overflow-x: auto; font-family: var(--mono); font-size: 13px; }
.bubble.md code { font-size: 13px; }
.bubble.md pre code { background: transparent; padding: 0; }
.bubble.md ul, .bubble.md ol { padding-left: 22px; margin: 6px 0 10px; }
.bubble.md table { border-collapse: collapse; margin: 8px 0; font-size: 14px; }
.bubble.md th, .bubble.md td { border: 1px solid var(--line); padding: 6px 10px; }
.bubble.md blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--accent); color: var(--ink-2); }
.bubble.md h1, .bubble.md h2, .bubble.md h3 { margin: 12px 0 6px; font-size: 1.05em; }
.cursor::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg.error .bubble { border-color: var(--danger); color: var(--danger); }

/* ---------- composer ---------- */
.composer-wrap { padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); }
.composer { max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 7px 7px 7px 8px; transition: border .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
#input { flex: 1; resize: none; border: 0; background: transparent; outline: none; max-height: 200px; padding: 8px 4px; line-height: 1.45; overflow-y: auto; scrollbar-width: thin; min-width: 0; }
#input::placeholder { color: var(--ink-3); }
.send-btn { width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--accent-grad); color: #fff; cursor: pointer; flex: none; display: grid; place-items: center; padding: 0; }
.send-btn:disabled { opacity: .5; cursor: default; }
.send-btn.stop { background: var(--danger); }
.mic-btn { position: relative; }
.mic-btn.rec { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.mic-btn.rec::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }
.composer-hint { text-align: center; color: var(--ink-3); font-size: 12px; margin: 8px 0 0; }
.composer-hint.rec { color: var(--danger); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(10,12,20,.55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 6px 18px 18px; }
.modal-body section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.modal-body section:last-of-type { border-bottom: 0; }
.modal-body h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 14px; }
.kv span { color: var(--ink-2); }
.kv.edit { align-items: center; }
.kv.edit input { flex: 1; max-width: 220px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-2); outline: none; }
.kv.edit input:focus { border-color: var(--accent); }
details { margin-top: 8px; } summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 8px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; }
.seg button.active { border-color: var(--accent); color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); z-index: 60; max-width: 90vw; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; }
.only-mobile { display: none; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 320px); z-index: 40; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: grid; }
  .msg.user .bubble { max-width: 92%; }
  .badge { display: none; }
  .messages { padding: 16px 12px 8px; }
  .empty { margin-top: 5vh; }
  .empty h1 { font-size: 24px; }
  .model-btn { padding: 7px 8px; } .model-btn .name { max-width: 150px; }
  .model-pop { left: -44px; }
}

/* ---------- TZ-9 stage 2: auto, cost line, compare ---------- */

.tier-auto { --tier-color: #30b0ff; }
.tier-auto .tier-dot, .model-btn.tier-auto .tier-dot { background: var(--rainbow); box-shadow: none; }
.tier-tag.tier-auto { color: var(--ink); background: var(--bg-3); }
.model-item.tier-auto.active { border-left-color: #30b0ff; }
.model-group.tier-auto { border-bottom: 1px solid var(--line); margin-bottom: 4px; padding-bottom: 8px; }
.msg .meta { font-variant-numeric: tabular-nums; }
.icon-btn.active { color: var(--accent); background: var(--accent-soft); }

.compare-bar { max-width: 820px; margin: 0 auto 8px; border: 1px solid var(--line); background: var(--bg-2); border-radius: 16px; padding: 10px 12px; }
.cmp-bar-h { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.cmp-bar-h b { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 14px; }
.cmp-bar-h .icon-btn { margin-left: auto; width: 30px; height: 30px; }
.cmp-models { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 6px; }
.cmp-pick { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 13px; color: var(--ink-2); }
.cmp-pick small { color: var(--ink-3); font-size: 11px; }
.cmp-pick.on { border-color: var(--tier-color); color: var(--ink); background: color-mix(in srgb, var(--tier-color) 12%, var(--bg)); font-weight: 600; }
.cmp-warn { margin: 4px 2px 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.cmp-warn b { color: var(--ink); }
.cmp-warn.low { color: var(--danger); } .cmp-warn.low b { color: var(--danger); }

.msg.compare .cmp-wrap { flex: 1; min-width: 0; }
.cmp-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); margin: 4px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.cmp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.cmp-col { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); border-top: 3px solid var(--tier-color, var(--line)); transition: opacity .15s, border-color .15s; }
.cmp-col .cmp-h { display: flex; align-items: center; gap: 8px; padding: 9px 12px 0; font-size: 14px; }
.cmp-col .cmp-h .tier-tag { margin-left: auto; font-size: 10px; }
.cmp-col .bubble { border: 0; background: transparent; padding: 8px 12px; flex: 1; }
.cmp-col .cmp-f { display: flex; align-items: center; gap: 8px; padding: 8px 12px 10px; border-top: 1px solid var(--line); }
.cmp-col .cmp-f .meta { margin: 0; flex: 1; }
.cmp-col .keep { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.cmp-col.kept { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-ring); }
.cmp-col.kept .keep { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.cmp-col.dim { opacity: .62; }
.cmp-col.error .bubble { color: var(--danger); }
@media (max-width: 860px) {
  .cmp-grid { display: flex; align-items: flex-start; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; padding-bottom: 4px; }
  .cmp-col { flex: 0 0 86%; scroll-snap-align: start; }
  .cmp-bar-h span { display: none; }
}

/* ---------- TZ-9 stage 3: attachments, search sources, image edit ---------- */
.attach-row { max-width: 820px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.att-chip { display: flex; align-items: center; gap: 8px; max-width: 320px; padding: 6px 6px 6px 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); }
.att-chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; flex: none; }
.att-chip .att-ico { width: 40px; height: 40px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.att-chip .att-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.att-chip .att-meta b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-chip .att-meta small { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-chip.uploading { opacity: .75; } .att-chip.error { border-color: var(--danger); } .att-chip.error small { color: var(--danger); }
.att-x { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.att-x:hover { background: var(--bg-3); color: var(--danger); }
.att-mode { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; border: 1px dashed var(--line); background: var(--bg); color: var(--ink-2); font-size: 13px; cursor: pointer; }
.att-mode.on { border-style: solid; border-color: var(--tier-premium); color: var(--ink); background: color-mix(in srgb, var(--tier-premium) 12%, var(--bg)); font-weight: 600; }
.msg-atts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: flex-start; margin-bottom: 6px; }
.att-img img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); display: block; }
.att-doc { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); text-decoration: none; font-size: 13px; max-width: 260px; }
.att-doc span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .att-doc .ico { color: var(--accent); } .att-doc small { color: var(--ink-3); }
.bubble.md img { max-width: min(100%, 512px); max-height: 420px; object-fit: contain; border-radius: 12px; display: block; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.src-h { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); margin-right: 2px; }
.src { display: inline-flex; align-items: center; gap: 6px; max-width: 280px; padding: 5px 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); text-decoration: none; font-size: 12.5px; }
.src:hover { border-color: var(--accent); }
.src b { width: 18px; height: 18px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 11px; flex: none; }
.src span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .src small { color: var(--ink-3); white-space: nowrap; }
.edit-wait { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 860px) {
  .att-chip { max-width: 100%; flex: 1 1 100%; }
  .src { max-width: 100%; }
  .composer .icon-btn { width: 32px; height: 36px; }
  .composer { gap: 2px; }
}

/* ================= ТЗ-11: приложение (PWA) ================= */
html { -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior-y: none; }
.messages, .chat-list, .modal-card, .sheet { overscroll-behavior: contain; }
html.is-standalone .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
html.is-standalone .sidebar { padding-top: env(safe-area-inset-top); }
.topbar, .composer-wrap { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
/* iOS не увеличивает страницу при фокусе, если шрифт поля не меньше 16px */
#input, .search, .auth-form input, .modal-body input { font-size: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }
kbd { font-family: var(--mono); font-size: 12px; background: var(--bg-3); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; }

/* индикатор связи */
.net-pill { font-size: 12px; font-weight: 600; color: var(--danger); background: var(--bg-3); padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.net-pill::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }

/* полоса обновления и предложение уведомлений */
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); z-index: 70; display: flex; align-items: center; gap: 10px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 14px; padding: 8px 8px 8px 16px; width: max-content; max-width: calc(100vw - 24px); font-size: 14px; }
.update-bar .btn.primary { width: auto; margin: 0; padding: 8px 14px; white-space: nowrap; }
.push-offer { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); }

/* баннер установки на телефоне */
.install-banner { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 45; display: flex; align-items: center; gap: 12px; background: var(--bg); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 16px; padding: 10px 8px 10px 12px; max-width: 520px; margin: 0 auto; }
.install-banner .ib-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; color: var(--ink-2); line-height: 1.3; }
.install-banner .ib-text b { color: var(--ink); font-size: 15px; }
.install-banner .btn.primary { width: auto; margin: 0; padding: 9px 14px; }
.install-btn { margin: 0 12px 8px; width: auto; align-self: stretch; max-width: calc(100% - 24px); }
.app-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.app-actions .btn { width: auto; margin: 0; }
#app-version { font-family: var(--mono); font-weight: 500; font-size: 13px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
#pwa-stats { margin-top: 10px; padding: 10px 12px; background: var(--bg-2); border-radius: 12px; }
#pwa-stats h4 { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }

/* нижняя навигация: только на телефоне */
.bottom-nav { display: none; }
@media (max-width: 860px) {
  .bottom-nav:not(.hidden) { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bg); border-top: 1px solid var(--line); padding: 4px max(6px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
  .bottom-nav button { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; min-height: 48px; font-size: 11px; color: var(--ink-2); cursor: pointer; border-radius: 10px; }
  .bottom-nav button.active { color: var(--accent); }
  html.has-bnav .app { height: calc(var(--vvh, 100dvh) - 57px - env(safe-area-inset-bottom)); }
  html.has-bnav .composer-wrap { padding-bottom: 10px; }
  html.kb-open .bottom-nav { display: none !important; }
  html.kb-open .app { height: var(--vvh, 100dvh) !important; }
  html.has-bnav .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* окно «Создать» (снизу на телефоне, по центру на компьютере) */
.sheet-wrap { position: fixed; inset: 0; z-index: 55; background: rgba(10,12,20,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: var(--bg); border-radius: 20px 20px 0 0; padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); max-height: 85vh; overflow-y: auto; }
@media (min-width: 861px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-h { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.sheet-h h2 { margin: 0; font-size: 18px; }
.sheet-tabs { display: flex; gap: 6px; background: var(--bg-2); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.sheet-tabs button { flex: 1; border: 0; background: transparent; padding: 9px 8px; border-radius: 9px; cursor: pointer; color: var(--ink-2); font-weight: 600; min-height: 40px; }
.sheet-tabs button.active { background: var(--bg); color: var(--ink); box-shadow: var(--shadow-sm); }
.sheet-body { display: flex; flex-direction: column; gap: 8px; }
.sheet-item { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); text-decoration: none; cursor: pointer; }
.sheet-item:hover { border-color: var(--accent); }
.sheet-item span { color: var(--ink-2); font-size: 13px; }

/* скелетоны и прерванный ответ */
.skeleton { max-width: 820px; margin: 24px auto; display: flex; flex-direction: column; gap: 14px; padding: 0 16px; }
.skeleton i { display: block; height: 54px; border-radius: 14px; background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
.skeleton i:nth-child(2) { margin-left: 30%; }
.skeleton i.short { width: 55%; }
@keyframes sk { to { background-position: -200% 0; } }
.interrupted { margin: 10px 0 0; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; background: var(--bg-2); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; font-size: 14px; }
.interrupted .btn { width: auto; margin: 0; }
.interrupted small { color: var(--ink-2); font-size: 12px; }

/* окно с инструкцией установки (общее с публичными страницами) */
.ig-modal { position: fixed; inset: 0; z-index: 80; background: rgba(10,12,20,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.ig-card { position: relative; width: 100%; max-width: 420px; background: var(--bg, #fff); color: var(--ink, #15181E); border-radius: 18px; padding: 22px 20px 18px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.ig-card h2 { margin: 0 32px 8px 0; font-size: 19px; }
.ig-lead, .ig-note { color: var(--ink-2, #5F6673); font-size: 14px; margin: 6px 0; }
.ig-steps { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.ig-step { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.ig-n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-2, #2F5BB0); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.ig-ico { flex: none; min-width: 36px; padding: 0 6px; height: 36px; border-radius: 10px; background: var(--bg-2, #F6F7F9); display: grid; place-items: center; color: var(--accent, #3B6FD4); }
.ig-add { font-size: 11px; color: var(--accent, #3B6FD4); }
.ig-close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2, #5F6673); font-size: 18px; cursor: pointer; }
.ig-ok { width: 100%; margin-top: 8px; min-height: 44px; border: 0; border-radius: 12px; background: var(--accent-2, #2F5BB0); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ТЗ-12: подсказка iOS — две кнопки */
.ig-btns{display:flex;gap:8px;margin-top:8px}.ig-btns .ig-ok{margin-top:0;flex:1;width:auto}.ig-done{flex:1;min-height:44px;border:1px solid var(--line,#E3E6EC);border-radius:12px;background:transparent;color:var(--ink,#15181E);font-weight:600;font-size:15px;cursor:pointer}

/* ---- ТЗ-13: виджет «Помощь» ---- */
.help-btn { justify-content: flex-start; gap: 8px; margin-bottom: 6px; }
.sup-card { max-width: 560px; display: flex; flex-direction: column; height: min(720px, 92vh); overflow: hidden; }
.sup-list { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; }
.sup-msg { display: flex; flex-direction: column; max-width: 88%; }
.sup-msg.user { align-self: flex-end; align-items: flex-end; }
.sup-msg small { color: var(--ink-2); margin: 0 4px 2px; font-size: 12px; }
.sup-bubble { padding: 9px 12px; border-radius: 14px; background: var(--bg-3); color: var(--ink); line-height: 1.45; font-size: 15px; word-wrap: break-word; }
.sup-msg.user .sup-bubble { background: var(--accent-grad); color: #fff; }
.sup-msg.operator .sup-bubble { background: var(--accent-soft); border: 1px solid var(--accent-ring); }
.sup-msg.wait .sup-bubble { opacity: .65; }
.sup-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }
.sup-acts .btn.sm { width: auto; margin: 0; padding: 5px 10px; font-size: 13px; border-radius: 10px; }
.sup-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 16px; border-top: 1px solid var(--line); }
.sup-form textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; font: inherit; background: var(--bg); color: var(--ink); max-height: 140px; }
.sup-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.sup-foot { display: flex; gap: 10px; align-items: center; padding: 0 16px 14px; flex-wrap: wrap; }
.sup-foot .btn { width: auto; margin: 0; }
.sup-foot .hint { margin: 0; }
@media (max-width: 600px) { .sup-card { height: 100%; max-height: 100%; border-radius: 0; } #support.modal { padding: 0; } }

/* ---- ТЗ-16 этап A: действия под сообщением, меню чата, своё окно подтверждения, подарок ---- */
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: .55; transition: opacity .15s; flex-wrap: wrap; align-items: center; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
@media (pointer: coarse) { .msg-actions { opacity: 1; } }
.msg.user .msg-actions { justify-content: flex-end; }
.msg-actions .act { border: 0; background: transparent; color: var(--ink-3); width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.msg-actions .act:hover { background: var(--bg-3); color: var(--ink); }
.msg-actions .act.on { color: var(--accent); background: var(--accent-soft); }
.msg-actions .act:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.edit-area { width: 100%; min-width: min(560px, 70vw); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; background: var(--bg); color: var(--ink); resize: vertical; }
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.edit-actions .btn { width: auto; margin: 0; }
.chat-item { position: relative; }
.chat-item .more { opacity: 0; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; padding: 2px; border-radius: 6px; display: grid; place-items: center; }
.chat-item:hover .more, .chat-item.active .more, .chat-item .more:focus-visible { opacity: 1; }
@media (pointer: coarse) { .chat-item .more { opacity: 1; } }
.chat-item .more:hover { color: var(--ink); background: var(--bg); }
.chat-item .pin-mark { color: var(--accent); flex: none; }
.chat-item input.rename { flex: 1; min-width: 0; border: 1px solid var(--accent); border-radius: 6px; padding: 3px 6px; font: inherit; font-size: 14px; background: var(--bg); color: var(--ink); }
.chat-menu { position: absolute; right: 6px; top: calc(100% - 4px); z-index: 20; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 4px; min-width: 180px; display: flex; flex-direction: column; }
.chat-menu button { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; color: var(--ink); text-align: left; padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 14px; }
.chat-menu button:hover, .chat-menu button:focus-visible { background: var(--bg-3); outline: none; }
.chat-menu button.danger { color: var(--danger); }
.confirm-card { max-width: 400px; }
.confirm-card .modal-body { padding: 20px; }
.confirm-card h2 { font-size: 18px; margin: 0 0 8px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.confirm-actions .btn { width: auto; margin: 0; }
.btn.danger-btn { background: var(--danger); }
.empty .gift { background: var(--accent-soft); color: var(--ink); border-radius: 12px; padding: 8px 14px; font-size: 14px; max-width: 520px; margin: 4px auto 10px; }

/* ---- ТЗ-16 этап B: «Прослушать» и плеер ---- */
.msg-actions .act.listen { width: auto; padding: 0 9px; gap: 5px; display: inline-flex; align-items: center; font: inherit; font-size: 12px; color: var(--ink-3); }
.msg-actions .act.listen.busy { color: var(--accent); }
.tts-player { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 6px; margin-left: 4px; min-width: 220px; }
.tts-player button { border: 0; background: transparent; color: var(--ink-2); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; padding: 0; font: inherit; font-size: 12px; font-weight: 700; }
.tts-player button:hover { background: var(--bg-3); color: var(--ink); }
.tts-player .tp-play { background: var(--accent); color: #fff; }
.tts-player .tp-play:hover { background: var(--accent-2); color: #fff; }
.tts-player .tp-speed { width: auto; padding: 0 6px; border-radius: 8px; }
.tts-player .tp-loop.on { color: var(--accent); background: var(--accent-soft); }
.tts-player .tp-pos { font-size: 11px; color: var(--ink-3); min-width: 0; font-variant-numeric: tabular-nums; }
.tts-player .tp-bar { flex: 1; height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden; min-width: 60px; }
.tts-player .tp-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.tts-voice-row select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--bg); color: var(--ink); font: inherit; max-width: 60%; }

/* ---- ТЗ-16 этап C: умные кнопки ---- */
.smart-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.smart-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.smart-btn:hover { background: var(--accent); color: #fff; }

/* ТЗ-16 G: согласие при регистрации */
.auth-form .consent { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2); flex-direction: row; }
.auth-form .consent input { width: 16px; height: 16px; margin-top: 2px; flex: none; }

/* Approved rainbow GPT Mix brand, 2026-11-02 */
.ring{background:transparent url("/static/brand/logo.svg?v=rainbow20261102") center/contain no-repeat!important;border:0!important;box-shadow:none!important;overflow:visible!important}.ring>*{visibility:hidden!important}.ring:before,.ring:after{display:none!important}

.mix{background:linear-gradient(110deg,#008bff,#00bf80 30%,#edc600 53%,#fa38ac 75%,#aa19f6);background-clip:text;-webkit-background-clip:text;color:transparent!important}
