:root {
  --bg: #070a0f;
  --bg-soft: #0b1018;
  --panel: rgba(15, 22, 33, 0.72);
  --panel-solid: #0f1621;
  --panel-2: rgba(22, 31, 45, 0.6);
  --border: rgba(148, 163, 184, 0.13);
  --border-strong: rgba(148, 163, 184, 0.24);
  --text: #e8eef7;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --accent: #7dd3fc;
  --green: #34d399;
  --red: #fb7185;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
::selection { background: rgba(34, 211, 238, 0.28); color: #fff; }

/* ===== Ambient background ===== */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(900px 600px at 12% -10%, rgba(34, 211, 238, 0.09), transparent 60%),
    radial-gradient(800px 600px at 92% 8%, rgba(167, 139, 250, 0.1), transparent 60%),
    linear-gradient(180deg, #080c12 0%, #070a0f 55%, #06090d 100%);
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  animation: drift 18s ease-in-out infinite alternate;
}
.orb-a { width: 420px; height: 420px; left: -140px; top: 18%; background: rgba(34, 211, 238, 0.14); }
.orb-b { width: 460px; height: 460px; right: -160px; bottom: 4%; background: rgba(167, 139, 250, 0.16); animation-delay: -7s; }
.grid-glow {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 55% at 50% 0%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 55% at 50% 0%, #000 20%, transparent 75%);
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(30px, -24px, 0) scale(1.08); }
}

/* ===== Shell ===== */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100dvh;
  width: 100%;
}

.sidebar {
  width: 268px;
  flex: 0 0 268px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 14px 16px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 19, 28, 0.92), rgba(8, 12, 18, 0.86));
  backdrop-filter: blur(18px);
  z-index: 40;
}

.brand { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 8px; }
.brand-link { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.16), rgba(167, 139, 250, 0.14));
  border: 1px solid rgba(125, 211, 252, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 24px -12px rgba(34, 211, 238, 0.5);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand-text strong { font-size: 17px; letter-spacing: -0.02em; font-weight: 750; }
.brand-text strong span { color: var(--cyan); }
.brand-text small { font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 3px; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  transition: 0.18s ease;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { color: var(--text); background: rgba(148, 163, 184, 0.1); border-color: var(--border); }
.sidebar-close { display: none; }

.new-session {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 8px 0 12px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.12), rgba(34, 211, 238, 0.04));
  color: #d9f5fd;
  font-size: 13.5px;
  font-weight: 600;
  transition: 0.18s ease;
}
.new-session svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.new-session kbd { margin-left: auto; }
.new-session:hover { border-color: rgba(125, 211, 252, 0.45); background: linear-gradient(180deg, rgba(34, 211, 238, 0.2), rgba(34, 211, 238, 0.07)); }

kbd {
  font-family: var(--font);
  font-size: 10px;
  padding: 2px 5px;
  border-radius: 5px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-dim);
  white-space: nowrap;
}

.tool-nav { flex: 1; overflow-y: auto; padding-right: 4px; margin-right: -4px; scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.2) transparent; }
.tool-nav::-webkit-scrollbar { width: 5px; }
.tool-nav::-webkit-scrollbar-thumb { background: rgba(148,163,184,.18); border-radius: 99px; }
.nav-group { margin-bottom: 14px; }
.nav-label { display: block; padding: 0 10px 6px; font-size: 10.5px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: 0.16s ease;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { color: var(--text); background: rgba(148, 163, 184, 0.08); }
.nav-item.active {
  color: #e6f9ff;
  border-color: rgba(34, 211, 238, 0.2);
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.16), rgba(34, 211, 238, 0.03));
  box-shadow: inset 2px 0 0 var(--cyan);
}

.sidebar-foot { padding: 12px 10px 0; border-top: 1px solid var(--border); }
.status-line { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-dim); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); box-shadow: 0 0 0 3px rgba(148,163,184,.1); }
.status-dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.14), 0 0 10px rgba(52, 211, 153, 0.6); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.14); }
.sidebar-foot p { margin: 7px 0 0; font-size: 11px; color: var(--text-faint); }
.admin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 11px;
  padding: 6px 8px;
  border-radius: 7px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  transition: 0.18s ease;
}
.admin-link svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.admin-link:hover { color: var(--text); background: rgba(148, 163, 184, 0.08); }
.sidebar-foot .tiny { font-size: 10px; opacity: 0.65; margin-top: 5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100dvh; }
.topbar {
  height: 62px;
  flex: 0 0 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 18, 0.6);
  backdrop-filter: blur(16px);
  z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-faint); min-width: 0; }
.crumbs strong { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; opacity: 0.5; }

.model-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 30px 0 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.06);
  transition: 0.18s ease;
}
.model-picker:hover { border-color: var(--border-strong); background: rgba(148, 163, 184, 0.1); }
.model-icon { width: 15px; height: 15px; fill: none; stroke: var(--cyan); stroke-width: 1.6; stroke-linecap: round; opacity: 0.9; }
.model-picker .chev { position: absolute; right: 9px; width: 13px; height: 13px; fill: none; stroke: var(--text-faint); stroke-width: 2; pointer-events: none; }
.model-picker select {
  appearance: none;
  border: 0;
  background: transparent;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text);
  padding-right: 2px;
  max-width: 210px;
  cursor: pointer;
  outline: none;
}
.model-picker select option { background: #0f1621; color: var(--text); }
.model-rate {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.045);
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 550;
  white-space: nowrap;
}
.balance-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid rgba(52, 211, 153, 0.22);
  background: rgba(52, 211, 153, 0.06);
  color: #a7f3d0;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: 0.18s ease;
}
.balance-chip:hover { border-color: rgba(52, 211, 153, 0.42); background: rgba(52, 211, 153, 0.11); }
.balance-chip.is-negative { border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.08); color: #fca5a5; }

.view { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.22) transparent; }
.view::-webkit-scrollbar { width: 8px; }
.view::-webkit-scrollbar-thumb { background: rgba(148,163,184,.16); border-radius: 99px; }
.view.view--chat { overflow: hidden; }

/* ===== Home ===== */
.home-view { max-width: 1120px; margin: 0 auto; padding: 54px 34px 64px; }
.hero { max-width: 760px; }
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  background: rgba(34, 211, 238, 0.07);
  color: #a5e9f8;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 0 rgba(34,211,238,.6); animation: pulse 2.2s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(34, 211, 238, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); }
}
.hero h1 {
  margin: 20px 0 0;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.04;
  letter-spacing: -0.035em;
  font-weight: 760;
}
.grad-text {
  background: linear-gradient(100deg, #67e8f9 0%, #a5b4fc 45%, #c4b5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-sub { margin: 18px 0 0; max-width: 600px; font-size: 15.5px; line-height: 1.65; color: var(--text-dim); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 24px; font-size: 12px; color: var(--text-faint); }
.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero-meta i { width: 4px; height: 4px; border-radius: 50%; background: var(--cyan); opacity: 0.8; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 17px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: 0.18s ease;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary {
  color: #04121a;
  background: linear-gradient(135deg, #67e8f9, #22d3ee 55%, #38bdf8);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 30px -12px rgba(34, 211, 238, 0.65), inset 0 1px 0 rgba(255,255,255,.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 16px 36px -12px rgba(34, 211, 238, 0.8); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.7; cursor: wait; transform: none; }
.btn-ghost { background: rgba(148, 163, 184, 0.07); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.13); border-color: var(--border-strong); }
.btn-quiet { background: transparent; color: var(--text-dim); border-color: transparent; height: 38px; }
.btn-quiet:hover { background: rgba(148,163,184,.08); color: var(--text); }

.section-head { display: flex; align-items: baseline; gap: 12px; margin: 58px 0 18px; }
.section-head h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.section-head p { margin: 0; font-size: 12.5px; color: var(--text-faint); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 12px; }
.tool-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 17px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(20, 29, 42, 0.72), rgba(13, 19, 28, 0.6));
  overflow: hidden;
  transition: 0.2s ease;
}
.tool-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(240px 120px at 12% 0%, rgba(34, 211, 238, 0.12), transparent 70%);
  opacity: 0;
  transition: 0.25s ease;
  pointer-events: none;
}
.tool-card:hover { transform: translateY(-2px); border-color: rgba(125, 211, 252, 0.3); box-shadow: 0 18px 40px -22px rgba(0,0,0,.9); }
.tool-card:hover::after { opacity: 1; }
.tool-card .tc-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(148, 163, 184, 0.06);
  color: #9fe8f7;
}
.tool-card .tc-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool-card h3 { margin: 0; font-size: 14px; font-weight: 620; letter-spacing: -0.01em; }
.tool-card p { margin: 4px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--text-dim); }
.tool-card .tc-go { margin-top: auto; display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--cyan); opacity: 0.85; }
.tool-card .tc-go svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; transition: 0.18s ease; }
.tool-card:hover .tc-go svg { transform: translateX(3px); }

.home-tip {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-top: 34px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(167, 139, 250, 0.16);
  background: linear-gradient(120deg, rgba(167, 139, 250, 0.07), rgba(34, 211, 238, 0.04));
}
.tip-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 10px; background: rgba(167, 139, 250, 0.12); color: #c4b5fd; }
.tip-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.home-tip strong { display: block; font-size: 13px; font-weight: 600; }
.home-tip p { margin: 5px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--text-dim); }

/* ===== Tool view ===== */
.tool-view { max-width: 1240px; margin: 0 auto; padding: 30px 30px 50px; }
.tool-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.tool-icon {
  width: 46px; height: 46px;
  flex: 0 0 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.14), rgba(167, 139, 250, 0.08));
  color: #a5e9f8;
}
.tool-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool-head h1 { margin: 0; font-size: 21px; letter-spacing: -0.025em; }
.tool-head p { margin: 4px 0 0; font-size: 12.5px; color: var(--text-dim); }

.tool-layout { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.form-panel { padding: 18px; }
.fields { display: flex; flex-direction: column; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field label .req { color: var(--red); font-size: 11px; }
.field .count { font-size: 10.5px; font-weight: 500; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.field input[type="text"], .field textarea, .field select {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(6, 10, 15, 0.55);
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  outline: none;
  transition: 0.16s ease;
}
.field textarea { resize: vertical; min-height: 96px; max-height: 340px; }
.field input::placeholder, .field textarea::placeholder { color: #4d5d72; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
  background: rgba(6, 10, 15, 0.8);
}
.field select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.field select option { background: #0f1621; }
.form-foot { display: flex; align-items: center; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-hint { margin-left: auto; font-size: 10.5px; color: var(--text-faint); }
.form-hint kbd { font-size: 9px; }
.spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(4, 18, 26, 0.3);
  border-top-color: #04121a;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.output-panel { display: flex; flex-direction: column; min-height: 430px; position: sticky; top: 16px; }
.output-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.output-title { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; color: var(--text-dim); letter-spacing: 0.01em; }
.output-title svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.output-actions { display: flex; gap: 6px; }
.mini-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.05);
  color: var(--text-dim);
  font-size: 11px; font-weight: 550;
  transition: 0.16s ease;
}
.mini-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mini-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); background: rgba(148, 163, 184, 0.1); }
.mini-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.output-body { flex: 1; min-height: 360px; padding: 20px; overflow-wrap: anywhere; }
.output-body.loading { opacity: 0.65; }
.empty-state { height: 100%; min-height: 340px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; padding: 20px; }
.empty-visual { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 15px; border: 1px dashed rgba(148, 163, 184, 0.22); color: #5c718a; margin-bottom: 8px; }
.empty-visual svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.empty-state strong { font-size: 13.5px; color: var(--text-dim); font-weight: 600; }
.empty-state p { margin: 2px 0 0; font-size: 12px; color: var(--text-faint); }

/* ===== Markdown ===== */
.markdown { font-size: 13.8px; line-height: 1.7; color: #d7e1ee; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 1.5em 0 0.55em; line-height: 1.3; letter-spacing: -0.015em; color: #f1f6fc; font-weight: 680; }
.markdown h1 { font-size: 1.45em; }
.markdown h2 { font-size: 1.25em; }
.markdown h3 { font-size: 1.08em; }
.markdown h4 { font-size: 0.98em; }
.markdown p { margin: 0 0 0.9em; }
.markdown strong { color: #f4f8fd; font-weight: 650; }
.markdown em { color: #c9d6e6; }
.markdown a { color: var(--cyan); text-decoration: underline; text-underline-offset: 2px; }
.markdown ul, .markdown ol { margin: 0 0 1em; padding-left: 1.35em; }
.markdown li { margin: 0.25em 0; }
.markdown li::marker { color: var(--cyan); }
.markdown blockquote { margin: 1em 0; padding: 8px 14px; border-left: 2px solid rgba(34, 211, 238, 0.5); background: rgba(34, 211, 238, 0.05); border-radius: 0 8px 8px 0; color: #b9c8da; }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.markdown code { font-family: var(--mono); font-size: 0.88em; padding: 2px 5px; border-radius: 5px; background: rgba(148, 163, 184, 0.13); color: #a5e9f8; }
.markdown .codeblock { margin: 1em 0; border-radius: 11px; border: 1px solid var(--border); overflow: hidden; background: rgba(4, 8, 13, 0.8); }
.markdown .code-head { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; border-bottom: 1px solid var(--border); background: rgba(148, 163, 184, 0.05); }
.markdown .code-lang { font-family: var(--mono); font-size: 10.5px; color: var(--text-faint); text-transform: lowercase; letter-spacing: 0.04em; }
.markdown .copy-code { border: 0; background: transparent; color: var(--text-faint); font-size: 10.5px; font-weight: 550; padding: 2px 4px; border-radius: 4px; }
.markdown .copy-code:hover { color: var(--cyan); background: rgba(34, 211, 238, 0.08); }
.markdown pre { margin: 0; padding: 13px 14px; overflow-x: auto; }
.markdown pre code { background: transparent; padding: 0; color: #cfdce9; font-size: 12.5px; line-height: 1.65; }
.markdown table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 12.5px; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.markdown th { background: rgba(148, 163, 184, 0.08); color: var(--text); }

/* ===== Chat ===== */
.chat-view { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.chat-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; scrollbar-color: rgba(148,163,184,.22) transparent; }
.chat-scroll::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-thumb { background: rgba(148,163,184,.16); border-radius: 99px; }
.chat-messages { max-width: 820px; margin: 0 auto; padding: 30px 26px 10px; display: flex; flex-direction: column; gap: 22px; }

.chat-welcome { padding: 42px 0 20px; text-align: center; }
.chat-welcome .cw-mark {
  width: 58px; height: 58px; margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 17px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.16), rgba(167, 139, 250, 0.12));
  box-shadow: 0 20px 50px -24px rgba(34, 211, 238, 0.55);
  color: #a5e9f8;
}
.chat-welcome .cw-mark svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.chat-welcome h2 { margin: 0; font-size: 25px; letter-spacing: -0.03em; }
.chat-welcome h2 span { background: linear-gradient(100deg, #67e8f9, #c4b5fd); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chat-welcome p { margin: 9px auto 0; max-width: 430px; font-size: 13.5px; line-height: 1.6; color: var(--text-dim); }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 26px auto 0; max-width: 560px; }
.suggestion {
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.045);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.45;
  transition: 0.17s ease;
}
.suggestion strong { display: block; color: var(--text); font-size: 12.5px; font-weight: 600; margin-bottom: 2px; }
.suggestion span { color: var(--text-faint); font-size: 11.5px; }
.suggestion:hover { border-color: rgba(34, 211, 238, 0.32); background: rgba(34, 211, 238, 0.06); transform: translateY(-1px); }

.msg { display: flex; gap: 11px; align-items: flex-start; animation: rise 0.25s ease backwards; }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } }
.msg-avatar {
  width: 30px; height: 30px;
  flex: 0 0 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-dim);
  font-size: 11px; font-weight: 700;
}
.msg-avatar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.msg.assistant .msg-avatar { color: #a5e9f8; border-color: rgba(34, 211, 238, 0.24); background: linear-gradient(145deg, rgba(34, 211, 238, 0.14), rgba(167, 139, 250, 0.1)); }
.msg-body { flex: 1; min-width: 0; padding-top: 3px; }
.msg-role { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 11.5px; font-weight: 650; color: var(--text-dim); }
.msg-role .model-tag { font-weight: 500; color: var(--text-faint); font-size: 10.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); }
.msg.user { flex-direction: row-reverse; }
.msg.user .msg-body { flex: 0 1 auto; max-width: 84%; padding: 10px 14px; border-radius: 14px 14px 4px 14px; background: linear-gradient(145deg, rgba(34, 211, 238, 0.13), rgba(56, 189, 248, 0.08)); border: 1px solid rgba(34, 211, 238, 0.18); }
.msg.user .msg-role { display: none; }
.msg.user .msg-content { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; }
.msg.user .msg-avatar { background: rgba(34, 211, 238, 0.16); color: #b9f3ff; border-color: rgba(34, 211, 238, 0.25); font-size: 10px; }
.msg-content { min-width: 0; }
.typing { display: inline-flex; gap: 4px; align-items: center; height: 20px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
.msg-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.msg-foot .mini-btn { height: 26px; font-size: 10.5px; padding: 0 8px; }
.msg-cost { font-size: 9.5px; color: var(--text-faint); white-space: nowrap; padding-left: 3px; }
.msg-error { color: #fda4af; font-size: 13px; }

.composer-wrap { flex: 0 0 auto; padding: 10px 26px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, transparent, rgba(7, 10, 15, 0.85) 30%); }
.composer {
  max-width: 820px;
  margin: 0 auto;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: rgba(15, 22, 33, 0.9);
  box-shadow: 0 18px 44px -20px rgba(0, 0, 0, 0.9);
  padding: 11px 12px 9px;
  transition: 0.18s ease;
}
.composer:focus-within { border-color: rgba(34, 211, 238, 0.4); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.07), 0 18px 44px -20px rgba(0, 0, 0, 0.9); }
.composer textarea {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 14px;
  line-height: 1.55;
  max-height: 180px;
  padding: 2px 3px 6px;
  color: var(--text);
}
.composer textarea::placeholder { color: #52627a; }
.attach-btn {
  width: 32px; height: 32px;
  flex: 0 0 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  transition: 0.17s ease;
}
.attach-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.attach-btn:hover { color: var(--text); background: rgba(148, 163, 184, 0.1); border-color: var(--border); }
.attach-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.attach-tray { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 2px 9px; max-height: 128px; overflow: auto; }
.attach-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 220px;
  padding: 5px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.055);
}
.attach-thumb { width: 38px; height: 38px; flex: 0 0 38px; object-fit: cover; border-radius: 7px; background: #0b1018; display: block; }
.attach-doc {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: rgba(34, 211, 238, 0.1);
  color: #a5e9f8;
}
.attach-doc svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.attach-meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; padding-right: 14px; }
.attach-name { font-size: 11.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-size { font-size: 9.5px; color: var(--text-faint); white-space: nowrap; }
.attach-remove {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 6px;
  border: 0;
  background: rgba(4, 8, 13, 0.65);
  color: var(--text-faint);
}
.attach-remove:hover { color: #fda4af; background: rgba(251, 113, 133, 0.16); }
.attach-remove svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.msg-attachments { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.msg-image { display: block; max-width: 280px; max-height: 240px; border-radius: 10px; border: 1px solid var(--border); object-fit: contain; background: rgba(4, 8, 13, 0.5); }
.msg-file {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(4, 8, 13, 0.35);
  color: var(--text-dim);
  font-size: 11.5px;
}
.msg-file svg { width: 14px; height: 14px; flex: 0 0 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.msg-file span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file small { color: var(--text-faint); font-size: 9.5px; white-space: nowrap; }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.composer-hint { font-size: 10.5px; color: var(--text-faint); padding-left: 3px; }
.composer-hint kbd { font-size: 9px; }
.send-btn {
  margin-left: auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: linear-gradient(135deg, #67e8f9, #22d3ee);
  color: #04121a;
  transition: 0.17s ease;
}
.send-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.send-btn:hover { box-shadow: 0 8px 22px -8px rgba(34, 211, 238, 0.8); transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.stop-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 9px; border: 1px solid rgba(251, 113, 133, 0.3); background: rgba(251, 113, 133, 0.08); color: #fda4af; font-size: 11.5px; font-weight: 600; }
.stop-btn span { width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.stop-btn:hover { background: rgba(251, 113, 133, 0.16); }
.disclaimer { max-width: 820px; margin: 8px auto 0; text-align: center; font-size: 10.5px; color: var(--text-faint); }

/* ===== Misc ===== */
.overlay { position: fixed; inset: 0; z-index: 35; background: rgba(2, 5, 9, 0.6); backdrop-filter: blur(3px); opacity: 0; visibility: hidden; transition: 0.22s ease; }
.overlay.show { opacity: 1; visibility: visible; }

.balance-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 5, 9, 0.72);
  backdrop-filter: blur(6px);
}
.balance-modal {
  width: min(100%, 420px);
  padding: 22px;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, rgba(20, 30, 44, 0.98), rgba(11, 16, 24, 0.98));
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.95);
}
.balance-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.balance-modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.balance-modal-head p { margin: 5px 0 0; font-size: 11.5px; color: var(--text-faint); }
.balance-now {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
  padding: 12px 13px;
  border-radius: 11px;
  border: 1px solid rgba(52, 211, 153, 0.18);
  background: rgba(52, 211, 153, 0.055);
  color: var(--text-dim);
  font-size: 12px;
}
.balance-now strong { color: #a7f3d0; font-size: 14px; }
.balance-label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 600; color: var(--text-dim); }
.balance-key {
  width: 100%;
  height: 38px;
  margin-bottom: 14px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(7, 10, 15, 0.6);
  outline: none;
  font-size: 12px;
  letter-spacing: 0.03em;
}
.balance-key:focus { border-color: rgba(34, 211, 238, 0.45); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08); }
.topup-field { display: flex; align-items: center; gap: 8px; }
.topup-field > span {
  display: grid;
  place-items: center;
  height: 42px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.06);
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 700;
}
.topup-field input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(7, 10, 15, 0.6);
  outline: none;
  font-size: 14px;
  font-weight: 600;
}
.topup-field input:focus { border-color: rgba(34, 211, 238, 0.45); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08); }
.topup-field .btn { height: 42px; }
.topup-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.topup-presets button {
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.055);
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  transition: 0.18s ease;
}
.topup-presets button:hover { border-color: var(--border-strong); background: rgba(148, 163, 184, 0.1); color: var(--text); }
.balance-modal-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 10px; color: var(--text-faint); }
.balance-modal-foot .mini-btn { height: 28px; font-size: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100;
  transform: translate(-50%, 16px);
  max-width: min(92vw, 460px);
  padding: 11px 16px;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: rgba(15, 22, 33, 0.96);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.9);
  opacity: 0;
  visibility: hidden;
  transition: 0.22s ease;
  text-align: center;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(251, 113, 133, 0.35); color: #fecdd3; }
.toast.success { border-color: rgba(52, 211, 153, 0.35); color: #bbf7d0; }

.result-meta { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 10.5px; color: var(--text-faint); display: flex; gap: 10px; flex-wrap: wrap; }

/* ===== Auth / customer ===== */
.auth-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  background:
    radial-gradient(700px 500px at 20% 0%, rgba(34, 211, 238, 0.1), transparent 60%),
    radial-gradient(700px 500px at 85% 100%, rgba(167, 139, 250, 0.12), transparent 60%),
    rgba(2, 5, 9, 0.78);
  backdrop-filter: blur(9px);
}
.auth-card {
  width: min(100%, 420px);
  margin: auto;
  padding: 30px;
  border-radius: 22px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, rgba(20, 30, 44, 0.98), rgba(9, 13, 20, 0.99));
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.auth-tabs {
  display: flex;
  gap: 5px;
  padding: 4px;
  margin-bottom: 20px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.05);
}
.auth-tab {
  flex: 1;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 650;
  transition: 0.18s ease;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.is-active {
  color: #d9f5fd;
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.18), rgba(34, 211, 238, 0.06));
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.22);
}
.auth-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--cyan);
  font-size: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.auth-link:hover { color: #a5f3fc; }
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.auth-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 99px;
  border: 1px solid rgba(34, 211, 238, 0.22);
  background: rgba(34, 211, 238, 0.08);
  color: #a5f3fc;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.auth-card h1 { margin: 14px 0 8px; font-size: 26px; letter-spacing: -0.035em; }
.auth-card > p { margin: 0; font-size: 12.5px; line-height: 1.6; color: var(--text-dim); }
.auth-label { display: block; margin: 16px 0 7px; font-size: 11px; font-weight: 650; letter-spacing: 0.03em; color: var(--text-dim); }
.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(7, 10, 15, 0.65);
  outline: none;
  font-size: 13.5px;
  transition: 0.18s ease;
}
.auth-input::placeholder { color: var(--text-faint); }
.auth-input:focus { border-color: rgba(34, 211, 238, 0.45); box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.08); }
.auth-submit { width: 100%; height: 44px; margin-top: 20px; }
.auth-hint { margin-top: 16px !important; padding-top: 14px; border-top: 1px solid var(--border); font-size: 11px !important; color: var(--text-faint) !important; text-align: center; line-height: 1.55 !important; }

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 11px 0 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.055);
  color: var(--text);
  transition: 0.18s ease;
}
.account-chip:hover { border-color: var(--border-strong); background: rgba(148, 163, 184, 0.1); }
.account-avatar {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(125, 211, 252, 0.25);
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.2), rgba(167, 139, 250, 0.18));
  color: #d9f5fd;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.02em;
}
.account-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; text-align: left; }
.account-text strong { font-size: 11.5px; font-weight: 650; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text small { font-size: 10.5px; color: #a7f3d0; font-variant-numeric: tabular-nums; }
.account-chip.is-negative .account-text small { color: #fca5a5; }

.sidebar-account {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 10px;
  padding: 8px 9px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.05);
}
.sidebar-account-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sidebar-account-meta strong { font-size: 12px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account-meta small { font-size: 10.5px; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account .icon-btn { width: 30px; height: 30px; flex: none; }

.wallet-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 18px 0;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, 0.18);
  background: rgba(52, 211, 153, 0.055);
}
.wallet-summary span { font-size: 11px; color: var(--text-faint); }
.wallet-summary strong { font-size: 24px; letter-spacing: -0.02em; color: #a7f3d0; font-variant-numeric: tabular-nums; }
.wallet-summary small { font-size: 10.5px; color: var(--text-faint); }
.voucher-field { display: flex; gap: 8px; }
.voucher-field .balance-key { flex: 1; min-width: 0; margin-bottom: 0; }
.voucher-field .btn { flex: none; height: 38px; }
.voucher-help { margin: 9px 0 0; font-size: 10.5px; line-height: 1.5; color: var(--text-faint); }

@media (max-width: 640px) {
  .auth-card { padding: 24px 18px; }
  .auth-card h1 { font-size: 23px; }
  .account-chip { padding: 0 6px; }
  .account-text { display: none; }
  .voucher-field { flex-direction: column; }
  .voucher-field .btn { width: 100%; }
}

/* ===== Responsive ===== */
@media (max-width: 1060px) {
  .tool-layout { grid-template-columns: 1fr; }
  .output-panel { position: static; min-height: 340px; }
  .output-body { min-height: 280px; }
  .empty-state { min-height: 260px; }
}

@media (max-width: 980px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; transform: translateX(-102%); transition: transform 0.25s cubic-bezier(0.4, 0.1, 0.2, 1); box-shadow: 26px 0 60px -20px rgba(0,0,0,.8); width: 280px; flex-basis: 280px; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .menu-btn { display: grid; }
  .home-view { padding: 38px 24px 50px; }
  .tool-view { padding: 22px 20px 40px; }
  .topbar { padding: 0 14px; }
  .model-picker select { max-width: 150px; }
  .model-rate { display: none; }
}

@media (max-width: 640px) {
  .balance-modal { padding: 18px; }
  .topup-presets { grid-template-columns: repeat(2, 1fr); }
  .topup-field { flex-wrap: wrap; }
  .topup-field .btn { width: 100%; }
  .topbar { height: 56px; flex-basis: 56px; }
  .crumbs { font-size: 12px; }
  .crumbs #crumbGroup, .crumb-sep { display: none; }
  #clearBtn { display: none; }
  .balance-chip { height: 30px; padding: 0 7px; font-size: 10px; }
  .model-picker { height: 34px; padding-left: 8px; }
  .model-picker select { max-width: 122px; font-size: 11.5px; }
  .model-icon { display: none; }
  .home-view { padding: 28px 18px 42px; }
  .hero h1 { font-size: 34px; }
  .hero-sub { font-size: 14px; }
  .hero-actions .btn { flex: 1; }
  .hero-meta { gap: 12px; font-size: 11px; }
  .section-head { margin-top: 40px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 9px; }
  .tool-card { padding: 13px; gap: 9px; }
  .tool-card .tc-icon { width: 33px; height: 33px; }
  .tool-card h3 { font-size: 12.5px; }
  .tool-card p { font-size: 11px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .tool-card .tc-go { font-size: 10.5px; }
  .tool-view { padding: 18px 14px 34px; }
  .tool-head { margin-bottom: 16px; gap: 11px; }
  .tool-icon { width: 40px; height: 40px; flex-basis: 40px; border-radius: 11px; }
  .tool-head h1 { font-size: 18px; }
  .tool-head p { font-size: 11.5px; }
  .form-panel { padding: 14px; }
  .field-row { grid-template-columns: 1fr; }
  .form-hint { display: none; }
  .form-foot .btn-primary { flex: 1; }
  .output-body { padding: 15px; }
  .chat-messages { padding: 20px 15px 6px; gap: 18px; }
  .composer-wrap { padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .attach-chip { max-width: 190px; }
  .msg-image { max-width: 100%; }
  .suggestions { grid-template-columns: 1fr; }
  .msg.user .msg-body { max-width: 90%; }
  .chat-welcome { padding-top: 28px; }
  .chat-welcome h2 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
