:root {
  --bg: #f6efe4;
  --bg-accent: #efe0c9;
  --surface: rgba(255, 252, 247, 0.86);
  --surface-strong: #fffaf2;
  --ink: #1b1a17;
  --muted: #6a6358;
  --line: rgba(27, 26, 23, 0.1);
  --primary: #b74d27;
  --primary-deep: #8e3718;
  --secondary: #1f5c59;
  --good: #2e7d32;
  --warn: #a66200;
  --bad: #a12d2d;
  --shadow: 0 20px 40px rgba(86, 58, 20, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(183, 77, 39, 0.12), transparent 32%),
    radial-gradient(circle at top right, rgba(31, 92, 89, 0.12), transparent 28%),
    linear-gradient(180deg, #f9f3ea 0%, var(--bg) 100%);
  color: var(--ink);
}

body {
  display: flex;
  justify-content: center;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1080px);
  min-height: 100vh;
  padding: 20px 16px 32px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 24px 20px 22px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(140deg, rgba(255, 248, 240, 0.96), rgba(248, 236, 214, 0.94)),
    var(--surface);
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  right: -36px;
  top: -40px;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(183, 77, 39, 0.18), transparent 70%);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.06;
}

.hero-copy {
  position: relative;
  z-index: 1;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.hero-stats,
.account-row,
.stat-grid,
.card-grid,
.plan-grid,
.filters-grid,
.module-grid,
.action-grid,
.question-meta,
.confidence-actions,
.review-grid,
.chips,
.tabbar {
  display: grid;
  gap: 12px;
}

.hero-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.account-row {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-top: 18px;
}

.mini-stat,
.surface-card,
.question-card,
.option,
.tab,
.pill,
.list-card,
.record-card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
}

.mini-stat {
  padding: 12px;
  border-radius: var(--radius-md);
}

.mini-stat strong,
.score-value,
.stat-value {
  display: block;
  font-size: 22px;
}

.mini-stat span,
.score-label,
.stat-label,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.tabbar {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin: 18px 0 16px;
}

.tab {
  min-height: 56px;
  padding: 10px 8px;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 252, 247, 0.72);
  font-size: 12px;
  line-height: 1.3;
}

.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  box-shadow: 0 12px 24px rgba(183, 77, 39, 0.22);
}

#view {
  display: grid;
  gap: 16px;
}

.surface-card,
.question-card,
.list-card,
.record-card {
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.surface-card h2,
.surface-card h3,
.question-card h2,
.question-card h3,
.list-card h3,
.record-card h3 {
  margin: 0 0 10px;
}

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

.section-head .pill {
  flex-shrink: 0;
}

.section-head p,
.section-copy,
.detail,
.explanation,
.quick-note p,
.focus-note p,
.module-copy,
.list-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.section-kicker {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.card-grid,
.stat-grid,
.module-grid,
.action-grid,
.review-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.plan-grid {
  grid-template-columns: 1fr;
}

.dashboard-lead {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at right top, rgba(183, 77, 39, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(255, 249, 241, 0.98), rgba(255, 252, 248, 0.92));
}

.dashboard-view {
  display: grid;
  gap: 16px;
}

.dashboard-basis-grid {
  grid-template-columns: 1fr;
}

.dashboard-basis-card {
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.68);
}

.dashboard-summary-strip,
.dashboard-main-grid {
  display: grid;
  gap: 16px;
}

.dashboard-summary-strip {
  margin-top: 18px;
}

.dashboard-summary-card,
.dashboard-profile-highlight {
  padding: 18px 20px;
  border-radius: 20px;
  border: 1px solid rgba(27, 26, 23, 0.08);
  background: rgba(255, 255, 255, 0.74);
}

.dashboard-summary-card.accent,
.dashboard-profile-highlight {
  background:
    linear-gradient(135deg, rgba(31, 92, 89, 0.08), rgba(183, 77, 39, 0.08)),
    rgba(255, 255, 255, 0.78);
}

.dashboard-summary-value,
.dashboard-profile-title {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.15;
}

.dashboard-main-grid {
  grid-template-columns: 1fr;
}

.dashboard-panel {
  display: grid;
  gap: 16px;
}

.dashboard-panel-warm {
  background:
    linear-gradient(180deg, rgba(255, 248, 239, 0.98), rgba(255, 252, 248, 0.92));
}

.dashboard-panel-cool {
  background:
    linear-gradient(180deg, rgba(245, 250, 248, 0.98), rgba(255, 252, 248, 0.92));
}

.dashboard-score-grid,
.dashboard-stat-grid {
  grid-template-columns: 1fr;
}

.dashboard-score-card {
  min-height: 184px;
}

.dashboard-actions {
  background:
    radial-gradient(circle at left top, rgba(31, 92, 89, 0.1), transparent 24%),
    linear-gradient(180deg, rgba(255, 251, 245, 0.98), rgba(255, 253, 250, 0.94));
}

.filters-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 8px;
}

.score-card,
.stat-card,
.module-card,
.action-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.score-card {
  background: linear-gradient(180deg, rgba(255, 245, 233, 0.98), #fff);
}

.score-card.focus {
  border-color: rgba(183, 77, 39, 0.28);
}

.score-bar,
.mastery-bar {
  margin-top: 10px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(27, 26, 23, 0.08);
}

.score-bar span,
.mastery-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
}

.pills,
.chips {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pill {
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.pill.primary {
  color: #fff;
  background: var(--secondary);
}

.pill.warn {
  background: rgba(166, 98, 0, 0.1);
  color: var(--warn);
}

.action-card {
  text-align: left;
}

.basics-view {
  display: grid;
  gap: 16px;
}

.basics-dual-grid,
.knowledge-module-grid,
.knowledge-mini-grid,
.knowledge-card-head,
.knowledge-badges {
  display: grid;
  gap: 12px;
}

.basics-dual-grid {
  grid-template-columns: 1fr;
}

.knowledge-module-grid {
  grid-template-columns: 1fr;
}

.knowledge-card {
  display: grid;
  gap: 14px;
  align-content: start;
  background: linear-gradient(180deg, rgba(255, 250, 243, 0.98), #fffdf9);
}

.knowledge-card-head {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.knowledge-card-title h3 {
  margin-bottom: 6px;
}

.knowledge-badges {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
}

.knowledge-summary {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.knowledge-mini-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.knowledge-mini-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(27, 26, 23, 0.08);
}

.knowledge-mini-card strong {
  font-size: 22px;
  line-height: 1;
}

.knowledge-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.knowledge-section.compact {
  margin-top: 0;
}

.knowledge-section strong {
  font-size: 14px;
}

.knowledge-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.knowledge-list.compact {
  gap: 6px;
}

.knowledge-list li {
  padding-left: 2px;
}

.knowledge-details {
  border-top: 1px dashed rgba(27, 26, 23, 0.12);
  padding-top: 12px;
}

.knowledge-details summary {
  cursor: pointer;
  color: var(--secondary);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
}

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

.knowledge-details-body {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.cta,
.ghost,
.small-btn,
.option,
.confidence-btn {
  width: 100%;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.cta,
.ghost,
.small-btn,
.confidence-btn {
  padding: 13px 14px;
  border-radius: 14px;
}

.cta {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  box-shadow: 0 16px 26px rgba(183, 77, 39, 0.22);
}

.ghost {
  color: var(--secondary);
  background: rgba(31, 92, 89, 0.08);
}

.ghost.compact {
  width: auto;
  min-width: 108px;
}

.small-btn {
  padding: 10px 12px;
  color: var(--primary);
  background: rgba(183, 77, 39, 0.08);
}

.cta:active,
.ghost:active,
.small-btn:active,
.option:active,
.confidence-btn:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

.question-card {
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.96), rgba(255, 247, 238, 0.88));
}

.question-card header {
  display: grid;
  gap: 12px;
}

.question-index {
  font-size: 12px;
  color: var(--primary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.question-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.5;
}

.question-meta {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.meta-box {
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(27, 26, 23, 0.08);
}

.meta-box span {
  display: block;
}

.option-list {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.option {
  padding: 14px;
  border-radius: 16px;
  text-align: left;
  background: rgba(255, 255, 255, 0.78);
}

.option.selected {
  border-color: rgba(31, 92, 89, 0.35);
  background: rgba(31, 92, 89, 0.08);
}

.option.correct {
  border-color: rgba(46, 125, 50, 0.35);
  background: rgba(46, 125, 50, 0.1);
}

.option.wrong {
  border-color: rgba(161, 45, 45, 0.35);
  background: rgba(161, 45, 45, 0.1);
}

.question-actions,
.session-footer {
  display: grid;
  gap: 10px;
}

.session-footer {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-banner {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
}

.result-banner.good {
  color: var(--good);
  background: rgba(46, 125, 50, 0.08);
}

.result-banner.bad {
  color: var(--bad);
  background: rgba(161, 45, 45, 0.08);
}

.explanation {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
}

.quick-note,
.focus-note {
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
}

.quick-note {
  background: rgba(31, 92, 89, 0.08);
  border: 1px solid rgba(31, 92, 89, 0.16);
}

.focus-note {
  background: rgba(183, 77, 39, 0.08);
  border: 1px solid rgba(183, 77, 39, 0.16);
}

.quick-note strong,
.focus-note strong {
  display: block;
  margin-bottom: 6px;
}

.confidence-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.confidence-btn {
  background: rgba(27, 26, 23, 0.06);
  color: var(--ink);
}

.confidence-btn.primary {
  color: #fff;
  background: var(--secondary);
}

.empty-state {
  padding: 28px 18px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: rgba(255, 252, 247, 0.72);
  border: 1px dashed rgba(27, 26, 23, 0.16);
  color: var(--muted);
}

.review-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.review-item strong {
  display: block;
  line-height: 1.5;
}

.review-related {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.review-related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.review-related-card {
  display: grid;
  gap: 4px;
  min-width: 140px;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(31, 92, 89, 0.12);
  border-radius: 14px;
  background: rgba(31, 92, 89, 0.06);
  color: var(--secondary);
  text-align: left;
}

.review-related-card span {
  font-size: 11px;
  color: var(--muted);
}

.review-related-card strong {
  font-size: 13px;
  line-height: 1.45;
}

.review-item-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.review-module-list {
  display: grid;
  gap: 18px;
}

.review-sort-chips {
  margin-bottom: 14px;
}

.review-filters-grid {
  margin-bottom: 12px;
}

.review-module-group {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(27, 26, 23, 0.08);
}

.review-group-pill {
  color: var(--secondary);
  background: rgba(31, 92, 89, 0.08);
}

.review-followup {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(31, 92, 89, 0.08);
  border: 1px solid rgba(31, 92, 89, 0.14);
}

.review-followup strong {
  font-size: 14px;
}

.review-followup p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.review-summary-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed rgba(27, 26, 23, 0.12);
}

.auth-card {
  max-width: 560px;
  margin: 0 auto;
}

.auth-form,
.field {
  display: grid;
  gap: 8px;
}

.auth-provider-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.auth-hint {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(31, 92, 89, 0.08);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid rgba(31, 92, 89, 0.14);
}

.auth-form {
  gap: 14px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 96px;
}

.form-message,
.memory-text {
  margin: 0;
  color: var(--bad);
  font-size: 13px;
  line-height: 1.6;
}

.note-field {
  margin-top: 14px;
}

@media (max-width: 420px) {
  .hero-stats,
  .account-row,
  .card-grid,
  .stat-grid,
  .filters-grid,
  .module-grid,
  .action-grid,
  .review-grid,
  .question-meta,
  .session-footer,
  .confidence-actions,
  .knowledge-mini-grid {
    grid-template-columns: 1fr;
  }

  .tabbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-summary-value,
  .dashboard-profile-title {
    font-size: 24px;
  }
}

@media (max-width: 768px) {
  .app-shell {
    padding: 12px 12px 24px;
  }

  .hero {
    padding: 18px 16px;
    border-radius: 22px;
  }

  .hero h1 {
    font-size: 26px;
    line-height: 1.12;
  }

  .hero-copy {
    font-size: 13px;
    line-height: 1.7;
  }

  .account-row,
  .hero-stats,
  .card-grid,
  .stat-grid,
  .plan-grid,
  .filters-grid,
  .module-grid,
  .action-grid,
  .review-grid,
  .review-item-actions,
  .question-meta,
  .session-footer,
  .confidence-actions,
  .knowledge-mini-grid,
  .dashboard-basis-grid,
  .dashboard-summary-strip,
  .dashboard-main-grid,
  .dashboard-score-grid,
  .dashboard-stat-grid {
    grid-template-columns: 1fr;
  }

  .account-row {
    align-items: stretch;
  }

  .ghost.compact {
    width: 100%;
    min-width: 0;
  }

  .tabbar {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(82px, 92px);
    grid-template-columns: none;
    overflow-x: auto;
    padding-bottom: 4px;
    margin: 14px 0;
    scrollbar-width: none;
  }

  .tabbar::-webkit-scrollbar {
    display: none;
  }

  .tab {
    min-height: 72px;
    border-radius: 20px;
    font-size: 13px;
  }

  .surface-card,
  .question-card,
  .list-card,
  .record-card {
    padding: 16px;
    border-radius: 20px;
  }

  .section-head {
    flex-direction: column;
  }

  .section-head h2 {
    font-size: 20px;
    line-height: 1.2;
  }

  .module-card h3,
  .score-card h3,
  .action-card h3,
  .list-card h3,
  .review-item strong {
    font-size: 18px;
    line-height: 1.4;
    word-break: break-word;
  }

  .question-title {
    font-size: 18px;
    line-height: 1.55;
  }

  .chips {
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .field input,
  .field textarea,
  .field select,
  .cta,
  .ghost,
  .small-btn,
  .confidence-btn {
    min-height: 50px;
  }
}

@media (min-width: 860px) {
  .app-shell {
    padding: 28px 22px 40px;
  }

  .hero h1 {
    font-size: 40px;
  }

  #view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  #view > .surface-card:first-child,
  #view > .question-card:first-child,
  #view > .basics-view,
  #view > .dashboard-view {
    grid-column: 1 / -1;
  }

  .dashboard-basis-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-summary-strip {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  }

  .dashboard-main-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }

  .dashboard-score-grid,
  .dashboard-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .basics-dual-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .knowledge-module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .knowledge-card-head {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}
