/* TwoSides — calm, chat-style layout. No external fonts or scripts (CSP: 'self' only). */
:root {
  --bg: #faf9f6;
  --side: #f2f1ec;
  --surface: #ffffff;
  --raised: #f4f3ee;
  --text: #1f1e1c;
  --muted: #6d6b64;
  --faint: #9a978e;
  --line: #e5e3dc;
  --line-strong: #d6d3ca;
  --accent: #1f6b66;
  --accent-ink: #ffffff;
  --accent-soft: #e3efed;
  --fake: #b2452f;
  --fake-bg: #fbf1ed;
  --fake-line: #f0d4ca;
  --real: #2b7a51;
  --real-bg: #eef6f0;
  --real-line: #cfe6d7;
  --shadow: 0 1px 2px rgba(30, 28, 22, .05), 0 6px 24px rgba(30, 28, 22, .06);
  --radius: 14px;
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1a; --side: #161615; --surface: #252523; --raised: #2b2b28; --text: #ecebe6; --muted: #a8a59c;
    --faint: #7d7a72; --line: #33322e; --line-strong: #44423d; --accent: #5fb3aa; --accent-ink: #0f1f1d;
    --accent-soft: #1f3331; --fake: #ef8f78; --fake-bg: #2c211e; --fake-line: #4a312a; --real: #7dcb9c;
    --real-bg: #1d2a22; --real-line: #2e4a39; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c1a; --side: #161615; --surface: #252523; --raised: #2b2b28; --text: #ecebe6; --muted: #a8a59c;
  --faint: #7d7a72; --line: #33322e; --line-strong: #44423d; --accent: #5fb3aa; --accent-ink: #0f1f1d;
  --accent-soft: #1f3331; --fake: #ef8f78; --fake-bg: #2c211e; --fake-line: #4a312a; --real: #7dcb9c;
  --real-bg: #1d2a22; --real-line: #2e4a39; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; }
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.defs { position: absolute; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.i.sm { width: 14px; height: 14px; }
.mark { width: 24px; height: 24px; flex: none; }
.mk-l { fill: var(--fake); }   /* plain selectors: <use> clones are styled from the symbol's own context */
.mk-r { fill: var(--real); }
.mark.big { width: 46px; height: 46px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 264px 1fr; height: 100dvh; }
.app.side-closed { grid-template-columns: 0 1fr; }
.app.side-closed .sidebar { visibility: hidden; }

.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; overflow: hidden; padding: 10px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 16.5px; letter-spacing: -.01em; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.new-btn { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 560; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.new-btn:hover { border-color: var(--faint); }
.side-label { margin: 18px 8px 6px; font-size: 12px; font-weight: 600; color: var(--faint); letter-spacing: .02em; }
.history { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 0 -2px; padding: 0 2px; }
.h-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.h-item:hover { background: var(--raised); }
.h-item.on { background: var(--line); }
.history-empty { margin: 4px 10px; font-size: 13px; color: var(--faint); line-height: 1.45; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; display: flex; flex-direction: column; gap: 1px; }
.side-link { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 7px 10px; border-radius: 8px; color: var(--muted); font-size: 14px; text-align: left; }
.side-link:hover { background: var(--raised); color: var(--text); }
.scrim { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; position: relative; }
.topbar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; min-height: 56px; }
.app:not(.side-closed) #openSide { display: none; }
.topbar-spacer { flex: 1; }
.model-chip { display: inline-flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 7px 11px; border-radius: 10px; }
.model-chip:hover { background: var(--raised); }
.model-name { font-weight: 640; font-size: 15.5px; }
.model-sub { color: var(--muted); font-size: 13.5px; }
.model-pick { position: relative; }
.model-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 40; width: min(330px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 36px rgba(0,0,0,.16); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.model-opt { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 9px 11px; }
.model-opt:hover, .model-opt:focus-visible { background: var(--raised); outline: none; }
.opt-top { display: flex; align-items: center; gap: 8px; }
.opt-name { font-weight: 640; font-size: 14.5px; }
.opt-check { margin-left: auto; color: var(--accent); visibility: hidden; stroke-width: 2.4; }
.model-opt[aria-checked="true"] .opt-check { visibility: visible; }
.opt-desc { font-size: 12.5px; color: var(--muted); line-height: 1.4; padding-left: 16px; }
.model-how { display: flex; align-items: center; gap: 8px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; padding: 9px 11px 5px; margin-top: 4px; text-align: left; border-radius: 0 0 10px 10px; }
.model-how:hover, .model-how:focus-visible { color: var(--text); outline: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: #3aa76d; box-shadow: 0 0 0 3px rgba(58, 167, 109, .16); }
.dot.down { background: #d9822b; }

.scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }

/* ---------- welcome ---------- */
.welcome { max-width: 780px; margin: 0 auto; padding: 7vh 24px 24px; text-align: center; }
.welcome h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(28px, 4vw, 38px); letter-spacing: -.015em; line-height: 1.15; margin: 18px 0 12px; }
.lead { color: var(--muted); font-size: 16px; max-width: 600px; margin: 0 auto; }
.t-fake { color: var(--fake); font-weight: 560; }
.t-real { color: var(--real); font-weight: 560; }
.examples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 34px 0 30px; text-align: left; }
.ex { display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 10px; cursor: pointer; transition: border-color .15s, transform .15s, box-shadow .15s; text-align: left; }
.ex:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.ex img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 9px; background: var(--raised); }
.ex-src { font-size: 11.5px; color: var(--faint); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.ex-title { font-size: 14px; line-height: 1.4; font-weight: 560; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pillars { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; text-align: left; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.pillars strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }

/* ---------- thread ---------- */
.thread { max-width: 780px; margin: 0 auto; padding: 8px 24px 40px; }
.thread:empty { display: none; }
.msg { margin: 18px 0 30px; }
.user { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.user-img { max-width: 260px; max-height: 220px; border-radius: 12px; border: 1px solid var(--line); object-fit: cover; }
.bubble { background: var(--raised); border-radius: 18px 18px 6px 18px; padding: 12px 16px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }
.bubble.clamped { max-height: 12.2em; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent); mask-image: linear-gradient(to bottom, #000 62%, transparent); }
.more { border: 0; background: transparent; color: var(--muted); font-size: 13px; padding: 0 4px; }
.more:hover { color: var(--text); text-decoration: underline; }

.bot-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bot-name { font-weight: 640; }
.bot-tag { font-size: 12.5px; color: var(--faint); }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side { border-radius: var(--radius); border: 1px solid; padding: 14px 16px 15px; min-height: 116px; position: relative; }
.side.fake { background: var(--fake-bg); border-color: var(--fake-line); }
.side.real { background: var(--real-bg); border-color: var(--real-line); }
.side-h { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; letter-spacing: .01em; margin-bottom: 7px; }
.fake .side-h { color: var(--fake); }
.real .side-h { color: var(--real); }
.side-t { font-size: 15px; line-height: 1.62; white-space: pre-wrap; overflow-wrap: anywhere; }
.side.wait .side-t::after { content: ""; display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: currentColor; opacity: .55; animation: blink 1s steps(2) infinite; }
.side.idle .side-t { color: var(--faint); }
@keyframes blink { 50% { opacity: 0; } }
.skeleton { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.skeleton span { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--line) 0%, var(--raised) 50%, var(--line) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton span:nth-child(2) { width: 88%; }
.skeleton span:nth-child(3) { width: 64%; }
@keyframes shimmer { to { background-position: -200% 0; } }
.raw { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 8px; }
.act { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border: 0; background: transparent; color: var(--muted); padding: 6px 9px; border-radius: 8px; font-size: 13px; }
.act:hover { background: var(--raised); color: var(--text); }
.act:disabled { opacity: .4; cursor: default; background: transparent; }
.note { font-size: 12.5px; color: var(--faint); margin-left: auto; }
.err { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--fake-line); background: var(--fake-bg); color: var(--text); border-radius: 12px; padding: 11px 14px; font-size: 14px; }
.err .i { color: var(--fake); margin-top: 2px; }
.versions { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; color: var(--muted); font-size: 12.5px; }
.versions button { border: 0; background: transparent; color: var(--muted); border-radius: 6px; padding: 2px 6px; }
.versions button:hover:not(:disabled) { background: var(--raised); color: var(--text); }
.versions button:disabled { opacity: .35; cursor: default; }

/* ---------- composer ---------- */
.composer-wrap { padding: 6px 24px 10px; background: linear-gradient(to bottom, transparent, var(--bg) 22%); }
.composer { position: relative; max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 22px; box-shadow: var(--shadow); padding: 10px 10px 8px 14px; transition: border-color .15s; }
.composer:focus-within { border-color: var(--faint); }
.composer.drag { border-color: var(--accent); border-style: dashed; }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; padding: 6px 4px 4px; max-height: 38vh; min-height: 28px; line-height: 1.55; font-size: 15.5px; }
.composer textarea::placeholder { color: var(--faint); }
.tools { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.tool-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 5px 12px 5px 10px; font-size: 13.5px; }
.tool-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--raised); }
.tool-btn.has { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.count { margin-left: auto; font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.count.over { color: var(--fake); font-weight: 600; }
.send { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); transition: opacity .15s, transform .1s; }
.send:active { transform: scale(.95); }
.send:disabled { opacity: .25; cursor: default; }
.send .i { stroke-width: 2.2; }
.attach-row { padding: 2px 0 8px; }
.attach { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 6px 8px 6px 6px; background: var(--raised); max-width: 100%; }
.attach img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; }
.attach-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.attach-name { font-size: 13px; font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.attach-size { font-size: 12px; color: var(--faint); }
.attach-x { border: 0; background: var(--surface); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.attach-x:hover { color: var(--text); }
.drop-hint { display: none; position: absolute; inset: 0; border-radius: 22px; background: var(--accent-soft); color: var(--accent); font-weight: 600; place-items: center; }
.composer.drag .drop-hint { display: grid; }
.fineprint { max-width: 780px; margin: 7px auto 0; text-align: center; font-size: 12px; color: var(--faint); }

/* ---------- about ---------- */
.about { width: min(680px, calc(100vw - 32px)); max-height: min(86vh, 900px); border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.about::backdrop { background: rgba(20, 18, 14, .42); }
.about-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px 26px; background: var(--surface); }
.about-head h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 24px; }
.about-body { padding: 0 26px 24px; font-size: 14.5px; }
.about-body > p:first-child { margin-top: 0; color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 18px 0; display: flex; flex-direction: column; gap: 14px; }
.steps li { display: flex; gap: 14px; }
.step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13.5px; }
.steps h3 { margin: 2px 0 2px; font-size: 15px; }
.steps p { margin: 0; color: var(--muted); }
.about-h { font-size: 15px; margin: 22px 0 10px; }
.models { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
.steps .models li { display: list-item; margin: 5px 0; }
.models strong { color: var(--text); }
.limits { margin: 0; padding-left: 18px; color: var(--muted); }
.limits li { margin: 4px 0; }
.about-foot { margin: 18px 0 0; font-size: 12.5px; color: var(--faint); }

.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); z-index: 50; max-width: calc(100vw - 32px); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .app, .app.side-closed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 284px; z-index: 30; transform: translateX(-100%); transition: transform .2s; visibility: visible !important; }
  .app.side-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .app.side-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 20; }
  .app:not(.side-closed) #openSide, #openSide { display: inline-grid; }
  .examples, .pillars { grid-template-columns: 1fr; }
  .examples { gap: 8px; margin: 26px 0 24px; }
  .ex { flex-direction: row; align-items: center; }
  .ex img { width: 76px; aspect-ratio: 1; flex: none; }
  .sides { grid-template-columns: 1fr; }
  .welcome { padding: 4vh 16px 16px; }
  .thread { padding: 8px 16px 32px; }
  .composer-wrap { padding: 6px 12px 8px; }
  .model-sub { display: none; }
  .model-menu { position: fixed; top: 54px; left: 16px; right: 16px; width: auto; }
  .bubble { max-width: 94%; }
  .actions .note { display: none; }
  .act { padding: 6px 7px; }
}
