:root {
  --paper: #F2EFE9;
  --page: #FAF8F4;
  --card-inner: #EFE9DE;
  --ink: #1C1917;
  --ink-secondary: #44403C;
  --muted: #78716C;
  --line: #D8D2C5;
  --line-light: #E8E3DA;
  --accent: #A83A20;
  --accent-light: #FBEBE8;
  --accent-ink: #7C2712;
  --success: #1E6B40;
  --success-light: #EAF4EE;
  --shadow-sm: 0 2px 8px rgba(28, 25, 23, 0.04);
  --shadow-md: 0 12px 32px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 20px 48px rgba(28, 25, 23, 0.12);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

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

[hidden] {
  display: none !important;
}

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: manipulation;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
}

/* iOS/PWA zooms the page when a focused field is under 16px. */
input, textarea, select {
  font-size: 16px;
}

input, textarea {
  touch-action: auto;
  -webkit-user-select: text;
  user-select: text;
}

button {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:active:not(:disabled):not(.is-busy),
a.btn:active,
.tab-item:active,
.suggestion-chip:active,
button.is-pressed:not(:disabled),
a.btn.is-pressed,
.tab-item.is-pressed,
.suggestion-chip.is-pressed {
  transform: scale(0.96);
}

button.is-busy,
button:disabled {
  pointer-events: none;
}

textarea {
  resize: none;
}

/* 布局主容器 */
#app {
  max-width: min(44rem, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(62px + var(--safe-t)) 18px calc(76px + var(--safe-b));
  overflow-x: hidden;
}

/* 顶部 Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.header-inner {
  max-width: min(44rem, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(12px + var(--safe-t)) 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.brand-logo {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin-top: 1px;
}

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

.account-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  background: var(--page);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.account-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.account-btn span {
  white-space: nowrap;
}

.account-btn.signed-in {
  color: var(--muted);
  background: var(--card-inner);
  border-color: var(--line);
  font-weight: 600;
}

.account-credits-num {
  color: var(--accent-ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.header-new-round-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--card-inner);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.header-new-round-btn:hover {
  border-color: var(--ink);
  background: var(--page);
}

.header-new-round-btn svg {
  flex-shrink: 0;
}

.credits-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 34px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--card-inner);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.credits-btn span:first-child {
  color: var(--accent-ink);
}

.account-credits {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-ink);
}

.ledger-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(36vh, 280px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ledger-empty {
  font-size: 12px;
  color: var(--muted);
}

.ledger-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--card-inner);
}

.ledger-item-meta {
  min-width: 0;
}

.ledger-item-reason {
  font-size: 13px;
  font-weight: 600;
}

.ledger-item-time {
  font-size: 11px;
  color: var(--muted);
}

.ledger-item-delta {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ledger-item-delta.spend {
  color: var(--accent-ink);
}

.ledger-item-delta.gain {
  color: var(--success);
}

.account-choice,
.account-subpanel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.account-choice .btn {
  flex: 1;
  min-width: 0;
}

.account-subpanel {
  flex-direction: column;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--card-inner);
}

.otp-row {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.otp-row input {
  flex: 1;
  min-width: 0;
}

.otp-row .btn {
  flex-shrink: 0;
}

/* 新版本提示 */
.update-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.update-btn.visible {
  animation: updatePulse 1.6s ease-in-out 3;
}

.update-btn:hover {
  filter: brightness(1.08);
}

.update-btn.loading {
  opacity: 0.65;
  pointer-events: none;
}

.update-btn.loading svg {
  animation: spin 0.9s linear infinite;
}

@keyframes updatePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 58, 32, 0.45); }
  50% { box-shadow: 0 0 0 5px rgba(168, 58, 32, 0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 400px) {
  .update-btn span {
    display: none;
  }
  .update-btn {
    width: 34px;
    padding: 0;
  }
}

.icon-action-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  color: var(--ink-secondary);
  background: var(--page);
  border: 1px solid var(--line);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.icon-action-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge.badge-dot {
  min-width: 8px;
  width: 8px;
  height: 8px;
  padding: 0;
  top: -2px;
  right: -2px;
  background: var(--accent);
  border: 1.5px solid var(--paper);
}

.badge.badge-dot.pulsing {
  animation: dotPulse 1.8s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.85; }
}

/* 主工作区与 Tab 面板 */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.2s ease-out;
}

.tab-panel.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 核心卡片系统 */
.card {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.practice-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-lead {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.step-num {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  background: var(--card-inner);
  padding: 2px 6px;
  border-radius: 4px;
}

.step-num.step-draft {
  color: var(--accent);
  background: var(--accent-light);
}

.step-desc {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  flex: 1;
  margin-left: 8px;
}

.practice-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.practice-divider {
  height: 1px;
  background: var(--line-light);
  margin: 4px 0;
}

/* 步骤二引导与渐进展开 */
.draft-cue-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  background: rgba(239, 233, 222, 0.5);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  margin: 2px 0;
}

.draft-cue-bar:hover {
  background: rgba(239, 233, 222, 0.9);
  border-color: var(--ink);
  color: var(--ink);
}

.draft-cue-bar.hidden {
  display: none !important;
}

.draft-cue-bar .step-num {
  font-size: 11.5px;
}

.draft-cue-text {
  flex: 1;
  text-align: left;
  margin-left: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
}

.draft-cue-icon {
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.step-draft-wrap {
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.22s ease, margin 0.3s ease;
  max-height: 400px;
  opacity: 1;
}

.step-draft-wrap.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.draft-block {
  background: rgba(239, 233, 222, 0.45);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 2px 0;
  transition: all 0.2s ease;
}

.draft-block:focus-within {
  background: var(--page);
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}

/* 通用胶囊按钮体系 (Pill Button System) */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--card-inner);
  transition: all 0.15s ease;
  cursor: pointer;
  user-select: none;
  line-height: 1.2;
}

.pill-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
  background: #fff;
}

.pill-btn svg {
  flex-shrink: 0;
}

.clear-pill-btn {
  font-size: 11.5px;
  visibility: hidden;
  pointer-events: none;
}

.clear-pill-btn.is-visible {
  visibility: visible;
  pointer-events: auto;
}

.clear-pill-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.input-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 主输入区域 */
.input-wrap {
  position: relative;
}

.main-input {
  width: 100%;
  border: 0;
  font-size: 16px;
  color: var(--ink);
  line-height: 1.6;
  padding: 4px 0;
  background: transparent;
  outline: none;
}

.main-input-intent {
  min-height: 140px;
  max-height: 360px;
  resize: vertical;
  overflow-y: auto;
}

.main-input::placeholder {
  color: #9C9589;
  font-size: 15px;
}

.card-foot-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex-wrap: wrap;
}

.contrast-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}

.contrast-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.contrast-switch-ui {
  position: relative;
  width: 36px;
  height: 22px;
  border-radius: 999px;
  background: #D8D2C8;
  border: 1px solid var(--line);
  transition: background 0.18s ease, border-color 0.18s ease;
  flex-shrink: 0;
}

.contrast-switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.contrast-switch input:checked + .contrast-switch-ui {
  background: var(--ink);
  border-color: var(--ink);
}

.contrast-switch input:checked + .contrast-switch-ui::after {
  transform: translateX(14px);
}

.contrast-switch input:checked ~ .contrast-switch-label {
  color: var(--ink);
}

.contrast-switch input:focus-visible + .contrast-switch-ui {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 渐进式展开区域 */
.options-drawer {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0 6px;
  border-top: 1px dashed var(--line);
  animation: fadeIn 0.18s ease;
}

.options-drawer.open {
  display: flex;
}

.opt-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.opt-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.opt-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--card-inner);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}

.opt-input:focus {
  border-color: var(--ink);
  background: #fff;
}

.opt-input::placeholder {
  color: #A49D92;
  font-size: 13px;
}

/* 操作底部栏 */
.card-foot {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
}

.text-toggle-btn {
  font-size: 11.5px;
  color: var(--muted);
  padding: 6px 0;
  transition: color 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.text-toggle-btn:hover {
  color: var(--ink);
}

.btn-clear {
  font-size: 13px;
  color: var(--muted);
  padding: 6px 8px;
}

.btn-clear:hover {
  color: var(--accent);
}

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

a.btn {
  color: inherit;
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn > span {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ink);
  color: var(--page);
}

.btn-primary:hover {
  background: #000;
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.shortcut-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  height: 18px;
  padding: 0 5px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  font-family: var(--font-sans);
  letter-spacing: 0.04em;
  color: inherit;
  box-sizing: border-box;
}

.status-tip {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.status-tip.ok { color: var(--success); }
.status-tip.bad { color: var(--accent); }

/* 追问多轮连贯流 (Thread & Follow-up Stream) */
.result-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: slideUp 0.22s ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.thread-stream {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.thread-turn {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.turn-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 0 4px;
}

.turn-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.turn-badge.is-followup {
  color: var(--accent-ink);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 4px;
}

.turn-badge.is-reverse {
  color: #1F4D3C;
  background: #E4F1EC;
  padding: 2px 8px;
  border-radius: 4px;
}

.turn-prompt-preview {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  white-space: normal;
  overflow: visible;
  max-width: 100%;
  line-height: 1.45;
  word-break: break-word;
}

.thread-connector {
  display: flex;
  align-items: center;
  margin: -4px 0 -4px 14px;
}

.connector-line {
  width: 2px;
  height: 14px;
  background: var(--line);
  border-radius: 1px;
}

/* 追问输入框卡片 */
/* 流式输出中的实时卡片 */
.streaming-card {
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: slideUp 0.2s ease-out;
}

.streaming-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.streaming-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.streaming-text {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.streaming-card.has-text .streaming-head {
  display: none;
}

.streaming-card.has-text .streaming-text::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: caretBlink 1s step-end infinite;
}

@keyframes caretBlink {
  50% { opacity: 0; }
}

.followup-card {
  position: relative;
  overflow: hidden;
  background: var(--page);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
  transition: all 0.2s ease;
}

.followup-card.is-locked {
  border-style: solid;
  border-color: var(--line);
}

/* Solid mask: frosted overlay often fails to paint on desktop Chrome. */
.followup-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--page);
  cursor: progress;
  animation: fadeIn 0.15s ease-out;
  pointer-events: auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.followup-overlay-inner {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 100%;
  min-width: 0;
}

.followup-overlay-quote {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.followup-overlay-quote-mark {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent-ink);
  background: var(--accent-light);
  border-radius: 4px;
  padding: 2px 6px;
}

.followup-overlay-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.followup-overlay-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: thinkingBounce 1.2s ease-in-out infinite;
}

.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes thinkingBounce {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.followup-card:focus-within {
  border-style: solid;
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* 快捷追问建议选项 (Follow-up Suggestion Chips) */
.followup-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 2px 0 2px;
}

.suggestions-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suggestion-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-secondary);
  background: var(--card-inner);
  border: 1px solid var(--line);
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  text-align: left;
  line-height: 1.3;
}

.suggestion-chip:hover {
  background: #fff;
  color: var(--ink);
  border-color: var(--ink);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.suggestion-chip:active {
  transform: scale(0.98);
}

.suggestion-chip.is-selected {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.followup-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.followup-icon {
  color: var(--muted);
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 7px;
}

.followup-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  outline: none;
  padding: 4px 0;
  resize: none;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.45;
  field-sizing: content;
  -webkit-user-select: text;
  user-select: text;
}

.followup-input::placeholder {
  color: #9C9589;
  font-size: 13px;
  line-height: 1.45;
}

.btn-followup-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px;
  background: var(--ink);
  color: var(--page);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 2px;
  transition: all 0.15s ease;
}

.btn-followup-submit > span {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.btn-followup-submit:hover {
  background: #000;
}

.btn-followup-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.followup-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 2px;
}

.followup-hint {
  font-size: 11.5px;
  color: var(--muted);
}

.followup-status-tip {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.followup-status-tip.ok { color: var(--success); }
.followup-status-tip.bad { color: var(--accent); }

/* 独立底部重置一轮按钮 */
.thread-footer-bar {
  display: flex;
  justify-content: center;
  padding: 10px 0 6px;
}

.btn-thread-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--card-inner);
  border: 1px solid var(--line);
  padding: 7px 16px;
  border-radius: 999px;
  transition: all 0.15s ease;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn-thread-reset:hover {
  color: var(--ink);
  background: #fff;
  border-color: var(--ink);
  transform: translateY(-1px);
}

.result-card {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.scenario-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

.result-interp {
  font-size: 13px;
  color: var(--muted);
  background: var(--card-inner);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  line-height: 1.45;
}

.result-interp strong {
  color: var(--ink);
}

/* 追问解答 / 教练笔记卡片 (Coach Explanation / Q&A Box) */
.result-explanation {
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.explanation-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent-ink);
  letter-spacing: 0.04em;
}

.explanation-content {
  font-size: 13.5px;
  color: var(--ink);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.explanation-content strong {
  color: var(--ink);
  font-weight: 700;
}

.natural-output-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.natural-output-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.natural-sentence {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 目标语言精读卡片专属样式 */
.reading-target-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.reading-target-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reading-target-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.reading-target-text {
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: pre-wrap;
  word-break: break-word;
}

.reading-meaning-wrap {
  background: transparent;
  border-left: 3px solid #1F4D3C;
  padding-left: 12px;
}

.reading-meaning-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reading-meaning-sentence {
  font-family: var(--font-sans);
  font-size: 14.5px !important;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.65;
  letter-spacing: normal;
}

.interp-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.output-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  background: var(--card-inner);
  border: 1px solid var(--line);
  padding: 3px 10px;
  border-radius: 999px;
  transition: all 0.15s ease;
  user-select: none;
}

.tool-btn:hover {
  background: #fff;
  color: var(--ink);
  border-color: var(--ink);
}

.tool-btn svg {
  flex-shrink: 0;
}

/* 对照模块 (你写的 vs 地道说法) */
.contrast-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  background: var(--card-inner);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
}

@media (min-width: 640px) {
  .contrast-box {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

.contrast-col h4 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
}

.contrast-col p {
  font-size: 14px;
  color: var(--ink-secondary);
}

.contrast-col.target p {
  color: var(--ink);
  font-weight: 600;
  font-family: var(--font-sans);
  font-size: 14.5px;
}

/* 盲点点评 */
.missed-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  list-style: none;
}

.missed-item {
  font-size: 13px;
  color: var(--ink-secondary);
  padding-left: 10px;
  border-left: 2px solid var(--accent);
  line-height: 1.5;
}

/* 词块列表 */
.chunks-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--line-light);
  padding-top: 10px;
}

.chunks-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.chunk-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--card-inner);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.chunk-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chunk-phrase {
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}

.chunk-context {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.btn-speak-chunk,
.btn-practice-chunk {
  font-size: 11px;
  padding: 2px 8px;
  flex-shrink: 0;
}

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

.chunk-practice-scrim {
  align-items: flex-end;
  justify-content: center;
  padding: max(8px, env(safe-area-inset-top, 0px)) 0 0;
}

.chunk-practice-sheet {
  width: min(44rem, 100%);
  height: min(92dvh, 960px);
  max-height: 92dvh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: none;
  padding: 10px 18px calc(14px + var(--safe-b));
  gap: 12px;
  animation: slideUp 0.22s ease-out;
}

.chunk-practice-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  margin: 2px auto 4px;
  flex-shrink: 0;
}

.chunk-practice-phrase {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  padding: 8px 12px;
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.chunk-practice-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-light);
  border-radius: var(--radius-md);
  background: var(--page);
}

.chunk-practice-questions {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.chunk-practice-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-radius: inherit;
  background: color-mix(in srgb, var(--page) 82%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.chunk-practice-overlay[hidden] {
  display: none;
}

.chunk-practice-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-radius: var(--radius-md);
  background: var(--card-inner);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.chunk-practice-foot {
  border-top: 1px solid var(--line-light);
  padding-top: 10px;
}

.chunk-practice-item {
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chunk-practice-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chunk-practice-num {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.chunk-practice-scenario {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink, var(--ink));
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
  padding: 2px 8px;
}

.chunk-practice-prompt {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
}

.chunk-practice-item textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  padding: 8px 10px;
  font-family: var(--font-sans);
}

.chunk-practice-item textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.chunk-practice-item textarea:disabled {
  opacity: 0.85;
}

.chunk-practice-feedback {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--line-light);
}

.chunk-practice-score {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.chunk-practice-score-note,
.chunk-practice-ref {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.chunk-practice-ref strong {
  color: var(--ink);
  font-weight: 600;
}

.chunk-practice-actions {
  flex-wrap: wrap;
}

.hist-chunk-tag.btn-practice-chunk {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--page);
}

.hist-chunk-tag.btn-practice-chunk:hover {
  border-color: var(--ink);
  color: var(--ink);
}

/* GDC 多语种卡片结构（顺序平铺） */
.gdc-result-card {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.gdc-boxes-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gdc-code-box,
.custom-code-box {
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
}

.gdc-code-head,
.custom-code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #E5DFD4;
  border-bottom: 1px solid var(--line);
  min-height: 36px;
  box-sizing: border-box;
}

.gdc-lang-title,
.custom-code-lang {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.copy-btn-mini {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-secondary);
  background: var(--page);
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 999px;
  transition: all 0.15s ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.copy-btn-mini:hover {
  background: #fff;
  color: var(--ink);
  border-color: var(--ink);
}

.gdc-code-content,
.custom-code-content {
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  max-height: 480px;
  overflow-y: auto;
}

/* 底部 3-Tab Bar */
.app-tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(242, 239, 233, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  padding: 6px 12px calc(8px + var(--safe-b));
  z-index: 10;
}

.tab-item {
  flex: 1;
  max-width: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: all 0.15s ease;
}

.tab-item.active {
  color: var(--ink);
}

.tab-icon {
  stroke-width: 1.8;
  transition: transform 0.15s ease;
}

.tab-item.active .tab-icon {
  stroke-width: 2.2;
  transform: scale(1.05);
}

.tab-text {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* 抽屉 & 模态窗体系 */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
  padding: 16px 16px calc(16px + var(--safe-b));
  animation: fadeIn 0.15s ease;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y;
  max-width: 100%;
}

.drawer-scrim[hidden] {
  display: none;
}

.drawer-panel {
  width: min(44rem, 100%);
  max-width: 100%;
  min-width: 0;
  height: min(88dvh, 720px);
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease-out;
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.drawer-title-wrap h2 {
  font-size: 18px;
  font-weight: 700;
}

.drawer-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.btn-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--muted);
  border-radius: 999px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-close:hover {
  background: var(--card-inner);
  color: var(--ink);
}

.drawer-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  flex-shrink: 0;
}

.search-icon {
  color: var(--muted);
  flex-shrink: 0;
}

.drawer-search-bar input {
  width: 100%;
  min-width: 0;
  outline: none;
  font-size: 16px;
  color: var(--ink);
}

.drawer-search-bar input::placeholder {
  color: #9C9589;
}

/* 历史列表 */
.history-list-view {
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 2px 12px;
  min-height: 0;
}

.history-view-tabs {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  padding: 0 2px;
}

.history-view-tab {
  flex: 1;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-inner);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.history-view-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.history-card {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
  overflow: hidden;
  flex-shrink: 0;
}

.practice-hist-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.practice-hist-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 0;
}

.practice-hist-chunk {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}

.practice-hist-count {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.practice-hist-card .hist-en {
  font-size: 13.5px;
  font-weight: 600;
}

.practice-hist-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.practice-hist-score {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-light);
  border-radius: 999px;
  padding: 2px 8px;
}

.practice-hist-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 12px;
}

.practice-hist-detail-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.practice-hist-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--card-inner);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
}

.practice-hist-detail-item {
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.practice-hist-detail-prompt {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
}

.practice-hist-detail-answer,
.practice-hist-detail-ref,
.practice-hist-detail-feedback {
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  word-break: break-word;
}

.practice-hist-detail-answer strong,
.practice-hist-detail-ref strong {
  color: var(--ink);
  font-weight: 600;
}

.history-card:hover {
  background: #fff;
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.history-card:active {
  transform: scale(0.99);
}

.hist-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.hist-tag-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.hist-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hist-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hist-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.hist-delete-btn:hover {
  background: #fff1f0;
  color: #cf1322;
}

.hist-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex-shrink: 0;
}

.hist-en {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.hist-cn {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.hist-chunks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

.hist-chunk-tag {
  font-size: 11px;
  color: var(--ink-secondary);
  background: var(--page);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.35;
  word-break: break-word;
}

.empty-state {
  margin: auto 0;
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.empty-state-title {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

/* 设置模态窗 */
.settings-modal {
  width: min(40rem, 100%);
  max-width: 100%;
  min-width: 0;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-lg);
  max-height: min(90dvh, 640px);
  overflow: hidden;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-head h2 {
  font-size: 17px;
  font-weight: 700;
}

.modal-intro {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  flex-shrink: 0;
}

.settings-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.settings-section-head {
  display: flex;
  align-items: center;
  padding-top: 4px;
  margin-bottom: -4px;
}

.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
}

.settings-row-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 0;
}

.user-tab-box {
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.user-tab-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.user-tab-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-tab-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--page);
  border: 1px solid var(--line);
  color: var(--accent-ink);
  flex-shrink: 0;
}

.user-tab-info h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

.user-tab-info p {
  font-size: 11.5px;
  color: var(--muted);
}

.user-tab-restore-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}

.user-tab-restore-link:hover {
  color: var(--ink);
}

/* 自定义助手独立配置模态窗体系 */
.custom-tab-modal {
  width: min(44rem, 100%);
  max-height: min(92dvh, 720px);
}

.custom-tab-form-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 10px;
}

.field-composite-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.field-composite-row select {
  flex: 1;
  min-width: 0;
  height: 42px;
  box-sizing: border-box;
}

.btn-auto-match {
  flex-shrink: 0;
  height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-inner);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
  transition: all 0.15s ease;
}

.btn-auto-match:hover {
  background: #fff;
  border-color: var(--ink);
}

.modal-field-checkbox {
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 2px;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--ink);
  cursor: pointer;
}

.checkbox-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.checkbox-text strong {
  font-size: 13px;
  color: var(--ink);
}

.checkbox-text span {
  font-size: 11.5px;
  color: var(--muted);
}

@media (max-width: 480px) {
  .settings-row-pair {
    grid-template-columns: 1fr;
  }
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.btn-fetch-models {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-light);
  border: 1px solid #EACEC8;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-fetch-models:hover {
  background: var(--accent);
  color: #fff;
}

.btn-fetch-models.loading {
  opacity: 0.6;
  pointer-events: none;
}

.btn-fetch-models.loading svg {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.modal-field input,
.modal-field select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--card-inner);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.modal-field select {
  overflow: hidden;
  text-overflow: ellipsis;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-color: var(--card-inner);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378716C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.modal-field input:focus,
.modal-field select:focus {
  border-color: var(--ink);
  background-color: #fff;
}

.modal-foot {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
  background: var(--page);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.settings-build {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}

.settings-version {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  opacity: 0.72;
}

.settings-update-btn {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 2px 0;
  opacity: 0.8;
}

.settings-update-btn:hover,
.settings-update-btn:active,
.settings-update-btn.is-pressed {
  color: var(--ink);
  opacity: 1;
}

.settings-update-btn.has-update {
  color: var(--accent-ink);
  opacity: 1;
}

.settings-update-btn.is-busy,
.settings-update-btn.loading {
  opacity: 0.5;
  pointer-events: none;
}

.modal-status-slot {
  height: 3.4em;
  overflow-x: hidden;
  overflow-y: auto;
}

.modal-status-slot .status-tip {
  margin-top: 0;
}

#auth-form-view,
#account-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  padding: 3px;
  background: var(--card-inner);
  border-radius: var(--radius-sm);
}

.auth-tab {
  flex: 1;
  height: 32px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.auth-tab.active {
  background: var(--page);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.auth-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

.account-email {
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
}

/* Toast 优雅轻量顶部通知 */
.toast {
  position: fixed;
  top: calc(16px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 26, 23, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #FAF8F5;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  z-index: 100;
  pointer-events: none;
  white-space: nowrap;
  max-width: min(90vw, 360px);
  overflow: hidden;
  text-overflow: ellipsis;
  animation: toastSlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastSlideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
}

/* 移动端与小屏专属排版优化 */
@media (max-width: 640px), (hover: none) and (pointer: coarse) {
  #app {
    padding: calc(56px + var(--safe-t)) 14px calc(72px + var(--safe-b));
  }
  .header-inner {
    padding: calc(10px + var(--safe-t)) 14px 10px;
  }
  .brand-sub {
    display: none;
  }
  .brand-title {
    font-size: 16px;
  }
  .header-actions {
    gap: 6px;
  }
  .account-btn {
    padding: 0 8px;
    height: 32px;
    font-size: 11.5px;
  }
  .header-new-round-btn {
    height: 32px;
    padding: 0 8px;
    font-size: 11.5px;
    gap: 3px;
  }
  .credits-btn {
    height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }
  .icon-action-btn {
    width: 32px;
    height: 32px;
  }
  .card {
    padding: 14px 14px;
  }
  /* 移动触控端隐藏键盘快捷键徽章，彻底避免宽度不够把按钮文字挤换行 */
  .shortcut-kbd {
    display: none !important;
  }
  .btn {
    height: 36px;
    padding: 0 13px;
    font-size: 13px;
  }
  .card-foot .btn-primary {
    height: 44px;
    min-height: 44px;
    padding: 0 16px;
  }
  .card-lead {
    gap: 6px;
  }
  .step-desc {
    font-size: 12.5px;
  }
  .main-input {
    font-size: 16px;
  }
  .main-input::placeholder {
    font-size: 16px;
  }
  .custom-tab-modal {
    height: 94dvh;
    max-height: 94dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 16px 16px 12px;
  }
  .custom-tab-form-body {
    padding-bottom: 24px;
  }
}

/* 桌面端优化 */
@media (min-width: 680px) {
  body {
    font-size: 16px;
  }
  .drawer-scrim {
    align-items: center;
  }
  .drawer-scrim.chunk-practice-scrim {
    align-items: flex-end;
  }
  .drawer-panel {
    border-radius: var(--radius-lg);
  }
  .drawer-panel.chunk-practice-sheet {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: min(40rem, 100%);
  }
  .natural-sentence {
    font-size: 16.5px;
  }
  .reading-target-text,
  .reading-meaning-sentence {
    font-size: 15px !important;
  }
}

/* 管理员对账页 */
.admin-app {
  max-width: 72rem;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-t)) 20px calc(32px + var(--safe-b));
}

.admin-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.admin-head h1 {
  font-size: 22px;
  letter-spacing: -0.03em;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 16px;
}

@media (max-width: 860px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.admin-card {
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.admin-card h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

.admin-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-toolbar input {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-inner);
}

.admin-table-wrap {
  overflow: auto;
  max-height: min(62vh, 560px);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line-light);
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--page);
}

.admin-table tbody tr {
  cursor: pointer;
}

.admin-table tbody tr:hover,
.admin-table tbody tr.active {
  background: var(--accent-light);
}

.admin-grant {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.admin-grant input,
.admin-grant select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card-inner);
}

.admin-grant input {
  width: 120px;
}

.admin-muted {
  font-size: 12px;
  color: var(--muted);
}

.models-meta {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  min-height: 1.45em;
}

.models-meta.is-busy {
  color: var(--ink);
  font-weight: 600;
}

.models-meta.is-ok {
  color: var(--success);
  font-weight: 600;
}

.models-meta.is-bad {
  color: var(--accent);
  font-weight: 600;
}

#refresh-models.is-busy {
  opacity: 0.85;
  cursor: wait;
}

.admin-muted code {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--page);
}

.admin-form-box {
  background: var(--card-inner);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 12px 0;
  animation: fadeIn 0.15s ease-out;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.btn-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--page);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-xs:hover {
  border-color: var(--ink);
  background: #fff;
}
