/* ==========================================================================
   嘉嘉老师餐食回忆 AAC - 现代化高品质界面改版样式表
   保留全部功能和数据交互，升级视觉设计与交互体验
   ========================================================================== */

:root {
  /* 主题色系 - 专业、温暖、亲和、高辨识度 */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-active: #1e40af;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --primary-shadow: #1e40af;

  /* 辅助与状态色 */
  --correct: #10b981;
  --correct-dark: #059669;
  --correct-soft: #ecfdf5;
  --correct-border: #a7f3d0;
  --correct-glow: rgba(16, 185, 129, 0.25);

  --wrong: #f43f5e;
  --wrong-dark: #e11d48;
  --wrong-soft: #fff1f2;
  --wrong-border: #fecdd3;

  --accent-sun: #f59e0b;
  --accent-sun-soft: #fef3c7;
  --accent-sun-dark: #d97706;

  /* 中性色系 */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;

  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-dark: #94a3b8;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;

  /* 阴影层级 */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 16px -2px rgba(15, 23, 42, 0.07), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.09), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 24px 48px -8px rgba(15, 23, 42, 0.16);

  /* 圆角规范 */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* 动画缓动 */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 基础重置 */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
  border: 0;
  background: transparent;
  user-select: none;
  touch-action: manipulation;
}

button:focus-visible, input:focus-visible, select:focus-visible, .file-btn:focus-within {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   顶栏导航 (Topbar)
   ========================================================================== */
.topbar {
  height: 72px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #ffc53d, #fa8c16);
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(250, 140, 22, 0.3);
  transform: rotate(-10deg);
  transition: transform 0.25s var(--ease-bounce);
}

.brand:hover .brand-mark {
  transform: rotate(0deg) scale(1.05);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand strong {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand small {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}

/* 导航选项卡 */
.adult-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 5px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow-x: auto;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 96px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.15s ease-out;
  white-space: nowrap;
}

.nav-icon {
  font-size: 15px;
  line-height: 1;
}

.nav-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.6);
}

.nav-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* 账号微标 */
.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-subtle);
  padding: 6px 8px 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-light);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.account-chip .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--correct);
  box-shadow: 0 0 0 2px var(--correct-soft);
}

.account-chip button {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  transition: all 0.15s;
}

.account-chip button:hover {
  background: var(--wrong-soft);
  color: var(--wrong);
  border-color: var(--wrong-border);
}

/* ==========================================================================
   主体工作区 (Workspace)
   ========================================================================== */
.workspace {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 36px 64px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewFadeIn 0.22s var(--ease-smooth);
}

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

/* 区块头部 (Section Heading) */
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.section-heading h1 {
  margin: 4px 0 0;
  font-size: clamp(24px, 2.6vw, 34px);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow-badge {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.eyebrow-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid var(--primary-border);
  transition: all 0.15s;
}

.eyebrow-link:hover {
  background: var(--primary);
  color: white;
}

/* 通用按钮系统 */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--primary-shadow), var(--shadow-sm);
  transition: all 0.12s ease-out;
}

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

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--primary-shadow);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-xs);
  transition: all 0.15s ease-out;
}

.secondary-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.secondary-btn:active {
  transform: translateY(1px);
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  transition: background 0.15s;
}

.text-btn:hover {
  background: var(--primary-soft);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 20px;
  line-height: 1;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.file-btn input[type="file"] {
  display: none;
}

/* ==========================================================================
   出一道题 (Builder View)
   ========================================================================== */
.builder-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.setup-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.setup-column {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-self: start;
}

.setup-column > #startPractice {
  align-self: flex-start;
}

.setup-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
}

/* 输入框与下拉选择框 */
.text-input {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: 8px 14px;
  font-size: 14px;
  transition: all 0.15s;
}

.text-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  outline: none;
}

.text-input.large {
  min-height: 50px;
  font-size: 16px;
  font-weight: 700;
}

.question-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232563eb' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
  border-color: var(--primary-border);
  background-color: var(--bg-surface);
}

.question-select:hover {
  border-color: var(--primary);
}

/* 分段选择器 (Segmented Control) */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.segment {
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.15s ease-out;
}

.segment:hover {
  color: var(--text-primary);
}

.segment.active {
  background: var(--bg-surface);
  color: var(--primary);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

/* 出题方式模式卡片 */
.mode-cards {
  display: grid;
  gap: 8px;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  text-align: left;
  transition: all 0.15s;
}

.mode-card strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
}

.mode-card small {
  font-size: 12px;
  color: var(--text-secondary);
}

.mode-card:hover {
  border-color: var(--border-medium);
  background: var(--bg-subtle);
}

.mode-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.mode-card.active strong {
  color: var(--primary);
}

/* 干扰项自动补齐行 */
.auto-fill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-medium);
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.switch-label input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--border-medium);
  transition: background 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s var(--ease-bounce);
}

.switch-label input:checked + .switch {
  background: var(--primary);
}

.switch-label input:checked + .switch::after {
  transform: translateX(18px);
}

/* 图例 */
.legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.correct-dot {
  background: var(--correct);
  box-shadow: 0 0 0 2px var(--correct-soft);
}

.distractor-dot {
  background: var(--text-tertiary);
  box-shadow: 0 0 0 2px var(--bg-subtle);
}

/* 选择面板 (Selection Panel) */
.selection-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

.selection-toolbar {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(to bottom, #ffffff, var(--bg-subtle));
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}

.selection-info strong {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.selection-info small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
}

.pick-role-choices {
  display: flex;
  gap: 10px;
  padding: 14px 18px 0;
  flex-wrap: wrap;
}

.pick-role {
  min-height: 42px;
  padding: 0 16px;
  border: 2px solid var(--border-medium);
  border-radius: var(--radius-full);
  background: #fff;
  color: var(--text-secondary);
  font-weight: 800;
}

.pick-role.active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.first-run-guide {
  margin: 18px;
  padding: 30px;
  border: 2px dashed var(--primary-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #f0f9ff, #f0fdf4);
  text-align: center;
}

.first-run-guide .guide-icon { font-size: 46px; }
.first-run-guide h2 { margin: 8px 0 14px; }
.first-run-guide ol { display: inline-grid; gap: 8px; margin: 0 auto 20px; padding-left: 24px; text-align: left; color: var(--text-secondary); font-weight: 700; }

/* 食物选择卡片网格 */
.food-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  padding: 22px;
  flex: 1;
}

.food-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 2.5px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition: all 0.15s ease-out;
  cursor: pointer;
}

.food-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.food-card:active {
  transform: translateY(0);
}

.food-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--bg-subtle);
  padding: 8px;
}

.food-card .food-name {
  display: block;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
}

/* 选中为干扰项 */
.food-card.selected {
  border-color: var(--text-secondary);
  box-shadow: 0 0 0 3px rgba(71, 85, 105, 0.15);
}

/* 选中为正确答案 */
.food-card.correct {
  border-color: var(--correct);
  box-shadow: 0 0 0 3px var(--correct-glow);
}

.food-role {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 30px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: var(--text-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 2;
  animation: popIn 0.2s var(--ease-bounce);
}

.food-card.correct .food-role {
  background: var(--correct);
}

@keyframes popIn {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* 空状态 (Empty State) */
.empty-state:empty::after,
.library-grid:empty::after,
.record-list:empty::after {
  content: attr(data-empty);
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 40px 20px;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  color: var(--text-tertiary);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  margin: 10px;
}

/* ==========================================================================
   食物库 (Library View)
   ========================================================================== */
.photo-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.camera-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--primary-border);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all 0.15s;
}

.camera-btn:hover {
  background: #dbeafe;
  border-color: var(--primary);
}

.camera-btn:active {
  transform: translateY(1px);
}

.library-tools {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  gap: 16px;
  margin-bottom: 24px;
}

.search-box, .online-search {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 4px 10px 4px 14px;
  transition: all 0.15s;
}

.search-box:focus-within, .online-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-box input, .online-search input {
  min-width: 0;
  flex: 1;
  height: 40px;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--text-primary);
}

.search-box span {
  font-size: 18px;
  color: var(--text-tertiary);
}

.online-search .secondary-btn {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px;
}

.library-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: all 0.15s ease-out;
}

.library-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-medium);
}

.library-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--bg-subtle);
  padding: 8px;
}

.library-card-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.library-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.library-card-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.library-card-actions button {
  min-height: 44px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-subtle);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all 0.15s;
}

.library-action span {
  font-size: 13px;
  line-height: 1;
}

.library-action b {
  font-size: 12px;
  font-weight: 700;
}

.library-action.edit {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.library-action.edit:hover {
  background: #dbeafe;
}

.library-action.rename {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.library-action.rename:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
}

.library-action.delete {
  background: var(--wrong-soft);
  color: var(--wrong);
  border-color: var(--wrong-border);
}

.library-action.delete:hover {
  background: #fee2e2;
  color: var(--wrong-dark);
}

.online-results {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 2px dashed var(--border-medium);
}

.subheading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.subheading h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.subheading small {
  color: var(--text-secondary);
  font-size: 12px;
}

/* ==========================================================================
   餐食记录与历史题目 (Record Lists)
   ========================================================================== */
.record-list {
  display: grid;
  gap: 14px;
}

.record-card {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
}

.record-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.record-date {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  display: inline-block;
  text-align: center;
}

.record-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}

.record-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.record-actions .secondary-btn {
  min-height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

/* ==========================================================================
   设置与备份 (Settings View)
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-card h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.settings-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.voice-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.voice-hint {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-card.safety {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border-color: var(--primary-border);
}

.settings-switch { margin-top: 16px; }
.attempt-summary { margin-top: 7px !important; color: #176b57 !important; font-weight: 800 !important; }

/* ==========================================================================
   儿童 AAC 练习模式 (Practice Area) - 全屏专注沉浸设计
   ========================================================================== */
.practice-area {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #f1f5f9;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  user-select: none;
  -webkit-user-select: none;
}

.practice-header {
  position: relative;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 140px;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: #0f172a;
  color: white;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
  min-height: 80px;
}

.progress-pill {
  justify-self: start;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

#practiceQuestion {
  margin: 0;
  text-align: center;
  font-size: clamp(22px, 3.2vw, 38px);
  font-weight: 900;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.question-time-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.time-illustration {
  display: block;
  width: clamp(48px, 6vw, 70px);
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.time-emoji {
  display: grid;
  place-items: center;
  width: clamp(48px, 6vw, 70px);
  aspect-ratio: 1;
  font-size: clamp(38px, 4.7vw, 58px);
  line-height: 1;
  flex: 0 0 auto;
}

.exit-btn {
  justify-self: end;
  min-width: 90px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: #f8fafc;
  font-size: 15px;
  font-weight: 800;
  transition: all 0.15s;
}

.exit-btn:hover {
  background: rgba(255, 255, 255, 0.24);
  border-color: #fff;
}

.exit-btn:active {
  transform: scale(0.96);
}

.practice-actions { justify-self: end; display: flex; gap: 8px; }
.practice-actions .exit-btn { justify-self: auto; }

.practice-hint {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 105;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  background: #334155;
  color: white;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(15,23,42,.25);
}

/* 练习卡片网格 */
.practice-grid {
  height: 100%;
  min-height: 0;
  display: grid;
  gap: clamp(12px, 1.6vw, 22px);
  padding: clamp(14px, 2vw, 28px);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.practice-grid.count-4 {
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
}

.practice-grid.count-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: 1fr;
  max-width: 980px;
  align-items: stretch;
}

.practice-grid.count-9 {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.practice-grid.count-16 {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

/* 练习选项卡片 (Answer Tile) */
.answer-tile {
  position: relative;
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding: clamp(8px, 1vw, 14px);
  border-radius: clamp(16px, 2vw, 26px);
  background: #ffffff;
  border: 4px solid #ffffff;
  box-shadow: 0 6px 0 #cbd5e1, 0 12px 24px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}

.answer-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #cbd5e1, 0 16px 28px rgba(15, 23, 42, 0.12);
}

.answer-tile:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #cbd5e1, 0 6px 12px rgba(15, 23, 42, 0.08);
}

.answer-tile img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  pointer-events: none;
}

.answer-tile .answer-label {
  display: block;
  padding-top: 6px;
  font-size: clamp(16px, 2.2vw, 28px);
  font-weight: 900;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  visibility: hidden;
  opacity: 0;
  transform: translateY(6px);
  transition: all 0.2s var(--ease-bounce);
}

.answer-tile.revealed .answer-label {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

/* 答案状态标记徽章 (✓ 或 ×) */
.answer-tile .answer-mark {
  position: absolute;
  top: 10px;
  right: 10px;
  width: clamp(38px, 4.5vw, 64px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  font-size: clamp(24px, 3.4vw, 44px);
  font-weight: 900;
  opacity: 0;
  transform: scale(0.4);
  transition: all 0.22s var(--ease-bounce);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 5;
}

/* 正确选择状态 */
.answer-tile.correct-choice {
  border-color: var(--correct);
  box-shadow: 0 6px 0 var(--correct-dark), 0 0 0 5px var(--correct-soft);
  transform: scale(1.01);
}

.answer-tile.correct-choice .answer-mark {
  background: var(--correct);
  opacity: 1;
  transform: scale(1);
}

/* 错误选择状态 */
.answer-tile.wrong-choice {
  border-color: var(--wrong);
  box-shadow: 0 6px 0 var(--wrong-dark), 0 0 0 5px var(--wrong-soft);
  animation: gentleShake 0.3s var(--ease-smooth);
}

.answer-tile.wrong-choice .answer-mark {
  background: var(--wrong);
  opacity: 1;
  transform: scale(1);
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.answer-tile[disabled] {
  cursor: default;
  pointer-events: none;
}

/* 触控防抖遮罩 */
.tap-blocker {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: end center;
  pointer-events: all;
  padding-bottom: 28px;
}

.tap-blocker span {
  padding: 10px 24px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.2s;
}

/* ==========================================================================
   通关庆祝弹窗 (Celebration Dialog)
   ========================================================================== */
.celebration-dialog {
  width: min(540px, calc(100vw - 36px));
  padding: 36px 28px 32px;
  border: 0;
  border-radius: var(--radius-xl);
  text-align: center;
  color: var(--text-primary);
  background: #ffffff;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.celebration-dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(10px);
}

.celebration-plate {
  width: 130px;
  height: 130px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 12px solid #fef3c7;
  background: linear-gradient(135deg, #ffc53d, #fa8c16);
  box-shadow: inset 0 0 0 4px #ffffff, 0 10px 30px rgba(250, 140, 22, 0.35);
  animation: bouncePlate 0.6s var(--ease-bounce);
}

.celebration-plate span {
  font-size: 64px;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

@keyframes bouncePlate {
  0% { transform: scale(0.3) rotate(-30deg); }
  60% { transform: scale(1.15) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.celebration-dialog h2 {
  margin: 8px 0;
  font-size: 34px;
  font-weight: 900;
  color: var(--text-primary);
}

.celebration-dialog p {
  margin: 0 0 28px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}

.celebration-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
}

.celebration-actions .secondary-btn {
  min-height: 50px;
  padding: 0 26px;
  font-size: 16px;
}

.celebration-actions .primary-btn {
  min-height: 50px;
  padding: 0 32px;
  font-size: 16px;
}

/* ==========================================================================
   通用弹窗 (Dialogs)
   ========================================================================== */
.dialog {
  width: min(840px, calc(100vw - 36px));
  max-height: 88vh;
  padding: 28px;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xl);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.dialog-head h2 {
  margin: 2px 0 0;
  font-size: 24px;
  font-weight: 800;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* 记录餐食弹窗 */
.meal-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.dialog .food-pick-grid {
  max-height: 42vh;
  overflow-y: auto;
  padding: 4px;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

/* 命名与小图裁剪弹窗 */
.small-dialog {
  width: min(540px, calc(100vw - 36px));
}

#nameDialog {
  max-height: 94vh;
  overflow-y: auto;
}

.name-preview {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  margin-top: 14px;
}

/* 裁剪区域编辑器 (Crop Editor) */
.crop-editor {
  margin-top: 12px;
}

.crop-editor p {
  margin: 6px 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.5;
}

.crop-stage {
  --crop-ratio: 1;
  width: min(100%, calc(34vh * var(--crop-ratio)));
  aspect-ratio: var(--crop-ratio);
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  touch-action: none;
  box-shadow: var(--shadow-sm);
}

.crop-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.crop-stage canvas:active {
  cursor: grabbing;
}

.crop-stage.area-mode canvas {
  cursor: crosshair;
}

.crop-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 10px;
}

.crop-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 12px 0;
  background: var(--bg-subtle);
  padding: 12px 16px;
  border-radius: var(--radius-md);
}

.crop-controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.crop-controls input[type="range"] {
  accent-color: var(--primary);
  height: 6px;
  cursor: pointer;
}

#resetCrop {
  width: 100%;
  margin-top: 6px;
}

/* 上传处理与拆分弹窗 */
.intake-dialog {
  width: min(620px, calc(100vw - 36px));
}

.intake-body {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.intake-body img {
  display: block;
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.intake-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.upload-choice-dialog {
  width: min(520px, calc(100vw - 36px));
}

.upload-choice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.upload-choice-actions .file-btn {
  min-height: 56px;
  font-size: 15px;
}

/* 批量上传 */
.batch-dialog {
  width: min(880px, calc(100vw - 36px));
}

.batch-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  max-height: 42vh;
  overflow-y: auto;
  padding-right: 4px;
  margin-top: 14px;
}

.batch-preview-grid figure {
  margin: 0;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.batch-preview-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.batch-preview-grid figcaption {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.batch-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

/* 整盘拆分候选 (Plate Candidates) */
.plate-dialog {
  width: min(980px, calc(100vw - 36px));
}

.plate-review {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
  gap: 20px;
  margin-top: 16px;
}

.plate-source img {
  display: block;
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
}

.plate-source p {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.plate-candidates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-height: 56vh;
  overflow-y: auto;
  padding-right: 4px;
}

.plate-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  transition: all 0.15s;
}

.plate-card:has(input[type="checkbox"]:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.plate-crop-stage {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-subtle);
  touch-action: none;
}

.plate-crop-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.plate-crop-stage canvas:active {
  cursor: grabbing;
}

.plate-card-fields {
  display: grid;
  gap: 6px;
}

.plate-card label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  cursor: pointer;
}

.plate-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.plate-card .text-input {
  min-height: 36px;
  font-size: 14px;
  padding: 4px 8px;
}

.plate-reset {
  justify-self: start;
  font-size: 12px;
  padding: 2px 4px;
}

/* 账号与登录弹窗 (Auth Dialog) */
.auth-dialog {
  width: min(460px, calc(100vw - 32px));
}

.auth-help {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 4px 0 16px;
}

.setup-warning {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--wrong-soft);
  color: var(--wrong-dark);
  font-size: 13px;
  line-height: 1.5;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.auth-tab.active {
  background: var(--bg-surface);
  color: var(--primary);
  font-weight: 800;
  box-shadow: var(--shadow-xs);
}

.auth-fields {
  display: grid;
  gap: 12px;
}

.password-field {
  position: relative;
}

.password-field .text-input {
  padding-right: 70px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
  border-radius: var(--radius-xs);
  background: var(--primary-soft);
}

.code-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.code-field .secondary-btn {
  min-height: 44px;
  white-space: nowrap;
}

.auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

.auth-links button {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  padding: 4px 0;
}

.privacy-consent {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 10px;
}

.privacy-consent input {
  margin-top: 2px;
}

.password-tip {
  margin: 0;
  font-size: 11px;
  color: var(--text-tertiary);
}

.error-text {
  min-height: 20px;
  margin: 6px 0;
  color: var(--wrong);
  font-size: 13px;
  font-weight: 700;
}

.auth-actions {
  align-items: center;
  justify-content: space-between;
}

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

/* ==========================================================================
   浮动通知 (Toast)
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 150;
  transform: translate(-50%, 140%);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-lg);
  transition: transform 0.24s var(--ease-bounce);
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translate(-50%, 0);
}

/* ==========================================================================
   响应式设计与断点优化 (Responsive Breakpoints)
   ========================================================================== */
@media (max-width: 960px) {
  .topbar {
    height: auto;
    padding: 12px 18px;
    flex-wrap: wrap;
    gap: 14px;
  }

  .brand {
    min-width: auto;
  }

  .adult-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .workspace {
    padding: 20px 18px 48px;
  }

  .builder-layout {
    grid-template-columns: 1fr;
  }

  .setup-panel {
    position: static;
  }

  .setup-column {
    position: static;
  }

  .library-tools, .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-card.safety {
    grid-column: auto;
  }

  .record-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .record-actions {
    justify-content: flex-end;
  }
}

@media (max-width: 600px) {
  .section-heading {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .photo-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .photo-actions [data-go-builder] {
    grid-column: 1 / -1;
  }

  .photo-actions .primary-btn,
  .photo-actions .secondary-btn,
  .photo-actions .camera-btn {
    width: 100%;
    padding: 0 10px;
    min-height: 44px;
  }

  .practice-header {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 10px 14px;
    min-height: 70px;
  }

  #practiceQuestion {
    grid-row: 2;
    grid-column: 1 / -1;
    font-size: 20px;
    gap: 8px;
  }

  .time-illustration {
    width: 42px;
  }

  .practice-header .exit-btn {
    grid-column: 2;
    grid-row: 1;
    height: 38px;
    min-width: 76px;
    padding: 0 12px;
    font-size: 13px;
  }

  .practice-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .practice-actions .exit-btn {
    min-width: auto;
  }

  #speakQuestion { font-size: 0; }
  #speakQuestion::before { content: "🔊"; font-size: 18px; }

  .progress-pill {
    padding: 6px 14px;
    font-size: 13px;
  }

  .practice-grid {
    gap: 8px;
    padding: 10px;
  }

  .answer-tile {
    padding: 6px;
    border-radius: var(--radius-sm);
  }

  .plate-review {
    grid-template-columns: 1fr;
  }

  .plate-card {
    grid-template-columns: 100px minmax(0, 1fr);
  }

  .plate-crop-stage {
    grid-row: span 3;
  }

  .batch-actions, .intake-actions, .upload-choice-actions {
    grid-template-columns: 1fr;
  }
}

/* 动效辅助无障碍 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Family account actions remain usable on narrow phones. */
.topbar { flex-wrap: wrap; height: auto; min-height: 72px; padding-top: 12px; padding-bottom: 12px; }
.account-chip { flex-wrap: wrap; white-space: normal; max-width: 100%; border-radius: 16px; }
#accountName { overflow-wrap: anywhere; }
#syncStatus { flex-basis: 100%; order: 5; overflow-wrap: anywhere; font-weight: 500; }
.account-chip button { min-height: 40px; white-space: nowrap; }
@media (max-width: 600px) { .account-chip { width: 100%; } }
