/* ============================================================
   OmniChat — Poe-style, dual theme.
   Dark: near-black canvas, luminous accent, app-tile gallery.
   Light: airy paper white, soft shadows, same colorful tiles.
   ============================================================ */

:root {
  --bg: #0e0e10;
  --rail: #131316;
  --panel: #17171b;
  --surface: #1c1c21;
  --raise: #222228;
  --border: #26262d;
  --hairline: #1f1f25;
  --text: #ececf1;
  --soft: #c9c9d2;
  --muted: #9b9ba6;
  --faint: #6b6b76;
  --accent: #8b7cf8;
  --danger: #f87171;

  --scroll: #2e2e36;
  --overlay-bg: rgba(8, 8, 10, 0.65);
  --glow: rgba(139, 124, 248, 0.16);
  --word-a: #ffffff;
  --word-b: #b9aefc;
  --tile-shadow: rgba(0, 0, 0, 0.45);
  --row-fade: rgba(14, 14, 16, 0.9);
  --composer-shadow: none;
  --shadow-pop: 0 30px 80px rgba(0, 0, 0, 0.6);
  --card-shadow: none;

  --font: -apple-system, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

html[data-theme="light"] {
  --bg: #f6f6f8;
  --rail: #ffffff;
  --panel: #ffffff;
  --surface: #f1f1f4;
  --raise: #e9e9ee;
  --border: #e4e4ea;
  --hairline: #ececf1;
  --text: #17171c;
  --soft: #45454e;
  --muted: #71717c;
  --faint: #a3a3ae;
  --accent: #7161f0;
  --danger: #dc2626;

  --scroll: #d6d6de;
  --overlay-bg: rgba(23, 23, 28, 0.35);
  --glow: rgba(113, 97, 240, 0.12);
  --word-a: #17171c;
  --word-b: #7161f0;
  --tile-shadow: rgba(23, 23, 28, 0.2);
  --row-fade: rgba(246, 246, 248, 0.95);
  --composer-shadow: 0 1px 2px rgba(20, 20, 30, 0.04),
                     0 14px 34px -14px rgba(20, 20, 30, 0.14);
  --shadow-pop: 0 30px 80px rgba(20, 20, 30, 0.22);
  --card-shadow: 0 1px 2px rgba(20, 20, 30, 0.04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

::selection { background: rgba(139, 124, 248, 0.35); }

:focus-visible { outline: 2px solid rgba(139, 124, 248, 0.4); outline-offset: 2px; }
textarea:focus-visible, input:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

.spacer { flex: 1; }

/* theme-dependent icon swap on the toggle button */
html[data-theme="light"] .ico-sun { display: none; }
html:not([data-theme="light"]) .ico-moon { display: none; }

/* ---------- wordmark ---------- */

.wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
}

.wordmark .mark {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 15px;
  filter: drop-shadow(0 6px 20px rgba(110, 120, 255, 0.4));
}
.wordmark .mark img { width: 100%; height: 100%; object-fit: contain; display: block; }

.wordmark .word {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1.5px;
  background: linear-gradient(100deg, var(--word-a) 30%, var(--word-b));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.wordmark.lg { margin-bottom: 6px; }
.wordmark.lg .mark { width: 44px; height: 44px; border-radius: 13px; }
.wordmark.lg .word { font-size: 27px; }

/* ---------- auth ---------- */

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 23rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--composer-shadow);
  padding: 36px 32px 30px;
  animation: rise 0.4s ease both;
}

.auth-sub {
  margin: 12px 0 22px;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  background: var(--surface);
  border-radius: 11px;
  padding: 3px;
  margin-bottom: 16px;
}

.auth-tab {
  border: none;
  border-radius: 8px;
  background: none;
  padding: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.auth-tab.active { background: var(--panel); color: var(--text); box-shadow: var(--card-shadow); }
html:not([data-theme="light"]) .auth-tab.active { background: var(--raise); }

.field-label {
  display: block;
  margin: 14px 2px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  padding: 10px 13px;
  font: 14px/1.5 var(--font);
  color: var(--text);
  transition: border-color 0.15s;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--faint); }

.auth-error {
  min-height: 18px;
  margin: 10px 2px 4px;
  font-size: 12.5px;
  color: var(--danger);
}

.cta {
  width: 100%;
  border: none;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 1.5px;
  padding: 12px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s, opacity 0.15s;
}
.cta:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.cta:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- shell ---------- */

.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* icon rail */

.rail {
  flex-shrink: 0;
  width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 0;
  background: var(--rail);
  border-right: 1px solid var(--hairline);
  transition: background 0.25s ease;
}

.rail-logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: none;
  border-radius: 12px;
  background: none;
  padding: 0;
  cursor: pointer;
  margin-bottom: 12px;
  transition: transform 0.15s, filter 0.15s;
}
.rail-logo:hover { transform: translateY(-1px); filter: drop-shadow(0 4px 14px rgba(110, 120, 255, 0.45)); }
.rail-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

.rail-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border: none;
  border-radius: 11px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.13s, color 0.13s;
}
.rail-btn:hover { background: var(--raise); color: var(--text); }
.rail-btn.active { background: var(--raise); color: var(--text); }
.rail-btn svg { width: 19px; height: 19px; }

.rail-spacer { flex: 1; }

.rail-avatar {
  width: 34px; height: 34px;
  margin-top: 4px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #8b7cf8, #5a8bff);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

/* history drawer */

.drawer {
  flex-shrink: 0;
  width: 284px;
  display: flex;
  flex-direction: column;
  background: var(--rail);
  border-right: 1px solid var(--hairline);
  animation: rise 0.2s ease both;
  transition: background 0.25s ease;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 10px;
}

.drawer-title { font-size: 15px; font-weight: 750; }

.credits-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.drawer-head { flex-wrap: nowrap; }
.drawer-head .ghost-btn { margin-left: 8px; flex-shrink: 0; }

.ghost-btn {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: var(--soft);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 13px;
  cursor: pointer;
  transition: background 0.13s, color 0.13s, border-color 0.13s;
}
.ghost-btn:hover { background: var(--raise); color: var(--text); border-color: var(--border); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-list::-webkit-scrollbar { width: 6px; }
.chat-list::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 3px; }

.chat-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  border: none;
  border-radius: 11px;
  background: none;
  padding: 9px 12px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.chat-item:hover { background: var(--raise); }
.chat-item.active { background: var(--surface); }

.chat-item-title {
  display: block;
  width: 100%;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item:hover .chat-item-title, .chat-item.active .chat-item-title { color: var(--text); }

.chat-item-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--faint);
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.chat-item-del {
  position: absolute;
  top: 8px; right: 8px;
  display: none;
  width: 20px; height: 20px;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--faint);
  font-size: 11px;
  cursor: pointer;
}
.chat-item:hover .chat-item-del { display: grid; }
.chat-item-del:hover { color: var(--danger); background: rgba(248, 113, 113, 0.12); }

.chat-list-empty {
  margin: 10px 12px;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.9;
}

/* ---------- main ---------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- home ---------- */

.home {
  flex: 1;
  overflow-y: auto;
  padding: 0 32px 60px;
}
.home::-webkit-scrollbar { width: 8px; }
.home::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 4px; }

.hero {
  position: relative;
  z-index: 0;
  max-width: 860px;
  margin: 0 auto;
  padding-top: clamp(48px, 14vh, 150px);
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: rise 0.4s ease both;
}

/* soft accent glow behind the hero — gives the empty canvas some depth */
.hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, 90%);
  height: 360px;
  background: radial-gradient(closest-side, var(--glow), transparent 72%);
  pointer-events: none;
}

/* quick chips */

.chip-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--surface);
  color: var(--soft);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 13px 6px 7px;
  cursor: pointer;
  transition: background 0.13s, color 0.13s, border-color 0.13s;
}
.chip:hover { background: var(--raise); color: var(--text); }
html[data-theme="light"] .chip { border-color: var(--border); background: var(--panel); box-shadow: var(--card-shadow); }
html[data-theme="light"] .chip:hover { background: var(--surface); }
.chip.icon-only { padding: 6px 9px; color: var(--muted); }

.chip svg { width: 15px; height: 15px; }

/* composer (shared home + chat) */

.composer {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--composer-shadow);
  padding: 16px 18px 10px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.25s ease;
}
.composer:focus-within {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent),
              var(--composer-shadow);
}

.composer textarea {
  display: block;
  width: 100%;
  border: none;
  resize: none;
  background: transparent;
  color: var(--text);
  font: 15px/1.7 var(--font);
  min-height: 27px;
  max-height: 180px;
}
.composer textarea::placeholder { color: var(--faint); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 9px;
}

.composer-model {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  background: var(--surface);
  color: var(--soft);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px 5px 6px;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
}
.composer-model:hover { background: var(--raise); color: var(--text); }
.composer-model svg { width: 14px; height: 14px; flex-shrink: 0; }
.composer-model.on {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}

.composer-hint { font-size: 11px; color: var(--faint); }

/* pending attachment chips inside the composer */

.att-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 9px;
}

.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 6px 4px 10px;
  font-size: 12px;
  color: var(--soft);
  animation: rise 0.2s ease both;
  max-width: 260px;
  overflow: hidden;
  white-space: nowrap;
}
.att-chip svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--accent); }

.att-x {
  display: grid;
  place-items: center;
  width: 17px; height: 17px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--faint);
  font-size: 10px;
  cursor: pointer;
}
.att-x:hover { background: var(--raise); color: var(--text); }

.att-spin {
  flex-shrink: 0;
  width: 12px; height: 12px;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: att-spin 0.8s linear infinite;
}
@keyframes att-spin { to { transform: rotate(360deg); } }

.send-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s, opacity 0.15s;
}
.send-btn:hover:not(:disabled) { filter: brightness(1.12); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; background: var(--raise); color: var(--muted); }
.send-btn svg { width: 17px; height: 17px; }

.home-note {
  margin: -8px 4px 0;
  text-align: center;
  font-size: 12px;
  color: var(--faint);
  min-height: 16px;
}
.home-note.error { color: var(--danger); }

/* ---------- bot icons ---------- */

.bot-ico {
  position: relative;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 76px; height: 76px;
  border-radius: 22px;
  color: #fff;
  font-weight: 800;
  font-size: 27px;
  letter-spacing: -1px;
  user-select: none;
}
.bot-ico.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 13px; letter-spacing: -0.5px; }
.bot-ico.xs { width: 22px; height: 22px; border-radius: 7px; font-size: 10.5px; letter-spacing: -0.5px; }
.bot-ico.md { width: 58px; height: 58px; border-radius: 17px; font-size: 22px; }
.bot-ico.xl { width: 88px; height: 88px; border-radius: 26px; font-size: 32px; }

/* LobeHub brand SVG recolored to white via mask (mask-image set inline);
   absolutely positioned so it can't disturb tile layout */
.bot-mark {
  position: absolute;
  inset: 21%;
  background: #fff;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  mask-repeat: no-repeat;
}

/* ---------- bot gallery ---------- */

.bot-sections {
  max-width: 860px;
  margin: 54px auto 0;
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.bot-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.bot-section-title { margin: 0; font-size: 16.5px; font-weight: 750; }

.see-all {
  border: none;
  background: none;
  color: var(--accent);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
}
.see-all:hover { text-decoration: underline; }

.bot-row-wrap { position: relative; }

.bot-row {
  display: flex;
  gap: 22px;
  overflow-x: auto;
  scroll-behavior: smooth;
  padding: 4px 2px 8px;
  scrollbar-width: none;
}
.bot-row::-webkit-scrollbar { display: none; }

.bot-section.expanded .bot-row { flex-wrap: wrap; overflow: visible; }
.bot-section.expanded .row-arrow { display: none; }

.row-arrow {
  position: absolute;
  right: -6px;
  top: 26px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--soft);
  cursor: pointer;
  box-shadow: -14px 0 24px var(--row-fade), var(--card-shadow);
  transition: background 0.13s, color 0.13s;
}
.row-arrow:hover { background: var(--raise); color: var(--text); }
.row-arrow svg { width: 16px; height: 16px; }

.bot-tile {
  flex-shrink: 0;
  width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  border: none;
  background: none;
  padding: 4px 2px;
  font-family: var(--font);
  cursor: pointer;
}
.bot-tile .bot-ico { transition: transform 0.15s, box-shadow 0.15s; }
.bot-tile:hover .bot-ico { transform: translateY(-3px); box-shadow: 0 10px 26px var(--tile-shadow); }

.bot-tile-name {
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--soft);
  text-align: center;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}
.bot-tile:hover .bot-tile-name { color: var(--text); }

.ico-wrap { position: relative; }

.bot-badge {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
  font-size: 9.5px;
  font-weight: 700;
  color: #fff;
  background: #3f3f4a;
  border: 1px solid #4d4d59;
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}
html[data-theme="light"] .bot-badge { background: #17171c; border-color: #17171c; }

.bot-empty {
  margin: 4px 2px;
  font-size: 13px;
  color: var(--faint);
}

/* ---------- chat view ---------- */

.chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--hairline);
}

.chat-model-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: none;
  border-radius: 11px;
  background: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.13s;
}
.chat-model-btn:hover { background: var(--raise); }
.chat-model-btn .chev { width: 13px; height: 13px; color: var(--muted); }

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 24px 10px;
  scroll-behavior: smooth;
}
.thread::-webkit-scrollbar { width: 8px; }
.thread::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 4px; }

.thread-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* empty-state hello */

.bot-hello {
  margin: auto;
  padding-top: 8vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.bot-hello-name { margin: 12px 0 0; font-size: 19px; font-weight: 750; }
.bot-hello-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.8; max-width: 30rem; }
.bot-hello-sub { margin: 2px 0 0; font-size: 11.5px; color: var(--faint); }

/* messages */

.msg {
  display: flex;
  flex-direction: column;
  animation: rise 0.25s ease both;
}

.msg.user { align-items: flex-end; }

.msg.user .msg-body {
  max-width: 78%;
  background: var(--raise);
  border-radius: 18px 18px 6px 18px;
  padding: 11px 16px;
  font-size: 14.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
html[data-theme="light"] .msg.user .msg-body {
  background: #17171c;
  color: #f4f4f7;
}

.msg.bot { align-items: flex-start; }

.msg-head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--soft);
}

.msg.bot .msg-body {
  max-width: 100%;
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--soft);
  word-break: break-word;
}

.msg-body h4 { margin: 8px 0 3px; font-size: 14.5px; font-weight: 700; color: var(--text); }
.msg-body ul { margin: 4px 0; padding-left: 20px; }
.msg-body li { margin: 2px 0; }
.msg-body strong { color: var(--text); font-weight: 650; }
.msg-body code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.5px 5px;
}
/* code blocks stay dark in both themes — reads as a designed surface */
.msg-body pre {
  margin: 10px 0;
  padding: 13px 15px;
  background: #101014;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow-x: auto;
}
html[data-theme="light"] .msg-body pre { border-color: #101014; }
.msg-body pre code {
  display: block;
  background: none;
  border: none;
  padding: 0;
  color: #dcdce4;
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre;
}

/* rich markdown extras */
.msg-body h1, .msg-body h2, .msg-body h3 {
  margin: 14px 0 6px;
  font-size: 15.5px;
  font-weight: 750;
  color: var(--text);
}
.msg-body h1 { font-size: 17px; }
.msg-body p { margin: 6px 0; }
.msg-body ol { margin: 4px 0; padding-left: 22px; }
.msg-body table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}
.msg-body th, .msg-body td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  text-align: left;
}
.msg-body th { background: var(--surface); color: var(--text); font-weight: 650; }
.msg-body blockquote {
  margin: 8px 0;
  padding: 2px 14px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}
.msg-body hr { border: none; border-top: 1px solid var(--hairline); margin: 14px 0; }
.msg-body img { max-width: 100%; border-radius: 10px; }
.msg-body .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.msg-body .katex { font-size: 1.05em; }

/* code block toolbar */
.msg-body pre { position: relative; padding-top: 0; }
.msg-body pre code.hljs { background: transparent; padding: 0; }
.code-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 -15px 11px;
  padding: 7px 12px 7px 15px;
  border-bottom: 1px solid #23232b;
}
.code-lang {
  font-family: var(--mono);
  font-size: 10.5px;
  color: #8b8b96;
  text-transform: lowercase;
}
.code-acts { display: flex; gap: 6px; }
.code-btn {
  border: none;
  border-radius: 6px;
  background: #23232b;
  color: #c9c9d2;
  font-family: var(--font);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
}
.code-btn:hover { background: #2f2f3a; color: #fff; }

/* html preview modal (canvas 画布) */
.preview-modal {
  width: 100%;
  max-width: 62rem;
  height: 80vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: rise 0.2s ease both;
}
.preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--hairline);
}
.preview-title { font-size: 13.5px; font-weight: 700; }
.preview-modal iframe { flex: 1; border: none; background: #fff; }

.msg-err { color: var(--danger); }

.sys-note {
  align-self: center;
  font-size: 11px;
  color: var(--faint);
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--surface);
}

.msg-meta {
  margin-top: 7px;
  font-size: 10.5px;
  color: var(--faint);
  user-select: none;
}

/* attachments shown inside a sent message */

.msg-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.msg-att-img {
  max-width: 240px;
  max-height: 180px;
  border-radius: 12px;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.msg-att-file {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 11.5px;
  opacity: 0.85;
}

/* streamed reasoning (chain of thought) */

.think {
  margin: 0 0 10px;
  border-left: 2px solid var(--border);
  padding-left: 12px;
}
.think summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--faint);
  user-select: none;
  list-style: none;
}
.think summary::before { content: "▸ "; }
.think[open] summary::before { content: "▾ "; }
.think-body {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.75;
  color: var(--faint);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
}

.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.1s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing { 40% { transform: translateY(-4px); opacity: 0.5; } }

.chat-composer-wrap {
  padding: 10px 24px 18px;
}
.chat-composer-wrap .composer {
  max-width: 780px;
  margin: 0 auto;
}

/* ---------- admin ---------- */

.admin {
  flex: 1;
  overflow-y: auto;
  padding: 40px 32px 60px;
}

.admin-wrap { max-width: 640px; margin: 0 auto; }

.admin-title { margin: 0 0 6px; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.admin-sub { margin: 0 0 22px; font-size: 12.5px; line-height: 1.8; color: var(--muted); }

.admin-list { display: flex; flex-direction: column; gap: 8px; }

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--card-shadow);
  padding: 12px 14px;
}

.admin-avatar {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b7cf8, #5a8bff);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.admin-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 650;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.tag {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  border-radius: 5px;
  padding: 1.5px 7px;
  margin-left: 6px;
  vertical-align: 1px;
}
.tag-admin { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.tag-ban { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }

.admin-credits {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  min-width: 64px;
  text-align: right;
}

.admin-acts { flex-shrink: 0; display: flex; gap: 6px; }
.admin-acts .ghost-btn { font-size: 11.5px; padding: 5px 10px; }

/* ---------- model overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
  background: var(--overlay-bg);
  backdrop-filter: blur(3px);
}

.model-modal {
  width: 100%;
  max-width: 34rem;
  max-height: 62vh;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: rise 0.2s ease both;
}

.model-search {
  border: none;
  border-bottom: 1px solid var(--hairline);
  background: transparent;
  color: var(--text);
  font: 14.5px/1.5 var(--font);
  padding: 15px 18px;
}
.model-search::placeholder { color: var(--faint); }

.model-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.model-list::-webkit-scrollbar { width: 7px; }
.model-list::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 4px; }

.model-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  border-radius: 12px;
  background: none;
  padding: 9px 12px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}
.model-row:hover { background: var(--raise); }
.model-row.selected { background: var(--surface); }

.model-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.model-row-name {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-row-desc {
  font-size: 11.5px;
  color: var(--faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-row-vendor {
  flex-shrink: 0;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--faint);
  text-transform: uppercase;
}

.model-row-rate {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
}

.model-list-empty { margin: 14px; font-size: 13px; color: var(--faint); }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .drawer { position: fixed; left: 64px; top: 0; bottom: 0; z-index: 40; box-shadow: 20px 0 60px rgba(0,0,0,0.5); }
  .wordmark .word { font-size: 34px; }
  .home { padding: 0 18px 40px; }
}
