:root {
  --bg: #FAF8F4;
  --surface: #FFFFFF;
  --surface-alt: #F4EFE6;
  --border: #E5DEC9;
  --ink: #1E242B;
  --ink-muted: #5A626E;
  --accent: #A62626;
  --accent-soft: #FDF0EE;
  --accent-dark: #7E1B1B;
  --gold: #A66E1A;
  --gold-soft: #FDF6E7;
  --green: #1E6F4E;
  --green-soft: #ECF8F2;
  --shadow: 0 4px 18px rgba(30, 36, 43, 0.06);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Serif SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
}

.hidden {
  display: none !important;
}

/* Auth Screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top right, #F6EAE3 0%, var(--bg) 55%);
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.auth-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

.auth-subtitle {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--ink-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 18px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.form-group input,
.search-input,
.select-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
}

.form-group input:focus,
.search-input:focus,
.select-input:focus {
  outline: 2px solid rgba(166, 38, 38, 0.2);
  border-color: var(--accent);
}

.auth-error {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #F2C4C4;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-quick {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.auth-hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-full {
  width: 100%;
}

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

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

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

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

.btn-ghost {
  background: transparent;
  color: var(--ink-muted);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.btn-success {
  background: var(--green-soft);
  color: var(--green);
  border-color: #B7E1CC;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-seal {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
}

.brand-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-btn {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.user-name {
  font-weight: 700;
}

.user-streak {
  color: var(--accent);
  font-weight: 600;
}

/* Stats Strip */
.stats-strip {
  max-width: 1280px;
  margin: 16px auto 0;
  padding: 0 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

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

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 2px;
}

/* Main */
.main-container {
  max-width: 1280px;
  margin: 16px auto 48px;
  padding: 0 20px;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-header h2 {
  margin: 0;
  font-size: 20px;
}

.section-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.subtabs {
  display: flex;
  gap: 6px;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: 10px;
}

.subtab {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.subtab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* Daily View */
.daily-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

.panel-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.box-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
}

.report-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-nav-item {
  text-align: left;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.report-nav-item:hover {
  border-color: var(--accent);
}

.report-nav-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.report-nav-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.report-nav-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.daily-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.daily-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--ink-muted);
}

.pill-red {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-gold {
  background: var(--gold-soft);
  color: var(--gold);
}

.pill-green {
  background: var(--green-soft);
  color: var(--green);
}

.daily-hero h1 {
  margin: 8px 0 10px;
  font-size: 22px;
}

.daily-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.news-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.news-card h3 {
  margin: 8px 0 10px;
  font-size: 18px;
}

.book-anchor-box {
  background: var(--gold-soft);
  border: 1px solid #ECD8AC;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

.quote-box {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin: 10px 0;
  font-size: 14px;
}

.inline-hats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mini-hat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.mini-hat-keyword {
  color: var(--accent);
  font-weight: 700;
}

.exam-tip-box {
  margin-top: 12px;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}

/* Retrospective Timeline & Qiushi Table */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.hat-filters > * {
  flex: 1 1 180px;
}

.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.timeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
}

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

.data-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.data-table .pill {
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-alt);
  font-weight: 700;
}

/* Hats Flashcards */
.summary-line {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.hats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}

.hat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hat-card.is-mastered {
  border-color: #9ED6B8;
  background: #FBFEFC;
}

.hat-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.hat-statement {
  font-size: 15px;
  font-weight: 600;
}

.hat-blank {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px dashed var(--accent);
  cursor: pointer;
}

.hat-blank.concealed {
  background: var(--accent);
  color: transparent;
  user-select: none;
}

.hat-trap {
  font-size: 13px;
  color: var(--ink-muted);
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 8px;
}

.hat-meta {
  font-size: 12px;
  color: var(--ink-muted);
}

.hat-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* Quiz */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.quiz-question {
  font-size: 16px;
  font-weight: 700;
  margin: 8px 0 14px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: var(--bg);
}

.quiz-option:hover {
  border-color: var(--accent);
}

.quiz-feedback {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
}

.quiz-feedback.correct {
  background: var(--green-soft);
  border: 1px solid #B7E1CC;
}

.quiz-feedback.wrong {
  background: var(--accent-soft);
  border: 1px solid #F2C4C4;
}

/* Book TOC */
.toc-layout {
  display: grid;
  grid-template-columns: 390px 1fr;
  gap: 18px;
  align-items: start;
}

.toc-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.toc-module {
  margin-bottom: 14px;
}

.toc-module-title {
  font-weight: 700;
  font-size: 14px;
  padding: 6px 8px;
  background: var(--surface-alt);
  border-radius: 8px;
  margin-bottom: 6px;
}

.toc-chapter-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.toc-chapter-btn:hover {
  background: var(--bg);
}

.toc-chapter-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 600;
}

.toc-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.empty-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--ink-muted);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 50;
}

@media (max-width: 920px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .daily-layout,
  .toc-layout {
    grid-template-columns: 1fr;
  }
  .hats-grid {
    grid-template-columns: 1fr;
  }
}
