@font-face { font-family: 'Tutou Sans'; src: url('assets/noto-sans-regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Tutou Sans'; src: url('assets/noto-sans-bold.woff2') format('woff2'); font-weight: 600 700; font-display: swap; }

:root {
  --bg: #faf8f6; --panel: #ffffff; --side: #f4f0ed; --rail: #efe9e5; --line: #e7e0dc; --line-2: #d9d0cb;
  --text: #221f1f; --muted: #6b6264; --subtle: #8b8184; --accent: #cd2c39; --accent-2: #b3202d; --on-accent: #fff;
  --soft: #fbecee; --soft-line: #f0c6cc; --hover: #00000008; --active: #cd2c3914; --field: #fff;
  --code-bg: #f3eeeb; --code-line: #e6ddd8; --inline: #f1e8e6;
  --ok: #1f8a4c; --ok-bg: #e4f4ea; --warn: #9a6400; --warn-bg: #fff1cc; --err: #c42b3a; --err-bg: #fde8ea; --info: #3b5bab; --info-bg: #e8edfa;
  --diff-add: #e6f4ea; --diff-add-t: #1c6b3a; --diff-del: #fdecee; --diff-del-t: #a3212f;
  --shadow: 0 1px 2px #2a1d1f0d, 0 8px 28px #2a1d1f12; --shadow-lg: 0 20px 60px #2a1d1f2e;
  --fs: 17px; --radius: 14px; --side-w: 300px; --rail-w: 60px; --col: 820px;
  --font: 'Tutou Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', 'Noto Sans SC', sans-serif;
  --serif: ui-serif, 'Iowan Old Style', 'Palatino Linotype', Georgia, 'Songti SC', 'Noto Serif CJK SC', serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, 'Noto Sans Mono CJK SC', monospace;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #171415; --panel: #1f1b1c; --side: #1b1718; --rail: #141112; --line: #342d2f; --line-2: #473d40;
  --text: #f3eced; --muted: #b3a7aa; --subtle: #8f8386; --accent: #ff737d; --accent-2: #ff8e96; --on-accent: #2a0f13;
  --soft: #3a2027; --soft-line: #66343f; --hover: #ffffff0a; --active: #ff737d1f; --field: #1a1617;
  --code-bg: #120f10; --code-line: #2c2527; --inline: #33282b;
  --ok: #6fdc9d; --ok-bg: #173826; --warn: #f2c85c; --warn-bg: #3d3115; --err: #ff8f99; --err-bg: #46212a; --info: #9db4ff; --info-bg: #1f2944;
  --diff-add: #173822; --diff-add-t: #8fe0ab; --diff-del: #45202a; --diff-del-t: #ffa4ad;
  --shadow: 0 1px 2px #0006, 0 8px 28px #0005; --shadow-lg: 0 20px 60px #000a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-text-size-adjust: 100%; }
body { overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.ic { width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--active); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .3; } }
@keyframes fadein { from { opacity: 0; } }

/* ---------- start-up ---------- */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }
.boot img { border-radius: 16px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.94); opacity: .7; } }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-weight: 600; font-size: 14px; line-height: 1; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { background: var(--hover); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-2); }
.btn.primary.danger-fill { background: var(--err); border-color: var(--err); color: #fff; }
.btn.big { min-height: 50px; font-size: 16px; border-radius: 14px; width: 100%; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: .5; cursor: default; }
.btn .ic { width: 17px; height: 17px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; border: 0; background: transparent; color: var(--muted); flex: none; text-decoration: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; background: transparent; }
.icon-btn.soft { color: var(--muted); }
.icon-btn.on { color: var(--accent); background: var(--active); }
input[type=text], input[type=search], input[type=password], input:not([type]), textarea, select { background: var(--field); border: 1px solid var(--line); border-radius: 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--active); }
select { appearance: none; -webkit-appearance: none; padding: 0 30px 0 12px; min-height: 38px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }

/* ---------- sign-in ---------- */
.login { position: fixed; inset: 0; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); overflow: auto; }
.login-art { position: relative; overflow: hidden; background: linear-gradient(160deg, #2a0f14, #5b1520 55%, #cd2c39); display: flex; align-items: flex-end; padding: 56px; }
:root[data-theme="dark"] .login-art { background: linear-gradient(160deg, #0f0a0b, #3a1219 55%, #9e2330); }
.orb { position: absolute; border-radius: 50%; filter: blur(8px); opacity: .5; }
.o1 { width: 420px; height: 420px; right: -120px; top: -120px; background: radial-gradient(circle at 30% 30%, #ff8a93, transparent 70%); animation: float 12s ease-in-out infinite; }
.o2 { width: 300px; height: 300px; left: -80px; top: 30%; background: radial-gradient(circle at 50% 50%, #ffb0a0, transparent 70%); opacity: .25; animation: float 16s ease-in-out infinite reverse; }
@keyframes float { 50% { transform: translate(-30px, 30px) scale(1.05); } }
.login-quote { position: relative; color: #fff; max-width: 480px; }
.login-mark { display: block; border-radius: 14px; box-shadow: 0 10px 30px #0004; }
.login-quote p { font-family: var(--serif); font-size: 28px; line-height: 1.35; margin: 18px 0 0; }
.login-card { align-self: center; justify-self: center; width: min(420px, calc(100% - 40px)); padding: 40px 0; }
.login-brand { display: flex; gap: 14px; align-items: center; }
.login-brand img { border-radius: 14px; }
.login-brand b { display: block; font-size: 20px; }
.login-brand small { color: var(--muted); font-size: 13px; }
.login h1 { font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.2; margin: 34px 0 10px; letter-spacing: -.01em; }
.login-sub { color: var(--muted); line-height: 1.55; margin: 0 0 24px; font-size: 14.5px; }
.login .field { display: grid; gap: 7px; margin-bottom: 16px; }
.login .field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.login input { height: 50px; padding: 0 16px; font-size: 16px; color: var(--text); width: 100%; min-width: 0; }
.phone-row, .code-row { display: flex; gap: 8px; align-items: stretch; }
.phone-row .prefix { display: grid; place-items: center; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-weight: 600; color: var(--muted); }
.code-row input { letter-spacing: .3em; }
.code-row .btn { min-height: 50px; flex: none; min-width: 120px; }
.login-note { font-size: 12.5px; color: var(--subtle); margin: 12px 0 0; text-align: center; }
.local-box { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.local-box .ic-slot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--soft); color: var(--accent); flex: none; }
.local-box code { font-family: var(--mono); font-size: 16px; font-weight: 600; user-select: all; }
.form-error { color: var(--err); min-height: 22px; font-size: 14px; margin: 12px 0 0; line-height: 1.45; }
.login-prefs { display: flex; gap: 10px; margin-top: 18px; }
.login-prefs { align-items: center; flex-wrap: wrap; }
.login-prefs select { min-height: 36px; font-size: 13px; }

/* ---------- app layout ---------- */
.app { position: fixed; left: 0; right: 0; top: var(--vv-top, 0px); height: var(--app-h, 100dvh); display: flex; }
.app > .main { flex: 1; }
.rail { width: var(--rail-w); flex: none; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 12px 0 14px; gap: 6px; border-right: 1px solid var(--line); z-index: 5; }
.rail-logo img { border-radius: 10px; display: block; margin-bottom: 10px; }
.rail-nav { display: flex; flex-direction: column; gap: 6px; }
.rail-btn { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 13px; background: transparent; color: var(--muted); }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.on { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
.rail-btn .ic { width: 22px; height: 22px; }
.rail-btn[data-tip]:hover::after { content: attr(data-tip); position: absolute; left: 52px; top: 50%; transform: translateY(-50%); background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 8px; white-space: nowrap; pointer-events: none; z-index: 30; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.rail-me { border: 0; padding: 0; background: none; border-radius: 12px; }
.rail-me .uavatar { width: 36px; height: 36px; }
.badge-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px var(--rail); }

.sessions { position: relative; width: var(--side-w); flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding: 14px 12px 10px; gap: 10px; }
.app.side-collapsed .sessions { display: none; }
.app:not(.view-chat-on) .sessions { display: none; }
.sessions-head { display: flex; align-items: center; justify-content: space-between; min-height: 34px; padding: 0 4px; }
.brand-line { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.brand-line img { border-radius: 7px; }
.new-chat { justify-content: flex-start; background: var(--panel); box-shadow: var(--shadow); border-color: transparent; min-height: 44px; }
.new-chat .ic { color: var(--accent); width: 20px; height: 20px; }
.search-wrap { position: relative; }
.search-wrap .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--subtle); pointer-events: none; }
.search-wrap input { width: 100%; height: 38px; padding: 0 12px 0 36px; background: var(--panel); border-color: transparent; font-size: 14px; }
.session-list { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px 12px; overscroll-behavior: contain; }
.group-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); padding: 14px 8px 6px; }
.list-empty { padding: 24px 8px; color: var(--subtle); font-size: 13.5px; text-align: center; }
.srow { position: relative; display: grid; grid-template-columns: 14px 1fr auto; gap: 4px 9px; align-items: start; padding: 9px 10px; border-radius: 11px; color: var(--text); text-decoration: none; cursor: pointer; border: 1px solid transparent; }
.srow:hover { background: var(--hover); }
.srow.on { background: var(--panel); border-color: var(--line); box-shadow: var(--shadow); }
.srow .sdot { margin-top: 7px; }
.srow .stitle { font-size: 14px; font-weight: 500; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.srow .stime { font-size: 11.5px; color: var(--subtle); white-space: nowrap; margin-top: 2px; }
.srow .row-menu { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 8px; background: var(--panel); color: var(--muted); display: grid; place-items: center; opacity: 0; box-shadow: var(--shadow); }
.srow:hover .row-menu, .srow.on .row-menu, .srow .row-menu:focus-visible { opacity: 1; }
.srow .row-menu .ic { width: 17px; height: 17px; }
@media (hover: hover) { .srow:hover .stime, .srow.on .stime { visibility: hidden; } }
@media (hover: none) { .srow .row-menu { opacity: .9; background: transparent; box-shadow: none; } .srow .stime { margin-right: 26px; } }
.sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); flex: none; display: inline-block; }
.sdot.running { background: var(--ok); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .sdot.running, .o1, .o2, .boot img, .spark-sm { animation: none; } }
.sessions-foot { font-size: 12px; color: var(--subtle); padding: 6px 6px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; }
.resizer { position: absolute; top: 0; right: -4px; bottom: 0; width: 8px; cursor: col-resize; z-index: 4; }
.resizer:hover, .resizer.drag { background: linear-gradient(90deg, transparent 3px, var(--accent) 3px, var(--accent) 5px, transparent 5px); }
.scrim { position: fixed; inset: 0; background: #0006; z-index: 40; }

.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.topbar { position: relative; z-index: 20; display: flex; align-items: center; gap: 10px; min-height: 60px; padding: 8px 16px; padding-top: calc(8px + var(--safe-t)); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.title-block { min-width: 0; flex: 1; }
.title-block h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.005em; }
.subline { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 2px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.status-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 999px; background: var(--hover); color: var(--muted); }
.status-pill.running { background: var(--ok-bg); color: var(--ok); }
.conn-banner { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 6px 12px; padding-top: calc(6px + var(--safe-t)); background: var(--err-bg); color: var(--err); font-size: 13px; font-weight: 600; }
.conn-banner::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--err); animation: blink 1s infinite; }

/* ---------- chat ---------- */
.chat-body { flex: 1; display: flex; min-height: 0; }
.chat-col { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
.thread { width: min(var(--col), calc(100% - 32px)); margin: 0 auto; padding: 22px 0 28px; font-size: var(--fs); line-height: 1.65; }
.thread-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--subtle); font-size: 14px; padding: 40px 0; }
.msg { margin: 0 0 18px; position: relative; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .col { display: flex; flex-direction: column; align-items: flex-end; max-width: 100%; min-width: 0; }
.bubble { max-width: min(88%, 680px); background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 6px 18px; padding: 11px 16px; box-shadow: var(--shadow); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.bubble.clip { max-height: 320px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 75%, transparent); mask-image: linear-gradient(#000 75%, transparent); }
.bubble-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.bubble-imgs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.bubble-imgs:last-child { margin-bottom: 0; }
.bubble .fstrip { margin-top: 8px; white-space: normal; }
.user-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--subtle); min-height: 22px; }
.msg-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: .75; } }
.mini-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--subtle); }
.mini-btn:hover { background: var(--hover); color: var(--text); }
.mini-btn .ic { width: 16px; height: 16px; }
/* Retry belongs to the last finished reply only. */
.thread > .msg:not(:last-child) [data-act=retry], .msg.live [data-act=retry] { display: none; }

.msg-assistant { display: grid; grid-template-columns: 30px 1fr; gap: 12px; }
.avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--soft); color: var(--accent); margin-top: 2px; overflow: hidden; }
.avatar img { width: 100%; height: 100%; display: block; }
.a-body { min-width: 0; }
.a-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--subtle); margin-bottom: 2px; min-height: 22px; }
.a-head b { color: var(--text); font-size: 13px; }
.a-model { font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.a-head .msg-actions { margin-left: auto; }
.a-text > .card-note { margin-top: 8px; }
.a-wait { display: flex; gap: 5px; padding: 10px 0 4px; }
.a-wait span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .3; animation: dots 1.2s ease-in-out infinite; }
.a-wait span:nth-child(2) { animation-delay: .2s; } .a-wait span:nth-child(3) { animation-delay: .4s; }
@keyframes dots { 40% { opacity: 1; transform: translateY(-3px); } }
.md { word-break: break-word; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .8em; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; margin: 1.2em 0 .5em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.12em; } .md h4 { font-size: 1em; }
.md ul, .md ol { padding-left: 1.4em; margin: .4em 0 .9em; }
.md li { margin: .2em 0; }
.md li > p { margin: 0; }
.md blockquote { margin: .6em 0; padding: .2em 1em; border-left: 3px solid var(--soft-line); color: var(--muted); }
.md code { font-family: var(--mono); font-size: .86em; background: var(--inline); padding: .12em .4em; border-radius: 6px; }
.md pre { position: relative; background: var(--code-bg); border: 1px solid var(--code-line); border-radius: 12px; padding: 12px 14px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; margin: .6em 0 1em; }
.md pre code { background: none; padding: 0; font-size: inherit; white-space: pre; }
/* code blocks: a header with the language and a copy button, then the code */
.md .code-wrap { margin: .6em 0 1em; border: 1px solid var(--code-line); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.md .code-wrap pre { margin: 0; border: 0; border-radius: 0; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px 4px 14px; border-bottom: 1px solid var(--code-line); font-size: 12px; color: var(--muted); }
.code-lang { font-family: var(--mono); letter-spacing: .02em; text-transform: lowercase; }
.code-head .copy-code { display: inline-flex; align-items: center; gap: 5px; width: auto; height: 26px; padding: 0 8px; border-radius: 7px; font-size: 12px; color: var(--muted); }
.code-head .copy-code:hover { color: var(--text); background: var(--hover); }
.code-head .copy-code .ic { width: 14px; height: 14px; }
.code-head .copy-code.done { color: var(--ok); }
/* syntax colours (highlight.js classes), light and dark */
.md .hljs-keyword, .md .hljs-selector-tag, .md .hljs-meta .hljs-keyword, .md .hljs-doctag { color: #a626a4; }
.md .hljs-string, .md .hljs-regexp, .md .hljs-addition, .md .hljs-meta .hljs-string { color: #50a14f; }
.md .hljs-number, .md .hljs-literal, .md .hljs-symbol, .md .hljs-bullet { color: #b76b01; }
.md .hljs-title, .md .hljs-title.function_, .md .hljs-section { color: #4078f2; }
.md .hljs-title.class_, .md .hljs-type, .md .hljs-built_in { color: #c18401; }
.md .hljs-attr, .md .hljs-attribute, .md .hljs-variable, .md .hljs-template-variable, .md .hljs-selector-class, .md .hljs-selector-id { color: #986801; }
.md .hljs-comment, .md .hljs-quote { color: #8b8184; font-style: italic; }
.md .hljs-meta, .md .hljs-params { color: inherit; }
.md .hljs-name, .md .hljs-tag { color: #e45649; }
.md .hljs-deletion { color: #c42b3a; }
.md .hljs-emphasis { font-style: italic; } .md .hljs-strong { font-weight: 700; }
[data-theme=dark] .md .hljs-keyword, [data-theme=dark] .md .hljs-selector-tag, [data-theme=dark] .md .hljs-doctag { color: #d197e5; }
[data-theme=dark] .md .hljs-string, [data-theme=dark] .md .hljs-regexp, [data-theme=dark] .md .hljs-addition { color: #9ad08a; }
[data-theme=dark] .md .hljs-number, [data-theme=dark] .md .hljs-literal, [data-theme=dark] .md .hljs-symbol, [data-theme=dark] .md .hljs-bullet { color: #e8b26a; }
[data-theme=dark] .md .hljs-title, [data-theme=dark] .md .hljs-title.function_, [data-theme=dark] .md .hljs-section { color: #79b0ff; }
[data-theme=dark] .md .hljs-title.class_, [data-theme=dark] .md .hljs-type, [data-theme=dark] .md .hljs-built_in { color: #e6c07b; }
[data-theme=dark] .md .hljs-attr, [data-theme=dark] .md .hljs-attribute, [data-theme=dark] .md .hljs-variable, [data-theme=dark] .md .hljs-template-variable { color: #e5a46e; }
[data-theme=dark] .md .hljs-comment, [data-theme=dark] .md .hljs-quote { color: #8f8386; }
[data-theme=dark] .md .hljs-name, [data-theme=dark] .md .hljs-tag { color: #ff8e96; }
.md table { border-collapse: collapse; margin: .6em 0 1em; font-size: .92em; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--code-bg); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md a { word-break: break-all; }
.md img { max-width: 100%; border-radius: 10px; cursor: zoom-in; }
.streaming-caret::after { content: ''; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -2px; background: var(--accent); border-radius: 2px; animation: blink .9s steps(2) infinite; }
.path-link { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.md code.path-link:hover { color: var(--accent); }

/* tool steps */
.steps { margin: 6px 0 12px; border-left: 2px solid var(--line); }
.steps-head { width: 100%; max-width: 100%; min-width: 0; text-align: left; display: flex; align-items: center; gap: 8px; margin: 0 0 4px -2px; padding: 4px 8px; border: 0; background: none; color: var(--muted); font-size: 13px; font-weight: 600; border-radius: 8px; }
.steps-head:hover { color: var(--text); background: var(--hover); }
.steps-head .ic { width: 15px; height: 15px; transition: transform .15s; }
.steps.open > .steps-head .chev { transform: rotate(90deg); }
.steps:not(.open) > .steps-body { display: none; }
.steps.single { border-left: 0; }
.steps.single > .steps-head { display: none; }
.steps.single > .steps-body > .tool { margin-left: 0; }
.tool { margin: 2px 0 2px 12px; }
.tool-head { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px; padding: 5px 10px; border: 1px solid transparent; border-radius: 10px; background: none; text-align: left; font-size: 13.5px; color: var(--text); min-width: 0; }
.tool-head:hover { background: var(--hover); }
.tool.open > .tool-head { background: var(--panel); border-color: var(--line); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.tool-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--code-bg); color: var(--muted); flex: none; }
.tool-ic .ic { width: 15px; height: 15px; }
.tool.failed .tool-ic { background: var(--err-bg); color: var(--err); }
.tool-name { font-weight: 600; flex: none; }
.tool-sum { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.tool-state { flex: none; display: inline-flex; align-items: center; }
.tool-state .ok { color: var(--ok); } .tool-state .err { color: var(--err); }
.tool-state .ic { width: 16px; height: 16px; }
.tool-body { border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; background: var(--panel); padding: 10px 12px; font-size: 13px; }
.tool:not(.open) > .tool-body { display: none; }
.tool-body .label { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--subtle); margin: 8px 0 4px; }
.tool-body .label:first-child { margin-top: 0; }
.tool-body .label.with-copy { display: flex; align-items: center; justify-content: space-between; }
.tool-body .label .mini-btn { width: 24px; height: 24px; }
.tool-wait { display: flex; align-items: center; gap: 8px; color: var(--subtle); font-size: 12.5px; }
.pre { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: var(--code-bg); border: 1px solid var(--code-line); border-radius: 9px; padding: 9px 11px; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-height: 420px; overflow: auto; margin: 0; }
.pre.err { color: var(--err); }
.diff { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; border: 1px solid var(--code-line); border-radius: 9px; overflow: auto; max-height: 460px; background: var(--code-bg); }
.diff div { padding: 0 10px; white-space: pre-wrap; word-break: break-word; }
.diff .add { background: var(--diff-add); color: var(--diff-add-t); }
.diff .del { background: var(--diff-del); color: var(--diff-del-t); }
.diff .ctx-sep { color: var(--subtle); background: var(--hover); }
/* reasoning */
.thinking { margin: 4px 0 10px; }
.thinking > button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--subtle); font-size: 13px; padding: 3px 6px; border-radius: 7px; font-style: italic; }
.thinking > button:hover { background: var(--hover); color: var(--muted); }
.thinking .ic { width: 15px; height: 15px; }
.thinking .chev { transition: transform .15s; }
.thinking.open .chev { transform: rotate(180deg); }
.thinking.live > button .ic:first-child { color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.thinking .th-body { display: none; margin: 4px 0 0 6px; padding: 4px 0 4px 14px; border-left: 2px solid var(--line); color: var(--muted); font-size: .9em; white-space: pre-wrap; max-height: 50vh; overflow: auto; }
.thinking.open .th-body { display: block; }
.sysline { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--subtle); font-size: 12.5px; }
.sysline::before, .sysline::after { content: ''; flex: 1; border-top: 1px dashed var(--line-2); }
.sysline.plain { margin: 6px 0 10px; }
.sysline.plain::before, .sysline.plain::after { display: none; }
.sysline .ic { width: 15px; height: 15px; flex: none; }
.sysline span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-note { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--panel); font-size: 14px; margin: 0 0 16px; line-height: 1.5; }
.card-note.notice { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.card-note.error { background: var(--err-bg); border-color: transparent; color: var(--err); }
.card-note.error .err-line { display: flex; gap: 8px; align-items: flex-start; }
.card-note.error .err-line .ic { width: 17px; height: 17px; margin-top: 2px; }
.card-note.error .btn { margin-top: 8px; }
.card-note .pre { margin-top: 8px; color: var(--text); }
.err-detail summary { cursor: pointer; font-size: 12.5px; margin-top: 6px; }
.sys-note { background: var(--info-bg); color: var(--info); }
.sys-note summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.sys-note summary .ic { width: 16px; height: 16px; }
.turn-end { font-size: 12px; color: var(--subtle); margin: 4px 0 0; display: flex; gap: 6px; align-items: center; }
.turn-end .ic { width: 13px; height: 13px; }
/* files an answer or a message points to */
.fstrip { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.fchip { display: inline-flex; align-items: center; gap: 8px; max-width: 260px; min-height: 40px; padding: 6px 12px 6px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); font-size: 13px; text-align: left; box-shadow: var(--shadow); }
button.fchip:hover { border-color: var(--soft-line); background: var(--soft); }
.fchip .ic { width: 18px; height: 18px; color: var(--accent); }
.fchip .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fchip.thumb { flex-direction: column; align-items: stretch; padding: 4px; gap: 4px; width: 168px; }
.fchip.thumb img { width: 100%; height: 120px; object-fit: cover; border-radius: 9px; display: block; background: var(--code-bg); }
.fchip.thumb .fname { font-size: 12px; padding: 0 4px 2px; color: var(--muted); }
.fchip.missing { opacity: .5; text-decoration: line-through; box-shadow: none; cursor: default; }
.fchip.missing img { display: none; }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 60vh; padding: 20px 0; }
.empty-logo { border-radius: 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.empty h1 { font-family: var(--serif); font-weight: 500; font-size: 32px; margin: 0 0 10px; }
.empty p { color: var(--muted); max-width: 560px; margin: 0 0 26px; line-height: 1.6; font-size: 15.5px; }
.sugg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 640px; }
.sugg button { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 13px 15px; font-size: 14px; line-height: 1.45; color: var(--text); box-shadow: var(--shadow); }
.sugg button:hover { border-color: var(--soft-line); background: var(--soft); }

.jump { position: absolute; right: 22px; top: -52px; z-index: 6; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
.jump .ic { width: 16px; height: 16px; }

/* composer */
.composer-wrap { position: relative; padding: 0 16px calc(10px + var(--safe-b)); }
.composer, .requests, .activity, .disclaimer { width: min(var(--col), 100%); margin-left: auto; margin-right: auto; }
.activity { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); padding: 0 6px 8px; }
.spark-sm { width: 14px; height: 14px; flex: none; background: var(--accent); clip-path: polygon(50% 0, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0 50%, 39% 39%); animation: spin 2.4s linear infinite; }
.act-verb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.act-elapsed { font-family: var(--mono); font-size: 12px; color: var(--subtle); margin-left: auto; }
.composer { position: relative; background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px; box-shadow: var(--shadow); padding: 10px 10px 8px 14px; transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--active), var(--shadow); }
.composer textarea { display: block; width: 100%; border: 0; outline: none; background: transparent; box-shadow: none !important; resize: none; font-size: 16px; line-height: 1.5; padding: 4px 2px; min-height: 30px; max-height: 40vh; color: var(--text); }
.composer-bar { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.composer-bar .icon-btn.soft { width: 32px; height: 32px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.composer-bar .icon-btn.soft:hover { background: var(--hover); border-color: var(--line-2); color: var(--text); }
.composer-bar .icon-btn.soft .ic { width: 17px; height: 17px; }
.chips { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip-select { position: relative; display: inline-flex; align-items: center; flex: none; min-width: 0; max-width: 100%; }
.chip-select .chip-ic { position: absolute; left: 9px; pointer-events: none; color: var(--muted); display: grid; }
.chip-select .ic { width: 15px; height: 15px; }
.chip-select select { field-sizing: content; min-height: 32px; border-radius: 999px; font-size: 12.5px; font-weight: 600; padding-left: 29px; padding-right: 26px; background-color: var(--bg); border-color: var(--line); color: var(--muted); max-width: 230px; text-overflow: ellipsis; background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; }
.chip-select.hot select { color: var(--accent); border-color: var(--soft-line); background-color: var(--soft); }
.chip-select.hot .chip-ic { color: var(--accent); }
.voice-slot { display: contents; }
.send { width: 40px; height: 40px; border-radius: 13px; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; margin-left: auto; transition: transform .1s, background .15s; }
.send:hover { background: var(--accent-2); }
.send:disabled { background: var(--line-2); color: var(--panel); cursor: default; }
.send.stop { background: var(--text); color: var(--bg); }
.send .ic { width: 20px; height: 20px; }
.disclaimer { margin-top: 6px; margin-bottom: 0; text-align: center; font-size: 11.5px; color: var(--subtle); }
.attachments { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; }
.att { position: relative; flex: none; display: flex; align-items: center; gap: 8px; height: 58px; padding: 0 30px 0 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); max-width: 220px; cursor: pointer; }
.att > img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; flex: none; }
.att > span { min-width: 0; overflow: hidden; }
.att .att-name, .att .att-size { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.att .att-name { font-size: 12.5px; }
.att .att-size { font-size: 11px; color: var(--subtle); }
.att .file-ic { width: 40px; height: 40px; border-radius: 8px; background: var(--code-bg); display: grid; place-items: center; color: var(--muted); flex: none; }
.att .x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--text); color: var(--bg); display: grid; place-items: center; }
.att .x .ic { width: 12px; height: 12px; }
.att.busy { cursor: default; }
/* approval cards: long ones scroll in their own box (the chat column has a fixed height) */
.requests { display: grid; gap: 10px; margin-bottom: 10px; max-height: calc(var(--app-h, 100dvh) * .6); overflow-y: auto; overscroll-behavior: contain; border-radius: 16px; }
.requests:empty { display: none; }
.req { background: var(--panel); border: 1px solid var(--soft-line); border-radius: 16px; box-shadow: var(--shadow); padding: 14px 16px; animation: fadein .2s ease-out; }
.req h4 { margin: 0 0 6px; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.req h4 .ic { color: var(--warn); }
.req-desc { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.req .pre { max-height: 30vh; }
.req .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

/* ---------- files ---------- */
.path-bar { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.path-bar select { min-height: 36px; font-size: 13.5px; font-weight: 600; flex: none; max-width: 46%; }
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.crumbs::-webkit-scrollbar { display: none; }
.crumbs button { border: 0; background: none; padding: 5px 7px; border-radius: 8px; font-size: 13.5px; color: var(--muted); flex: none; }
.crumbs button:hover { background: var(--hover); color: var(--text); }
.crumbs button:last-child { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--subtle); }
.files-body { flex: 1; display: flex; min-height: 0; }
.files-body.drag { outline: 3px dashed var(--accent); outline-offset: -10px; background: var(--soft); }
.file-list { flex: 1; overflow-y: auto; padding: 8px 12px calc(20px + var(--safe-b)); min-width: 0; }
.frow { display: grid; grid-template-columns: 34px 1fr auto auto 32px; gap: 12px; align-items: center; padding: 7px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.frow:hover { background: var(--hover); }
.frow.on { background: var(--active); }
.frow .fic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--code-bg); color: var(--muted); }
.frow.dir .fic { background: var(--soft); color: var(--accent); }
.frow .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .fsize, .frow .fdate { font-size: 12px; color: var(--subtle); white-space: nowrap; }
.frow .fmenu { width: 32px; height: 32px; opacity: .6; }
.frow:hover .fmenu { opacity: 1; }
.file-preview { width: min(56%, 760px); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.fp-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.fp-head b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.fp-body { flex: 1; min-height: 0; overflow: auto; }
.fp-body textarea { width: 100%; height: 100%; border: 0; border-radius: 0; resize: none; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.55; background: var(--panel); box-shadow: none !important; white-space: pre; }
.fp-body textarea[wrap=soft] { white-space: pre-wrap; overflow-wrap: anywhere; }
.fp-body img, .fp-body video { max-width: 100%; display: block; margin: 12px auto; }
.fp-body img { cursor: zoom-in; }
.fp-body audio { width: calc(100% - 24px); margin: 30px 12px; }
.fp-empty { padding: 30px; color: var(--muted); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; line-height: 1.5; }
.fp-empty > .ic { width: 34px; height: 34px; color: var(--subtle); }
.fp-empty p { margin: 0; max-width: 420px; }

/* ---------- pages: settings, users ---------- */
.page { flex: 1; overflow-y: auto; padding: 20px 16px calc(30px + var(--safe-b)); }
.page-inner { width: min(820px, 100%); margin: 0 auto; display: grid; gap: 14px; }
.panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 6px 16px; }
.panel-card > .hint { margin: 10px 0 4px; }
.hint { color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.set-tabs { display: flex; width: 100%; overflow-x: auto; scrollbar-width: none; }
.set-tabs::-webkit-scrollbar { display: none; }
.set-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: 1 0 auto; white-space: nowrap; }
.set-tabs .ic { width: 16px; height: 16px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row > label { font-weight: 600; font-size: 14px; min-width: 0; }
.set-row small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-top: 2px; line-height: 1.45; }
.set-row select, .set-row input[type=text] { min-width: 160px; max-width: 100%; height: 38px; padding-left: 12px; }
.set-save { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.set-save small { margin-right: auto; color: var(--muted); font-size: 12.5px; }
.set-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--line); }
.inline-form { display: flex; gap: 8px; align-items: center; min-width: 0; }
.inline-form input { flex: 1; min-width: 0; }
textarea.soul { display: block; width: 100%; min-height: 46vh; margin: 8px 0 4px; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.55; resize: vertical; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 3px; flex: none; max-width: 100%; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--accent); box-shadow: var(--shadow); }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line-2); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px #0003; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: .45; cursor: default; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14px; margin: 12px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.avatar-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
/* user list (owner) */
.user-list { padding: 6px 16px; }
.urow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.urow:last-child { border-bottom: 0; }
.urow.off { opacity: .6; }
.u-main { flex: 1; min-width: 0; }
.u-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.u-name b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.u-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--subtle); margin-top: 3px; }
.u-meta span { display: inline-flex; align-items: center; gap: 4px; }
.u-meta .ic { width: 13px; height: 13px; }
.u-meta code { font-family: var(--mono); font-size: 12px; }
.badge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--soft); border: 1px solid var(--soft-line); padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.badge.off { color: var(--muted); background: var(--hover); border-color: var(--line); }

/* ---------- user photo ---------- */
.uavatar { width: 34px; height: 34px; border-radius: 30%; display: grid; place-items: center; background: var(--soft); color: var(--accent); font-weight: 700; font-size: 14px; flex: none; position: relative; --ring: 1.5px; }
.uavatar .ic { width: 58%; height: 58%; }
.uavatar.av-lg { width: 56px; height: 56px; font-size: 22px; --ring: 2px; }
.uavatar.av-img { background: transparent; }
.uavatar .av-clip { width: 100%; height: 100%; overflow: hidden; border-radius: inherit; }
.uavatar.av-img img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; -webkit-user-drag: none; }
.uavatar.sh-rounded { border-radius: 30%; }
.uavatar.sh-circle { border-radius: 50%; }
.uavatar.fr-brand { box-shadow: 0 0 0 var(--ring) var(--bg), 0 0 0 calc(var(--ring) * 2) var(--accent); }
.uavatar.fr-gold { box-shadow: 0 0 0 var(--ring) var(--bg), 0 0 0 calc(var(--ring) * 2) #d4a017; }
.uavatar.fr-dark { box-shadow: 0 0 0 var(--ring) var(--bg), 0 0 0 calc(var(--ring) * 2) #2b2527; }
:root[data-theme="dark"] .uavatar.fr-dark { box-shadow: 0 0 0 var(--ring) var(--bg), 0 0 0 calc(var(--ring) * 2) #e9e2e4; }
.uavatar.fr-glow { box-shadow: 0 0 0 var(--ring) var(--accent), 0 0 calc(var(--ring) * 6) calc(var(--ring) * 1.5) color-mix(in srgb, var(--accent) 50%, transparent); }
.uavatar.fr-rainbow { padding: calc(var(--ring) * 1.5); background: conic-gradient(#ef4148, #f59e0b, #eab308, #22c55e, #3b82f6, #a855f7, #ef4148); }
.uavatar.fr-rainbow .av-clip { box-shadow: 0 0 0 var(--ring) var(--bg); }
.av-editor { width: min(440px, 100%); }
.av-stage-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px 0 14px; }
.av-stage-wrap small { color: var(--subtle); font-size: 12px; text-align: center; }
.av-stage { width: 200px; height: 200px; display: grid; place-items: center; cursor: grab; touch-action: none; border-radius: 16px; background: repeating-conic-gradient(var(--code-bg) 0 25%, var(--panel) 0 50%) 0 0 / 16px 16px; }
.av-stage:active { cursor: grabbing; }
.uavatar.av-edit { width: 168px; height: 168px; --ring: 4px; }
.uavatar.av-mini { width: 30px; height: 30px; }
.av-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 14px; }
.av-row > span { width: 64px; flex: none; color: var(--muted); }
.av-row input[type=range] { flex: 1; accent-color: var(--accent); }
.av-row.col { flex-direction: column; align-items: stretch; }
.av-chips { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.av-chip { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.av-chip.on { border-color: var(--accent); color: var(--accent); background: var(--soft); }

/* ---------- menus, toasts, dialogs ---------- */
.pop-menu { position: fixed; z-index: 70; min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; }
.pop-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 9px; font-size: 14px; color: var(--text); }
.pop-menu button:hover { background: var(--hover); }
.pop-menu button.danger { color: var(--err); }
.pop-menu .ic { width: 18px; height: 18px; }
.pop-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
/* account menu: who is signed in, language, theme, settings, sign-out */
.acct-menu { width: 272px; }
.acct-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 6px; }
.acct-who { display: flex; flex-direction: column; min-width: 0; }
.acct-who b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-who small { font-size: 12px; color: var(--subtle); }
.acct-label { display: flex; align-items: center; gap: 6px; padding: 8px 10px 5px; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--subtle); }
.acct-label .ic { width: 14px; height: 14px; }
.acct-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 0 6px 6px; }
.pop-menu .acct-seg button { justify-content: center; padding: 8px 4px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.pop-menu .acct-seg button.on { border-color: var(--accent); background: var(--soft); color: var(--accent); }
#drawer-me .uavatar { width: 30px; height: 30px; font-size: 12px; }
.toast-host { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-b)); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); max-width: min(92vw, 520px); animation: tin .2s ease-out; }
.toast.err { background: var(--err); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
.modal-host { position: fixed; inset: 0; z-index: 97; background: #0007; display: grid; place-items: center; padding: 16px; animation: fadein .15s ease-out; }
.modal { background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg); width: min(460px, 100%); padding: 20px; max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 12px; font-family: var(--serif); font-weight: 600; font-size: 19px; line-height: 1.35; overflow-wrap: anywhere; }
.modal input { width: 100%; height: 44px; padding: 0 12px; font-size: 15px; }
.modal .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.drop-hint { position: fixed; inset: 12px; border: 3px dashed var(--accent); border-radius: 24px; background: color-mix(in srgb, var(--soft) 80%, transparent); z-index: 95; display: grid; place-items: center; font-size: 20px; font-weight: 600; color: var(--accent); pointer-events: none; }

/* ---------- viewer & image editor ---------- */
.mv-scrim { position: fixed; inset: 0; z-index: 94; background: #000a; display: flex; align-items: center; justify-content: center; padding: 16px; padding-top: calc(16px + var(--safe-t)); padding-bottom: calc(16px + var(--safe-b)); animation: fadein .15s ease-out; }
.mv { width: min(980px, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--panel); border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden; }
.mv-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.mv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mv-title b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-title small { font-family: var(--mono); font-size: 11.5px; color: var(--subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.mv-body { position: relative; flex: 1; min-height: 160px; overflow: auto; background: var(--panel); display: flex; flex-direction: column; }
.mv-img { flex: 1; display: grid; place-items: center; overflow: auto; background: #141112; }
.mv-img img { max-width: 100%; max-height: 72vh; object-fit: contain; cursor: zoom-in; display: block; }
.mv-img.zoom { place-items: start; }
.mv-img.zoom img { max-width: none; max-height: none; cursor: zoom-out; }
.mv-video { width: 100%; max-height: 62vh; background: #000; display: block; }
.mv-audio { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 36px 16px; color: var(--muted); }
.mv-audio .ic { width: 54px; height: 54px; opacity: .7; }
.mv-audio audio { width: min(520px, 100%); }
.mv-pdf { width: 100%; height: 70vh; border: 0; background: #fff; }
.mv-open { position: absolute; right: 10px; bottom: 10px; }
.mv-code { flex: 1; margin: 0; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 55vh; }
.mv-text { flex: 1; width: 100%; min-height: 55vh; border: 0; border-radius: 0; padding: 12px 14px; font-family: var(--mono); font-size: 13px; line-height: 1.55; background: var(--panel); color: var(--text); resize: none; box-shadow: none !important; }
.mv-md { flex: 1; min-height: 55vh; padding: 16px 18px 32px; color: var(--text); font-size: 15px; line-height: 1.6; overflow: auto; }
.mv-table { overflow: auto; min-height: 55vh; padding: 8px; }
.mv-table table { border-collapse: collapse; font-size: 13px; }
.mv-table th, .mv-table td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; white-space: nowrap; }
.mv-table th { background: var(--code-bg); position: sticky; top: 0; }
.mv-foot { padding: 7px 12px; font-size: 12px; color: var(--subtle); border-top: 1px solid var(--line); min-height: 18px; }
.ie { position: fixed; inset: 0; z-index: 96; background: #141112; color: #ece6e7; display: flex; flex-direction: column; padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
.ie-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.ie-head b { flex: 1; font-size: 15px; }
.ie-head .icon-btn { color: #ece6e7; }
.ie-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 8px; }
.ie-canvas { max-width: 100%; max-height: 100%; touch-action: none; background: repeating-conic-gradient(#2a2425 0 25%, #1f1b1c 0 50%) 0 0 / 16px 16px; }
.ie-crop { position: absolute; border: 2px dashed #fff; box-shadow: 0 0 0 9999px #0008; pointer-events: none; }
.ie-textin { position: absolute; min-width: 140px; height: 36px; padding: 0 10px; font-size: 16px; background: #fff; color: #111; border-radius: 8px; border: 2px solid var(--accent); z-index: 2; }
.ie-panel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 12px; min-height: 44px; font-size: 13px; }
.ie-panel label { display: inline-flex; align-items: center; gap: 6px; }
.ie-panel input[type=range] { width: 120px; accent-color: #ff737d; }
.ie-hint { color: #b9aeb1; font-size: 12.5px; }
.ie-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.ie-chips button { border: 1px solid #473d40; background: #1f1b1c; color: #ece6e7; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.ie-chips button.on { border-color: #ff737d; color: #ff737d; }
.ie-colors { display: flex; gap: 8px; }
.ie-colors button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #473d40; }
.ie-colors button.on { border-color: #fff; box-shadow: 0 0 0 2px #ff737d; }
.ie-tools { display: flex; gap: 4px; overflow-x: auto; padding: 8px; border-top: 1px solid #342d2f; scrollbar-width: none; }
.ie-tools::-webkit-scrollbar { display: none; }
.ie-tools button { flex: 1 0 auto; min-width: 62px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; color: #b9aeb1; padding: 6px 8px; border-radius: 10px; font-size: 11.5px; }
.ie-tools button .ic { width: 20px; height: 20px; }
.ie-tools button.on { color: #ff737d; background: #ff737d1f; }

/* ---------- phones ---------- */
.tabbar { display: none; }
.only-mobile { display: none; }
.head-tools { display: none; align-items: center; gap: 2px; }
button, a, .srow, .tool-head, .steps-head, .frow { touch-action: manipulation; }
@media (min-width: 901px) { #sessions-close { display: none; } }
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .rail { display: none; }
  .sessions { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; width: min(340px, 88vw); box-shadow: var(--shadow-lg); padding-top: calc(14px + var(--safe-t)); transform: translateX(-102%); transition: transform .22s ease; display: flex !important; }
  .app.side-open .sessions { transform: none; }
  .resizer { display: none; }
  .only-mobile { display: inline-grid; }
  .head-tools.only-mobile-flex { display: flex; }
  .sessions-head { gap: 6px; }
  .main { min-height: 0; }
  .tabbar { flex: none; display: grid; grid-template-columns: repeat(var(--tabs, 3), 1fr); background: var(--panel); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 10; }
  .app.kb-open .tabbar { display: none; }
  .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; height: 56px; border: 0; background: none; color: var(--subtle); font-size: 11px; font-weight: 600; position: relative; }
  .tabbar button.on { color: var(--accent); }
  .tabbar .ic { width: 22px; height: 22px; }
  .tabbar .badge-dot { top: 8px; right: calc(50% - 18px); box-shadow: 0 0 0 2px var(--panel); }
  .topbar { min-height: 54px; padding: 6px 8px; padding-top: calc(6px + var(--safe-t)); gap: 6px; }
  .main:has(.conn-banner:not([hidden])) .topbar { padding-top: 6px; }
  .title-block h2 { font-size: 17px; }
  .thread { width: calc(100% - 24px); padding-top: 14px; }
  .msg-assistant { grid-template-columns: 1fr; gap: 4px; }
  .msg-assistant .avatar { display: none; }
  .tool { margin-left: 8px; }
  .bubble { max-width: 92%; }
  .composer-wrap { padding: 0 8px 6px; }
  .composer { border-radius: 18px; padding: 8px 8px 6px 12px; }
  .chip-select select { max-width: min(230px, calc(100vw - 140px)); }
  .disclaimer { display: none; }
  .jump { right: 14px; }
  .sugg { grid-template-columns: 1fr; }
  .empty { min-height: 0; padding-top: 18px; }
  .empty-logo { width: 52px; height: 52px; margin-bottom: 12px; }
  .empty h1 { font-size: 24px; }
  .empty p { font-size: 14.5px; margin-bottom: 16px; }
  .sugg button { padding: 10px 13px; font-size: 14px; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login h1 { font-size: 28px; margin: 26px 0 8px; }
  .file-preview { position: fixed; inset: 0; width: auto; z-index: 60; border-left: 0; padding-top: var(--safe-t); padding-bottom: var(--safe-b); }
  .frow { grid-template-columns: 34px 1fr auto 32px; gap: 10px; }
  .frow .fdate { display: none; }
  .path-bar select { max-width: 55%; }
  #files-up, #files-refresh { display: none; } /* the crumbs go up; opening a folder reloads it */
  #files-upload span { display: none; }
  #files-upload { padding: 0 9px; }
  .status-pill .txt { display: none; }
  .toast-host { bottom: calc(130px + var(--safe-b)); }
  .set-row { flex-wrap: wrap; }
  .set-row > label { flex: 1 1 100%; }
  .set-row select, .set-row .inline-form { flex: 1; min-width: 0; }
  .set-tabs button span { font-size: 12.5px; }
  .set-tabs button { padding: 6px 9px; }
  .kv dd { white-space: normal; overflow-wrap: anywhere; }
  .av-chips { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .urow { flex-wrap: wrap; }
  .mv-scrim { padding: 0; }
  .mv { border-radius: 0; height: 100%; }
  .mv-img img { max-height: 70vh; }
  /* no focus zoom on phones */
  input:not([type=checkbox]):not([type=range]), textarea, select { font-size: 16px !important; }
}
@supports (-webkit-touch-callout: none) { input, textarea, select { font-size: 16px !important; } }
@media (max-width: 380px) {
  .code-row .btn { min-width: 0; padding: 0 12px; }
  .phone-row .prefix { padding: 0 10px; }
}
/* short screens (a phone in landscape): the space goes to the conversation */
@media (max-height: 520px) and (max-width: 1100px) {
  .tabbar button { height: 40px; }
  .tabbar button span { display: none; }
  .tabbar .badge-dot { top: 6px; }
  .topbar { min-height: 44px; padding-top: calc(4px + var(--safe-t)); padding-bottom: 4px; }
  .topbar .subline { display: none; }
  .title-block h2 { font-size: 15.5px; }
  .activity { padding-bottom: 4px; }
  .composer { padding: 6px 8px 4px 10px; }
  .composer textarea { max-height: 22vh; min-height: 26px; }
  .composer-bar { margin-top: 2px; }
  .composer .icon-btn, .send { width: 34px; height: 34px; }
  .chip-select select { min-height: 30px; }
  .disclaimer { display: none; }
  .jump { top: -44px; }
}

/* Voice calls in the chat: what was said (a block per stretch of talk) and the tasks the rabbit handed over */
.voice-block { margin: 0 0 18px; padding: 10px 14px 12px; border: 1px dashed var(--soft-line); border-radius: 14px; background: color-mix(in srgb, var(--soft) 55%, transparent); font-size: 15px; line-height: 1.55; }
.vb-head { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 4px; }
.vb-head .ic { width: 16px; height: 16px; }
.vb-head .ts { margin-left: auto; font-weight: 400; color: var(--subtle); }
.vb-line { display: flex; gap: 10px; padding: 2px 0; }
.vb-line b { flex: none; min-width: 3.4em; font-weight: 600; font-size: 13px; color: var(--muted); padding-top: 2px; }
.vb-line.rabbit b { color: var(--accent); }
.vb-line span { white-space: pre-wrap; word-break: break-word; min-width: 0; }
.utag-voice { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 4px; white-space: normal; }
.utag-voice .ic { width: 14px; height: 14px; }
.uvoice-ctx { margin-top: 6px; font-size: 13px; color: var(--muted); white-space: normal; }
.uvoice-ctx summary { cursor: pointer; width: fit-content; }
.uvoice-lines { white-space: pre-wrap; margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--line-2); }
.srow.live .stitle { font-weight: 600; }
