:root {
  --mono-font: "Berkeley Mono", "JetBrains Mono", "Fira Code", "SFMono-Regular", Monaco, Consolas, monospace;
  --sans-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "avenir next", avenir, helvetica, "helvetica neue", ubuntu, roboto, noto, "segoe ui", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", arial, sans-serif;

  /* iOS 色彩系统 */
  --bg: light-dark(#ffffff, #000000);
  --surface: light-dark(#f2f2f7, #1c1c1e);          /* systemGroupedBackground */
  --card: light-dark(#ffffff, #2c2c2e);             /* secondarySystemGroupedBackground */
  --text: light-dark(#1c1c1e, #f5f5f7);             /* label */
  --text-dim: light-dark(#6e6e73, #98989d);         /* secondaryLabel */
  --text-faint: light-dark(#aeaeb2, #636366);       /* tertiaryLabel */
  --accent: light-dark(#1d4ed8, #60a5fa);           /* 沉稳深蓝 */
  --ok: light-dark(#34c759, #30d158);               /* green */
  --miss: light-dark(#ff3b30, #ff453a);             /* red */
  --separator: light-dark(rgba(60, 60, 67, 0.18), rgba(84, 84, 88, 0.45));
  --hairline: light-dark(rgba(60, 60, 67, 0.09), rgba(84, 84, 88, 0.28));

  --mode-border: light-dark(#555, #eee);
  --mode-dark: #555;
  --mode-light: #fff;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans-font);
  font-size: 17px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
summary,
label {
  cursor: pointer;
}

a {
  color: var(--text);
  text-decoration: none;
}

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

button:active {
  transform: scale(0.97);
}

/* ---------- 布局 ---------- */

.site-frame {
  position: relative;
  padding: 20px;
}

.limiter,
.header {
  max-width: 640px;
  margin: 0 auto;
}

.limiter {
  padding: 40px 0 90px;
}

.header {
  display: block;
  padding: 18px 0 30px;
  color: var(--text-dim);
}

.header h2 {
  margin: 0 0 0.25em;
  font-size: 1rem;
  line-height: 1.6;
}

.header a {
  color: var(--text);
  text-decoration: none;
}

.header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7em;
}

.header nav a {
  color: var(--text-dim);
  font-size: 15px;
}

.header nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

/* ---------- 主题切换（与博客一致） ---------- */

.mode-container {
  position: absolute;
  top: 28px;
  right: 20px;
  z-index: 2;
  display: flex;
  gap: 8px;
}

.mode {
  display: block;
  width: 18px;
  min-width: 0;
  height: 18px;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  color: transparent;
  background: transparent;
  border: 2px solid var(--mode-border);
  border-radius: 10px;
  opacity: 0.25;
  text-indent: -10000px;
  transition: opacity 0.15s ease;
}

.mode-container:hover .mode,
.mode:focus-visible {
  opacity: 1;
}

.mode.is-selected {
  opacity: 0.55;
}

.mode.auto {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20'><rect width='100%' height='100%' fill='white'/><path fill='%23777' d='M0,0L0,20L20,20L0,0'/></svg>");
}

.mode.light {
  background-color: var(--mode-light);
}

.mode.dark {
  background-color: var(--mode-dark);
}

/* ---------- 视图切换（iOS 风格滑动淡入） ---------- */

.view {
  display: none;
}

body[data-view="idle"] .view-start,
body[data-view="practice"] .view-practice,
body[data-view="finished"] .view-report {
  display: block;
  animation: view-in 0.32s var(--ease);
}

body[data-view="practice"] .history-section {
  display: none;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- 开始页（iOS 空状态布局） ---------- */

.view-start {
  text-align: center;
  padding-top: 56px;
}

.title-tag {
  margin: 0 0 14px;
  color: var(--accent);
  font-family: var(--mono-font);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.title {
  margin: 0 0 10px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.022em;
}

.intro-meta {
  margin: 0 auto 48px;
  color: var(--text-dim);
  font-family: var(--mono-font);
  font-size: 13px;
  letter-spacing: 0.01em;
}

/* iOS 分段控件 */

.mode-strip {
  display: flex;
  gap: 3px;
  max-width: 400px;
  margin: 0 auto 30px;
  padding: 3px;
  background: var(--surface);
  border-radius: 11px;
}

.mode-strip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-strip label {
  flex: 1;
  min-width: 0;
}

.mode-strip span {
  display: block;
  padding: 8px 6px;
  color: var(--text-dim);
  font-size: 15px;
  text-align: center;
  border-radius: 8px;
  white-space: nowrap;
  transition: color 0.18s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.mode-strip label:hover span {
  color: var(--accent);
}

.mode-strip input:checked + span {
  color: var(--text);
  background: var(--card);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

/* 主按钮 */

.start-button {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: 0 auto 26px;
  padding: 14px 24px;
  color: var(--bg);
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.12s var(--ease);
}

.start-button:hover {
  color: var(--text);
  background: var(--bg);
}

.start-button:active {
  transform: scale(0.98);
}

.start-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  color: var(--text-faint);
  font-size: 15px;
}

.start-links button {
  padding: 8px 6px;
  color: var(--text);
  background: none;
  border: 0;
  font-size: 15px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.start-links button:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ---------- 听写卡片 ---------- */

.practice-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 44px;
}

.exit-link {
  padding: 8px 0;
  color: var(--text);
  background: none;
  border: 0;
  font-size: 16px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.exit-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.progress {
  padding: 5px 11px;
  color: var(--text-dim);
  background: var(--surface);
  border-radius: 999px;
  font-family: var(--mono-font);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--text-faint);
  font-family: var(--mono-font);
  font-size: 13px;
}

.session-title {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 15px;
}

/* iOS 风格输入框 */

.answer-input {
  display: block;
  width: 100%;
  min-height: 108px;
  padding: 14px 16px;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: 14px;
  font-size: 20px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
}

.answer-input:focus {
  border-color: var(--accent);
  background: var(--bg);
}

.answer-input::placeholder {
  color: var(--text-faint);
}

/* 结果反馈 */

.result {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  margin-top: 14px;
  font-size: 16px;
  font-weight: 600;
}

.result:empty {
  display: none;
}

.result[data-state="correct"] {
  color: var(--ok);
  animation: result-in 0.3s var(--ease);
}

.result[data-state="wrong"] {
  color: var(--miss);
  animation: result-in 0.3s var(--ease);
}

@keyframes result-in {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 答案展示卡片 */

.answer-panel {
  margin-top: 14px;
  padding: 16px;
  background: var(--surface);
  border-radius: 14px;
  animation: result-in 0.3s var(--ease);
}

.answer-word {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.answer-meaning {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 15px;
}

/* 操作按钮（胶囊） */

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.mini-actions button {
  padding: 9px 18px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.mini-actions button:hover:not(:disabled) {
  color: var(--accent);
  background: var(--surface);
}

.mini-actions [data-action="check"]:not(:disabled) {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.mini-actions [data-action="check"]:hover:not(:disabled) {
  color: var(--text);
  background: var(--bg);
}

.mini-actions button:disabled {
  color: var(--text-faint);
  opacity: 0.6;
  cursor: default;
}

.kbd-hint {
  margin: 12px 0 0;
  color: var(--text-faint);
  font-family: var(--mono-font);
  font-size: 12px;
}

/* ---------- 词表（iOS 分组列表） ---------- */

.word-list-section {
  margin-top: 40px;
}

.word-list-section summary {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 4px 0 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  list-style: none;
}

.word-list-section summary::-webkit-details-marker {
  display: none;
}

.word-list-section summary::after {
  content: "▾";
  color: var(--text-faint);
  font-size: 12px;
  transition: transform 0.2s var(--ease);
}

.word-list-section[open] summary::after {
  transform: rotate(180deg);
}

.word-list-section summary span:last-child {
  margin-right: auto;
  margin-left: 10px;
  color: var(--text-faint);
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 400;
}

.word-list {
  list-style: none;
  margin: 0;
  padding: 0 10px;
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
}

.word-list li + li {
  border-top: 0.5px solid var(--separator);
}

.word-list button {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px 6px;
  color: inherit;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.word-list button:hover {
  background: var(--hairline);
}

.word-list .id,
.word-list .status {
  color: var(--text-dim);
  font-family: var(--mono-font);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.word-list li.is-current .id {
  color: var(--accent);
  font-weight: 600;
}

.word-list li.is-done .status {
  color: var(--ok);
}

/* ---------- 报告 ---------- */

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

.report-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.report-head span {
  color: var(--text-faint);
  font-family: var(--mono-font);
  font-size: 12px;
  white-space: nowrap;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 26px;
}

.report-actions button {
  padding: 9px 18px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.report-actions button:hover:not(:disabled) {
  color: var(--accent);
  background: var(--surface);
}

.report-actions button:disabled {
  color: var(--text-faint);
  opacity: 0.6;
  cursor: default;
}

.report-actions [data-action="start"] {
  color: var(--bg);
  background: var(--text);
  border-color: var(--text);
}

.report-actions [data-action="start"]:hover {
  color: var(--text);
  background: var(--bg);
}

/* 统计卡片 */

.report-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}

.report-summary:empty,
.report-table:empty {
  display: none;
}

.report-summary div {
  padding: 14px 14px 12px;
  background: var(--surface);
  border-radius: 14px;
}

.report-summary strong {
  display: block;
  font-family: var(--mono-font);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.report-summary span {
  color: var(--text-dim);
  font-size: 13px;
}

/* 报告行（分组列表） */

.report-table {
  overflow: hidden;
  padding: 0 10px;
  background: var(--surface);
  border-radius: 14px;
}

.report-row {
  display: grid;
  grid-template-columns: 64px 118px minmax(100px, 0.8fr) 64px minmax(0, 1.6fr);
  gap: 10px;
  align-items: baseline;
  padding: 11px 6px;
}

.report-row + .report-row {
  border-top: 0.5px solid var(--separator);
}

.report-cell {
  min-width: 0;
}

.report-id,
.report-answer span {
  color: var(--text-dim);
  font-family: var(--mono-font);
  font-size: 12px;
}

.report-id span,
.report-id small,
.report-answer span {
  display: block;
}

.report-id small {
  overflow: hidden;
  font-size: 11px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-row.correct .report-status {
  color: var(--ok);
}

.report-row.wrong .report-status {
  color: var(--miss);
}

.report-word {
  font-size: 15px;
}

.report-word strong {
  display: block;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-answer strong {
  display: block;
  overflow: hidden;
  color: var(--text-dim);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-status {
  font-family: var(--mono-font);
  font-size: 12px;
  text-align: right;
  white-space: nowrap;
}

.report-meaning {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

/* ---------- 历史 ---------- */

.history-section {
  margin-top: 44px;
}

.history-section summary {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 4px 0 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  list-style: none;
}

.history-section summary::-webkit-details-marker {
  display: none;
}

.history-section summary::after {
  content: "▾";
  color: var(--text-faint);
  font-size: 12px;
  transition: transform 0.2s var(--ease);
}

.history-section[open] summary::after {
  transform: rotate(180deg);
}

.history-section summary span:last-child {
  margin-left: auto;
  color: var(--text-faint);
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 400;
}

.history-list {
  overflow: hidden;
  padding: 0 10px;
  background: var(--surface);
  border-radius: 14px;
}

.history-empty {
  padding: 16px 6px;
  color: var(--text-dim);
}

.history-record {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 6px;
}

.history-record + .history-record {
  border-top: 0.5px solid var(--separator);
}

.history-main strong {
  display: block;
  font-weight: 600;
}

.history-main span,
.history-main p {
  color: var(--text-dim);
}

.history-main p {
  margin-top: 2px;
  font-family: var(--mono-font);
  font-size: 13px;
}

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

.history-actions button {
  padding: 7px 14px;
  color: var(--text);
  background: var(--card);
  border: 0;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.history-actions button:hover:not(:disabled) {
  color: var(--accent);
  background: var(--card);
}

.history-actions button:disabled {
  color: var(--text-faint);
  opacity: 0.6;
  cursor: default;
}

/* ---------- 设置弹窗（iOS 毛玻璃 + 分组表单） ---------- */

.settings-dialog {
  width: min(540px, calc(100vw - 36px));
  max-height: min(84vh, 720px);
  padding: 24px 26px;
  overflow: auto;
  color: var(--text);
  background: var(--bg);
  border: 0.5px solid var(--separator);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 4px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 0;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.dialog-close:hover {
  color: var(--accent);
  background: var(--hairline);
}

/* 分组卡片 */

.settings-group {
  margin-top: 20px;
}

.group-label {
  margin: 0 0 8px;
  padding-left: 14px;
  color: var(--text-dim);
  font-family: var(--mono-font);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.settings-grid {
  overflow: hidden;
  padding: 0 16px;
  background: var(--surface);
  border-radius: 14px;
}

.settings-grid label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
}

.settings-grid label + label {
  border-top: 0.5px solid var(--separator);
}

.settings-grid label > span:first-child {
  color: var(--text);
  font-size: 15px;
  white-space: nowrap;
}

.settings-grid input[type="number"],
.settings-grid select {
  width: auto;
  min-width: 92px;
  padding: 8px 0;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: 0;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
  transition: color 0.15s ease;
}

.settings-grid input[type="number"]:focus,
.settings-grid select:focus {
  color: var(--text);
}

.day-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.day-row input {
  min-width: 52px;
}

.day-row em {
  color: var(--text-dim);
  font-size: 14px;
  font-style: normal;
  white-space: nowrap;
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.meta-line {
  margin: 18px 2px 0;
  color: var(--text-faint);
  font-family: var(--mono-font);
  font-size: 12px;
}

.dialog-done {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  color: var(--bg);
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.dialog-done:hover {
  color: var(--text);
  background: var(--bg);
}

/* ---------- 响应式 ---------- */

@media (max-width: 720px) {
  .site-frame {
    padding: 18px;
  }

  .header {
    padding-bottom: 24px;
  }

  .mode-container {
    top: 24px;
    right: 18px;
  }

  .limiter {
    padding-top: 28px;
  }

  .view-start {
    padding-top: 36px;
  }

  .report-summary {
    grid-template-columns: 1fr 1fr;
  }

  .report-row {
    grid-template-columns: 52px 1fr auto;
    gap: 8px;
  }

  .report-answer,
  .report-meaning {
    grid-column: 2 / -1;
  }

  .report-status {
    text-align: right;
  }

  .word-list button {
    grid-template-columns: 52px 1fr auto;
  }

  .history-record {
    grid-template-columns: 1fr;
  }

  .history-actions {
    flex-wrap: wrap;
  }
}
