/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a56db;
  --primary-light: #e8f0fe;
  --success: #0d904f;
  --success-light: #e6f4ea;
  --warning: #e37400;
  --warning-light: #fef7e0;
  --danger: #d93025;
  --danger-light: #fce8e6;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1f2937;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --nav-height: 56px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--nav-height) + 24px);
}

/* === Typography === */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
h4 { font-size: 1rem; font-weight: 600; }
p { margin-bottom: 0.75rem; }
a { color: var(--primary); text-decoration: none; }

/* === Header === */
.header {
  background: var(--primary);
  color: #fff;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-inner { max-width: 800px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.header h1 { font-size: 1.15rem; }
.header .sub { font-size: 0.8rem; opacity: 0.85; margin-top: 2px; }
.back-link { color: #fff; font-size: 0.9rem; opacity: 0.9; }

/* === Container === */
.container { max-width: 800px; margin: 0 auto; padding: 16px; }

/* === Cards === */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}

/* === Stats Row === */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}
.stat-card .num { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.stat-card .label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; }

/* === Countdown === */
.countdown {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  color: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
  margin-bottom: 16px;
}
.countdown .big { font-size: 2rem; font-weight: 800; }
.countdown .desc { font-size: 0.85rem; opacity: 0.9; }

/* === Callout Boxes === */
.callout {
  border-radius: 10px;
  padding: 14px 16px;
  margin: 12px 0;
  font-size: 0.9rem;
  line-height: 1.6;
  border-left: 4px solid;
}
.callout.tip { background: var(--success-light); border-color: var(--success); }
.callout.warn { background: var(--warning-light); border-color: var(--warning); }
.callout.danger { background: var(--danger-light); border-color: var(--danger); }
.callout.info { background: var(--primary-light); border-color: var(--primary); }
.callout strong { display: block; margin-bottom: 4px; }

/* === Accordion === */
.accordion { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 12px; background: var(--card); }
.accordion-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 14px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text);
  font-family: inherit;
}
.accordion-btn::after { content: '+'; font-size: 1.3rem; font-weight: 300; color: var(--text-secondary); }
.accordion.open .accordion-btn::after { content: '−'; }
.accordion-body { display: none; padding: 0 16px 16px; font-size: 0.9rem; }
.accordion.open .accordion-body { display: block; }

/* === Tables === */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 12px 0; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; font-weight: 600; position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

/* === Tag/Label === */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}
.tag.green { background: var(--success-light); color: var(--success); }
.tag.red { background: var(--danger-light); color: var(--danger); }
.tag.blue { background: var(--primary-light); color: var(--primary); }
.tag.orange { background: var(--warning-light); color: var(--warning); }

/* === Bottom Nav === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  height: var(--nav-height);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-decoration: none;
  border-top: 3px solid transparent;
}
.bottom-nav a.active { color: var(--primary); border-top-color: var(--primary); }
.bottom-nav a .icon { font-size: 1.2rem; margin-bottom: 2px; }

/* === Essay Template === */
.essay-block {
  background: #fafafa;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0;
  font-size: 0.85rem;
  white-space: pre-line;
  line-height: 1.8;
}
.essay-block.comment { border-style: solid; border-color: #fbbf24; background: #fffbeb; }

/* === Highlight === */
.highlight { background: #fef08a; padding: 1px 4px; border-radius: 3px; font-weight: 600; }

/* === Responsive === */
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  h1 { font-size: 1.75rem; }
}

/* === Print === */
@media print {
  .bottom-nav, .header { display: none; }
  body { padding-bottom: 0; }
}

/* === Topic Grid === */
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.topic-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.15s;
}
.topic-card:active { transform: scale(0.97); }
.topic-card .emoji { font-size: 1.5rem; display: block; margin-bottom: 6px; }

/* === Checklist === */
.checklist { list-style: none; padding: 0; }
.checklist li { padding: 6px 0; padding-left: 24px; position: relative; font-size: 0.9rem; }
.checklist li::before { content: '☐'; position: absolute; left: 0; }
.checklist li.done::before { content: '☑'; color: var(--success); }
