/* ==========================================================================
   《有教无类》Apple 极简视觉系统（对标 Apple HIG / Apple Books / Apple Health）
   ========================================================================== */

:root {
  /* 色彩 Tokens */
  --bg-page: #F5F5F7;
  --bg-surface: #FFFFFF;
  --bg-subtle: #EFEFF4;
  --bg-glass: rgba(245, 245, 247, 0.82);
  --border-subtle: #E5E5EA;
  --border-strong: #D1D1D6;

  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #86868B;

  --accent-primary: #0071E3;
  --accent-hover: #0077ED;
  --accent-soft: rgba(0, 113, 227, 0.09);

  --state-correct: #28A745;
  --state-correct-bright: #34C759;
  --state-correct-bg: rgba(52, 199, 89, 0.11);
  --state-correct-border: rgba(52, 199, 89, 0.42);

  --state-wrong: #D93025;
  --state-wrong-bright: #FF3B30;
  --state-wrong-bg: rgba(255, 59, 48, 0.10);
  --state-wrong-border: rgba(255, 59, 48, 0.42);

  /* 圆角与阴影 */
  --radius-card: 18px;
  --radius-control: 13px;
  --radius-pill: 999px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.035);
  --shadow-thumb: 0 1px 4px rgba(0, 0, 0, 0.10), 0 0.5px 1px rgba(0, 0, 0, 0.06);
  --shadow-float: 0 10px 30px rgba(0, 0, 0, 0.12);

  /* 排版与布局 */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  --content-max-width: 680px;
  --ease-apple: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* 现代 CSS：允许 block-size 向 auto 固有尺寸平滑插值 */
  interpolate-size: allow-keywords;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg-page);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2.5px solid var(--accent-primary);
  outline-offset: 2px;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* 辅助阅读隐藏类（保留在无障碍树中） */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* ==========================================================================
   视图与容器布局
   ========================================================================== */

.view[hidden] {
  display: none !important;
}

.view {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page-container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 16px 16px 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.page-container--with-dock {
  padding-bottom: calc(128px + env(safe-area-inset-bottom, 0px));
}

/* ==========================================================================
   顶部毛玻璃导航栏
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-glass);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(229, 229, 234, 0.75);
}

.topbar-inner {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  min-height: 58px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.brand-subtitle {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.topbar-center-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
}

.count-muted {
  font-weight: 500;
  color: var(--text-tertiary);
  font-size: 14px;
}

.topbar-spacer {
  min-width: 56px;
}

.progress-track {
  width: 100%;
  height: 2.5px;
  background: rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-primary);
  border-radius: 0 2px 2px 0;
  transition: width 0.3s var(--ease-apple);
}

/* ==========================================================================
   卡片与通用控件
   ========================================================================== */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.section-card {
  padding: 18px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-caption {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: right;
  flex-shrink: 1;
}

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0 14px;
}

.sub-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.sub-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.sub-hint {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* 演示模式提示条 */
.demo-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(142, 142, 147, 0.12);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.4;
}

.demo-banner[hidden] {
  display: none;
}

.demo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-primary);
  flex-shrink: 0;
}

.demo-dot--green {
  background: var(--state-correct-bright);
}

.home-footer {
  padding: 4px 8px 8px;
  text-align: center;
}

.home-footer p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-tertiary);
}

/* 按钮体系 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s var(--ease-apple), transform 0.14s var(--ease-apple), opacity 0.2s var(--ease-apple);
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

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

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent-primary);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: #F9F9FB;
}

.btn-danger {
  background: var(--state-wrong-bright);
  color: #FFFFFF;
}

.btn-danger:hover:not(:disabled) {
  background: #E63228;
}

.btn-soft-red {
  background: var(--state-wrong-bg);
  color: var(--state-wrong);
  border-color: rgba(255, 59, 48, 0.22);
}

.btn-soft-red:hover:not(:disabled) {
  background: rgba(255, 59, 48, 0.16);
}

.btn-subtle-green {
  min-height: 36px;
  padding: 0 14px;
  font-size: 14px;
  border-radius: var(--radius-pill);
  background: var(--state-correct-bright);
  color: #FFFFFF;
}

.btn-subtle-green:hover:not(:disabled) {
  background: #2DB84E;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--accent-primary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.text-btn--sm {
  font-size: 13px;
  justify-content: flex-end;
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* 顶部错题本入口按钮与角标 */
.icon-pill-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  transition: background-color 0.2s var(--ease-apple), transform 0.14s var(--ease-apple);
}

.icon-pill-btn:hover {
  background: #FAFAFC;
}

.icon-pill-btn:active {
  transform: scale(0.97);
}

.badge-dot {
  position: absolute;
  top: 2px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--state-wrong-bright);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg-page);
}

.badge-dot[hidden] {
  display: none;
}

/* ==========================================================================
   页面一：模块选择器、考点标签、自由搜索与分段控制器
   ========================================================================== */

.module-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 460px) {
  .module-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.module-btn {
  min-height: 44px;
  padding: 8px 6px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: #FAFAFC;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-apple);
}

.module-btn:hover {
  border-color: var(--border-strong);
  background: #F2F2F7;
}

.module-btn[aria-selected="true"] {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(0, 113, 227, 0.24);
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.topic-chip {
  min-height: 40px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s var(--ease-apple);
}

.topic-chip:hover {
  background: #F6F6F9;
}

.topic-chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  font-weight: 600;
}

/* 自由搜索输入与交互后校验（:user-invalid） */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-hint {
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.45;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 4px;
}

.search-icon {
  position: absolute;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 42px 10px 40px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: #F9F9FB;
  font-size: 15px;
  color: var(--text-primary);
  transition: border-color 0.2s var(--ease-apple), background-color 0.2s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}

.search-input::placeholder {
  color: #9A9AA0;
}

.search-input:focus {
  outline: none;
  background: var(--bg-surface);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3.5px rgba(0, 113, 227, 0.14);
}

/* 隐藏 WebKit 默认搜索清除按钮，使用自定义无障碍清除按钮 */
.search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* 仅在用户交互后显示错误样式，避免输入过程过早泛红 */
.search-input:is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--state-wrong-bright);
  background: var(--state-wrong-bg);
}

.field-error {
  display: none;
  margin-top: 2px;
  font-size: 13px;
  color: var(--state-wrong);
  line-height: 1.4;
}

.search-input-wrap:has(.search-input:is(:user-invalid, .user-invalid-fallback)) + .field-error {
  display: block;
}

/* 不支持 :has() 的极旧环境通过类切换兜底 */
.field.has-error .field-error {
  display: block;
}

.clear-input-btn {
  position: absolute;
  right: 4px;
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
}

.clear-input-btn[hidden] {
  display: none;
}

.clear-input-btn svg {
  width: 18px;
  height: 18px;
}

/* 分段控制器 Segmented Control */
.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
}

@media (max-width: 460px) {
  .config-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
}

.config-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 3px;
  border-radius: 11px;
  background: var(--bg-subtle);
  flex: 1;
  max-width: 360px;
}

@media (max-width: 460px) {
  .segmented {
    max-width: none;
  }
}

.segmented-btn {
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: 8.5px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s var(--ease-apple), color 0.2s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}

.segmented-btn[aria-checked="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-thumb);
}

/* 底部固定毛玻璃主操作栏 */
.bottom-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  background: rgba(245, 245, 247, 0.88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid rgba(229, 229, 234, 0.8);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}

.bottom-dock[hidden] {
  display: none;
}

.bottom-dock-inner {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selection-summary {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.keyboard-hint {
  display: none;
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

@media (hover: hover) and (pointer: fine) {
  .keyboard-hint {
    display: block;
  }
}

/* ==========================================================================
   生成中骨架屏与呼吸灯动效
   ========================================================================== */

.loading-status-card {
  padding: 24px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.breathing-orb {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #5AC8FA, var(--accent-primary));
  box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.35);
  animation: breathe 1.8s ease-in-out infinite;
  margin-bottom: 4px;
}

@keyframes breathe {
  0%, 100% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.32);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 0 14px rgba(0, 113, 227, 0);
  }
}

.loading-stage {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.loading-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-tertiary);
}

.skeleton-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeleton-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-option {
  padding: 18px 20px;
}

.skeleton-line {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #ECECF0 25%, #F5F5F8 50%, #ECECF0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton-pill {
  width: 112px;
  height: 22px;
  border-radius: var(--radius-pill);
}

.skeleton-w-100 { width: 100%; }
.skeleton-w-92 { width: 92%; }
.skeleton-w-85 { width: 85%; }
.skeleton-w-80 { width: 80%; }
.skeleton-w-75 { width: 75%; }
.skeleton-w-70 { width: 70%; }
.skeleton-w-68 { width: 68%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   页面二：沉浸式刷题页
   ========================================================================== */

.timer-pill {
  min-width: 56px;
  text-align: right;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.question-card {
  padding: 20px;
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.meta-pill--subtle {
  background: transparent;
  border: 1px solid var(--border-subtle);
  font-weight: 500;
  color: var(--text-tertiary);
}

.question-stem {
  margin: 0;
  font-size: 17.5px;
  font-weight: 500;
  line-height: 1.72;
  color: var(--text-primary);
  letter-spacing: 0.005em;
}

/* 四个独立选项卡片 */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-card {
  width: 100%;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 15px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s var(--ease-apple), background-color 0.2s var(--ease-apple), transform 0.14s var(--ease-apple);
}

.option-card:hover:not(:disabled) {
  border-color: #C7C7CC;
  background: #FBFBFD;
}

.option-card:active:not(:disabled) {
  transform: scale(0.992);
}

.option-card:disabled {
  cursor: default;
}

.option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background-color 0.2s var(--ease-apple), color 0.2s var(--ease-apple);
}

.option-text {
  flex: 1;
  font-size: 15.5px;
  line-height: 1.58;
  color: var(--text-primary);
  padding-top: 2px;
}

.option-status-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 判分状态 */
.option-card.is-correct {
  background: var(--state-correct-bg);
  border-color: var(--state-correct-border);
}

.option-card.is-correct .option-letter {
  background: var(--state-correct-bright);
  color: #FFFFFF;
}

.option-card.is-correct .option-status-icon {
  color: var(--state-correct);
}

.option-card.is-wrong {
  background: var(--state-wrong-bg);
  border-color: var(--state-wrong-border);
}

.option-card.is-wrong .option-letter {
  background: var(--state-wrong-bright);
  color: #FFFFFF;
}

.option-card.is-wrong .option-status-icon {
  color: var(--state-wrong);
}

.option-card.is-dimmed {
  opacity: 0.62;
}

/* 错题重刷答对移出提示条 */
.master-prompt-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--state-correct-bg);
  border: 1px solid var(--state-correct-border);
}

.master-prompt-card[hidden] {
  display: none;
}

.master-prompt-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #1A6B2F;
}

.master-check {
  font-weight: 700;
}

/* 三段式解析卡片 */
.explanation-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeSlideIn 0.28s var(--ease-apple);
}

.explanation-card[hidden] {
  display: none;
}

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

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

.explanation-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.exp-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.exp-dot--blue { background: var(--accent-primary); }
.exp-dot--green { background: var(--state-correct-bright); }
.exp-dot--red { background: var(--state-wrong-bright); }

.explanation-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.68;
  color: var(--text-primary);
}

.explanation-text--strong {
  font-weight: 600;
}

/* ==========================================================================
   AI 1 对 1 错题答疑卡片（方案 2 核心组件：按需触发，答对时收纳进原生 <details>）
   ========================================================================== */

.tutor-slot[hidden] {
  display: none;
}

.tutor-card {
  background: linear-gradient(180deg, #FBFBFF 0%, #FFFFFF 100%);
  border: 1px solid rgba(0, 113, 227, 0.20);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeSlideIn 0.26s var(--ease-apple);
}

.tutor-card--compact {
  padding: 14px 16px;
  border-radius: 14px;
  margin-top: 6px;
}

/* 原生 <details> 折叠收纳（答对时或复盘/错题本中按需展开，遵循 accordion 与 noise-reduction 规范） */
.tutor-disclosure {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.tutor-disclosure--embedded {
  border-radius: 14px;
  background: #FAFAFD;
  box-shadow: none;
  margin-top: 6px;
}

.tutor-disclosure-summary {
  list-style: none;
  padding: 13px 16px;
  min-height: 46px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-primary);
}

.tutor-disclosure-summary::-webkit-details-marker {
  display: none;
}

.tutor-disclosure-summary::before {
  content: "";
  inline-size: 15px;
  block-size: 15px;
  flex-shrink: 0;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  rotate: -90deg;
}

.tutor-disclosure[open] > .tutor-disclosure-summary::before {
  rotate: 0deg;
}

.tutor-disclosure::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}

.tutor-disclosure:not([open])::details-content {
  block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .tutor-disclosure-summary::before {
    transition: rotate 0.2s var(--ease-apple);
  }
  .tutor-disclosure::details-content {
    transition: block-size, content-visibility, display;
    transition-duration: 0.26s;
    transition-timing-function: var(--ease-apple);
    transition-behavior: allow-discrete;
  }
}

.tutor-disclosure-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
}

.tutor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.tutor-title-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.tutor-sparkle {
  width: 18px;
  height: 18px;
  color: var(--accent-primary);
  flex-shrink: 0;
}

.tutor-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.tutor-mode-badge--offline {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.tutor-subtitle {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.tutor-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tutor-chip-btn {
  min-height: 40px;
  padding: 6px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(0, 113, 227, 0.24);
  background: var(--bg-surface);
  color: var(--accent-primary);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s var(--ease-apple), border-color 0.18s var(--ease-apple), transform 0.14s var(--ease-apple);
}

.tutor-chip-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent-primary);
}

.tutor-chip-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.tutor-chip-btn--primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #FFFFFF;
}

.tutor-chip-btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.tutor-chip-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.tutor-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.tutor-input {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 8px 13px;
  border-radius: 11px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.2s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}

.tutor-input::placeholder {
  color: #9A9AA0;
}

.tutor-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
}

.tutor-submit-btn {
  min-height: 42px;
  min-width: 68px;
  padding: 0 14px;
  border-radius: 11px;
  border: 0;
  background: var(--text-primary);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.18s var(--ease-apple), transform 0.14s var(--ease-apple);
}

.tutor-submit-btn:hover:not(:disabled) {
  opacity: 0.88;
}

.tutor-submit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tutor-loading {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-page);
}

.tutor-loading[hidden] {
  display: none;
}

.tutor-loading-text {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* 原生 <progress> 语义化进度指示器 */
.tutor-progress {
  width: 100%;
  height: 4px;
  border: 0;
  border-radius: var(--radius-pill);
  overflow: hidden;
  accent-color: var(--accent-primary);
  background: rgba(0, 113, 227, 0.14);
}

.tutor-progress::-webkit-progress-bar {
  background: rgba(0, 113, 227, 0.14);
  border-radius: var(--radius-pill);
}

.tutor-progress::-webkit-progress-value {
  background: var(--accent-primary);
  border-radius: var(--radius-pill);
}

.tutor-error {
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--state-wrong-bg);
  color: var(--state-wrong);
  font-size: 13.5px;
  line-height: 1.5;
}

.tutor-error[hidden] {
  display: none;
}

.tutor-code-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-page);
  border: 1px solid var(--border-subtle);
}

.tutor-code-box[hidden] {
  display: none;
}

.tutor-code-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.tutor-reply {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 13px;
  background: #F7F9FC;
  border: 1px solid rgba(0, 113, 227, 0.12);
  animation: fadeSlideIn 0.24s var(--ease-apple);
}

.tutor-reply[hidden] {
  display: none;
}

.tutor-reply-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tutor-reply-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-primary);
}

.tutor-reply-text {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.66;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.tutor-tip-box {
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(52, 199, 89, 0.10);
  color: #165B28;
  font-size: 13.5px;
  line-height: 1.55;
  font-weight: 500;
}

.tutor-offline-notice {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-tertiary);
}

/* ==========================================================================
   页面三：练习结算页
   ========================================================================== */

.summary-hero-card {
  padding: 28px 20px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.accuracy-ring-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  margin-bottom: 14px;
}

.accuracy-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--bg-subtle);
  stroke-width: 9;
}

.ring-fill {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 9;
  stroke-linecap: round;
  stroke-dasharray: 314.16;
  stroke-dashoffset: 314.16;
  transition: stroke-dashoffset 0.7s var(--ease-apple), stroke 0.3s var(--ease-apple);
}

.accuracy-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.accuracy-number {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.accuracy-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.summary-headline {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.summary-subtitle {
  margin: 6px 0 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.stat-tile {
  padding: 12px 8px;
  border-radius: 14px;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-value--green { color: var(--state-correct); }
.stat-value--red { color: var(--state-wrong); }

.stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
}

.review-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.review-dot-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px solid transparent;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s var(--ease-apple), box-shadow 0.2s var(--ease-apple);
}

.review-dot-btn.is-correct {
  background: var(--state-correct-bg);
  color: var(--state-correct);
}

.review-dot-btn.is-wrong {
  background: var(--state-wrong-bg);
  color: var(--state-wrong);
}

.review-dot-btn[aria-pressed="true"] {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.16);
}

.summary-detail {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeSlideIn 0.22s var(--ease-apple);
}

.summary-detail[hidden] {
  display: none;
}

.summary-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.answer-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
}

.answer-badge--green {
  background: var(--state-correct-bg);
  color: var(--state-correct);
}

.answer-badge--red {
  background: var(--state-wrong-bg);
  color: var(--state-wrong);
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

/* ==========================================================================
   页面四：错题本与原生 <details> 手风琴动画
   ========================================================================== */

.filter-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: none;
}

.filter-strip::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  flex-shrink: 0;
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.18s var(--ease-apple);
}

.filter-pill[aria-selected="true"] {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #FFFFFF;
}

.filter-pill-count {
  font-size: 12px;
  opacity: 0.72;
}

.wrongbook-action-bar[hidden] {
  display: none;
}

.wrongbook-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 原生 <details> 错题卡片（严格遵循 modern-web-guidance accordion 规范） */
.wrong-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.wrong-card-summary {
  list-style: none;
  padding: 16px 18px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.wrong-card-summary::-webkit-details-marker {
  display: none;
}

/* 使用 ::before 绘制紧邻标题左侧的统一方向箭头 */
.wrong-card-summary::before {
  content: "";
  inline-size: 16px;
  block-size: 16px;
  margin-top: 3px;
  flex-shrink: 0;
  background-color: var(--text-tertiary);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6l4.5 4.5L12.5 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain;
  rotate: -90deg;
}

.wrong-card[open] > .wrong-card-summary::before {
  rotate: 0deg;
}

.wrong-card-head {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wrong-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.wrong-count-pill {
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--state-wrong-bg);
  color: var(--state-wrong);
  font-weight: 600;
}

.wrong-card-stem {
  margin: 0;
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.62;
  color: var(--text-primary);
}

/* 使用 ::details-content + interpolate-size 平滑展开与收起 */
.wrong-card::details-content {
  interpolate-size: allow-keywords;
  overflow: clip;
  contain: layout;
}

.wrong-card:not([open])::details-content {
  block-size: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .wrong-card-summary::before {
    transition: rotate 0.22s var(--ease-apple);
  }
  .wrong-card::details-content {
    transition: block-size, content-visibility, display;
    transition-duration: 0.28s;
    transition-timing-function: var(--ease-apple);
    transition-behavior: allow-discrete;
  }
}

.wrong-card-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mini-options {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.mini-option {
  padding: 9px 12px;
  border-radius: 10px;
  background: #F9F9FB;
  border: 1px solid transparent;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  gap: 8px;
}

.mini-option.is-correct {
  background: var(--state-correct-bg);
  border-color: var(--state-correct-border);
  color: #165B28;
  font-weight: 500;
}

.mini-option.is-last-wrong {
  background: var(--state-wrong-bg);
  border-color: var(--state-wrong-border);
  color: #9E1F18;
}

.mini-option-key {
  font-weight: 700;
  flex-shrink: 0;
}

.wrong-card-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.btn-mastered {
  min-height: 40px;
  padding: 0 16px;
  font-size: 14px;
  border-radius: var(--radius-pill);
  background: var(--state-correct-bg);
  color: var(--state-correct);
  border: 1px solid var(--state-correct-border);
}

.btn-mastered:hover {
  background: rgba(52, 199, 89, 0.18);
}

/* 空状态与异常卡片 */
.empty-state-card {
  padding: 40px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-state-card[hidden] {
  display: none;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.empty-icon--warn {
  background: var(--state-wrong-bg);
  color: var(--state-wrong);
}

.empty-icon svg {
  width: 26px;
  height: 26px;
}

.empty-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.empty-desc {
  margin: 0 0 8px;
  max-width: 360px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

/* ==========================================================================
   原生 <dialog> 退出确认模态框（含滚动穿透防护）
   ========================================================================== */

/* 不对未打开的 dialog 设置 display，仅针对 [open] */
.modal-dialog {
  width: min(340px, calc(100vw - 32px));
  padding: 22px 20px 18px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-float);
  color: var(--text-primary);
}

.modal-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 规范：阻止模态框内部与遮罩层滚动链式穿透至底层页面，不修改 html/body overflow */
dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.modal-desc {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
  text-align: center;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.modal-actions .btn {
  min-height: 44px;
  font-size: 15px;
  padding: 0 12px;
}

/* ==========================================================================
   非阻塞顶部轻提示 Toast（popover="manual" + 无障碍回退）
   ========================================================================== */

.toast-region {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: min(440px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  margin: 0 auto;
  padding: 10px 14px;
  max-width: min(440px, calc(100vw - 24px));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill);
  background: rgba(29, 29, 31, 0.92);
  color: #FFFFFF;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 14px;
  line-height: 1.4;
  gap: 10px;
  align-items: center;
  inset: auto;
  position: fixed;
  top: calc(14px + var(--toast-offset, 0px));
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.22s var(--ease-apple), transform 0.22s var(--ease-apple), display 0.22s, overlay 0.22s;
  transition-behavior: allow-discrete;
}

.toast-item:is(:popover-open, .is-popover-open) {
  display: inline-flex;
  opacity: 1;
}

@starting-style {
  .toast-item:is(:popover-open, .is-popover-open) {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

@supports not selector(:popover-open) {
  .toast-item:not(.is-popover-open) {
    display: none;
  }
}

.toast-text {
  word-break: break-word;
}

.toast-action-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
  padding: 4px 10px;
  min-height: 30px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.toast-action-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.toast-close-btn {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.toast-close-btn:hover {
  color: #FFFFFF;
  background: rgba(255, 255, 255, 0.14);
}

/* ==========================================================================
   减少动态效果无障碍适配（prefers-reduced-motion）
   ========================================================================== */

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