:root {
  --header: #008069;
  --header-2: #017561;
  --accent: #00a884;
  --accent-2: #008f72;
  --cf: #f6821f;
  --sidebar: #ffffff;
  --search-bg: #f0f2f5;
  --chat-bg: #efeae2;
  --incoming: #ffffff;
  --outgoing: #d9fdd3;
  --text: #111b21;
  --muted: #667781;
  --meta: #667781;
  --border: #e9edef;
  --active: #f0f2f5;
  --composer: #f0f2f5;
  --input: #ffffff;
  --app: #ffffff;
  --page: #e5ddd5;
  --strip: #008069;
  --shadow: 0 1px 3px rgba(11, 20, 26, 0.12);
  --danger: #d32f2f;
  --pattern: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'><g fill='none' stroke='%23d6cfc6' stroke-width='1.15' opacity='.85'><circle cx='22' cy='26' r='7'/><path d='M50 18h16M58 10v16'/><rect x='96' y='16' width='14' height='10' rx='2'/><path d='M142 30c6-8 14-8 20 0'/><path d='M16 92h10l6-10 6 10h10'/><circle cx='78' cy='90' r='5'/><path d='M112 84h16v12h-16z'/><path d='M150 96h16'/><path d='M20 146c8 0 8-10 16-10s8 10 16 10'/><circle cx='92' cy='148' r='6'/><path d='M124 138v16M132 146h-16'/><path d='M154 140l8 14 8-14'/></g></svg>");
  color-scheme: light;
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}

[data-theme="dark"] {
  --header: #202c33;
  --header-2: #202c33;
  --accent: #00a884;
  --accent-2: #06cf9c;
  --sidebar: #111b21;
  --search-bg: #111b21;
  --chat-bg: #0b141a;
  --incoming: #202c33;
  --outgoing: #005c4b;
  --text: #e9edef;
  --muted: #8696a0;
  --meta: rgba(233, 237, 239, 0.65);
  --border: #2a3942;
  --active: #2a3942;
  --composer: #202c33;
  --input: #2a3942;
  --app: #111b21;
  --page: #0b141a;
  --strip: #1f2c34;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --pattern: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'><g fill='none' stroke='%231a272e' stroke-width='1.2'><circle cx='22' cy='26' r='7'/><path d='M50 18h16M58 10v16'/><rect x='96' y='16' width='14' height='10' rx='2'/><path d='M142 30c6-8 14-8 20 0'/><path d='M16 92h10l6-10 6 10h10'/><circle cx='78' cy='90' r='5'/><path d='M112 84h16v12h-16z'/><path d='M150 96h16'/><path d='M20 146c8 0 8-10 16-10s8 10 16 10'/><circle cx='92' cy='148' r='6'/><path d='M124 138v16M132 146h-16'/><path d='M154 140l8 14 8-14'/></g></svg>");
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 127px;
  background: var(--strip);
  z-index: 0;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }

.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh;
  max-width: 1600px;
  margin: 0 auto;
  background: var(--app);
  box-shadow: var(--shadow);
  overflow: hidden;
}
@media (min-width: 1100px) {
  body { padding: 18px 16px; }
  .app { height: calc(100dvh - 36px); border-radius: 0; }
}

.sidebar {
  width: 400px;
  flex: 0 0 400px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--sidebar);
  border-inline-end: 1px solid var(--border);
}
.stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--chat-bg);
}

.topbar {
  height: 60px;
  flex: 0 0 60px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--header);
  color: #fff;
  position: relative;
  z-index: 5;
}
.brand, .peer {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: start;
  padding: 0;
}
.peer { cursor: pointer; border-radius: 8px; }
.brand-text, .peer-text { min-width: 0; }
.brand strong, .peer strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand small, .peer small {
  display: block;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.peer small.warn { color: #ffd7a8; }
.logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  place-items: center;
  color: #fff;
  flex: 0 0 auto;
}
.logo svg { width: 34px; height: 34px; }
.logo.lg {
  width: 84px;
  height: 84px;
  background: #e7f6f2;
  margin: 0 auto 8px;
}
.logo.lg svg { width: 64px; height: 64px; }
[data-theme="dark"] .logo.lg { background: #1f2c34; }

.top-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.icon-btn.light { color: #fff; }
.icon-btn.has-alert { position: relative; }
.icon-btn.has-alert::after {
  content: "";
  position: absolute;
  top: 7px;
  inset-inline-end: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5a5f;
  box-shadow: 0 0 0 2px var(--header);
}
.icon-btn:hover, .api-btn:hover { background: rgba(255, 255, 255, 0.12); }
.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.api-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--header);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 10px;
  height: 34px;
}
[data-theme="dark"] .api-btn { color: #111b21; }
.api-btn .icon { width: 16px; height: 16px; }
.api-btn.sm span { display: none; }
.api-btn.needs-key {
  background: var(--cf);
  color: #fff;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(246, 130, 31, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(246, 130, 31, 0); }
}
.back-btn { display: none; }

.search-wrap {
  position: relative;
  padding: 8px 12px;
  background: var(--search-bg);
  border-bottom: 1px solid var(--border);
}
.search-wrap input, #model-search, .field input, .field select, .custom-model input, #system-text, .rename {
  width: 100%;
  border: 0;
  background: var(--input);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
}
.search-wrap input {
  box-shadow: none;
  padding-inline-start: 36px;
}
.search-ico {
  position: absolute;
  inset-inline-start: 22px;
  top: 18px;
  width: 16px;
  height: 16px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
}
.chat-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.chat-item {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: start;
  min-height: 72px;
}
.chat-item:hover { background: color-mix(in srgb, var(--active) 70%, var(--sidebar)); }
.chat-item.active { background: var(--active); }
.avatar {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  flex: 0 0 auto;
  background: var(--av, var(--accent));
  letter-spacing: 0;
  font-size: 14px;
}
.chat-meta { flex: 1; min-width: 0; }
.chat-meta .row, .bubble .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-meta .row { min-width: 0; }
.chat-meta strong {
  font-size: 16px;
  font-weight: 600;
  min-width: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.when { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.preview {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.preview.live { color: var(--accent-2); }
.pin {
  width: 14px;
  height: 14px;
  margin-inline-start: 4px;
  vertical-align: -2px;
  fill: var(--muted);
}
.empty-list {
  padding: 36px 22px;
  text-align: center;
  color: var(--muted);
}
.side-foot {
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
}

.welcome, .thread {
  flex: 1;
  min-height: 0;
  background-color: var(--chat-bg);
  background-image: var(--pattern);
}
.welcome {
  display: grid;
  place-items: center;
  padding: 24px;
}
.welcome-card {
  width: min(460px, 100%);
  background: var(--incoming);
  background: color-mix(in srgb, var(--incoming) 94%, transparent);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}
.welcome-card h1 { margin: 0 0 8px; font-size: 28px; }
.welcome-card p { margin: 0 0 16px; color: var(--muted); }
.welcome-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.steps {
  text-align: start;
  margin: 18px 0 0;
  padding-inline-start: 18px;
  color: var(--muted);
  font-size: 14px;
}
.thread { position: relative; display: flex; flex-direction: column; }
.messages {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 7% 12px;
}
.day-chip, .note-chip {
  width: fit-content;
  margin: 10px auto;
  background: color-mix(in srgb, var(--incoming) 88%, #d1e7f0);
  color: var(--muted);
  font-size: 12.5px;
  padding: 5px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.1);
}
[data-theme="dark"] .day-chip, [data-theme="dark"] .note-chip {
  background: #182229;
  color: #d1d7db;
}
.msg {
  display: flex;
  margin: 2px 0;
}
.msg.out { justify-content: flex-end; }
.msg.in { justify-content: flex-start; }
.bubble {
  max-width: min(78%, 680px);
  border-radius: 10px;
  padding: 6px 8px 4px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  position: relative;
}
.msg.out .bubble {
  background: var(--outgoing);
  border-start-end-radius: 4px;
}
.msg.in .bubble {
  background: var(--incoming);
  border-start-start-radius: 4px;
}
.bubble-body { font-size: 14.6px; line-height: 1.65; overflow-wrap: anywhere; }
.bubble-body p { margin: 0 0 6px; }
.bubble-body p:last-child { margin-bottom: 0; }
.bubble-body .md-h { font-weight: 700; margin: 6px 0 2px; }
.bubble-body ul, .bubble-body ol { margin: 4px 0 6px; padding-inline-start: 18px; }
.bubble-body blockquote {
  margin: 6px 0;
  padding: 2px 10px;
  border-inline-start: 3px solid var(--accent);
  color: var(--muted);
}
.bubble-body a { color: #027eb5; }
[data-theme="dark"] .bubble-body a { color: #53bdeb; }
.bubble-body code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86em;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  padding: 0 4px;
  direction: ltr;
  unicode-bidi: isolate;
}
[data-theme="dark"] .bubble-body code { background: rgba(255, 255, 255, 0.08); }
.code {
  margin: 6px 0 2px;
  background: #111b21;
  color: #e9edef;
  border-radius: 8px;
  overflow: hidden;
  direction: ltr;
  text-align: left;
}
.code-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  color: #8696a0;
  font-size: 11px;
  background: #1d2a31;
}
.code-bar button {
  border: 0;
  background: transparent;
  color: #d1d7db;
  font-size: 12px;
}
.code code {
  display: block;
  padding: 8px 10px 10px;
  overflow-x: auto;
  white-space: pre;
  background: transparent;
  color: inherit;
  font-size: 12.5px;
  line-height: 1.55;
}
.pics { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.pics img {
  max-width: 260px;
  width: 100%;
  border-radius: 8px;
  display: block;
}
.meta {
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
  color: var(--meta);
  font-size: 11px;
  user-select: none;
}
.ticks { width: 16px; height: 11px; }
.ticks.read { color: #53bdeb; }
.msg-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  margin-top: 2px;
}
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg.show-actions .msg-actions, .msg.is-last .msg-actions {
  opacity: 1;
}
.msg-actions button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
}
.msg-actions button:hover { background: rgba(0, 0, 0, 0.05); }
.think {
  margin-bottom: 4px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  overflow: hidden;
}
[data-theme="dark"] .think { background: rgba(255, 255, 255, 0.05); }
.think summary {
  cursor: pointer;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12.5px;
}
.think pre {
  margin: 0;
  padding: 0 8px 8px;
  white-space: pre-wrap;
  font: inherit;
  font-size: 12.5px;
  color: var(--muted);
  max-height: 180px;
  overflow: auto;
}
.err {
  color: var(--danger);
  font-size: 13.5px;
}
.err-card {
  min-width: 180px;
}
.err-title {
  font-weight: 700;
  font-size: 13.5px;
  margin-bottom: 2px;
}
.err-code, .wait-clock {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  direction: ltr;
  text-align: left;
}
.err-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.err-actions button, .detail-btn {
  border: 0;
  background: rgba(0, 0, 0, 0.05);
  color: var(--accent-2);
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}
.detail {
  margin-top: 6px;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--muted);
  direction: ltr;
  text-align: left;
}
.err button {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font-weight: 700;
  padding: 0 4px;
}
.dots { display: inline-flex; gap: 4px; padding: 6px 2px; }
.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
.suggest {
  width: min(520px, 100%);
  margin: 8vh auto 0;
  background: color-mix(in srgb, var(--incoming) 94%, transparent);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.suggest h2 { margin: 0 0 4px; font-size: 18px; }
.suggest p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.suggest-grid { display: grid; gap: 8px; }
.suggest button, .jump {
  border: 1px solid var(--border);
  background: var(--sidebar);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: start;
}
.jump {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 6px 12px;
  font-size: 13px;
  z-index: 3;
}

.composer {
  position: relative;
  background: var(--composer);
  border-top: 1px solid transparent;
}
.edit-bar, .attach-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 12px 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--input);
  font-size: 13px;
  color: var(--muted);
  border-inline-start: 3px solid var(--accent);
}
.edit-bar button, .attach-row button {
  border: 0;
  background: transparent;
  color: var(--danger);
}
.thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.composer textarea {
  flex: 1;
  border: 0;
  resize: none;
  max-height: 140px;
  min-height: 42px;
  border-radius: 21px;
  background: var(--input);
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.45;
  outline: none;
}
.send {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 44px;
}
.send:disabled { opacity: 0.45; }
.send.stop { background: var(--danger); }
.plane { width: 20px; height: 20px; fill: #fff; transform: scaleX(-1); }
.mic.on { color: var(--danger); background: rgba(211, 47, 47, 0.1); }
.hint {
  display: none;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 0 8px 6px;
}
.emoji-pop {
  position: absolute;
  bottom: 62px;
  inset-inline-start: 10px;
  width: min(320px, calc(100% - 20px));
  background: var(--sidebar);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  z-index: 8;
}
.emoji-pop button {
  border: 0;
  background: transparent;
  font-size: 22px;
  border-radius: 8px;
  height: 36px;
}
.emoji-pop button:hover { background: var(--active); }

.dropdown {
  position: absolute;
  top: 52px;
  inset-inline-end: 8px;
  min-width: 210px;
  background: var(--sidebar);
  color: var(--text);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(11, 20, 26, 0.18);
  padding: 6px;
  z-index: 9;
}
.dropdown button {
  display: block;
  width: 100%;
  text-align: start;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 6px;
}
.dropdown button:hover { background: var(--active); }
.dropdown .danger { color: var(--danger); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(11, 20, 26, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-card {
  width: min(560px, 100%);
  max-height: min(88dvh, 760px);
  overflow: auto;
  background: var(--sidebar);
  color: var(--text);
  border-radius: 14px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.25);
}
.model-card { width: min(680px, 100%); }
.confirm-card { width: min(420px, 100%); }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 8px;
}
.modal-head h2 { margin: 0; font-size: 20px; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.modal-body { padding: 8px 16px 18px; }
.tabs { display: flex; gap: 6px; padding: 0 16px; }
.tab {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-weight: 600;
}
.tab.on { color: var(--accent-2); border-bottom-color: var(--accent); }
.field { display: grid; gap: 6px; margin: 12px 0; font-size: 14px; font-weight: 600; }
.field input, .field select, #system-text, .custom-model input {
  padding-inline: 12px;
  border: 1px solid var(--border);
  font-weight: 400;
  min-height: 42px;
}
#system-text { min-height: 140px; resize: vertical; padding: 10px 12px; }
.secret { display: flex; gap: 6px; }
.secret input { flex: 1; }
.secret button, .check {
  font-weight: 500;
  font-size: 14px;
}
.secret button {
  border: 1px solid var(--border);
  background: var(--search-bg);
  border-radius: 8px;
  padding: 0 10px;
}
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn {
  border-radius: 999px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  background: var(--sidebar);
  font-weight: 700;
}
.btn.primary, .btn.solid { background: var(--accent); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger-btn { color: var(--danger); margin-top: 8px; }
.verify {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--search-bg);
  font-size: 13.5px;
}
.verify.ok { background: #e7f7ef; color: #075e54; }
.verify.bad { background: #fdecea; color: #9b1c1c; }
[data-theme="dark"] .verify.ok { background: #12362e; color: #b7ebc9; }
[data-theme="dark"] .verify.bad { background: #3a1d1d; color: #ffc9c9; }
.help { margin-top: 14px; color: var(--muted); font-size: 14px; }
.help summary { cursor: pointer; color: var(--text); font-weight: 600; }
.help ol { padding-inline-start: 18px; }
.help-links { display: flex; gap: 12px; flex-wrap: wrap; }
.note { color: var(--muted); font-size: 13px; }
.account-chips, .chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.account-chips button, .chip {
  border: 1px solid var(--border);
  background: var(--search-bg);
  border-radius: 999px;
  padding: 6px 10px;
  white-space: nowrap;
  font-size: 13px;
}
.chip.on { background: var(--accent); color: #fff; border-color: transparent; }
.model-list { display: grid; gap: 8px; margin: 10px 0; max-height: 46dvh; overflow: auto; }
.model {
  display: flex;
  gap: 10px;
  width: 100%;
  text-align: start;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 12px;
  padding: 10px;
}
.model:hover, .model.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.model .name { font-weight: 700; }
.model .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--search-bg);
  color: var(--muted);
}
.tag.paid { background: rgba(246, 130, 31, 0.15); color: #c2410c; }
.custom-model { display: flex; gap: 8px; align-items: center; }
.custom-model input { flex: 1; }
.rename {
  font-weight: 700;
  font-size: 16px;
  padding: 2px 6px !important;
  min-height: 0;
  background: rgba(255, 255, 255, 0.16) !important;
  color: #fff !important;
}

.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100% - 24px));
}
.toast {
  background: #111b21;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.net-banner {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 80;
  background: #9b1c1c;
  color: #fff;
  padding: 10px 14px;
  text-align: center;
  font-size: 14px;
}
.pane-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: #9b1c1c;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}
.pane-status.warn { background: #b45309; }
.pane-status span { min-width: 0; }
.pane-status button {
  border: 0;
  background: rgba(255, 255, 255, 0.18);
  color: inherit;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
  white-space: nowrap;
}
.alerts {
  position: fixed;
  top: 16px;
  inset-inline-end: 16px;
  z-index: 75;
  width: min(420px, calc(100% - 24px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.alert {
  pointer-events: auto;
  background: var(--sidebar);
  color: var(--text);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(11, 20, 26, 0.22);
  padding: 12px;
  border-inline-start: 4px solid var(--danger);
  text-align: start;
}
.alert-warn { border-inline-start-color: #d97706; }
.alert-info { border-inline-start-color: var(--accent); }
.alert strong { display: block; font-size: 14.5px; }
.alert p { margin: 4px 0 0; font-size: 13.5px; }
.alert pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px;
  color: var(--muted);
  direction: ltr;
  text-align: left;
}
.alert-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.alert-actions button {
  border: 0;
  background: var(--search-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 700;
}
.sec-title { margin: 16px 0 6px; font-size: 14px; }
.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat {
  background: var(--search-bg);
  border-radius: 10px;
  padding: 8px;
  min-width: 0;
}
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat.bad strong { color: var(--danger); }
.stat.ok strong { color: var(--accent-2); }
.btn.on { outline: 2px solid var(--accent); }
.error-log { display: grid; gap: 8px; max-height: 220px; overflow: auto; }
.log-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.log-item div { display: flex; justify-content: space-between; gap: 8px; }
.log-item p { margin: 4px 0; font-size: 13px; }
.log-item code {
  display: block;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--muted);
  direction: ltr;
  text-align: left;
}
@media (max-width: 860px) {
  .alerts { top: 8px; inset-inline: 8px; width: auto; }
  .status-grid { grid-template-columns: 1fr; }
}

@media (min-width: 861px) {
  .hint { display: block; }
  .api-btn.sm span { display: inline; }
  #status-stage { display: none !important; }
}
@media (max-width: 860px) {
  body { padding: 0; background: var(--sidebar); }
  body::before { display: none; }
  .app { height: 100dvh; max-width: none; box-shadow: none; }
  .sidebar { width: 100%; flex: 1 1 auto; border: 0; }
  .stage { display: none; }
  body.pane-chat .sidebar { display: none; }
  body.pane-chat .stage { display: flex; width: 100%; }
  .back-btn { display: grid; }
  .messages { padding: 12px 10px 8px; }
  .bubble { max-width: 88%; }
  .welcome-card { box-shadow: none; background: transparent; }
  .modal { padding: 0; align-items: end; }
  .modal-card {
    width: 100%;
    max-height: 94dvh;
    border-end-start-radius: 0;
    border-end-end-radius: 0;
  }
}
@media (max-width: 1100px) and (min-width: 861px) {
  .sidebar { width: 330px; flex-basis: 330px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, 0.35); border-radius: 99px; }
