:root {
  --bg: #faf9f5;
  --sidebar: #f3f1ea;
  --panel: #ffffff;
  --text: #1f1e1d;
  --muted: #74716a;
  --faint: #a19e95;
  --border: #e5e2d8;
  --border-strong: #d6d2c5;
  --accent: #c96442;
  --accent-hover: #b4552f;
  --accent-text: #ffffff;
  --user-bubble: #f0eee6;
  --code-bg: #f5f3ec;
  --hover: rgba(31, 30, 29, 0.055);
  --active: rgba(31, 30, 29, 0.09);
  --danger: #b42318;
  --danger-bg: #fdf0ee;
  --ok: #2f7d4f;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 18px rgba(0,0,0,.06);
  --shadow-pop: 0 8px 30px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.08);
  --radius: 14px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262624; --sidebar: #1f1e1d; --panel: #30302e; --text: #ece9e1; --muted: #a4a197; --faint: #77756e;
    --border: #3a3936; --border-strong: #4a4945; --accent: #d97757; --accent-hover: #e08a6c;
    --user-bubble: #141413; --code-bg: #1d1d1b; --hover: rgba(255,255,255,.06); --active: rgba(255,255,255,.1);
    --danger: #f2877a; --danger-bg: #3a2522; --ok: #6fc28f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 18px rgba(0,0,0,.25);
    --shadow-pop: 0 10px 34px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #262624; --sidebar: #1f1e1d; --panel: #30302e; --text: #ece9e1; --muted: #a4a197; --faint: #77756e;
  --border: #3a3936; --border-strong: #4a4945; --accent: #d97757; --accent-hover: #e08a6c;
  --user-bubble: #141413; --code-bg: #1d1d1b; --hover: rgba(255,255,255,.06); --active: rgba(255,255,255,.1);
  --danger: #f2877a; --danger-bg: #3a2522; --ok: #6fc28f;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 18px rgba(0,0,0,.25);
  --shadow-pop: 0 10px 34px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- avatars */
.avatar {
  display: inline-grid; place-items: center; border-radius: 50%; color: #fff; font-weight: 600;
  width: 30px; height: 30px; font-size: 13px; flex: none; letter-spacing: .02em;
}
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.agent-dot { width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; }

/* ---------- login */
.login {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px;
}
.login h1 { font-family: var(--serif); font-weight: 400; font-size: 38px; margin: 0 0 6px; letter-spacing: -.01em; text-align: center; }
.login p.sub { color: var(--muted); margin: 0 0 34px; text-align: center; }
.login-users { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.login-user {
  width: 190px; padding: 26px 16px 22px; border-radius: 18px; background: var(--panel); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
}
.login-user:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.login-user.sel { border-color: var(--accent); }
.login-user .nm { font-weight: 600; font-size: 17px; }
.login-form { margin-top: 26px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.field {
  width: 100%; padding: 11px 14px; border-radius: 11px; border: 1px solid var(--border-strong); background: var(--panel); outline: none;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--panel); font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
a.btn { text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.small { padding: 5px 11px; font-size: 13.5px; border-radius: 8px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }

/* ---------- layout */
.layout { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar {
  width: 272px; flex: none; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; transition: margin-left .2s;
}
.layout.collapsed .sidebar { margin-left: -272px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 16px; }
.brand { font-family: var(--serif); font-size: 19px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand img { width: 24px; height: 24px; border-radius: 7px; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.mic.on { background: var(--danger); color: #fff; animation: mic-pulse 1.4s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 45%, transparent); } 50% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .icon-btn.mic.on { animation: none; } }
.new-chat {
  margin: 6px 10px 6px; padding: 9px 12px; border-radius: 10px; display: flex; align-items: center; gap: 10px; font-weight: 500;
}
.new-chat:hover { background: var(--hover); }
.new-chat .plus { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.new-chat .plus svg { width: 15px; height: 15px; stroke-width: 2.4; }
.tabs { display: flex; gap: 4px; margin: 6px 10px 4px; padding: 3px; border-radius: 10px; background: var(--hover); }
.tab { flex: 1; padding: 5px 8px; border-radius: 8px; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; min-height: 0; }
.group-label { font-size: 12px; color: var(--faint); padding: 14px 10px 4px; font-weight: 500; }
.chat-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 9px; font-size: 14px;
  position: relative;
}
.chat-item:hover { background: var(--hover); }
.chat-item.on { background: var(--active); }
.chat-item .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .mini-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chat-item .menu-btn { opacity: 0; width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); }
.chat-item:hover .menu-btn, .chat-item.on .menu-btn { opacity: 1; }
.chat-item .menu-btn:hover { background: var(--active); }
.chat-item .menu-btn svg { width: 16px; height: 16px; }
.empty-list { color: var(--faint); font-size: 13.5px; padding: 18px 12px; text-align: center; }
.spinner {
  width: 13px; height: 13px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }
.side-bottom { border-top: 1px solid var(--border); padding: 10px; }
.me-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 10px; text-align: left; }
.me-btn:hover { background: var(--hover); }
.me-btn .nm { font-weight: 500; flex: 1; }
.me-btn .sub { font-size: 12px; color: var(--faint); }

/* ---------- main */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 54px; }
.topbar .title {
  font-weight: 500; padding: 5px 9px; border-radius: 8px; max-width: min(520px, 60vw); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; text-align: left;
}
.topbar .title.editable:hover { background: var(--hover); }
.topbar .spacer { flex: 1; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); border: 1px solid var(--border);
  padding: 3px 9px 3px 4px; border-radius: 999px; white-space: nowrap;
}
.badge .agent-dot { width: 18px; height: 18px; border-radius: 6px; font-size: 10px; }
.scroller { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: auto; }
.thread { max-width: 780px; margin: 0 auto; padding: 8px 20px 40px; }

.hero { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 16px 8vh; }
.hero h2 {
  font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 4vw, 40px); margin: 0 0 26px; text-align: center;
  display: flex; align-items: center; gap: 14px; letter-spacing: -.01em;
}
.hero h2 .star { color: var(--accent); font-size: .9em; }
.hero .composer-wrap { width: 100%; max-width: 960px; padding: 0; }
.suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; max-width: 720px; }
.suggest button {
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 12px; font-size: 13.5px; color: var(--muted); background: var(--bg);
}
.suggest button:hover { background: var(--hover); color: var(--text); }

/* ---------- messages */
.msg { margin: 22px 0; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  background: var(--user-bubble); padding: 10px 16px; border-radius: 18px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg.user .who { font-size: 12px; color: var(--faint); margin: 0 6px 4px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; max-width: 85%; }
.file-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel); font-size: 13px; max-width: 260px;
}
.file-chip .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip .sz { color: var(--faint); font-size: 12px; flex: none; }
.file-chip svg { width: 15px; height: 15px; color: var(--muted); }
.file-chip .x { color: var(--muted); border-radius: 5px; width: 18px; height: 18px; display: grid; place-items: center; }
.file-chip .x:hover { background: var(--hover); color: var(--text); }
.file-chip .bar { height: 3px; background: var(--accent); border-radius: 2px; transition: width .2s; }
.file-chip.up { flex-direction: column; align-items: stretch; gap: 4px; min-width: 150px; }
.file-chip.fail { border-color: var(--danger); color: var(--danger); }

.msg.assistant .head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.msg.assistant .head .nm { font-weight: 600; color: var(--text); }
.md { 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: 500; line-height: 1.3; margin: 1.1em 0 .45em; }
.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: 0 0 .8em; }
.md li { margin: .2em 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--code-bg); border: 1px solid var(--border); padding: .08em .35em; border-radius: 5px; }
.md pre { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow-x: auto; margin: 0 0 .9em; }
.md pre code { background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.5; }
.md pre .copy {
  position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--panel);
  border: 1px solid var(--border); color: var(--muted); opacity: 0; transition: opacity .15s;
}
.md pre:hover .copy { opacity: 1; }
.md table { border-collapse: collapse; margin: 0 0 1em; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--code-bg); font-weight: 600; }
.md blockquote { margin: 0 0 .8em; padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.2em 0; }
.md.streaming > :last-child::after {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 5px; border-radius: 50%; background: var(--accent);
  vertical-align: middle; animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .25; } }

.steps { margin: 8px 0 12px; border-left: 2px solid var(--border); padding-left: 12px; display: flex; flex-direction: column; gap: 2px; }
.step > summary {
  list-style: none; display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 8px; margin-left: -8px; border-radius: 8px;
  font-size: 13.5px; color: var(--muted); min-width: 0;
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { background: var(--hover); color: var(--text); }
.step .st { width: 16px; height: 16px; display: grid; place-items: center; flex: none; }
.step .st svg { width: 15px; height: 15px; stroke-width: 2.2; }
.step .st.done { color: var(--ok); } .step .st.error { color: var(--danger); }
.step .lbl { flex: none; font-weight: 500; color: var(--text); }
.step .det { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.step .chev { margin-left: auto; flex: none; transition: transform .15s; opacity: .6; }
.step[open] .chev { transform: rotate(90deg); }
.step .body { margin: 4px 0 10px; }
.step pre {
  margin: 0 0 6px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-family: var(--mono);
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto;
}
.step .cap { font-size: 11.5px; color: var(--faint); margin: 6px 0 3px; text-transform: uppercase; letter-spacing: .04em; }
.thinking { font-style: italic; color: var(--muted); }
.todo { list-style: none; padding: 0; margin: 6px 0 12px; font-size: 14px; }
.todo li { display: flex; gap: 8px; align-items: baseline; padding: 2px 0; }
.todo li.done { color: var(--faint); text-decoration: line-through; }
.errbox {
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-bg); color: var(--danger);
  border-radius: 11px; padding: 10px 14px; margin: 8px 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.errbox .btn { margin-top: 8px; }
.msg-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--faint); font-size: 12.5px; min-height: 28px; }
.msg-foot .icon-btn { width: 28px; height: 28px; }
.msg-foot .icon-btn svg { width: 16px; height: 16px; }
.working { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: 14px; margin-top: 4px; }
.working .dots span { display: inline-block; width: 5px; height: 5px; margin-right: 3px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
.working .dots span:nth-child(2) { animation-delay: .2s; } .working .dots span:nth-child(3) { animation-delay: .4s; }

/* ---------- composer */
.composer-wrap { padding: 0 20px 18px; }
.composer-wrap.docked { max-width: 1000px; margin: 0 auto; width: 100%; }
.composer {
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 20px; box-shadow: var(--shadow);
  padding: 12px 12px 10px 16px; transition: border-color .15s, box-shadow .15s; position: relative;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--text) 30%, var(--border-strong)); }
.composer.drag { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.composer .atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.composer textarea {
  width: 100%; border: 0; outline: none; resize: none; background: transparent; min-height: 26px; max-height: 280px;
  line-height: 1.5; padding: 2px 0; display: block;
}
.composer textarea::placeholder { color: var(--faint); }
.cbar { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.cbar .grow { flex: 1; }
.pill {
  min-width: 0; flex: 0 1 auto;
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 6px; border-radius: 10px; font-size: 13.5px; color: var(--muted);
  max-width: 300px; white-space: nowrap;
}
.pill:hover { background: var(--hover); color: var(--text); }
.pill .agent-dot { width: 20px; height: 20px; border-radius: 6px; font-size: 10px; }
.pill .lbl { overflow: hidden; text-overflow: ellipsis; }
.pill.locked { cursor: default; }
.pill.locked:hover { background: none; color: var(--muted); }
.pill.plain { padding-left: 10px; }
.send {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none;
}
.send:hover { background: var(--accent-hover); }
.send:disabled { opacity: .4; cursor: default; }
.send svg { width: 18px; height: 18px; stroke-width: 2.3; }
.send.stop { background: var(--text); color: var(--bg); }
.send.stop svg { fill: currentColor; stroke: none; width: 12px; height: 12px; }
.hint { text-align: center; font-size: 12px; color: var(--faint); margin-top: 8px; }
.readonly-note {
  max-width: 780px; margin: 0 auto 18px; padding: 12px 16px; border-radius: 14px; border: 1px dashed var(--border-strong); color: var(--muted);
  text-align: center; font-size: 14px; width: calc(100% - 40px);
}

/* ---------- popovers & menus */
.pop {
  position: fixed; z-index: 50; background: var(--panel); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow-pop);
  padding: 6px; min-width: 220px; max-width: 320px; max-height: 70vh; overflow-y: auto; animation: popin .12s ease-out;
}
@keyframes popin { from { opacity: 0; transform: translateY(4px); } }
.pop .sec { font-size: 12px; color: var(--faint); padding: 8px 10px 3px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.pop .item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 8px; text-align: left; font-size: 14px;
}
.pop .item:hover { background: var(--hover); }
.pop .item .check { margin-left: auto; color: var(--accent); }
.pop .item.danger { color: var(--danger); }
.pop .sep { height: 1px; background: var(--border); margin: 5px 4px; }
.pop .note { font-size: 12px; color: var(--faint); padding: 4px 10px 6px; }

/* ---------- modals */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(20, 20, 19, .45); display: grid; place-items: center; padding: 16px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-pop); width: 100%; max-width: 620px;
  max-height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden;
}
.modal.wide { max-width: 980px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.modal-head h3 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 21px; flex: 1; }
.modal-body { padding: 4px 18px 18px; overflow-y: auto; }
.prov-card { border: 1px solid var(--border); border-radius: 14px; background: var(--panel); margin-bottom: 14px; overflow: hidden; }
.prov-card .ph { display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-weight: 600; border-bottom: 1px solid var(--border); }
.acc-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.acc-row:last-child { border-bottom: 0; }
.acc-row .an { font-weight: 500; }
.acc-row .as { font-size: 12.5px; color: var(--faint); flex: 1; min-width: 120px; }
.acc-row .as.ok { color: var(--ok); }
.acc-row .as.no { color: var(--danger); }
.acc-add { display: flex; gap: 8px; padding: 10px 14px; background: var(--bg); }
.acc-add .field { padding: 7px 11px; font-size: 14px; }
.help { font-size: 13.5px; color: var(--muted); margin: 0 0 14px; }
.term-box { background: #1a1a18; border-radius: 12px; padding: 8px; height: min(62vh, 560px); }
.term-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; align-items: center; font-size: 13px; }
.term-links .lnk {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 4px 6px 4px 10px;
  background: var(--panel);
}
.term-links .lnk span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; font-family: var(--mono); font-size: 12px; }
.journal { font-family: var(--mono); font-size: 12.5px; line-height: 1.6; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.journal div { padding: 2px 0; border-bottom: 1px dashed var(--border); white-space: pre-wrap; overflow-wrap: anywhere; }
.journal div:last-child { border-bottom: 0; }
.journal .who { color: var(--accent); font-weight: 600; }
.journal .when { color: var(--faint); }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px;
  border-radius: 10px; z-index: 80; font-size: 14px; box-shadow: var(--shadow-pop); animation: popin .15s;
}
.drop-hint {
  position: absolute; inset: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 82%, transparent); display: grid; place-items: center;
  border: 2px dashed var(--accent); border-radius: 18px; margin: 10px; font-size: 18px; color: var(--accent); pointer-events: none;
}

/* ---------- mobile */
.only-mobile { display: none; }
@media (max-width: 820px) {
  .only-mobile { display: inline-grid; }
  .sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; margin-left: -280px; box-shadow: var(--shadow-pop); }
  .layout.side-open .sidebar { margin-left: 0; }
  .layout.collapsed .sidebar { margin-left: -280px; }
  .layout.side-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
  .thread { padding: 6px 14px 30px; }
  .composer-wrap { padding: 0 10px 12px; }
  .bubble { max-width: 92%; }
  .hide-mobile { display: none !important; }
  .term-box { height: 55vh; }
}

/* ---------- approvals & autonomy */
.pending-dot {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; flex: none; animation: pulse 1.4s ease-in-out infinite;
}
.approval {
  border: 1px solid var(--border-strong); background: var(--panel); border-radius: 14px; padding: 12px 14px; margin: 10px 0 12px;
  box-shadow: var(--shadow);
}
.approval.danger { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.approval.change { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.ap-head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.ap-head svg { color: var(--accent); }
.approval.danger .ap-head svg { color: var(--danger); }
.ap-t { flex: 1; }
.ap-what { font-size: 13.5px; color: var(--muted); margin: 4px 0 8px; }
.approval pre {
  margin: 0 0 10px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-family: var(--mono);
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-height: 280px; overflow: auto;
}
.ap-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.risk { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; flex: none; }
.risk.danger { background: var(--danger-bg); color: var(--danger); }
.risk.change { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.risk.read, .risk.internal { background: var(--hover); color: var(--muted); }
.step .risk { margin-left: 2px; }
.pill.auto-0 svg, .pill.auto-1 svg { color: var(--ok); }
.pill.auto-2 svg { color: var(--accent); }
.pill.auto-3 svg { color: var(--danger); }
.auto-box { padding: 8px 10px 6px; width: 300px; max-width: calc(100vw - 40px); }
.auto-range { width: 100%; accent-color: var(--accent); margin: 4px 0 2px; }
.auto-ticks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 10px; }
.auto-ticks button { font-size: 11px; color: var(--faint); padding: 3px 2px; border-radius: 6px; line-height: 1.2; }
.auto-ticks button:hover { background: var(--hover); color: var(--text); }
.auto-ticks button.on { color: var(--text); font-weight: 600; }
.auto-title { font-weight: 600; margin-bottom: 4px; }
.auto-title.auto-0, .auto-title.auto-1 { color: var(--ok); }
.auto-title.auto-2 { color: var(--accent); }
.auto-title.auto-3 { color: var(--danger); }
.auto-desc { font-size: 13px; color: var(--muted); line-height: 1.45; }

/* ---------- model & effort picker */
.pop .sec.sub { padding-top: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.pop .mi { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.pop .mi .md2 { font-size: 12px; color: var(--faint); }
.effort-row { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 8px 6px; }
.effort-row .eff { font-size: 12.5px; padding: 4px 9px; border-radius: 8px; border: 1px solid var(--border); color: var(--muted); }
.effort-row .eff:hover { background: var(--hover); color: var(--text); }
.effort-row .eff.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pop { max-width: 340px; }
@media (max-width: 820px) {
  .cbar { flex-wrap: wrap; }
  .cbar .pill { max-width: 46vw; }
}

/* ---------- Discord: идеи и вопросы игроков ---------- */
.side-nav { display: flex; flex-direction: column; gap: 1px; margin: 0 10px 6px; }
.nav-btn { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 10px; font-size: 14px; color: var(--text); text-align: left; }
.nav-btn:hover { background: var(--hover); }
.nav-btn svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.nav-btn .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-btn .count, .comm-tabs .n {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-text);
  font-size: 11.5px; font-weight: 600; display: inline-grid; place-items: center;
}
.comm-tabs .n { margin-left: 6px; height: 18px; min-width: 18px; background: var(--border-strong); color: var(--text); }
.comm-head { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-bottom: 8px; }
.comm-status { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; background: var(--panel); }
.comm-status .row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px; }
.comm-status .err { margin-top: 6px; min-height: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comm-status .grow, .q-toolbar .grow { flex: 1; }
.st { display: inline-flex; align-items: center; gap: 6px; }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.st.ok::before { background: var(--ok); }
.st.warn::before { background: var(--accent); }
.st.bad { color: var(--danger); }
.st.bad::before { background: var(--danger); }
.usage { color: var(--muted); font-size: 12.5px; cursor: help; }
.comm-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.comm-actions .btn .spinner { display: inline-block; vertical-align: -2px; }
.help.inline { margin: 0; }
.comm-tabs { margin: 0; overflow-x: auto; }
.comm-tabs .tab { flex: none; padding: 5px 12px; display: inline-flex; align-items: center; }
.comm-body { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.card { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: var(--panel); position: relative; }
.card.with-chk { padding-left: 44px; }
.card-chk { position: absolute; left: 14px; top: 14px; }
.card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-title { font-weight: 600; font-size: 15px; flex: 1; min-width: 160px; }
.score { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.score.hi { background: color-mix(in srgb, var(--ok) 22%, transparent); color: var(--ok); }
.score.mid { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.score.lo { background: var(--hover); color: var(--muted); }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 20px; border: 1px solid var(--border); color: var(--muted); }
.card-meta { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
.card-sum { margin: 8px 0 0; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.card-text { font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; }
.card-text.q { margin-top: 0; font-weight: 500; }
.card .note { font-size: 13px; color: var(--accent); margin-top: 6px; }
.card-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 10px; font-size: 13.5px; }
.card-lists ul { margin: 2px 0 0; padding-left: 18px; }
.card .lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 8px; }
.card details { margin-top: 8px; font-size: 13.5px; }
.card summary { cursor: pointer; color: var(--muted); }
.card pre.task { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin: 6px 0 0; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.q-toolbar { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.chk input { width: 17px; height: 17px; accent-color: var(--accent); }
.q-answer { width: 100%; margin-top: 4px; resize: vertical; font: inherit; font-size: 14px; }
@media (max-width: 820px) {
  .card.with-chk { padding-left: 40px; }
  .comm-head { position: static; }
}

/* ---------- 1.4: разделы на весь экран (Тун Тун Сахур, идеи) ---------- */
.nav-btn.on { background: var(--hover); font-weight: 500; }
.section { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 10px 18px 0; }
.sec-head { flex: none; }
.sec-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.sec-actions .grow { flex: 1; }
.sec-split { flex: 1; display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 14px; min-height: 0; margin-top: 8px; padding-bottom: 14px; }
.sec-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; min-height: 0; padding: 2px 4px 2px 0; }
.sec-list .comm-tabs { flex: none; margin-bottom: 4px; flex-wrap: wrap; overflow: visible; }
.sec-detail { overflow-y: auto; min-height: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); padding: 14px 16px; }
.sec-empty { color: var(--faint); text-align: center; padding: 60px 10px; }
.sec-item { text-align: left; border: 1px solid var(--border); border-radius: 12px; padding: 9px 11px; background: var(--bg); display: flex; flex-direction: column; gap: 3px; width: 100%; }
.sec-item:hover { border-color: var(--border-strong); }
.sec-item.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 15%, transparent); }
.sec-item.idea { flex-direction: row; align-items: flex-start; gap: 10px; }
.sec-item.idea .grow { flex: 1; min-width: 0; }
.sec-item .score { width: 28px; height: 28px; font-size: 13px; }
.sec-item .row1 { display: flex; gap: 8px; align-items: center; min-width: 0; }
.sec-item .who { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-item .when, .sec-item .cnt { font-size: 12px; color: var(--faint); white-space: nowrap; }
.sec-item .prev { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.sbadge { font-size: 11.5px; padding: 1px 8px; border-radius: 20px; background: var(--hover); color: var(--muted); white-space: nowrap; }
.sbadge.new { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.sbadge.draft { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.sbadge.error { background: var(--danger-bg); color: var(--danger); }
.score.none { background: var(--hover); color: var(--faint); }
.field.small { width: auto; padding: 5px 8px; font-size: 13px; border-radius: 8px; }
.mpick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.dlg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.dlg-head .grow { flex: 1; min-width: 160px; }
.dlg-head .ttl { font-weight: 600; font-size: 16px; }
.icon-btn.back { display: none; }
.icon-btn.back svg { transform: rotate(180deg); }
.dlg-thread { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.bub { max-width: 82%; padding: 8px 12px; border-radius: 14px; background: var(--bg); border: 1px solid var(--border); }
.bub.player { align-self: flex-start; }
.bub.bot { align-self: flex-end; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.bub.reply { margin-left: 22px; }
.bub .meta { font-size: 12px; color: var(--faint); margin-bottom: 2px; }
.bub .txt { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.dlg-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.dlg .lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-top: 10px; }
.dlg .note { font-size: 13px; color: var(--accent); margin-top: 6px; }
.dlg .card-top { margin-bottom: 4px; }
.dlg details { margin-top: 10px; font-size: 13.5px; }
.dlg summary { cursor: pointer; color: var(--muted); }
.dlg pre.task { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin: 6px 0 0; }
.dlg .err { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 820px) {
  .section { padding: 8px 10px 0; }
  .sec-split { grid-template-columns: 1fr; }
  .sec-split.has-sel .sec-list { display: none; }
  .sec-split:not(.has-sel) .sec-detail { display: none; }
  .icon-btn.back { display: inline-grid; }
  .bub { max-width: 92%; }
  .usage { width: 100%; }
}

/* ---------- 1.8: предпросмотр Embed ---------- */
.emb-row { display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; margin-top: 6px; }
.emb-row .field.small { flex: 1; min-width: 160px; }
.emb-row .field.emo { flex: none; width: 56px; min-width: 56px; text-align: center; }
.emb-row textarea { flex-basis: 100%; }
.dc-embed { margin-top: 6px; max-width: 520px; background: #2b2d31; color: #dbdee1; border-left: 4px solid #c96442; border-radius: 6px; padding: 10px 14px 12px 14px; font-size: 14px; line-height: 1.45; }
.dc-author { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.dc-title { font-weight: 700; font-size: 16px; color: #00a8fc; margin-bottom: 6px; }
.dc-desc { margin-bottom: 8px; white-space: pre-wrap; }
.dc-field { margin-top: 10px; }
.dc-fname { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.dc-fval { white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-fval a { color: #00a8fc; text-decoration: none; }
.dc-footer { margin-top: 12px; font-size: 12px; color: #949ba4; }

/* ---- лимиты подписки */
.pill.upill .udot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.pill.upill.u-ok .udot { background: var(--ok); }
.pill.upill.u-mid .udot { background: #d9a21b; }
.pill.upill.u-low .udot, .pill.upill.u-out .udot { background: var(--danger); }
.pill.upill.u-low, .pill.upill.u-out { color: var(--danger); }
.pop .item .acc-name { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.acc-use { font-size: 11.5px; color: var(--faint); }
.acc-use.u-low, .acc-use.u-out { color: var(--danger); }
.upop { min-width: 260px; max-width: 320px; padding: 2px 6px 4px; }
.ubars { display: flex; flex-direction: column; gap: 9px; padding: 4px 10px 6px; }
.acc-usage { flex-basis: 100%; }
.acc-usage .ubars { padding: 2px 0 0; max-width: 460px; }
.ubar .ul { display: flex; justify-content: space-between; font-size: 12.5px; }
.ubar .ut { height: 6px; border-radius: 4px; background: var(--hover); overflow: hidden; margin: 3px 0; }
.ubar .ut i { display: block; height: 100%; background: var(--ok); border-radius: 4px; }
.ubar.mid .ut i { background: #d9a21b; }
.ubar.low .ut i, .ubar.out .ut i { background: var(--danger); }
.ubar .us { font-size: 11.5px; color: var(--faint); }

.plug-bar { display: flex; gap: 8px; margin-bottom: 8px; }
.plug-bar .field { flex: 1; }
.plug-row .plug-main { flex: 1; min-width: 200px; }
