:root {
  --bg: #faf9f5;
  --panel: #ffffff;
  --soft: #f0eee6;
  --soft-2: #e9e5da;
  --text: #1f1e1d;
  --muted: #6b675f;
  --faint: #9b9589;
  --line: #e7e2d7;
  --line-strong: #d9d3c5;
  --accent: #d97757;
  --accent-ink: #b85c3d;
  --code-bg: #1f1e1c;
  --code-head: #2b2926;
  --code-text: #f3efe6;
  --serif: Georgia, "Times New Roman", "Songti SC", "Noto Serif CJK SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(900px 420px at 50% -12%, #ffffff 0%, rgba(255, 255, 255, 0) 70%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d8d2c5; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #c4bdad; }

/* ---------- topbar ---------- */

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 249, 245, 0.88);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.mark { color: var(--accent); flex: 0 0 auto; }
.brand b {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 6px;
  transform: translateY(1px);
}

.actions { display: flex; align-items: center; gap: 10px; }
.usage {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--faint);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.rules-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 9px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
}
.rules-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.rice-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 9px;
  padding: 5px 8px;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.rice-btn:hover { border-color: var(--accent); }
.rice-svg { color: var(--accent); flex: 0 0 auto; }
.rice-balance {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.rice-tick {
  position: absolute;
  top: -6px;
  right: -5px;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.4;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 0 4px;
}
.rice-btn.bump { animation: riceBump 0.24s ease; }
.icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 8px;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.new-chat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 9px;
  padding: 6px 11px;
  font-size: 12px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.new-chat:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------- chat shell ---------- */

.chat {
  height: calc(100dvh - 58px);
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 22px 16px;
  scroll-behavior: smooth;
}

#thread {
  max-width: 760px;
  margin: 0 auto;
}

/* ---------- empty state ---------- */

.empty {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6vh 0 8vh;
  animation: fadeIn 0.4s ease both;
}
.empty-mark {
  font-size: 40px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 18px;
  user-select: none;
}
.empty h1 {
  font-family: var(--serif);
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
}
.empty p { color: var(--muted); font-size: 14.5px; margin: 0 0 28px; }
.chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  width: min(520px, 100%);
}
.chips button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--muted);
  text-align: left;
  transition: border-color 0.15s, color 0.15s, transform 0.15s;
}
.chips button:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  transform: translateY(-1px);
}
.region-note {
  margin: 22px 0 0;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--faint);
  line-height: 1.7;
}

/* ---------- messages ---------- */

.msg {
  max-width: 760px;
  margin: 0 auto 26px;
  animation: fadeUp 0.22s ease both;
}
.msg:last-child { margin-bottom: 6px; }

.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--soft);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 16px;
  max-width: 82%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.72;
}

.msg.assistant { display: flex; gap: 12px; align-items: flex-start; }
.msg.assistant .avatar {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin-top: 3px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 22px;
  line-height: 1;
  user-select: none;
}
.msg.assistant .content {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  line-height: 1.82;
  overflow-wrap: anywhere;
}
.msg.assistant .content.streaming { white-space: pre-wrap; }
.msg.assistant .content.streaming::after {
  content: "▍";
  color: var(--accent);
  margin-left: 2px;
  animation: caret 1s steps(1) infinite;
}

.msg.system { display: flex; justify-content: center; margin: 18px auto; }
.msg.system .note {
  font-size: 11px;
  color: var(--faint);
  background: rgba(31, 30, 29, 0.035);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  text-align: center;
  max-width: 92%;
}
.msg.system.bad .note { color: #b04a3d; border-color: #e7c9c2; background: #fbf0ed; }

/* 封禁回复：红边 + 放大的第一句 */
.msg.assistant.banned .avatar { color: #b23a2e; }
.msg.assistant.banned .content {
  border-left: 2px solid #e0b6ad;
  padding-left: 14px;
}
.msg.assistant.banned .content > p:first-child {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: #8f2f25;
  margin-bottom: 10px;
}

/* ---------- markdown ---------- */

.content p { margin: 0 0 12px; }
.content p:last-child { margin-bottom: 0; }
.content h1, .content h2, .content h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.35;
  margin: 22px 0 8px;
}
.content h1 { font-size: 23px; }
.content h2 { font-size: 20px; }
.content h3 { font-size: 17px; }
.content h1:first-child, .content h2:first-child, .content h3:first-child { margin-top: 0; }
.content ul, .content ol { margin: 6px 0 12px; padding-left: 23px; }
.content li { margin: 3px 0; }
.content blockquote {
  margin: 12px 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.content a { color: var(--accent-ink); text-underline-offset: 2px; }
.content strong { font-weight: 650; }
.content code {
  font-family: var(--mono);
  font-size: 12.8px;
  background: var(--soft-2);
  border-radius: 4px;
  padding: 1.5px 5px;
}
.content .code {
  margin: 13px 0;
  border-radius: 10px;
  overflow: hidden;
  background: var(--code-bg);
}
.content .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px 13px;
  background: var(--code-head);
  color: #a9a397;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
}
.content .code-head .copy {
  border: 1px solid #46423c;
  background: transparent;
  color: #b9b3a7;
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 9.5px;
  font-family: var(--mono);
}
.content .code-head .copy:hover { color: #fff; border-color: #6b655b; }
.content .code pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.65;
}
.content .code pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-size: inherit;
}

/* typing */

.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--faint);
  animation: blink 1.1s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }

/* ---------- composer ---------- */

.composer-wrap {
  flex: 0 0 auto;
  padding: 10px 22px 14px;
  background: linear-gradient(180deg, rgba(250, 249, 245, 0) 0%, var(--bg) 38%);
}

.composer {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 9px 9px 9px 16px;
  box-shadow: 0 8px 30px rgba(31, 30, 29, 0.055);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.composer:focus-within {
  border-color: #cfc7b6;
  box-shadow: 0 8px 34px rgba(31, 30, 29, 0.08);
}
.composer.disabled { opacity: 0.58; }

.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  max-height: 180px;
  padding: 4px 0;
}
.composer textarea::placeholder { color: var(--faint); }

.send {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  transition: background 0.15s, transform 0.15s;
}
.send:hover { background: var(--accent-ink); transform: translateY(-1px); }
.send:disabled { background: #ddd7ca; color: #fff; cursor: not-allowed; transform: none; }

.footnote {
  max-width: 760px;
  margin: 8px auto 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 10px;
  color: var(--faint);
  letter-spacing: 0.02em;
  text-align: center;
}

/* ---------- 封禁条 ---------- */

.ban-bar {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #fbf0ed;
  border: 1px solid #e7c9c2;
  border-radius: 14px;
  box-shadow: 0 8px 26px rgba(31, 30, 29, 0.04);
}
.ban-bar-text { min-width: 0; }
.ban-bar-text b {
  display: block;
  font-size: 12.5px;
  color: #8f2f25;
  line-height: 1.4;
}
.ban-bar-text span {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  color: #a8665c;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ban-bar-actions { display: flex; gap: 7px; flex: 0 0 auto; }
.ban-bar .btn { padding: 6px 10px; font-size: 11px; }

/* ---------- 说明 / 封禁弹层 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(31, 30, 29, 0.48);
  backdrop-filter: blur(7px);
  animation: fadeIn 0.18s ease both;
}

.sheet {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86dvh, 780px);
  overflow-y: auto;
  scrollbar-width: none;
  background: #fffdf8;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.26);
  padding: 28px 30px 24px;
  animation: sheetIn 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.sheet::-webkit-scrollbar { display: none; }
.sheet::-webkit-scrollbar-track { background: transparent; }
.sheet::-webkit-scrollbar-thumb {
  background: #d8d2c5;
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}
body[data-theme="dark"] .sheet::-webkit-scrollbar-thumb {
  background: #4a453d;
  background-clip: content-box;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 20px;
  line-height: 1;
  border-radius: 50%;
}
.modal-close:hover { background: var(--soft); color: var(--text); }

.doc-kicker {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  color: var(--faint);
  text-transform: uppercase;
}
.sheet h2 {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.3;
  margin: 7px 0 6px;
  padding-right: 92px;
}
.doc-meta {
  display: flex;
  gap: 10px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--faint);
  letter-spacing: 0.05em;
}
.doc-intro {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.75;
  margin: 16px 0 10px;
}
.rules {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.rules li {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.rule-no {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  padding-top: 3px;
}
.rules p { margin: 0; font-size: 13px; line-height: 1.7; }
.rules li.critical p, .rules li.critical .rule-no { color: #a33a2e; }

.device-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  padding: 10px 13px;
}
.device-head {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--faint);
  margin-bottom: 5px;
}
.device-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  padding: 2px 0;
}
.device-row code { font-family: var(--mono); font-size: 10.5px; color: var(--text); }
.device-row code.watching { color: #a33a2e; }
.doc-fine {
  font-size: 10px;
  color: var(--faint);
  line-height: 1.65;
  margin: 14px 0 0;
}

.ban-doc { border-top: 4px solid #a33a2e; }
.ban-doc h2 { color: #8f2f25; }
.stamp {
  position: absolute;
  top: 20px;
  right: 22px;
  border: 3px double #b23a2e;
  color: #b23a2e;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.16em;
  text-align: center;
  padding: 5px 9px;
  transform: rotate(-8deg);
  opacity: 0.88;
  animation: stampIn 0.4s 0.1s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.stamp span { font-size: 10px; letter-spacing: 0.28em; }
.ban-verdict { font-size: 12.5px; color: #7a3c32; margin: 0 0 12px; }
.evidence {
  list-style: none;
  margin: 0;
  padding: 11px 13px;
  background: #fbf0ed;
  border: 1px solid #efd6cf;
  border-radius: 9px;
}
.evidence li {
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.75;
  color: #7a3c32;
  overflow-wrap: anywhere;
}
.evidence li::before { content: "· "; color: #b23a2e; }
.rule-quote {
  margin: 14px 0 0;
  padding: 2px 0 2px 13px;
  border-left: 3px solid #b23a2e;
}
.rule-quote-head { font-size: 10px; color: var(--faint); }
.rule-quote p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.ban-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 18px;
  margin: 15px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.ban-grid div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  color: var(--faint);
}
.ban-grid code { font-family: var(--mono); color: var(--text); }
.ban-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 13px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  color: #7a3c32;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 17px;
}
.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 12px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn.primary { background: #1f1e1d; border-color: #1f1e1d; color: #fff; }
.btn.primary:hover { background: #3a3835; border-color: #3a3835; color: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 设置 / 商店 ---------- */

.settings-doc .sheet { padding-bottom: 22px; }
.settings-doc { width: min(760px, 100%); }
.env-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
  align-items: start;
}
.env-grid .device-box { margin-top: 0; }
.env-grid .settings-region { margin-top: 0; }
.activity-box { margin-top: 12px; }
.risk-card {
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.risk-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
}
.risk-head b {
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text);
}
.risk-track {
  height: 6px;
  margin-top: 7px;
  border-radius: 999px;
  background: var(--soft-2);
  overflow: hidden;
}
.risk-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: #6f9b68;
  transition: width 0.3s ease, background 0.3s ease;
}
.risk-track i[data-level="low"] { background: #c9a227; }
.risk-track i[data-level="mid"] { background: #d97757; }
.risk-track i[data-level="high"] { background: #b23a2e; }
.risk-sub { margin-top: 5px; font-size: 9px; color: var(--faint); }
.wallet-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}
.wallet-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--faint);
}
.wallet-amount {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
}
.wallet-sub { font-size: 10px; color: var(--muted); }
.rice-eat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.settings-region { margin-top: 12px; }
.shop-head {
  margin: 20px 0 8px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--faint);
}
.shop-list { display: flex; flex-direction: column; gap: 8px; }
.shop-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.shop-main { min-width: 0; }
.shop-name { font-size: 13px; font-weight: 600; line-height: 1.4; }
.shop-owned {
  display: inline-block;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 400;
  color: #5f7a5a;
  border: 1px solid #bfd0b8;
  border-radius: 999px;
  padding: 0 5px;
  vertical-align: 1px;
}
.shop-desc {
  margin: 3px 0 0;
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.55;
}
.shop-action {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.shop-action .btn { padding: 5px 9px; font-size: 10.5px; }
.shop-price { font-family: var(--mono); font-size: 9px; color: var(--faint); }
.switch {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--muted);
}
.switch.on {
  background: #eef4ea;
  border-color: #bfd0b8;
  color: #4f6b4a;
}
.nickname-row { display: flex; gap: 6px; margin-top: 8px; }
.nickname-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 11px;
  outline: none;
}
.nickname-row input:focus { border-color: var(--accent); }

/* ---------- 账号环境 ---------- */

.device-row code {
  max-width: 68%;
  text-align: right;
  overflow-wrap: anywhere;
}
.env-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}
.env-btn {
  border: 1px solid var(--line-strong);
  background: var(--bg);
  border-radius: 999px;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--muted);
}
.env-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.env-btn.on {
  background: #eef4ea;
  border-color: #bfd0b8;
  color: #4f6b4a;
}
.login-list { display: flex; flex-direction: column; gap: 7px; }
.login-item {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--muted);
}
.login-time { font-family: var(--mono); font-size: 9px; color: var(--faint); }
.login-main { min-width: 0; }
.login-main code {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
}
.login-main span {
  display: block;
  font-size: 9px;
  color: var(--faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.login-tag {
  font-family: var(--mono);
  font-size: 8px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 5px;
  white-space: nowrap;
}
.login-empty { font-size: 10px; color: var(--faint); }
.rebirth-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 11px 13px;
  border: 1px solid #e7c9c2;
  background: #fbf0ed;
  border-radius: 10px;
}
.rebirth-copy b { display: block; font-size: 12px; color: #8f2f25; }
.rebirth-copy span { display: block; font-size: 9.5px; color: #a8665c; }
.rebirth-card .btn { flex: 0 0 auto; padding: 6px 11px; font-size: 11px; }

.gain-float {
  position: fixed;
  z-index: 90;
  transform: translate(-50%, 0);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-ink);
  pointer-events: none;
  animation: gainFloat 0.8s ease-out forwards;
}

/* ---------- dark theme ---------- */

body[data-theme="dark"] {
  --bg: #171614;
  --panel: #211f1c;
  --soft: #2a2723;
  --soft-2: #332f2a;
  --text: #f2eee6;
  --muted: #b5aea1;
  --faint: #857e72;
  --line: #37332d;
  --line-strong: #4a453d;
  --accent: #e08968;
  --accent-ink: #f0a081;
  --code-bg: #0f0e0d;
  --code-head: #1b1917;
  --code-text: #f3efe6;
}
body[data-theme="dark"] .topbar { background: rgba(23, 22, 20, 0.88); }
body[data-theme="dark"] .sheet { background: #211f1c; }
body[data-theme="dark"] .msg.system .note { background: rgba(255, 255, 255, 0.04); }
body[data-theme="dark"] .msg.system.bad .note {
  background: #2b1f1c;
  border-color: #4a2e29;
  color: #e0a196;
}
body[data-theme="dark"] .ban-bar { background: #2b1f1c; border-color: #4a2e29; }
body[data-theme="dark"] .ban-bar-text b { color: #e0a196; }
body[data-theme="dark"] .ban-bar-text span { color: #b98a80; }
body[data-theme="dark"] .evidence { background: #2b1f1c; border-color: #4a2e29; }
body[data-theme="dark"] .evidence li { color: #d9a79d; }
body[data-theme="dark"] .ban-doc h2 { color: #e08a7a; }
body[data-theme="dark"] .ban-verdict { color: #d9a79d; }
body[data-theme="dark"] .ban-stats { color: #d9a79d; }
body[data-theme="dark"] .rules li.critical p,
body[data-theme="dark"] .rules li.critical .rule-no { color: #e08a7a; }
body[data-theme="dark"] .msg.assistant.banned .content > p:first-child { color: #e08a7a; }
body[data-theme="dark"] .msg.assistant.banned .content { border-left-color: #6b3a32; }
body[data-theme="dark"] .msg.assistant.banned .avatar { color: #e08968; }
body[data-theme="dark"] .shop-owned { color: #a8c79e; border-color: #41543a; }
body[data-theme="dark"] .switch.on {
  background: #263021;
  border-color: #41543a;
  color: #a8c79e;
}
body[data-theme="dark"] .env-btn { background: var(--bg); border-color: var(--line-strong); }
body[data-theme="dark"] .env-btn.on {
  background: #263021;
  border-color: #41543a;
  color: #a8c79e;
}
body[data-theme="dark"] .rebirth-card { background: #2b1f1c; border-color: #4a2e29; }
body[data-theme="dark"] .rebirth-copy b { color: #e0a196; }
body[data-theme="dark"] .rebirth-copy span { color: #b98a80; }
body[data-theme="dark"] .btn {
  background: var(--panel);
  border-color: var(--line-strong);
  color: var(--text);
}
body[data-theme="dark"] .btn.primary {
  background: #f2eee6;
  border-color: #f2eee6;
  color: #1f1e1d;
}
body[data-theme="dark"] .btn.primary:hover {
  background: #fff;
  border-color: #fff;
  color: #1f1e1d;
}
body[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #4a453d; }
body[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #5a544a; }
body[data-theme="dark"] .send:disabled { background: #4a453d; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: 70px;
  transform: translateX(-50%);
  background: #1f1e1d;
  color: #fff;
  font-size: 12px;
  padding: 8px 15px;
  border-radius: 999px;
  z-index: 60;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  animation: toastIn 0.2s ease both;
}

/* ---------- animations ---------- */

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes caret {
  50% { opacity: 0; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes stampIn {
  from { opacity: 0; transform: rotate(-18deg) scale(1.7); }
  to { opacity: 0.88; transform: rotate(-8deg) scale(1); }
}
@keyframes riceBump {
  50% { transform: scale(1.08) rotate(-2deg); }
}
@keyframes gainFloat {
  from { opacity: 0; transform: translate(-50%, 4px) scale(0.9); }
  30% { opacity: 1; }
  to { opacity: 0; transform: translate(-50%, -34px) scale(1.05); }
}

/* ---------- responsive ---------- */

@media (max-width: 700px) {
  .topbar { height: 52px; padding: 0 14px; }
  .brand b { font-size: 18px; }
  .badge { display: none; }
  .usage { display: none; }
  .chat { height: calc(100dvh - 52px); }
  .messages { padding: 20px 14px 12px; }
  .empty { padding: 4vh 0 6vh; }
  .empty-mark { font-size: 34px; margin-bottom: 14px; }
  .empty p { margin-bottom: 22px; }
  .chips { grid-template-columns: 1fr 1fr; gap: 8px; }
  .chips button { padding: 9px 11px; font-size: 12px; }
  .msg { margin-bottom: 22px; }
  .msg.user .bubble { max-width: 88%; font-size: 14.5px; }
  .msg.assistant .content { font-size: 14.5px; }
  .msg.assistant .avatar { width: 22px; height: 22px; font-size: 20px; }
  .composer-wrap { padding: 8px 12px 10px; }
  .composer { padding: 8px 8px 8px 13px; border-radius: 16px; }
  .footnote { font-size: 9px; padding: 0 2px; }
  .toast { top: 62px; }
}

@media (max-width: 700px) {
  .rules-btn { padding: 5px 8px; font-size: 11px; }
  #noticeBtn { display: none; }
  .rice-btn { padding: 5px 7px; }
  .wallet-card { flex-direction: column; align-items: stretch; }
  .rice-eat { width: 100%; }
  .shop-item { gap: 9px; }
  .region-note { margin-top: 18px; font-size: 9px; }
  .ban-bar { flex-direction: column; align-items: stretch; gap: 9px; }
  .ban-bar-actions { justify-content: flex-end; }
  .login-item { grid-template-columns: minmax(0, 1fr) auto; gap: 3px 8px; }
  .login-time { grid-column: 1 / -1; }
  .device-row code { max-width: 62%; font-size: 9.5px; }
  .env-btn { font-size: 8.5px; padding: 3px 6px; }
  .env-grid { grid-template-columns: 1fr; gap: 8px; }
  .modal { padding: 12px; }
  .sheet {
    padding: 22px 19px 18px;
    border-radius: 14px;
    max-height: 90dvh;
  }
  .sheet h2 { font-size: 22px; padding-right: 72px; }
  .stamp {
    top: 15px;
    right: 15px;
    font-size: 10px;
    padding: 4px 7px;
  }
  .stamp span { font-size: 8px; }
  .ban-grid { grid-template-columns: 1fr; gap: 4px; }
  .modal-actions { justify-content: stretch; }
  .modal-actions .btn { flex: 1; }
  .ban-stats { flex-direction: column; gap: 2px; }
  .rules p { font-size: 12.5px; }
  .doc-intro { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .messages { scroll-behavior: auto; }
}
