:root {
  --bg0: #1f1e1b;
  --bg: #26251f;
  --bg-elev: #30302b;
  --bg-soft: #353430;
  --panel: #2c2b26;
  --sidebar: #1a1916;
  --ink: #f5f4ef;
  --ink-soft: #c2c0b6;
  --muted: #8a877c;
  --accent: #d4a27f;
  --accent-2: #e8c4a8;
  --accent-dim: color-mix(in srgb, var(--accent) 16%, transparent);
  --user-bg: #3a3933;
  --line: #3a3933;
  --danger: #e87b7b;
  --ok: #8fbf8f;
  --radius: 16px;
  --sidebar-w: 280px;
  --composer-max: 720px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 16px 48px #00000055;
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --send-fg: #1f1e1b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  height: 100dvh;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
/* ≥16px avoids iOS auto-zoom on focus */
input, select, textarea { font-size: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid transparent;
  display: flex; flex-direction: column; min-height: 0; z-index: 20;
}
.sidebar-top { padding: 18px 14px 8px; border-bottom: 0; display: flex; flex-direction: column; gap: 14px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand {
  font-family: var(--serif); font-weight: 400; letter-spacing: -0.02em;
  font-size: 1.55rem; display: flex; align-items: center; gap: 9px; color: var(--ink);
}
.brand .dot { display: none; }
.btn-icon {
  background: transparent; border: 0; color: var(--ink-soft);
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer; display: grid; place-items: center;
}
.btn-icon:hover { background: var(--bg-soft); color: var(--ink); }
.btn-new, .btn-primary {
  width: 100%; background: #f5f4ef;
  border: 0; color: #1f1e1b; border-radius: 999px; padding: 10px 16px;
  font-weight: 600; cursor: pointer; text-align: center; font-size: 0.9rem;
}
.btn-primary { width: auto; background: var(--accent); color: var(--send-fg); font-weight: 600; border-radius: 12px; }
.btn-new:hover { filter: brightness(0.96); }
.btn-primary:hover { filter: brightness(1.05); }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px;
}
.user-chip img { width: 28px; height: 28px; border-radius: 8px; }
.user-chip .meta { flex: 1; min-width: 0; }
.user-chip .name { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .sub { font-size: 0.7rem; color: var(--muted); }
.conv-list, .skill-mini {
  flex: 1; overflow-y: auto; padding: 10px 8px 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.section-label {
  font-size: 0.78rem; color: var(--muted); text-transform: none;
  letter-spacing: 0; font-weight: 500; padding: 14px 16px 6px;
}
.conv-item, .skill-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 12px; cursor: pointer; border: 0; background: transparent;
  color: var(--ink-soft); text-align: left; width: 100%;
}
.conv-item:hover, .skill-chip:hover { background: var(--bg-soft); color: var(--ink); }
.conv-item.active { background: var(--bg-soft); color: var(--ink); box-shadow: none; }
.conv-item .title {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.9rem; background: transparent; border: 0; color: inherit; cursor: pointer; text-align: left;
}
.conv-item .del, .conv-item .share-btn {
  opacity: 0; background: transparent; border: 0; color: var(--muted);
  cursor: pointer; padding: 2px 6px; border-radius: 6px; font-size: 0.95rem;
}
.conv-item:hover .del, .conv-item.active .del,
.conv-item:hover .share-btn, .conv-item.active .share-btn { opacity: 1; }
.conv-item .del:hover { color: var(--danger); background: #2a1520; }
.badge {
  font-size: 0.65rem; padding: 2px 7px; border-radius: 999px;
  background: #1e3348; color: var(--accent-2); border: 1px solid #2a455f;
}
.badge.collab { background: #1a3a2e; color: var(--ok); border-color: #2a5a45; }
.badge.online { background: #1a3a2e; color: var(--ok); border-color: #2a5a45; }
.badge.offline { background: #3a1a22; color: var(--danger); border-color: #5a2a35; }
.prov-row.is-offline { opacity: 0.55; }
.provider-pick select option:disabled { color: var(--muted); }
.sidebar-foot {
  border-top: 0; padding: 10px 12px calc(12px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(to top, var(--sidebar) 70%, transparent);
}
.provider-pick label {
  font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.provider-pick select, .modal input, .modal select, .modal textarea {
  width: 100%; margin-top: 4px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; outline: none;
}
.modal textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
.provider-pick select:focus, .modal input:focus, .modal select:focus, .modal textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
}
.btn-ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; cursor: pointer; color: var(--ink-soft); font-size: 0.85rem;
  display: block; text-align: center;
}
.btn-ghost:hover { color: var(--ink); border-color: var(--muted); text-decoration: none; }
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: none; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px);
}
.topbar .title { flex: 1; font-weight: 600; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px; scroll-behavior: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.messages-inner { max-width: var(--composer-max); margin: 0 auto; display: flex; flex-direction: column; gap: 14px; min-height: 100%; }
.empty { margin: auto; text-align: center; color: var(--ink-soft); max-width: 28ch; padding: 32px 16px; }
.empty-mark {
  width: 44px; height: 44px; margin: 0 auto 18px;
  color: var(--accent); font-size: 2.2rem; line-height: 1;
  display: grid; place-items: center;
  animation: markIn .5s ease both;
}
.empty h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(1.55rem, 4.2vw, 2rem); letter-spacing: -0.02em;
  margin-bottom: 0; color: var(--ink); line-height: 1.25;
}
.empty p { display: none; }
.empty .links { display: none; }
@keyframes markIn { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
/* No default fade on .msg — re-render after stream was flashing the whole chat */
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 100%; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 0.72rem; font-weight: 700; margin-top: 2px;
}
.msg.assistant .avatar {
  background: transparent; color: var(--accent); font-size: 1.1rem; font-weight: 400;
  width: 28px; height: 28px;
}
.msg.user .avatar { display: none; }
.bubble {
  max-width: min(100%, 640px); padding: 10px 14px; border-radius: 18px;
  line-height: 1.6; font-size: 0.98rem; word-break: break-word;
}
.msg.user .bubble {
  background: var(--user-bg); border: 0; border-radius: 18px;
  white-space: pre-wrap; padding: 12px 16px;
}
.msg.assistant .bubble { background: transparent; border: 0; padding: 2px 0; }
.md > *:first-child { margin-top: 0; } .md > *:last-child { margin-bottom: 0; }
.md p { margin: 0.55em 0; }
.md h1,.md h2,.md h3 { margin: 0.9em 0 0.4em; letter-spacing: -0.02em; line-height: 1.25; }
.md h1 { font-size: 1.35rem; } .md h2 { font-size: 1.15rem; } .md h3 { font-size: 1.05rem; }
.md ul,.md ol { margin: 0.5em 0; padding-left: 1.35em; } .md li { margin: 0.25em 0; }
.md blockquote { margin: 0.6em 0; padding: 0.2em 0 0.2em 0.9em; border-left: 3px solid var(--accent); color: var(--ink-soft); }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.md code { font-family: var(--mono); font-size: 0.86em; background: #182030; padding: 0.12em 0.4em; border-radius: 6px; word-break: break-all; }
.md pre { margin: 0.7em 0; background: #080c12; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; overflow-x: auto; }
.md pre code { background: transparent; padding: 0; font-size: 0.82rem; line-height: 1.5; }
.md table { border-collapse: collapse; margin: 0.7em 0; width: 100%; font-size: 0.9rem; }
.md th,.md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; } .md th { background: #152032; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.md img {
  max-width: 100%;
  max-height: min(70vh, 560px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  margin: 0.5em 0;
  border: 1px solid var(--line);
  background: #0a1018;
  display: block;
}
.md em { color: var(--ink-soft); font-size: 0.86em; }
.charts { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.charts img { max-width: 100%; border-radius: 10px; background: #0a1018; border: 1px solid var(--line); }
.tool-chip {
  display: inline-flex; margin-top: 8px; font-size: 0.72rem; color: var(--muted);
  font-family: var(--mono); background: #141c28; border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px;
}
.msg-timeline,
.stream-timeline,
.tools-block {
  display: flex; flex-direction: column; gap: 8px;
  margin: 0 0 12px; max-width: min(100%, 640px);
}
.msg-timeline > .reasoning,
.msg-timeline > .tool-call,
.stream-timeline > .reasoning,
.stream-timeline > .tool-call {
  margin: 0;
  max-width: 100%;
}
/* Keep native <details> interactive while streaming */
.msg.streaming .reasoning summary,
.msg.streaming .tool-call summary {
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.tool-call {
  background: #101820;
  border: 1px solid #243246;
  border-radius: 12px;
  overflow: hidden;
}
/* Force-collapse tool/reasoning bodies — some browsers leave children painted */
details.tool-call:not([open]) > :not(summary),
details.reasoning:not([open]) > :not(summary) {
  display: none !important;
  height: 0 !important;
  overflow: hidden !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
}
.tool-call.err { border-color: color-mix(in srgb, #f87171 45%, #243246); }
.tool-call summary {
  cursor: pointer; list-style: none; padding: 8px 12px;
  font-size: 0.8rem; font-weight: 600; color: var(--ink-soft);
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call .t-ico { color: var(--accent); opacity: 0.9; }
.tool-detail {
  padding: 0 12px 10px; border-top: 1px solid #1c2736;
  font-size: 0.76rem; color: var(--muted);
}
.tool-name { margin-top: 8px; line-height: 1.4; }
.tool-args {
  margin: 8px 0 0; padding: 8px 10px; border-radius: 8px;
  background: #080c12; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.72rem; white-space: pre-wrap;
  max-height: 160px; overflow: auto; color: var(--ink-soft);
}
.tool-call.streaming {
  border-color: color-mix(in srgb, var(--accent) 40%, #243246);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}
.tool-call.streaming .t-ico {
  animation: toolPulse 1.1s ease-in-out infinite;
}
@keyframes toolPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}
.tool-live-file {
  margin-top: 8px;
  border: 1px solid #1c2736;
  border-radius: 10px;
  overflow: hidden;
  background: #080c12;
}
.tool-live-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid #1c2736;
  font-size: 0.74rem;
  color: var(--ink-soft);
}
.tool-live-head code {
  font-family: var(--mono);
  color: var(--accent-2);
}
.tool-live-badge {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.7rem;
}
.tool-live-chars {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tool-live-content {
  margin: 0;
  padding: 10px 12px;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.45;
  color: var(--ink);
}
.image-pick {
  margin: 0 0 10px; max-width: min(100%, 640px);
  background: linear-gradient(180deg, #141c28, #101820);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, #243246);
  border-radius: 14px; padding: 12px 14px;
}
.image-pick-head {
  font-size: 0.82rem; font-weight: 600; color: var(--accent-2);
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.image-pick-prompt {
  font-size: 0.86rem; color: var(--ink-soft); line-height: 1.45;
  background: #0a1018; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px; white-space: pre-wrap;
}
.image-pick-models {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.btn-img-model {
  appearance: none; border: 1px solid var(--line); background: #182030;
  color: var(--ink); border-radius: 999px; padding: 6px 12px;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s, transform .12s;
}
.btn-img-model:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn-img-model:disabled { opacity: 0.55; cursor: wait; }
.image-pick-status { margin-top: 10px; font-size: 0.84rem; }
.image-pick-status img { max-width: 100%; border-radius: 10px; margin-top: 6px; }
.reasoning summary .r-label { flex: 1; }
.prov-chip { transition: background .15s, border-color .15s; }
.msg-body { min-width: 0; max-width: min(100%, 640px); }
.reasoning {
  margin: 0 0 10px;
  background: linear-gradient(180deg, #121a24, #0e1520);
  border: 1px solid #243246;
  border-radius: 12px;
  overflow: hidden;
  max-width: min(100%, 640px);
}
.reasoning.live { border-color: color-mix(in srgb, var(--accent) 35%, #243246); }
.reasoning summary {
  cursor: pointer;
  list-style: none;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-2);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary .r-ico { opacity: 0.85; font-size: 0.85rem; }
.reasoning-body {
  padding: 0 12px 12px;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-soft);
  white-space: pre-wrap;
  max-height: 280px;
  overflow-y: auto;
  border-top: 1px solid #1c2736;
  padding-top: 10px;
}
.caret {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.msg.assistant.streaming .bubble { min-height: 1.4em; }
.muted { color: var(--muted); font-style: italic; }
.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); animation: bounce 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%,80%,100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.composer-wrap { padding: 8px 14px calc(14px + var(--safe-b)); background: linear-gradient(to top, var(--bg0) 60%, transparent); }
.composer {
  max-width: var(--composer-max); margin: 0 auto; background: var(--bg-elev);
  border: 0; border-radius: 22px; padding: 12px 12px 10px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: 0 8px 28px #00000033;
}
.composer:focus-within { box-shadow: 0 10px 32px #00000044; }
.composer-input-row { display: flex; width: 100%; }
.composer textarea {
  flex: 1; width: 100%; background: transparent; border: 0; outline: 0; resize: none;
  min-height: 28px; max-height: 180px; line-height: 1.45; padding: 4px 6px;
  font-size: 16px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-toolbar {
  display: flex; align-items: center; gap: 6px; width: 100%;
}
.composer-toolbar-spacer { flex: 1; }
.btn-attach {
  width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  color: var(--ink-soft); cursor: pointer; flex-shrink: 0; font-size: 1.15rem;
  display: grid; place-items: center;
}
.btn-attach.btn-plus { font-weight: 400; font-size: 1.25rem; line-height: 1; }
.btn-attach:hover { background: var(--bg-soft); color: var(--ink); border-color: var(--muted); }
.model-picker-wrap { position: relative; max-width: 46%; flex-shrink: 1; min-width: 0; }
.btn-model-pill {
  border: 1px solid var(--line); background: transparent; color: var(--ink-soft);
  border-radius: 999px; padding: 6px 10px 6px 12px; font-size: 0.78rem; font-weight: 500;
  cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px; width: 100%;
}
.btn-model-pill:hover, .model-picker-wrap.open .btn-model-pill { color: var(--ink); border-color: var(--muted); background: var(--bg-soft); }
.btn-model-pill .pill-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.btn-model-pill .pill-chevron {
  flex: 0 0 auto; opacity: 0.55; font-size: 0.65rem; line-height: 1;
  transition: transform .15s ease;
}
.model-picker-wrap.open .btn-model-pill .pill-chevron { transform: rotate(180deg); opacity: 0.9; }
.model-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 60;
  min-width: min(280px, 78vw); max-width: min(340px, 92vw);
  max-height: min(50vh, 360px); overflow: hidden;
  display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 14px; padding: 6px; box-shadow: var(--shadow);
}
.model-menu[hidden] { display: none !important; }
.model-menu-head {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); padding: 8px 10px 6px;
}
.model-menu-list {
  overflow-y: auto; max-height: min(40vh, 280px);
  display: flex; flex-direction: column; gap: 2px; padding: 0 2px 4px;
}
.model-menu-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  text-align: left; background: transparent; border: 0; color: var(--ink-soft);
  padding: 9px 10px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 0.85rem;
}
.model-menu-item:hover { background: var(--bg-soft); color: var(--ink); }
.model-menu-item.active { background: var(--accent-dim); color: var(--ink); }
.model-menu-item .mm-check {
  flex: 0 0 16px; width: 16px; text-align: center; color: var(--accent);
  font-size: 0.85rem; line-height: 1.35; opacity: 0;
}
.model-menu-item.active .mm-check { opacity: 1; }
.model-menu-item .mm-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.model-menu-item .mm-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-menu-item .mm-sub {
  font-size: 0.7rem; color: var(--muted); font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-menu-empty { padding: 10px; font-size: 0.8rem; color: var(--muted); }
.model-menu-section {
  padding: 8px 10px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.model-menu-manage { color: var(--muted) !important; font-size: 0.8rem !important; }
.btn-send {
  width: 36px; height: 36px; border-radius: 999px; border: 0; background: #f5f4ef;
  color: var(--send-fg); font-weight: 700; cursor: pointer; flex-shrink: 0; display: grid; place-items: center;
}
.btn-send:disabled { opacity: 0.35; cursor: wait; }
.btn-send:not(:disabled):hover { filter: brightness(0.96); }
.attach-preview {
  max-width: var(--composer-max); margin: 0 auto 8px; display: none; gap: 8px; flex-wrap: wrap;
}
.attach-preview.on { display: flex; }
.att-thumb {
  position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); background: #121820; flex-shrink: 0;
}
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-thumb.file {
  width: auto; min-width: 64px; padding: 8px 28px 8px 10px; display: flex; align-items: center;
  font-size: 0.72rem; color: var(--ink-soft); font-family: var(--mono);
}
.att-thumb .x {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border: 0; border-radius: 999px;
  background: #000000cc; color: #fff; cursor: pointer; font-size: 12px; line-height: 1;
}
.msg-body { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: min(100%, 640px); }
.msg.assistant .msg-body { align-items: flex-start; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.msg.user .attachments { justify-content: flex-end; }
.att-img { display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); max-width: min(100%, 320px); }
.att-img img { display: block; max-width: 100%; max-height: 280px; object-fit: contain; background: #0a1018; }
.att-file {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px;
  background: #141c28; border: 1px solid var(--line); font-size: 0.85rem; color: var(--accent);
  text-decoration: none;
}
.att-file:hover { filter: brightness(1.1); }
.hint { display: none; }
.toast { max-width: var(--composer-max); margin: 0 auto 6px; text-align: center; font-size: 0.8rem; color: var(--accent); min-height: 1.1em; }
.toast.err { color: var(--danger); }
.backdrop {
  position: fixed; inset: 0; background: #00000099; z-index: 40; display: none;
  align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(4px);
}
.backdrop.open { display: flex; }
.modal {
  width: min(520px, 100%); max-height: min(92dvh, 800px); overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 18px;
  padding: 20px; box-shadow: var(--shadow); animation: fadeUp 0.2s ease;
}
.modal.wide { width: min(640px, 100%); }
.modal h2 { font-size: 1.08rem; margin-bottom: 6px; letter-spacing: -0.02em; }
.modal .sub { color: var(--muted); font-size: 0.85rem; margin-bottom: 14px; line-height: 1.45; }
.modal label { display: block; font-size: 0.78rem; color: var(--muted); margin: 10px 0 4px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.prov-row, .skill-row {
  display: flex; justify-content: space-between; gap: 10px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem;
}
.prov-row:last-child, .skill-row:last-child { border-bottom: 0; }
.prov-row small, .skill-row small {
  display: block; color: var(--muted); font-family: var(--mono); font-size: 0.7rem;
  margin-top: 3px; word-break: break-all;
}
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-danger {
  background: transparent; border: 1px solid #4a2030; color: var(--danger);
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.btn-mini {
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink-soft);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 0.8rem;
}
.btn-mini:hover { color: var(--ink); }
.checkline { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 0.85rem; color: var(--ink-soft); }
.checkline input { width: auto; margin: 0; accent-color: var(--accent); }
.limits-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 10px;
}
@media (max-width: 640px) {
  .limits-row { grid-template-columns: 1fr; }
}
.limits-row label { font-size: 0.8rem; }
.limits-row .muted { font-size: 0.75rem; opacity: 0.75; }
.apikey-once {
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  word-break: break-all;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
}
.apikey-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.apikey-usage {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.apikey-usage .usage-mini {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.apikey-usage .usage-mini div {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.8rem;
}
.apikey-usage .usage-mini strong {
  display: block;
  font-size: 1rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.badge.guest-off { opacity: 0.75; }
.badge.limit-badge { font-size: 0.7rem; }
.skill-chip.active { background: #16352f; color: var(--accent); box-shadow: inset 0 0 0 1px #245a50; }
.skill-chip input { accent-color: var(--accent); }
.sidebar-scrim { display: none; position: fixed; inset: 0; background: #00000066; z-index: 15; }
.lite-bar {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent);
}
.lite-bar .spacer { flex: 1; }
.share-box {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-family: var(--mono); font-size: 0.78rem; word-break: break-all; margin-top: 8px;
}
.app.lite { grid-template-columns: 260px 1fr; }
@media (min-width: 821px) { .sidebar .brand-row .btn-icon.close-side { display: none; } }
@media (max-width: 820px) {
  .app, .app.lite { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(88vw, 320px);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateX(-105%); transition: transform 0.22s ease; box-shadow: 8px 0 40px #00000066;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim.open { display: block; }
  .topbar {
    display: flex;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 10px;
    position: sticky; top: 0; z-index: 5;
  }
  .topbar .btn-icon, .btn-icon, .btn-attach, .btn-send, .btn-stop {
    width: 44px; height: 44px; min-width: 44px; min-height: 44px;
  }
  .btn-new, .btn-ghost, .btn-primary { min-height: 44px; padding: 12px 14px; }
  .conv-item { padding: 12px 12px; min-height: 48px; }
  /* Hover-only actions are useless on touch */
  .conv-item .del, .conv-item .share-btn { opacity: 0.85; }
  .messages { padding: 12px 10px 8px; }
  .messages-inner { gap: 14px; }
  .bubble { font-size: 0.95rem; padding: 11px 14px; }
  .avatar { width: 28px; height: 28px; font-size: 0.65rem; }
  .composer-wrap { padding: 4px 8px calc(8px + var(--safe-b)); }
  .composer { border-radius: 18px; padding: 8px 10px; gap: 6px; }
  .composer textarea { max-height: 120px; }
  .hint { display: none; }
  .msg.user .bubble { max-width: 92%; }
  .live-dot { right: 10px; bottom: calc(72px + var(--safe-b)); }
  .backdrop { padding: 0; align-items: flex-end; }
  .modal, .modal.wide {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: 18px 18px 0 0;
    padding: 16px 14px calc(16px + var(--safe-b));
  }
  .modal-actions { gap: 10px; }
  .modal-actions .btn-ghost, .modal-actions .btn-primary, .modal-actions .btn-danger {
    flex: 1 1 auto; min-height: 44px;
  }
  .user-menu { left: 0; right: auto; bottom: calc(100% + 8px); top: auto; min-width: 180px; }
  .ctx-item { padding: 12px 12px; min-height: 44px; }
  .sidebar-foot { padding: 10px; gap: 6px; }
  .multi-prov { max-height: 88px; }
  .md pre { font-size: 0.78rem; padding: 10px; }
  .md table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .att-img { max-width: min(100%, 100%); }
  .att-img img { max-height: 220px; }
  .att-video video { max-width: 100%; max-height: 240px; }
  .reasoning-body { max-height: 180px; }
}
@media (max-width: 420px) {
  .brand { font-size: 0.98rem; }
  .topbar .title { font-size: 0.88rem; }
  .composer { border-radius: 16px; }
  .empty h1 { font-size: 1.35rem; }
  .empty p { font-size: 0.88rem; }
}

/* —— v4 UI: avatar chip, context menu, caps —— */
.brand-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.auth-box-inline { display: flex; align-items: center; }
.user-avatar-wrap { position: relative; z-index: 81; }
.user-avatar-btn {
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-elev); cursor: pointer; overflow: hidden;
}
.user-avatar-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-avatar-btn:hover { border-color: var(--accent); }
.btn-login-mini {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid #5865F2; color: #fff;
  text-decoration: none; background: #5865F2;
  font-size: 0.78rem; font-weight: 600; white-space: nowrap;
  box-shadow: 0 2px 10px color-mix(in srgb, #5865F2 35%, transparent);
}
.btn-login-mini:hover { filter: brightness(1.08); border-color: #7289da; }
.btn-login-mini .dc-ico { width: 16px; height: 16px; flex: 0 0 auto; }
.auth-local { color: var(--muted); font-size: 1.2rem; padding: 0 6px; }
.user-menu {
  display: none; position: absolute; left: 0; right: auto; bottom: calc(100% + 8px); top: auto; z-index: 80;
  min-width: 180px; max-width: min(260px, calc(100vw - 24px));
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; box-shadow: var(--shadow);
}
.user-menu.open { display: block; }
.user-menu-name {
  font-size: 0.8rem; font-weight: 600; padding: 8px 10px 6px; color: var(--ink);
  border-bottom: 1px solid var(--line); margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ctx-menu {
  position: fixed; z-index: 80; min-width: 180px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px;
  padding: 6px; box-shadow: var(--shadow);
}
.ctx-item {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--ink-soft); padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 0.85rem;
}
.ctx-item:hover:not(.disabled) { background: var(--bg-soft); color: var(--ink); }
.ctx-item.disabled { opacity: 0.65; cursor: default; color: var(--muted); }
.ctx-sep { height: 1px; background: var(--line); margin: 4px 2px; }
.caps-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cap-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft);
  font-size: 0.78rem; color: var(--ink-soft); cursor: pointer; margin: 0;
}
.cap-chip input { margin: 0; accent-color: var(--accent); }
.prompt-view {
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-family: var(--mono); font-size: 0.78rem; white-space: pre-wrap;
  max-height: 50vh; overflow: auto; color: var(--ink-soft); line-height: 1.45;
}
.share-banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: #132033; border-bottom: 1px solid var(--line); font-size: 0.85rem;
}
.share-banner[hidden] { display: none !important; }
.share-banner .badge { margin-left: auto; }

/* v5 — multi providers, gear, stop, media, live, animations */
.multi-prov { display: flex; flex-wrap: wrap; gap: 6px; max-height: 120px; overflow: auto; }
.prov-chip, .skill-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft);
  font-size: 0.75rem; color: var(--ink-soft); cursor: pointer; margin: 0;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.prov-chip input, .skill-chip input { margin: 0; accent-color: var(--accent); }
.prov-chip.active, .skill-chip.active {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-dim); color: var(--accent); transform: translateY(-1px);
}
.conv-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 4px; }
.conv-item .title { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-gear {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; position: relative;
  font-size: 0.85rem; transition: color .15s, border-color .15s, transform .2s;
}
.btn-gear:hover { color: var(--accent); border-color: var(--line); transform: rotate(45deg); }
.btn-gear i {
  position: absolute; top: -4px; right: -4px; font-style: normal;
  background: var(--accent); color: var(--send-fg); font-size: 0.6rem; font-weight: 700;
  min-width: 14px; height: 14px; border-radius: 999px; display: grid; place-items: center;
  padding: 0 3px;
}
.btn-stop {
  width: 40px; height: 40px; border-radius: 12px; border: 0; cursor: pointer;
  background: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--danger);
  font-size: 0.9rem; flex: 0 0 auto; transition: transform .12s ease, filter .12s;
}
.btn-stop:hover { filter: brightness(1.1); transform: scale(1.04); }
.btn-stop[hidden], .btn-send[hidden] { display: none !important; }
.att-audio audio, .att-video video {
  width: 100%; max-width: 420px; border-radius: 12px; margin-top: 8px;
  background: #000; outline: 1px solid var(--line);
}
.att-video video { max-height: 320px; }
.live-dot {
  position: fixed; right: 12px; bottom: calc(12px + var(--safe-b));
  width: 10px; height: 10px; border-radius: 50%; background: var(--muted);
  box-shadow: 0 0 0 0 transparent; z-index: 50; pointer-events: none;
  transition: background .2s, box-shadow .2s;
}
.live-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 25%, transparent);
  animation: livePulse 2.2s ease-in-out infinite;
}
.live-dot.off { background: var(--danger); }
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }
  50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ok) 0%, transparent); }
}
.anim-in { animation: fadeSlide .2s ease both; }
.anim-msg { animation: msgIn .18s ease-out; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}
.msg.streaming .bubble { animation: softGlow 1.6s ease-in-out infinite; }
@keyframes softGlow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
}
.composer { transition: box-shadow .25s ease; }
.composer:focus-within {
  box-shadow: 0 10px 32px #00000044;
}


.tool-call summary .t-purpose { flex: 1; min-width: 0; }
.tool-call summary .t-chev {
  opacity: 0.45; font-size: 0.7rem; transition: transform .15s ease;
}
.tool-call[open] summary .t-chev { transform: rotate(180deg); opacity: 0.7; }
.tool-call summary:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.reasoning summary:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.stream-tools, .stream-picks { max-width: min(100%, 640px); }
.msg.streaming .stream-content .caret {
  display: inline-block; width: 0.55em; height: 1em;
  background: var(--accent); margin-left: 2px; vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.btn-img-model:active { transform: translateY(0) scale(0.98); }
.image-pick { animation: pick-in .25s ease; }
@keyframes pick-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.model-pick, .file-card-list { margin: 8px 0; max-width: min(100%, 640px); }
.model-pick:not(.image-pick) {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  background: color-mix(in srgb, var(--bg-elev) 88%, var(--accent));
  animation: pick-in .25s ease;
}
.model-pick-head { font-weight: 600; font-size: 0.85rem; margin-bottom: 6px; }
.model-pick-body { font-size: 0.8rem; color: var(--ink-soft); white-space: pre-wrap; margin-bottom: 8px; }
.model-pick-models { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn-model-pick {
  display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px;
  max-width: 100%;
}
.btn-model-pick .pm-name { font-weight: 600; }
.btn-model-pick .pm-model {
  font-size: 0.68rem; color: var(--muted); font-family: var(--mono);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.image-pick-status img {
  max-width: 100%; max-height: min(60vh, 480px); width: auto; height: auto;
  object-fit: contain; border-radius: 12px; margin-top: 8px;
  border: 1px solid var(--line); background: #0a1018; display: block;
}
.file-card-list { display: flex; flex-direction: column; gap: 6px; }
.file-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev);
  cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit;
}
.file-card:hover { border-color: var(--accent); }
.file-card .fc-ico { font-size: 1.1rem; }
.file-card .fc-meta { flex: 1; min-width: 0; }
.file-card .fc-name { font-weight: 600; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .fc-size { font-size: 0.72rem; color: var(--muted); }
.followups {
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 4px 2px; max-width: min(100%, 720px);
}
.followups-label {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}
.followups-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.followups button {
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink-soft);
  border-radius: 12px; padding: 8px 12px; font: inherit; font-size: 0.8rem;
  cursor: pointer; text-align: left; line-height: 1.35; max-width: 100%;
}
.followups button:hover { border-color: var(--accent); color: var(--ink); }
.btn-tts {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 0.85rem; padding: 2px 6px; border-radius: 6px;
}
.btn-tts:hover { color: var(--accent); background: var(--bg-soft); }
#btn-mic.recording { color: #ff6b6b; animation: softGlow 1s ease-in-out infinite; }
.file-editor {
  width: 100%; min-height: 280px; font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
}
.file-preview-media { max-width: 100%; max-height: 60vh; border-radius: 10px; }


/* v54 — usage dashboard + client prompts + msg meta */
.msg-meta {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  opacity: 0.85;
}
.usage-period { margin-bottom: 18px; }
.usage-period-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.usage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) {
  .usage-grid { grid-template-columns: 1fr; }
}
.usage-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--panel) 88%, #0b1220);
}
.usage-card h3 {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
}
.usage-big {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-family: "Sora", system-ui, sans-serif;
  background: linear-gradient(120deg, #7dd3fc, #a78bfa 55%, #f0abfc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.usage-sub { font-size: 0.75rem; color: var(--muted); margin: 4px 0 10px; }
.usage-tops ul { list-style: none; padding: 0; margin: 0; }
.usage-tops li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  padding: 4px 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.usage-tops code { font-size: 0.72rem; }
.usage-of {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}
.usage-bar-row { margin: 8px 0 4px; }
.usage-bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.usage-bar-meta strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.usage-bar {
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 80%, transparent);
  overflow: hidden;
}
.usage-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #34d399, #22d3ee);
  transition: width 0.35s ease;
}
.usage-bar.is-warn .usage-bar-fill {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}
.usage-bar.is-crit .usage-bar-fill {
  background: linear-gradient(90deg, #f87171, #ef4444);
}
.usage-models { display: flex; flex-direction: column; gap: 10px; }
.usage-model-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--panel) 88%, #0b1220);
}
.usage-model-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.usage-model-head strong { font-size: 0.88rem; }
.usage-model-head small { color: var(--muted); }
.prov-usage-mini {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--muted);
}
.cp-choice, .cp-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 8px 0;
  cursor: pointer;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
}
.cp-choice:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.cp-custom input[type="text"] {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}
.client-prompt-modal { max-width: 420px; }
.reasoning + .reasoning,
.tool-call + .reasoning,
.reasoning + .tool-call { margin-top: 0; }
.composer-wrap .hint { display: none; }

/* —— Claude-inspired layout polish (v61) —— */
.main { background: var(--bg0); }
.topbar {
  background: transparent; border-bottom: 0;
  backdrop-filter: none;
}
.topbar .title { font-weight: 500; color: var(--ink-soft); font-size: 0.9rem; }
.side-nav {
  display: flex; flex-direction: column; gap: 2px; padding: 0 4px;
}
.side-nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--ink); padding: 10px 12px; border-radius: 12px;
  font: inherit; font-size: 0.95rem; font-weight: 500; cursor: pointer;
  text-decoration: none;
}
.side-nav-item:hover { background: var(--bg-soft); text-decoration: none; color: var(--ink); }
.storage-hint {
  font-size: 0.7rem;
  padding: 0 12px 6px;
  font-style: normal;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.side-nav-item .nav-ico {
  width: 22px; text-align: center; color: var(--ink-soft); font-size: 0.95rem;
  font-family: var(--mono); opacity: 0.9;
}
.side-details {
  border: 0; border-radius: 12px; padding: 0 4px;
  color: var(--muted); font-size: 0.78rem;
}
.side-details summary {
  cursor: pointer; list-style: none; padding: 6px 8px; border-radius: 8px;
  user-select: none;
}
.side-details summary::-webkit-details-marker { display: none; }
.side-details[open] summary { color: var(--ink-soft); }
.sidebar-bottom-bar {
  display: flex; align-items: center; gap: 10px;
}
.sidebar-bottom-bar .btn-new {
  flex: 1; min-width: 0; white-space: nowrap;
}
.sidebar-bottom-bar .auth-box-inline { flex: 0 0 auto; }
.conv-item {
  grid-template-columns: auto 1fr auto auto auto;
  gap: 8px;
}
.files-quota {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.files-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.files-upload-btn { cursor: pointer; display: inline-flex; align-items: center; }
.files-manager-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(55vh, 480px);
  overflow: auto;
}
.files-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid transparent;
}
.files-row:hover { border-color: var(--line); }
.files-main {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  min-width: 0;
  padding: 0;
}
.files-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 8px;
  background: #111;
  flex: 0 0 auto;
}
.files-ico {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #22211c;
  flex: 0 0 auto;
}
.files-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.files-meta strong {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.files-meta small { color: var(--muted); font-size: 0.72rem; }
.files-dl { text-decoration: none; min-width: 36px; text-align: center; }
.files-row .del { opacity: 0.85; }
.conv-item .conv-ico {
  color: var(--muted); font-size: 0.95rem; width: 18px; text-align: center;
  opacity: 0.75;
}
.conv-item.active .conv-ico { color: var(--accent); opacity: 1; }
.conv-list { padding: 4px 8px 12px; gap: 2px; }
.messages { padding: 8px 16px 12px; }
.messages-inner { gap: 22px; padding-bottom: 8px; }
.msg { gap: 12px; }
.msg.user { gap: 0; }
.msg.user .msg-body { margin-left: auto; }
.btn-stop {
  width: 36px; height: 36px; border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 18%, transparent);
}
.btn-gear i { background: var(--accent); color: var(--send-fg); }
.live-dot { opacity: 0.55; }
.md code { background: #2a2924; }
.md pre { background: #171612; border-color: #34322c; }
.md th { background: #2a2924; }
.reasoning, .tool-call {
  background: #26251f; border-color: #3a3933;
}
.reasoning summary { color: var(--accent-2); }
.reasoning-body { border-top-color: #34322c; }
.share-banner { background: #2a2924; }
.btn-login-mini {
  background: #5865F2; border-radius: 999px; box-shadow: none;
}
.user-avatar-btn { border-color: transparent; }
.prov-chip.active, .skill-chip.active {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: var(--accent-dim); color: var(--accent-2);
}
.usage-big {
  font-family: var(--serif);
  background: none; -webkit-background-clip: unset; background-clip: unset;
  color: var(--accent);
}
.modal { background: var(--panel); border-color: transparent; }
.cp-choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}
@media (min-width: 821px) {
  .topbar { display: flex; padding: 10px 18px 0; min-height: 48px; }
  .topbar .title { opacity: 0; pointer-events: none; }
  .top-ghost { margin-left: auto; }
}
@media (max-width: 820px) {
  .composer { border-radius: 20px; }
  .model-picker-wrap { max-width: 42%; }
  .btn-model-pill { font-size: 0.72rem; }
  .model-menu { left: 0; right: auto; min-width: min(260px, 86vw); }
  .empty h1 { font-size: 1.65rem; }
  .sidebar { background: #171612; }
}

/* —— LM Studio reasoning + context meter —— */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.reasoning-picker-wrap { display: flex; align-items: center; }
.reasoning-select {
  appearance: none;
  -webkit-appearance: none;
  max-width: 110px;
  cursor: pointer;
  padding-right: 22px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.ctx-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 160px;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.ctx-meter-bar {
  flex: 1;
  min-width: 48px;
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--line) 80%, transparent);
  overflow: hidden;
}
.ctx-meter-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .25s ease, background .25s ease;
}
.ctx-meter.warn .ctx-meter-bar > i { background: #e0b060; }
.ctx-meter.danger .ctx-meter-bar > i { background: var(--danger); }
.ctx-meter-label { white-space: nowrap; opacity: 0.9; }
.compact-banner {
  margin: 8px 14px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-elev));
  color: var(--accent-2);
  font-size: 0.82rem;
}
@media (max-width: 820px) {
  .ctx-meter { max-width: 110px; }
  .reasoning-select { max-width: 92px; font-size: 0.72rem; }
}


.model-menu-item.offline {
  opacity: 0.45;
  cursor: not-allowed;
}
.chat-inline-img,
.md img.chat-inline-img {
  max-width: 100%;
  max-height: min(70vh, 560px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  margin: 0.5em 0;
  border: 1px solid var(--line);
  background: #0a1018;
  display: block;
}

/* Site file tools modal */
.sf-actions { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0 6px; }
.sf-radio { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--ink); cursor: pointer; }
.sf-opts { margin-top: 8px; }
.sf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sf-result {
  margin-top: 12px;
  max-height: 320px;
  overflow: auto;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a1018;
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
#btn-site-file { font-size: 0.78rem; padding: 0 10px; white-space: nowrap; }
@media (max-width: 820px) {
  #btn-site-file { font-size: 0; padding: 0 8px; }
  #btn-site-file::before { content: "📂"; font-size: 0.95rem; }
}
