:root {
  --white: #ffffff;
  --ink: #111318;
  --muted: #6b7079;
  --line: #d9dadd;
  --line-soft: #e8e9eb;
  --surface: #f1f1f2;
  --blue: #4b5563;
  --deep: #15171b;
  --green: #2e9e44;
  --red: #d64545;
  --left-w: 264px;
  --right-w: 322px;
  --grid: rgba(17, 19, 24, 0.04);
  --glass: rgba(255, 255, 255, 0.92);
  --glass-2: rgba(255, 255, 255, 0.55);
  --glass-3: rgba(255, 255, 255, 0.86);
  --glass-4: rgba(255, 255, 255, 0.94);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--white);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

::selection { background: var(--deep); color: #fff; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8cacc; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.hidden { display: none !important; }

.app-shell {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  transition: grid-template-columns 0.25s ease;
}
.app-shell.settings-closed { grid-template-columns: var(--left-w) minmax(0, 1fr) 0px; }
.app-shell.settings-closed .settings-panel {
  overflow: hidden;
  border-left: 0;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
.app-shell.settings-open .settings-panel { visibility: visible; }

/* ============ Brand ============ */
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: "Orbitron", sans-serif;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 1.2px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.brand .mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--blue);
  color: var(--blue);
  flex-shrink: 0;
}
.brand .mark svg { width: 14px; height: 14px; }
.brand > span:last-child { color: var(--blue); }

.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { border-color: var(--blue); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }
.mobile-only { display: none; }

/* ============ Left sidebar ============ */
.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sb-top {
  flex-shrink: 0;
  padding: 16px 14px 14px;
  border-bottom: 1px solid var(--line);
}
.sb-top .brand { margin-bottom: 14px; padding-left: 2px; }

.new-chat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 38px;
  border: 1px solid var(--deep);
  background: var(--deep);
  color: #fff;
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  transition: opacity 0.15s ease;
}
.new-chat-btn:hover { opacity: 0.86; }
.new-chat-btn svg { width: 13px; height: 13px; }

.sb-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 10px;
}
.sb-label {
  padding: 0 6px 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.chat-list { display: flex; flex-direction: column; gap: 2px; }

.chat-item {
  display: flex;
  align-items: stretch;
  border: 1px solid transparent;
  transition: background 0.13s ease, border-color 0.13s ease;
}
.chat-item:hover { background: var(--surface); }
.chat-item.active { background: var(--deep); border-color: var(--deep); }
.ci-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 8px 9px 11px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
}
.ci-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ci-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-item.active .ci-main { color: #fff; }
.chat-item.active .ci-meta { color: #9aa5b4; }
.ci-del {
  width: 27px;
  flex-shrink: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  display: grid;
  place-items: center;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.ci-del svg { width: 12px; height: 12px; }
.ci-del:hover { color: var(--red); }
.chat-item:hover .ci-del { opacity: 1; }
.chat-item.active .ci-del { color: #8d97a5; }
.chat-item.active .ci-del:hover { color: #ff8b8b; }

.empty-chats {
  padding: 18px 8px;
  border: 1px dashed var(--line);
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
}

/* Sidebar account */
.sb-account {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sba-main { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sba-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.sba-main b {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sba-balance {
  flex-shrink: 0;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: var(--white);
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink);
}

/* ============ Center chat ============ */
.chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--glass-2);
}

.chat-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--glass-3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 20;
}
.chat-head-copy { flex: 1; min-width: 0; }
.chat-title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-sub {
  margin-top: 2px;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-head-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.header-balance {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.header-balance:hover { border-color: var(--blue); }
.header-balance .hb-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.header-balance b {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.thread {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 26px 26px 10px;
}

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: calc(100dvh - 250px);
  padding: 30px 0 40px;
  animation: fadeUp 0.4s ease;
}
.hero-mark {
  position: relative;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 2px solid var(--blue);
  color: var(--blue);
  font-family: "Orbitron", sans-serif;
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 22px;
}
.hero-mark::after {
  content: "";
  position: absolute;
  inset: -7px;
  border: 1px solid var(--line);
  pointer-events: none;
}
.hero h1 {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(28px, 4.6vw, 42px);
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 1;
  color: var(--ink);
}
.hero h1 span { color: var(--blue); }
.hero-sub {
  margin-top: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}
.hero-line { width: 56px; height: 1px; background: var(--line); margin: 26px 0; }

.suggestions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 600px;
}
.sugg {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  text-align: left;
  background: var(--white);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.sugg:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(21, 23, 27, 0.08);
}
.sugg .si {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--blue);
  flex-shrink: 0;
}
.sugg .si svg { width: 15px; height: 15px; }
.sugg-copy { min-width: 0; }
.sugg strong { display: block; font-size: 12px; font-weight: 700; color: var(--ink); }
.sugg small {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Messages */
.msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 28px;
  animation: fadeUp 0.22s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user { align-items: flex-end; }
.msg.user .bubble {
  max-width: 86%;
  padding: 12px 16px;
  background: var(--deep);
  border: 1px solid #252c36;
  color: #f4f7fb;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.assistant { align-items: stretch; }
.msg-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.avatar {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--blue);
  color: var(--blue);
  font-family: "Orbitron", sans-serif;
  font-size: 9px;
  font-weight: 900;
  flex-shrink: 0;
}
.who {
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink);
}
.msg-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  letter-spacing: 1px;
  color: var(--muted);
  margin-left: auto;
}

/* Thinking */
.think { margin-bottom: 11px; border: 1px solid var(--line); background: var(--surface); max-width: 100%; }
.think-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 11px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.think.open .think-toggle { color: var(--ink); }
.think-icon { width: 12px; height: 12px; color: var(--blue); flex-shrink: 0; }
.think.streaming .think-icon { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.88); }
}
.think-label { flex: 1; }
.think-dots { display: inline-flex; gap: 3px; margin-right: 2px; }
.think-dots i {
  width: 3px;
  height: 3px;
  background: var(--blue);
  border-radius: 50%;
  animation: blink 1.2s infinite;
}
.think-dots i:nth-child(2) { animation-delay: 0.18s; }
.think-dots i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}
.think-chev { width: 11px; height: 11px; transition: transform 0.2s ease; flex-shrink: 0; }
.think.open .think-chev { transform: rotate(180deg); }
.think-body { max-height: 0; overflow: hidden; transition: max-height 0.26s ease; }
.think.open .think-body { max-height: 320px; overflow-y: auto; }
.think-text {
  margin: 0 11px;
  padding: 9px 0 11px;
  border-top: 1px dashed var(--line);
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Markdown */
.msg .content {
  font-size: 14px;
  line-height: 1.72;
  color: var(--ink);
  word-break: break-word;
}
.content.streaming::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  background: var(--blue);
  vertical-align: -2px;
  animation: caret 1s step-end infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 {
  margin: 20px 0 9px;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.md h1 { font-size: 21px; }
.md h2 { font-size: 18px; }
.md h3 { font-size: 16px; }
.md h4 { font-size: 14.5px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 21px; }
.md li { margin: 4px 0; }
.md li > p { margin: 0; }
.md a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.md a:hover { color: var(--blue); }
.md strong { font-weight: 700; }
.md em { font-style: italic; }
.md del { color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.md blockquote {
  margin: 0 0 12px;
  padding: 6px 0 6px 13px;
  border-left: 2px solid var(--blue);
  color: var(--muted);
}
.md blockquote p:last-child { margin-bottom: 0; }
.md code {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1px 5px;
}
.md pre { margin: 13px 0; background: var(--deep); border: 1px solid #252c36; overflow: hidden; }
.md pre .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid #2a323d;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #9aa5b4;
}
.md pre code {
  display: block;
  padding: 13px;
  border: 0;
  background: none;
  color: #e8edf4;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
.code-file { display: flex; align-items: center; gap: 8px; min-width: 0; }
.code-file-name { color: #e8edf4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-lang { color: #6f7b8c; }
.code-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.copy-code,
.download-code {
  border: 1px solid #39424e;
  background: transparent;
  color: #9aa5b4;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.copy-code:hover,
.download-code:hover { color: #fff; border-color: #6b7079; }

/* Waiting dots */
.waiting { display: inline-flex; align-items: center; gap: 5px; padding: 7px 0; }
.waiting i { width: 5px; height: 5px; background: var(--blue); border-radius: 50%; animation: blink 1.2s infinite; }
.waiting i:nth-child(2) { animation-delay: 0.18s; }
.waiting i:nth-child(3) { animation-delay: 0.36s; }

/* ============ Composer ============ */
.composer-wrap {
  position: relative;
  flex-shrink: 0;
  padding: 8px 22px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--white) 60%, rgba(255, 255, 255, 0));
  z-index: 15;
}
.composer-wrap.drag-over::after {
  content: "Drop files here";
  position: absolute;
  inset: 5px 12px 9px;
  z-index: 30;
  display: grid;
  place-items: center;
  border: 1px dashed var(--blue);
  background: var(--glass-4);
  color: var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  pointer-events: none;
}

.model-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 828px;
  margin: 0 auto 8px;
  padding-bottom: 2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.model-strip::-webkit-scrollbar { height: 0; }
.mchip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.13s ease, background 0.13s ease, color 0.13s ease;
}
.mchip:hover { border-color: var(--blue); color: var(--ink); }
.mchip.active { background: var(--deep); border-color: var(--deep); color: #fff; }
.mchip .m-dot {
  width: 5px;
  height: 5px;
  background: var(--line);
  flex-shrink: 0;
}
.mchip.active .m-dot { background: var(--green); }

.model-bar {
  position: relative;
  width: 100%;
  max-width: 828px;
  margin: 0 auto 8px;
}
.model-trigger {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.model-trigger:hover { border-color: var(--blue); }
.model-trigger[aria-expanded="true"] { border-color: var(--blue); background: var(--surface); }
.mt-spark {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--blue);
}
.mt-spark svg { width: 12px; height: 12px; }
.mt-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.mt-label {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mt-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mt-chev { width: 13px; height: 13px; color: var(--muted); flex-shrink: 0; transition: transform 0.18s ease; }
.model-trigger[aria-expanded="true"] .mt-chev { transform: rotate(180deg); }

.model-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 60;
  width: min(430px, calc(100vw - 44px));
  max-height: min(66dvh, 560px);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--white);
  box-shadow: 0 18px 50px rgba(17, 19, 24, 0.16);
  animation: fadeUp 0.14s ease;
}
.mp-kicker {
  padding: 1px 2px 9px;
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.mp-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 9px 9px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--white);
}
.mp-search:focus-within { border-color: var(--blue); }
.mp-search svg { width: 13px; height: 13px; color: var(--muted); flex-shrink: 0; }
.mp-search input {
  flex: 1;
  height: 34px;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: "Inter", sans-serif;
  font-size: 12px;
}
.mp-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #c8cacc transparent;
}
.mp-list::-webkit-scrollbar { width: 5px; }
.mp-list::-webkit-scrollbar-thumb { background: #c8cacc; }
.mp-provider {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px 5px;
  background: var(--white);
  border-bottom: 1px solid var(--line-soft);
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}
.mp-provider:first-child { padding-top: 2px; }
.mp-provider b { color: var(--ink); font-weight: 700; }
.mp-empty {
  padding: 20px 10px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.mp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.mp-item:hover { background: var(--surface); }
.mp-item.active { background: var(--surface); border-color: var(--line); }
.mp-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.mp-check {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid transparent;
  color: transparent;
  font-size: 11px;
  font-weight: 800;
}
.mp-item.active .mp-check { border-color: var(--deep); background: var(--deep); color: #fff; }
.mp-sep { height: 1px; background: var(--line); margin: 11px 9px; }
.mp-think-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 9px; }
.mp-think-copy { display: flex; flex-direction: column; gap: 1px; }
.mp-think-title { font-size: 12px; font-weight: 700; }
.mp-think-sub {
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}
.mp-efforts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin: 10px 9px 0;
}
.mp-efforts button {
  height: 31px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.13s ease;
}
.mp-efforts button:hover { border-color: var(--blue); color: var(--ink); }
.mp-efforts button.active { background: var(--deep); border-color: var(--deep); color: #fff; }
.mp-efforts.disabled { opacity: 0.4; pointer-events: none; }
.mp-hint {
  padding: 8px 9px 2px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  max-width: 828px;
  margin: 0 auto;
  padding: 9px 9px 9px 15px;
  background: var(--white);
  border: 1px solid var(--line);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer:focus-within { border-color: var(--blue); box-shadow: 0 8px 30px rgba(21, 23, 27, 0.07); }
.composer textarea {
  flex: 1;
  min-height: 38px;
  max-height: 180px;
  padding: 8px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-family: "Inter", sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
}
.composer textarea::placeholder { color: #9aa0a8; }

.composer-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.composer-tool {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.composer-tool:hover { border-color: var(--blue); color: var(--ink); }
.composer-tool:disabled { opacity: 0.4; cursor: default; border-color: var(--line); color: var(--muted); }
.composer-tool svg { width: 16px; height: 16px; }
.file-input { display: none; }

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  max-width: 828px;
  max-height: 126px;
  overflow-y: auto;
  margin: 0 auto 6px;
}
.attach-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 250px;
  padding: 5px 6px;
  border: 1px solid var(--line);
  background: var(--white);
}
.attach-thumb,
.attach-ext {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: 1px solid var(--line-soft);
  object-fit: cover;
}
.attach-ext {
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.attach-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.attach-name {
  max-width: 165px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink);
}
.attach-size {
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.attach-remove {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.attach-remove:hover { color: var(--red); }

.msg-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.msg-file {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 270px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}
.msg-file img,
.msg-file .mf-ext {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.12);
}
.msg-file .mf-ext {
  display: grid;
  place-items: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #f4f7fb;
}
.msg-file .mf-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.msg-file .mf-name {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
  font-weight: 600;
}
.msg-file .mf-size {
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  letter-spacing: 0.4px;
  color: rgba(244, 247, 251, 0.65);
}

.think-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.think-btn:hover { border-color: var(--blue); }
.think-btn svg { width: 12px; height: 12px; }
.think-btn .mini-track {
  position: relative;
  width: 24px;
  height: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: background 0.18s ease, border-color 0.18s ease;
}
.think-btn .mini-track i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 7px;
  height: 7px;
  background: var(--muted);
  transition: left 0.18s ease, background 0.18s ease;
}
.think-btn[aria-checked="true"] { border-color: var(--blue); color: var(--ink); }
.think-btn[aria-checked="true"] .mini-track { background: var(--deep); border-color: var(--deep); }
.think-btn[aria-checked="true"] .mini-track i { left: 13px; background: #fff; }

.effort-wrap { position: relative; display: flex; align-items: center; }
.effort-wrap select {
  appearance: none;
  -webkit-appearance: none;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--white);
  padding: 0 26px 0 9px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  outline: none;
}
.effort-wrap select:focus { border-color: var(--blue); color: var(--ink); }
.effort-wrap .chev { position: absolute; right: 8px; width: 11px; height: 11px; color: var(--muted); pointer-events: none; }
.effort-wrap.off { opacity: 0.42; pointer-events: none; }

.send-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 0;
  background: var(--deep);
  color: #fff;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}
.send-btn:hover:not(:disabled) { opacity: 0.86; }
.send-btn:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.send-btn svg { width: 15px; height: 15px; }
.send-btn .ico-stop { display: none; }
.send-btn.stop { background: var(--red); }
.send-btn.stop .ico-send { display: none; }
.send-btn.stop .ico-stop { display: block; }

.composer-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 828px;
  margin: 7px auto 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============ Right settings ============ */
.settings-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-left: 1px solid var(--line);
  background: var(--glass-4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.2s ease;
}
.set-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 16px 14px;
  border-bottom: 1px solid var(--line);
}
.set-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.set-head h2 {
  font-family: "Orbitron", sans-serif;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.set-scroll { flex: 1; overflow-y: auto; padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }
.set-block { margin-bottom: 22px; }
.set-block:last-child { margin-bottom: 0; }
.set-label {
  margin-bottom: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

.balance-card {
  padding: 16px;
  background: var(--deep);
  border: 1px solid #252c36;
  color: #fff;
}
.bal-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bal-amount {
  font-family: "Orbitron", sans-serif;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: 0.5px;
  line-height: 1;
}
.mini-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid #39424e;
  background: transparent;
  color: #9aa5b4;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.mini-icon:hover { color: #fff; border-color: #6b7079; }
.mini-icon svg { width: 13px; height: 13px; }
.mini-icon.loading svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bal-sub {
  margin-top: 7px;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #9aa5b4;
}
.topup-btn {
  width: 100%;
  height: 38px;
  margin-top: 14px;
  border: 1px solid #fff;
  background: #fff;
  color: var(--deep);
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.topup-btn:hover { opacity: 0.86; }
.balance-pending {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid #2a323d;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  line-height: 1.5;
  color: #c5ced9;
}

.set-card { border: 1px solid var(--line); background: var(--white); padding: 2px 12px; }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 43px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  color: var(--ink);
}
.set-row:last-child { border-bottom: 0; }
.set-row > span { color: var(--muted); }
.set-row b { font-size: 11px; font-weight: 700; text-align: right; }
.set-row select {
  max-width: 130px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  outline: none;
  cursor: pointer;
}
.set-row select:focus { border-color: var(--blue); }

.price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--muted);
}
.price-row:last-of-type { border-bottom: 0; }
.price-row b { font-family: "JetBrains Mono", monospace; font-size: 11px; color: var(--ink); }
.topup-balance {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: "JetBrains Mono", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink);
}

.switch {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}
.switch .track {
  position: relative;
  display: block;
  width: 30px;
  height: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: background 0.18s ease, border-color 0.18s ease;
}
.switch .track i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: var(--muted);
  transition: left 0.18s ease, background 0.18s ease;
}
.switch[aria-checked="true"] .track { background: var(--deep); border-color: var(--deep); }
.switch[aria-checked="true"] .track i { left: 16px; background: #fff; }

.set-action {
  display: block;
  width: 100%;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: none;
  text-align: left;
  color: var(--ink);
  font-family: "Inter", sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.set-action:last-child { border-bottom: 0; }
.set-action:hover { color: var(--blue); }
.set-action.danger { color: var(--red); }
.set-action.danger:hover { color: #b03030; }
.support-link { text-decoration: none; }
.support-link:hover { color: var(--blue); }

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--muted);
}
.info-row:last-child { border-bottom: 0; }
.info-row b { font-size: 10px; font-weight: 700; color: var(--ink); font-family: "JetBrains Mono", monospace; }
.info-row b.online { color: var(--green); }

/* ============ Backdrop for drawers ============ */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 24, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 70;
}

/* ============ Top-up modal ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 19, 24, 0.62);
}
.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 440px;
  max-height: min(92dvh, 780px);
  background: var(--white);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(17, 19, 24, 0.25);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 17px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  font-family: "Orbitron", sans-serif;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.modal-scroll { flex: 1; overflow-y: auto; padding: 18px 18px 22px; }

.field-label {
  margin-bottom: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}
.amount-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.amount-chip {
  min-width: 60px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.13s ease;
}
.amount-chip:hover { border-color: var(--blue); color: var(--ink); }
.amount-chip.active { background: var(--deep); border-color: var(--deep); color: #fff; }
.custom-amount {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--white);
}
.custom-amount:focus-within { border-color: var(--blue); }
.custom-amount span { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }
.custom-amount input {
  flex: 1;
  height: 37px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: "Inter", sans-serif;
  font-size: 13px;
}

.coin-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.coin-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 78px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  background: var(--white);
  cursor: pointer;
  transition: all 0.13s ease;
}
.coin-chip:hover { border-color: var(--blue); }
.coin-chip.active { border-color: var(--deep); box-shadow: inset 0 0 0 1px var(--deep); }
.coin-chip b { font-size: 11.5px; font-weight: 700; color: var(--ink); }
.coin-chip small { font-family: "JetBrains Mono", monospace; font-size: 8px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }

.pay-box { margin-top: 16px; padding: 14px; border: 1px solid var(--line); background: var(--surface); }
.pay-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.pay-amount { font-size: 21px; font-weight: 800; line-height: 1; }
.pay-coin { margin-top: 4px; font-family: "JetBrains Mono", monospace; font-size: 9px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.pay-net {
  padding: 3px 8px;
  border: 1px solid var(--line);
  background: var(--white);
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.qr-wrap { display: flex; justify-content: center; margin: 14px 0 12px; }
.qr-wrap img { width: 164px; height: 164px; border: 1px solid var(--line); background: #fff; }
.wallet-row { display: flex; align-items: stretch; gap: 6px; }
.wallet-row code {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: var(--white);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  line-height: 1.4;
  color: var(--ink);
  word-break: break-all;
}
.copy-btn {
  flex-shrink: 0;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
}
.copy-btn:hover { border-color: var(--blue); color: var(--blue); }
.pay-note { margin-top: 10px; font-size: 10.5px; line-height: 1.55; color: var(--muted); }

.primary-btn {
  width: 100%;
  height: 42px;
  margin-top: 16px;
  border: 0;
  background: var(--deep);
  color: #fff;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.primary-btn:hover { opacity: 0.87; }
.primary-btn:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.claim-status {
  margin-top: 11px;
  padding: 11px 12px;
  border: 1px solid rgba(46, 158, 68, 0.4);
  background: rgba(46, 158, 68, 0.08);
  color: #1f7a36;
  font-size: 11px;
  line-height: 1.5;
}
.claim-status.error {
  border-color: rgba(214, 69, 69, 0.45);
  background: rgba(214, 69, 69, 0.08);
  color: var(--red);
}

.topup-modal { max-width: 470px; }
.coin-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--white);
}
.coin-search:focus-within { border-color: var(--blue); }
.coin-search svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.coin-search input {
  flex: 1;
  height: 38px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: "Inter", sans-serif;
  font-size: 12.5px;
}
.coin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  max-height: 224px;
  overflow-y: auto;
  padding-right: 3px;
}
.coin-grid .coin-chip {
  width: 100%;
  min-width: 0;
  flex-direction: row;
  align-items: center;
  gap: 7px;
  padding: 8px;
  text-align: left;
}
.coin-grid .coin-chip b { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 10px; }
.coin-grid .coin-chip small { display: none; }
.coin-ico { width: 17px; height: 17px; flex-shrink: 0; object-fit: contain; }
.coin-empty {
  grid-column: 1 / -1;
  padding: 18px 8px;
  border: 1px dashed var(--line);
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}
.topup-hint {
  margin-top: 9px;
  font-family: "JetBrains Mono", monospace;
  font-size: 8.5px;
  line-height: 1.55;
  letter-spacing: 0.2px;
  color: var(--muted);
}
.topup-hint.warn { color: var(--red); }
.checkout-back {
  margin-bottom: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
}
.checkout-back:hover { color: var(--ink); }
.pay-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: var(--white);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
}
.ps-spinner {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  border: 1.5px solid var(--line);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.pay-status.done { border-color: rgba(46, 158, 68, 0.4); color: #1f7a36; background: rgba(46, 158, 68, 0.07); }
.pay-status.failed { border-color: rgba(214, 69, 69, 0.4); color: var(--red); background: rgba(214, 69, 69, 0.06); }
.pay-done { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 24px 8px 10px; }
.pd-check {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 2px solid var(--green);
  color: var(--green);
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 16px;
}
.pay-done h4 {
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.pay-done p { margin-top: 8px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.pay-done .primary-btn { margin-top: 20px; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  padding: 11px 18px;
  background: var(--deep);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 200;
  max-width: min(90vw, 460px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Dark theme ============ */
html[data-theme="dark"] {
  --white: #0f1115;
  --ink: #f1f3f7;
  --muted: #98a0ae;
  --line: #2a2f38;
  --line-soft: #22262e;
  --surface: #191d24;
  --blue: #8b97a8;
  --deep: #0a0c10;
  --green: #42c463;
  --red: #ef6b6b;
  --grid: rgba(255, 255, 255, 0.045);
  --glass: rgba(15, 17, 21, 0.94);
  --glass-2: rgba(15, 17, 21, 0.72);
  --glass-3: rgba(15, 17, 21, 0.9);
  --glass-4: rgba(15, 17, 21, 0.96);
}
html[data-theme="dark"] body { background: var(--white); color: var(--ink); }
html[data-theme="dark"] .new-chat-btn,
html[data-theme="dark"] .send-btn,
html[data-theme="dark"] .primary-btn {
  background: #2a303a;
  border-color: #3a414d;
  color: #f1f3f7;
}
html[data-theme="dark"] .new-chat-btn:hover,
html[data-theme="dark"] .send-btn:hover:not(:disabled),
html[data-theme="dark"] .primary-btn:hover { background: #343b47; }
html[data-theme="dark"] .chat-item.active { background: var(--surface); border-color: var(--line); }
html[data-theme="dark"] .chat-item.active .ci-main { color: var(--ink); }
html[data-theme="dark"] .chat-item.active .ci-meta { color: var(--muted); }
html[data-theme="dark"] .chat-item.active .ci-del { color: var(--muted); }
html[data-theme="dark"] .msg.user .bubble { border-color: #303743; }
html[data-theme="dark"] .composer-wrap { background: linear-gradient(to top, var(--white) 60%, rgba(15, 17, 21, 0)); }
html[data-theme="dark"] .composer-wrap.drag-over::after { background: rgba(15, 17, 21, 0.96); }
html[data-theme="dark"] .mp-provider { background: var(--white); }
html[data-theme="dark"] .topup-btn { border-color: var(--ink); background: var(--ink); color: var(--deep); }
html[data-theme="dark"] .qr-wrap img { background: #fff; }
html[data-theme="dark"] .switch[aria-checked="true"] .track,
html[data-theme="dark"] .mp-item.active .mp-check,
html[data-theme="dark"] .mp-efforts button.active,
html[data-theme="dark"] .amount-chip.active,
html[data-theme="dark"] .coin-chip.active {
  background: #3a4352;
  border-color: #4a5568;
  color: #f1f3f7;
}
html[data-theme="dark"] .switch[aria-checked="true"] .track i { background: #fff; }

/* ============ Password strength ============ */
.pw-meter {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pw-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.pw-bars i {
  height: 4px;
  background: var(--line);
  transition: background 0.15s ease;
}
.pw-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.pw-meter.lvl-1 .pw-bars i:nth-child(1) { background: #d64545; }
.pw-meter.lvl-2 .pw-bars i:nth-child(-n+2) { background: #e08b2c; }
.pw-meter.lvl-3 .pw-bars i:nth-child(-n+3) { background: #c9b02c; }
.pw-meter.lvl-4 .pw-bars i { background: #2e9e44; }
.pw-meter.lvl-1 .pw-label { color: #d64545; }
.pw-meter.lvl-2 .pw-label { color: #b8721f; }
.pw-meter.lvl-3 .pw-label { color: #8f7d18; }
.pw-meter.lvl-4 .pw-label { color: #2e9e44; }

/* ============ Pricing ============ */
.pricing-card { max-height: 320px; overflow-y: auto; padding: 2px 12px; }
.pricing-card .price-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  font-family: "JetBrains Mono", monospace;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}
.pricing-card .price-head span,
.pricing-card .price-head b { color: var(--muted); font-size: 7.5px; }
.price-group {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 0 5px;
  background: var(--white);
  font-family: "JetBrains Mono", monospace;
  font-size: 7.5px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted);
}
.pricing-card .price-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}
.price-model {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 11px;
}
.pricing-card .price-row b {
  min-width: 46px;
  text-align: right;
  font-size: 10.5px;
}
.pricing-card .price-cached { color: var(--muted); }
.topup-action {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
  font-weight: 600;
}
.topup-action:hover { border-color: var(--blue); color: var(--ink); }

/* ============ Auth ============ */
.auth-modal { max-width: 420px; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
}
.auth-tab {
  height: 34px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.13s ease;
}
.auth-tab:hover { border-color: var(--blue); color: var(--ink); }
.auth-tab.active { background: var(--deep); border-color: var(--deep); color: #fff; }
.auth-input {
  display: flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: var(--white);
}
.auth-input:focus-within { border-color: var(--blue); }
.auth-input input {
  flex: 1;
  height: 40px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: "Inter", sans-serif;
  font-size: 13px;
}
.auth-error {
  margin-top: 14px;
  padding: 9px 11px;
  border: 1px solid rgba(214, 69, 69, 0.4);
  background: rgba(214, 69, 69, 0.06);
  color: var(--red);
  font-size: 11.5px;
}
#authForm .primary-btn { margin-top: 18px; }
html[data-theme="dark"] .auth-tab.active { background: var(--ink); border-color: var(--ink); color: var(--deep); }
html[data-theme="dark"] .price-group { background: var(--white); }

/* ============ Responsive ============ */
@media (max-width: 1200px) {
  .app-shell { grid-template-columns: var(--left-w) minmax(0, 1fr); }
  .app-shell.settings-closed { grid-template-columns: var(--left-w) minmax(0, 1fr); }
  .settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 100vw);
    z-index: 80;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -12px 0 40px rgba(17, 19, 24, 0.16);
    opacity: 1;
    border-left: 1px solid var(--line);
  }
  .app-shell.settings-closed .settings-panel { opacity: 1; border-left: 1px solid var(--line); }
  .app-shell.settings-open .settings-panel { transform: translateX(0); }
  .app-shell.settings-open .panel-backdrop { opacity: 1; pointer-events: auto; }
}

@media (max-width: 900px) {
  .app-shell,
  .app-shell.settings-closed { grid-template-columns: minmax(0, 1fr); }
  .mobile-only { display: grid; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(286px, 86vw);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 12px 0 40px rgba(17, 19, 24, 0.16);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .app-shell.sidebar-open .panel-backdrop { opacity: 1; pointer-events: auto; }
  .thread { padding: 20px 15px 8px; }
  .hero { min-height: calc(100dvh - 240px); }
  .suggestions { grid-template-columns: 1fr; max-width: 440px; }
  .composer-wrap { padding: 7px 12px calc(9px + env(safe-area-inset-bottom)); }
  .composer-hint span:last-child { display: none; }
  .chat-head { padding: 10px 12px; gap: 9px; }
  .header-balance { padding: 0 8px; }
  .header-balance .hb-label { display: none; }
  .chat-head-actions #newChatBtn2 { display: none; }
  .suggestions .sugg { padding: 12px 13px; }
  .ci-del { opacity: 0.55; }
}

@media (max-width: 560px) {
  .hero h1 { letter-spacing: 2px; }
  .hero-sub { letter-spacing: 2px; }
  .sugg small { display: none; }
  .sugg { padding: 11px 12px; }
  .sugg .si { width: 30px; height: 30px; }
  .think-btn span:not(.mini-track) { display: none; }
  .think-btn { padding: 0 8px; }
  .model-strip { margin-bottom: 7px; }
  .mchip { height: 28px; padding: 0 9px; font-size: 8.5px; }
  .msg.user .bubble { max-width: 92%; }
  .settings-panel { width: 100vw; }
  .model-popover { width: calc(100vw - 34px); max-height: 70dvh; }
  .coin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topup-modal { max-height: 94dvh; }
}
