/* QlyChat — 1:1 Official Claude.ai UI + Sub2API Account & Quota Management */
:root {
  --bg: #FFFFFF;
  --side: #FAFAFA;
  --side-border: #EEEDE9;
  --side-hover: #EFEFED;
  --side-active: #EAE9E6;
  --card: #FFFFFF;
  --card-border: #E4E3DE;
  --card-border-focus: #CFCDC6;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.045), 0 1px 3px rgba(0, 0, 0, 0.025);
  --surface-subtle: #F7F6F3;
  --ink: #1A1A19;
  --body: #2C2C2A;
  --muted: #7C7A74;
  --faint: #9B9890;
  --line: #ECEBE7;
  --user-bubble: #F0EEE6;
  --code-bg: #F7F6F2;
  --code-head: #EFECE5;
  --inline-code: #F1EFEA;
  --accent: #D97757;
  --accent-hover: #C86747;
  --accent-soft: rgba(217, 119, 87, 0.12);
  --danger: #C9402E;
  --danger-soft: rgba(201, 64, 46, 0.1);
  --ok: #2F8F5B;
  --ok-soft: rgba(47, 143, 91, 0.12);
  --badge-bg: #EAEAE6;
  --avatar-bg: #1A1A19;
  --avatar-fg: #FFFFFF;
  --backdrop: rgba(20, 20, 19, 0.36);
  --serif: "Copernicus", "Source Serif 4", "Source Serif Pro", Georgia, "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sans: "Anthropic Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color-scheme: light;
}

html.dark {
  --bg: #2C2B28;
  --side: #24231F;
  --side-border: #3A3933;
  --side-hover: #2F2F2B;
  --side-active: #1C1B18;
  --card: #393937;
  --card-border: #52514B;
  --card-border-focus: #6D6B63;
  --card-shadow: 0 4px 22px rgba(0, 0, 0, 0.32), 0 1px 3px rgba(0, 0, 0, 0.22);
  --surface-subtle: #282725;
  --ink: #E5E5E2;
  --body: #DCDCD7;
  --muted: #A6A39A;
  --faint: #848178;
  --line: #3A3933;
  --user-bubble: #21201C;
  --code-bg: #1A1915;
  --code-head: #24231F;
  --inline-code: #21201C;
  --accent: #D97757;
  --accent-hover: #C56847;
  --accent-soft: rgba(217, 119, 87, 0.18);
  --danger: #F06452;
  --danger-soft: rgba(240, 100, 82, 0.16);
  --ok: #4ADE80;
  --ok-soft: rgba(74, 222, 128, 0.16);
  --badge-bg: #393937;
  --avatar-bg: #E5E5E2;
  --avatar-fg: #2C2B28;
  --backdrop: rgba(0, 0, 0, 0.56);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128, 125, 118, 0.25); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128, 125, 118, 0.42); }

.layout {
  display: flex;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

/* ==================== Sidebar (Exact 1:1 Claude.ai) ==================== */
.sidebar {
  width: 248px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--side);
  border-right: 1px solid var(--side-border);
  transition: width 0.2s ease, transform 0.22s ease;
  overflow: hidden;
}

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

.wordmark {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 8px 8px;
}

.nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--body);
  font-size: 13.5px;
  text-align: left;
  transition: background-color 0.12s ease;
}

.nav-row:hover { background: var(--side-hover); }
.nav-row:disabled { opacity: 0.5; cursor: default; background: transparent; }
.nav-link { text-decoration: none; }
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }

.plus-badge {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--badge-bg);
  color: var(--body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.plus-badge svg { width: 12px; height: 12px; stroke-width: 2; }
.nav-ico { width: 15px; height: 15px; margin: 0 2.5px; color: var(--body); opacity: 0.82; }
.nav-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-kbd { font-size: 11px; color: var(--faint); white-space: nowrap; flex: none; }

.nav-search { cursor: text; }
.nav-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0; font-size: 13.5px; color: var(--ink); }
.nav-search input::placeholder { color: var(--body); }
.nav-search:focus-within input::placeholder { color: var(--faint); }
.nav-search:focus-within .search-kbd { display: none; }

.side-scroll { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 10px; }
.side-section { display: flex; flex-direction: column; }
.recents-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 5px; }
.recents-label { font-size: 11.5px; font-weight: 500; color: var(--faint); }

.history { padding: 0 8px; display: flex; flex-direction: column; gap: 1px; }

.history-item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background-color 0.12s ease;
}

.history-item:hover { background: var(--side-hover); }
.history-item[data-active="true"] { background: var(--side-active); }

.history-select {
  flex: 1;
  min-width: 0;
  padding: 6.5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-size: 13px;
  line-height: 1.4;
  color: var(--body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item[data-active="true"] .history-select { color: var(--ink); font-weight: 500; }
.history-select:disabled { cursor: default; }

.history-actions { display: inline-flex; align-items: center; padding-right: 3px; opacity: 0; transition: opacity 0.12s ease; }
.history-item:hover .history-actions,
.history-item:focus-within .history-actions { opacity: 1; }

.history-act {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-act svg { width: 12.5px; height: 12.5px; }
.history-act:hover { color: var(--ink); background: rgba(128, 125, 118, 0.14); }
.history-act.is-starred { color: var(--accent); }
.history-act.is-starred svg { fill: currentColor; }
.history-act.danger:hover { color: var(--danger); background: var(--danger-soft); }
.history-act:disabled { opacity: 0 !important; pointer-events: none; }
.history .empty { padding: 8px 10px; font-size: 12.5px; color: var(--faint); }

/* Sidebar bottom profile bar */
.side-bottom {
  border-top: 1px solid var(--side-border);
  padding: 8px 10px;
}

.profile-bar { display: flex; align-items: center; justify-content: space-between; gap: 4px; }

.profile-trigger {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  transition: background-color 0.12s ease;
}

.profile-trigger:hover { background: var(--side-hover); }

.profile-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--avatar-bg);
  color: var(--avatar-fg);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  text-transform: uppercase;
}

.profile-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.profile-name { font-size: 13px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.connection-row { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); min-width: 0; }
.connection { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.connection-row.ready .dot { background: var(--ok); }
.connection-row.down .dot { background: var(--danger); }

.profile-actions { display: inline-flex; align-items: center; gap: 1px; flex: none; }

.mini-icon-btn {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.mini-icon-btn:hover { background: var(--side-hover); color: var(--ink); }
.mini-icon-btn svg { width: 14px; height: 14px; }

.layout.sidebar-collapsed .sidebar { width: 0; border-right-width: 0; }
.expand-header-btn { display: none; }
.layout.sidebar-collapsed .expand-header-btn { display: inline-flex; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: background-color 0.12s ease, color 0.12s ease;
}

.icon-btn:hover { background: var(--side-hover); color: var(--ink); }

/* ==================== Main Canvas ==================== */
.main {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.toolbar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 48px;
  padding: 0 14px;
  background: var(--bg);
  z-index: 20;
}

.toolbar-left { display: flex; align-items: center; gap: 6px; }
.toolbar-center { display: flex; justify-content: center; min-width: 0; }
.toolbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }

.title-menu-wrap { position: relative; max-width: min(46vw, 420px); }

.title-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
}

.title-trigger:hover { background: var(--side-hover); }
.title-trigger h1 { margin: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-chevron { width: 14px; height: 14px; color: var(--muted); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 152px;
  padding: 4px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: var(--card-shadow);
  z-index: 40;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--body);
  font-size: 13px;
  text-align: left;
}

.dropdown-item:hover { background: var(--side-hover); color: var(--ink); }
.dropdown-item svg { width: 14px; height: 14px; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-sep { height: 1px; margin: 4px 6px; background: var(--line); }

#star-chat[aria-pressed="true"] { color: var(--accent); }
#star-chat[aria-pressed="true"] svg { fill: currentColor; }

/* Welcome State — 100% clean pure white canvas matching screenshot */
.layout.is-welcome .toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background: transparent;
  pointer-events: none;
}

.layout.is-welcome .toolbar button { pointer-events: auto; }
.layout.is-welcome .title-menu-wrap,
.layout.is-welcome .chat-only { display: none; }

.layout.is-welcome .main {
  justify-content: center;
  padding-bottom: 6vh;
}

.layout.is-welcome .timeline { flex: 0 0 auto; overflow: visible; }
.layout.is-welcome .welcome { height: auto; padding: 0 24px 26px; }
.layout.is-welcome .footer { padding-top: 0; }

.welcome { display: flex; align-items: center; justify-content: center; }
.greeting { display: inline-flex; align-items: center; justify-content: center; gap: 14px; }

.claude-spark {
  width: 38px;
  height: 38px;
  display: block;
  object-fit: contain;
  flex: none;
  user-select: none;
}

.greeting h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--body);
  line-height: 1.2;
}

/* ==================== Conversation Timeline ==================== */
.timeline { flex: 1; min-height: 0; overflow-y: auto; }
.messages { max-width: 720px; margin: 0 auto; padding: 18px 24px 32px; }
.turn { margin-bottom: 28px; }

.question { display: flex; flex-direction: column; align-items: flex-end; margin-bottom: 20px; }
.question-wrap { position: relative; max-width: 82%; }

.question-bubble {
  padding: 10px 16px;
  border-radius: 18px;
  background: var(--user-bubble);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.question-edit-btn {
  position: absolute;
  right: 6px;
  bottom: -12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  background: var(--card);
  color: var(--muted);
  font-size: 11.5px;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.14s ease, transform 0.14s ease, color 0.12s ease;
}

.question-edit-btn svg { width: 11.5px; height: 11.5px; }
.question-wrap:hover .question-edit-btn,
.question-edit-btn:focus-visible { opacity: 1; transform: scale(1); }
.question-edit-btn:hover { color: var(--ink); border-color: var(--card-border-focus); }

.edit-box {
  width: min(560px, 85vw);
  padding: 10px 12px;
  border: 1px solid var(--card-border-focus);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--card-shadow);
}

.edit-box textarea { width: 100%; min-height: 64px; border: 0; outline: 0; resize: vertical; background: transparent; font-size: 14.5px; line-height: 1.6; color: var(--ink); }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.answer { display: block; }
.answer-body { min-width: 0; }

.reply {
  font-family: var(--serif);
  font-size: 16.5px;
  line-height: 1.75;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.reply > :first-child { margin-top: 0; }
.reply > :last-child { margin-bottom: 0; }
.reply p { margin: 0 0 14px; }
.reply h1, .reply h2, .reply h3, .reply h4 { margin: 22px 0 10px; font-family: var(--sans); font-weight: 600; line-height: 1.4; }
.reply h1 { font-size: 20px; }
.reply h2 { font-size: 18px; }
.reply h3, .reply h4 { font-size: 16px; }
.reply ul, .reply ol { margin: 0 0 14px; padding-left: 24px; }
.reply li { margin: 5px 0; }
.reply code { font-family: var(--mono); font-size: 0.85em; padding: 1.5px 5px; border-radius: 5px; background: var(--inline-code); }
.reply blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 2.5px solid var(--card-border); color: var(--muted); }
.reply a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.reply hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.code-block { margin: 14px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--code-bg); overflow: hidden; font-family: var(--sans); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; background: var(--code-head); border-bottom: 1px solid var(--line); }
.code-lang { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.code-copy { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 11.5px; }
.code-copy:hover { background: var(--side-hover); color: var(--ink); }
.code-copy.copied { color: var(--ok); }
.code-copy svg { width: 13px; height: 13px; }
.code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; background: transparent; }
.code-block pre code { display: block; padding: 0; background: transparent; font-size: 13px; line-height: 1.6; color: var(--ink); }

.thinking { display: inline-flex; align-items: center; gap: 8px; font-family: var(--sans); font-size: 13.5px; color: var(--muted); padding: 4px 0; }
.thinking .claude-spark { width: 20px; height: 20px; animation: sparkSpin 2.4s linear infinite; }
@keyframes sparkSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.reply.pending:not(:empty) > :last-child::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  animation: pulse 1s ease-in-out infinite;
}
.reply.pending .thinking::after { display: none; }
@keyframes pulse { 0%, 100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: none; } }

.turn-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 8px; min-height: 28px; }
.turn-foot .icon-btn { width: 28px; height: 28px; color: var(--faint); }
.turn-foot .icon-btn:hover { color: var(--ink); }
.turn-foot svg { width: 14.5px; height: 14.5px; }
.turn-meta { margin-left: 6px; font-size: 12px; color: var(--faint); }
.turn-meta.turn-error { color: var(--danger); font-size: 13px; line-height: 1.5; }

.searched { margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.searched summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; }
.searched summary:hover { color: var(--ink); }
.searched summary::-webkit-details-marker { display: none; }
.searched summary::after { content: "›"; font-size: 15px; transition: transform 0.15s; }
.searched[open] summary::after { transform: rotate(90deg); }
.searched.live summary::after { content: ""; }
.searched summary svg { width: 14px; height: 14px; }
.searched ul { margin: 8px 0 0; padding: 0 0 0 20px; list-style: none; }
.searched li { margin: 4px 0; line-height: 1.5; }
.searched a { color: var(--body); text-decoration: none; }
.searched a:hover { text-decoration: underline; }
.searched .host { margin-left: 6px; font-size: 12px; color: var(--faint); }

/* ==================== Floating Composer Card ==================== */
.footer {
  flex: none;
  width: 100%;
  padding: 8px 24px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.composer {
  max-width: 650px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 14px 14px 10px 18px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--card-shadow);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer:focus-within {
  border-color: var(--card-border-focus);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.065), 0 1px 4px rgba(0, 0, 0, 0.03);
}

.composer textarea {
  width: 100%;
  min-height: 44px;
  max-height: 220px;
  padding: 2px 2px 6px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
}

.composer textarea::placeholder { color: var(--faint); }

.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 4px; }
.composer-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.composer-right { display: flex; align-items: center; gap: 6px; flex: none; }

.composer-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-size: 12.5px;
  color: var(--muted);
}

.composer-tool:hover:not(:disabled) { background: var(--side-hover); color: var(--ink); }
.composer-tool svg { width: 15px; height: 15px; }
.composer-tool[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.composer-tool:disabled { opacity: 0.45; cursor: default; }

.status { font-size: 12px; color: var(--faint); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #FFFFFF;
  transition: background-color 0.14s ease, transform 0.12s ease;
}

.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:active:not(:disabled) { transform: scale(0.94); }
.send:disabled { background: var(--side-hover); color: var(--faint); cursor: default; }
.send.stop { background: var(--ink); color: var(--bg); }
.send.stop svg { fill: currentColor; stroke: none; width: 13px; height: 13px; }

.under {
  max-width: 650px;
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px;
}

.under-left, .under-right { display: flex; align-items: center; gap: 6px; }

.picker select {
  max-width: 220px;
  padding: 3px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 12.5px;
  cursor: pointer;
}

.picker select option { background: var(--card); color: var(--ink); }
.picker select:hover:not(:disabled) { background: var(--side-hover); }
.picker select:disabled { opacity: 0.5; cursor: default; }
.model-picker select { color: var(--body); font-weight: 500; }
.effort-picker select, .muted-picker select { color: var(--muted); font-weight: 400; }

/* ==================== Claude-Style Modals (Auth + Quota/Keys) ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  width: 100%;
  max-height: min(88dvh, 720px);
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.16);
  padding: 20px 22px 22px;
}

.auth-card { max-width: 420px; }
.account-card { max-width: 560px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-brand { display: flex; align-items: center; gap: 10px; }
.modal-logo { width: 24px; height: 24px; object-fit: contain; }
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 19px; font-weight: 500; color: var(--ink); }
.modal-head-actions { display: flex; align-items: center; gap: 6px; }

.modal-tabs {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  margin-bottom: 16px;
}

.modal-tab {
  flex: 1;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  transition: background-color 0.14s ease, color 0.14s ease;
}

.modal-tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.form-alert {
  margin-bottom: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.5;
}

.form-alert.error { background: var(--danger-soft); color: var(--danger); }
.form-alert.ok { background: var(--ok-soft); color: var(--ok); }

.modal-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.field input,
.field select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  outline: 0;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-inline { display: flex; gap: 8px; }
.field-inline input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border: 1px solid var(--card-border); border-radius: 10px; background: var(--bg); color: var(--ink); font-size: 13.5px; outline: 0; }
.field-inline input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-hint { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

.btn-primary {
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color 0.14s ease, opacity 0.14s ease;
}

.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-inline { flex: none; padding: 0 18px; }

.btn-secondary {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--card-border);
  border-radius: 9px;
  background: var(--surface-subtle);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.btn-secondary:hover:not(:disabled) { background: var(--side-hover); }
.btn-secondary:disabled { opacity: 0.5; cursor: default; }

.btn-danger {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--danger-soft);
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.btn-danger:hover { filter: brightness(0.95); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }

/* Account Dashboard Cards */
.acc-pane { display: flex; flex-direction: column; gap: 14px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.stat-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 600; color: var(--ink); letter-spacing: -0.02em; }
.stat-sub { font-size: 11.5px; color: var(--faint); }

.acc-section {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acc-section h3 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); }

/* Subscriptions progress bars */
.subs-list { display: flex; flex-direction: column; gap: 10px; }
.sub-card { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); display: flex; flex-direction: column; gap: 8px; }
.sub-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 500; color: var(--ink); }
.sub-exp { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.meter-row { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
.meter-labels { display: flex; justify-content: space-between; }
.meter-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.2s ease; }

/* API Keys list */
.keys-list { display: flex; flex-direction: column; gap: 8px; }

.key-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.key-card.is-active {
  border-color: var(--accent);
  background: var(--card);
}

.key-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.key-title-wrap { display: flex; align-items: center; gap: 7px; min-width: 0; }
.key-name { font-size: 13.5px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-muted { background: var(--badge-bg); color: var(--muted); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

.key-meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.key-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* Recharge presets & Orders list */
.amount-presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.preset-btn {
  height: 34px;
  border: 1px solid var(--card-border);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}
.preset-btn:hover { background: var(--side-hover); }
.preset-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.pending-pay-box {
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
}

.orders-list { display: flex; flex-direction: column; gap: 8px; }
.order-card {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.order-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 500; }
.order-meta { font-size: 11.5px; color: var(--muted); font-family: var(--mono); display: flex; flex-wrap: wrap; gap: 8px; }
.order-actions { display: flex; gap: 6px; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }

.setting-list { display: flex; flex-direction: column; gap: 10px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
}

.setting-title { font-size: 13.5px; font-weight: 500; color: var(--ink); }
.setting-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.setting-actions { display: flex; gap: 6px; flex: none; }

.quota-content { font-size: 13px; line-height: 1.65; color: var(--body); white-space: pre-line; }
.empty-hint { margin: 0; font-size: 13px; line-height: 1.65; color: var(--muted); }
.empty-hint code { font-family: var(--mono); background: var(--inline-code); padding: 1px 5px; border-radius: 4px; color: var(--ink); }

/* ==================== Responsive (< 780px) ==================== */
.only-narrow { display: none; }

@media (max-width: 780px) {
  .only-wide { display: none !important; }
  .only-narrow { display: inline-flex; }
  .scrim.only-narrow { display: block; }
  .expand-header-btn { display: none !important; }
  .layout.sidebar-collapsed .sidebar { width: 268px; border-right-width: 1px; }

  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(82vw, 272px);
    transform: translateX(-100%);
  }

  .layout.history-open .sidebar { transform: translateX(0); box-shadow: 0 0 36px rgba(0, 0, 0, 0.16); }
  .scrim { position: fixed; z-index: 40; inset: 0; background: rgba(0, 0, 0, 0.22); opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
  .layout.history-open .scrim { opacity: 1; pointer-events: auto; }

  .greeting h2 { font-size: 28px; }
  .claude-spark { width: 30px; height: 30px; }
  .messages { padding: 16px 16px 24px; }
  .footer { padding: 8px 14px 14px; }
  .stat-grid, .field-grid { grid-template-columns: 1fr; }
}
