:root {
  --bg: #0b0b0c;
  --bg-soft: #151517;
  --panel: #121214;
  --sidebar: #121214;
  --field: #1a1a1d;
  --border: #2c2c30;
  --border-soft: #232326;
  --text: #f2f2f2;
  --muted: #9b9ba1;
  --accent: #ff8a3d;
  --accent-2: #ff3d2e;
  --grad: linear-gradient(135deg, #ff8a3d, #ff3d2e);
  --accent-soft: rgba(255, 138, 61, .14);
  --accent-line: rgba(255, 138, 61, .45);
  --accent-ink: #ffffff;
  --user-bubble: #1f1f23;
  --hover: #1f1f23;
  --danger: #ff8f80;
  --ok: #5fd09a;
  --code-bg: #151517;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 Inter, ui-sans-serif, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: #ff9a5a; }
a:hover { color: #ffc29a; }
.hidden { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--border); background: var(--bg); border-radius: 10px;
  padding: 8px 14px; transition: background .15s;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--grad); border-color: transparent; color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.input {
  width: 100%; border: 1px solid var(--border); background: var(--field); border-radius: 10px;
  padding: 10px 12px; outline: none;
}
.input:focus { border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }

/* ---------- auth screen ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: 100%; max-width: 380px; padding: 32px 28px; border: 1px solid var(--border);
  border-radius: 20px; background: var(--bg-soft);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 20px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-size: 16px; font-weight: 700;
}
.auth-card h1 { font-size: 22px; margin: 18px 0 4px; }
.auth-card p { color: var(--muted); margin: 0 0 8px; font-size: 14px; }
.auth-card .btn.primary { width: 100%; margin-top: 18px; padding: 11px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 18px;
  padding: 12px; text-decoration: none; background: #ffffff; color: #1f1f1f; border-color: #ffffff; font-weight: 600;
}
.google-btn:hover { background: #ececec; }
.auth-card .link-btn { display: block; margin-left: auto; margin-right: auto; }
.notice { border: 1px solid var(--border-soft); background: var(--bg-soft); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-top: 14px; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.error { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1em; }

/* ---------- app layout ---------- */
.app { display: flex; height: 100%; }
.sidebar {
  width: 272px; flex-shrink: 0; background: var(--sidebar); border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column; height: 100%;
}
.sidebar-top { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-top .brand { padding: 4px 6px 8px; font-size: 17px; }
.new-chat { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: var(--field); border: 1px solid var(--border); padding: 9px 12px; border-radius: 10px; }
.new-chat:hover { background: var(--hover); }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
.conv-group { font-size: 12px; color: var(--muted); padding: 12px 10px 4px; }
.conv-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px;
  cursor: pointer; font-size: 14px; position: relative;
}
.conv-item:hover, .conv-item.active { background: var(--hover); }
.conv-item .title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv-item .cost { font-size: 11px; color: var(--muted); }
.conv-item .del { display: none; background: none; border: none; color: var(--muted); padding: 0 2px; }
.conv-item:hover .del { display: block; }
.sidebar-bottom { border-top: 1px solid var(--border-soft); padding: 10px 12px; }
.usage-mini { width: 100%; text-align: left; background: var(--field); border: 1px solid var(--border-soft); border-radius: 12px; padding: 10px 12px; }
.usage-mini:hover { background: var(--hover); }
.usage-mini .label { font-size: 12px; color: var(--muted); }
.usage-mini .value { font-weight: 650; font-size: 18px; }
.bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.bar > div { height: 100%; background: var(--grad); width: 0; transition: width .3s; }
.bar.over > div { background: var(--danger); }
.user-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px 2px; font-size: 14px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #3d5c99; color: #fff;
  display: grid; place-items: center; font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.user-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 13px; padding: 2px 4px; }
.link-btn:hover { color: var(--text); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100%; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; min-height: 56px; }
.menu-btn { display: none; background: none; border: none; font-size: 20px; padding: 4px 8px; }
.model-select {
  border: 1px solid var(--border); background: var(--bg-soft); font-size: 15px; font-weight: 600; padding: 7px 10px;
  border-radius: 10px; cursor: pointer; max-width: 70vw; field-sizing: content;
}
.model-select:hover { background: var(--hover); }
.model-price { font-size: 12px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.conv-cost { font-size: 13px; color: var(--muted); }

.chat-scroll { flex: 1; overflow-y: auto; }
.chat { max-width: 780px; margin: 0 auto; padding: 16px 20px 40px; }
.empty { text-align: center; margin-top: 18vh; }
.empty h2 { font-size: 28px; font-weight: 600; margin: 0 0 6px; }
.empty p { color: var(--muted); margin: 0; }

.msg { margin: 22px 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--user-bubble); padding: 10px 16px; border-radius: 20px; max-width: 80%;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.assistant .content { word-wrap: break-word; }
.msg.assistant .content > :first-child { margin-top: 0; }
.msg.assistant .content > :last-child { margin-bottom: 0; }
.content pre {
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; overflow-x: auto; font-size: 13.5px; position: relative;
}
.content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.content :not(pre) > code { background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.content table { border-collapse: collapse; display: block; overflow-x: auto; }
.content th, .content td { border: 1px solid var(--border); padding: 6px 10px; }
.content blockquote { border-left: 3px solid var(--border); margin-left: 0; padding-left: 14px; color: var(--muted); }
.copy-code {
  position: absolute; top: 6px; right: 6px; font-size: 12px; padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--field); opacity: .9;
}
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.meta .chip { border: 1px solid var(--border); border-radius: 99px; padding: 1px 9px; }
.meta .chip.cost-chip { color: #fff; background: var(--accent-soft); border-color: var(--accent-line); }
.meta button { background: none; border: none; color: var(--muted); font-size: 12px; padding: 0; }
.meta button:hover { color: var(--text); }
.typing::after { content: '▍'; animation: blink 1s steps(1) infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }
.msg-error { color: var(--danger); border: 1px solid var(--danger); border-radius: 10px; padding: 10px 14px; font-size: 14px; }

.composer-wrap { padding: 0 16px 16px; }
.composer {
  max-width: 780px; margin: 0 auto; border: 1px solid var(--border); border-radius: 26px;
  background: var(--bg-soft); padding: 10px 10px 10px 18px; display: flex; align-items: flex-end; gap: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
}
.composer textarea {
  flex: 1; border: none; outline: none; resize: none; background: transparent; max-height: 220px;
  padding: 6px 0; line-height: 1.5;
}
.send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--grad); color: #fff;
  display: grid; place-items: center; flex-shrink: 0; font-size: 16px;
}
.send-btn:disabled { background: #2c2c30; color: #6f6f75; cursor: default; }
.foot-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 18px; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 24px;
}
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.close-x { background: none; border: none; font-size: 22px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.stat { border: 1px solid var(--border-soft); border-radius: 12px; padding: 12px; background: var(--field); }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 20px; font-weight: 650; margin-top: 2px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border-soft); padding: 8px 6px; }
table.data td { border-bottom: 1px solid var(--border-soft); padding: 8px 6px; vertical-align: middle; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.note { font-size: 12px; color: var(--muted); margin-top: 12px; }
.daily { display: flex; align-items: flex-end; gap: 3px; height: 70px; margin: 10px 0 4px; }
.daily div { flex: 1; max-width: 18px; background: var(--grad); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }

/* ---------- admin ---------- */
.admin { max-width: 1040px; margin: 0 auto; padding: 24px 16px 60px; }
.admin header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.card { border: 1px solid var(--border-soft); border-radius: 16px; padding: 20px; margin-bottom: 20px; background: var(--panel); }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .sub { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 160px; }
.table-wrap { overflow-x: auto; }
.badge { font-size: 11px; border-radius: 99px; padding: 1px 8px; border: 1px solid var(--border); }
.badge.admin { background: var(--grad); color: #fff; border-color: transparent; }
.badge.off { color: var(--danger); border-color: var(--danger); }
.key-status { font-family: ui-monospace, monospace; font-size: 13px; color: var(--muted); }
.ok { color: var(--ok); }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #f2f2f2; color: #111;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 100;
}

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.7); }
  .menu-btn { display: block; }
  .chat { padding: 12px 16px 30px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .model-price { display: none; }
}

/* admin activity */
.stats.six { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 900px) { .stats.six { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .stats.six { grid-template-columns: repeat(2, 1fr); } }
.stat.alert .v { color: var(--accent); }
.person { display: flex; align-items: center; gap: 10px; }
.person .avatar { width: 30px; height: 30px; }
.person .who { line-height: 1.3; }
.person .who small { color: var(--muted); display: block; font-size: 12px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.dau { display: flex; align-items: flex-end; gap: 3px; height: 80px; margin-top: 6px; }
.dau div { flex: 1; background: var(--grad); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.dau-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* language switch + privacy */
.lang-toggle {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); border-radius: 99px;
  padding: 4px 12px; font-size: 13px; font-weight: 600; min-height: 32px;
}
.lang-toggle:hover { background: var(--hover); }
.lang-corner { position: fixed; top: 16px; right: 16px; z-index: 10; }
.privacy-note { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 16px 0 0; text-align: center; }
.privacy-box { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.privacy-box h3 { margin: 0 0 4px; font-size: 15px; }
.privacy-box p { margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* waiting-for-approval card gets the gradient frame */
#pendingCard { border: 1.5px solid var(--accent-line); background: #151210; }
option, optgroup { background: #151517; color: #f2f2f2; }

/* brand tagline + creative tools list */
.tagline { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.tool-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.tool { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 10px; font-size: 14px; color: var(--muted); }
.tool.active { color: var(--text); background: var(--accent-soft); border: 1px solid var(--accent-line); }
.soon-tag { font-size: 10px; border: 1px solid var(--border); border-radius: 99px; padding: 1px 7px; color: var(--muted); }
