* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Light mode (default) */
:root {
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f1f3;
  --text: #1a1a2e;
  --text-muted: #555770;
  --accent: #16a34a;
  --accent-dim: #15803d;
  --border: #e2e4e9;
  --danger: #dc2626;
  --nav-bg: rgba(248, 249, 250, 0.9);
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #222636;
    --text: #e4e4e7;
    --text-muted: #9ca3af;
    --accent: #22c55e;
    --accent-dim: #16a34a;
    --border: #2a2d3a;
    --danger: #ef4444;
    --nav-bg: rgba(15, 17, 23, 0.9);
  }
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 17px;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Nav */
nav {
  position: sticky;
  top: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  padding: 16px 0;
}

nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav .logo {
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  text-decoration: none;
}

.lang-switch {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.lang-switch a {
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.lang-switch a.active {
  background: var(--accent);
  color: #fff;
}

/* Hero */
.hero {
  padding: 80px 0 60px;
  text-align: center;
}

.hero h1 {
  font-size: 42px;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--accent), #16a34a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@media (prefers-color-scheme: dark) {
  .hero h1 {
    background: linear-gradient(135deg, var(--accent), #86efac);
    -webkit-background-clip: text;
    background-clip: text;
  }
}

.hero .subtitle {
  font-size: 20px;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 32px;
}

.hero .badge {
  display: inline-block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 8px 20px;
  border-radius: 100px;
  font-size: 14px;
  color: var(--text-muted);
}

/* Sections */
section {
  padding: 60px 0;
  border-top: 1px solid var(--border);
}

section h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text);
}

section h3 {
  font-size: 20px;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--accent);
}

section h4 {
  font-size: 17px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text);
}

p {
  margin-bottom: 16px;
  color: var(--text-muted);
}

strong {
  color: var(--text);
  font-weight: 600;
}

/* Lists */
ul, ol {
  margin: 0 0 16px 20px;
  color: var(--text-muted);
}

li {
  margin-bottom: 6px;
}

li strong {
  color: var(--text);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (min-width: 640px) {
  .card-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.card h4 {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 16px;
}

.card p {
  margin: 0;
  font-size: 15px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 15px;
}

th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

tr:hover td {
  background: var(--bg-card);
}

/* Callout */
.callout {
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  padding: 20px 24px;
  border-radius: 0 12px 12px 0;
  margin-bottom: 24px;
}

.callout.warning {
  border-left-color: #f59e0b;
}

.callout.danger {
  border-left-color: var(--danger);
}

.callout p {
  margin: 0;
}

/* Checklist */
.checklist {
  list-style: none;
  margin-left: 0;
  padding: 0;
}

.checklist li {
  position: relative;
  padding: 8px 0 8px 32px;
  border-bottom: 1px solid var(--border);
}

.checklist li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
}

/* Plate diagram */
.plate-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin: 32px 0;
  flex-wrap: wrap;
}

.plate-circle {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 4px solid var(--border);
  position: relative;
  overflow: hidden;
}

.plate-half {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: #dcfce7;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #166534;
  line-height: 1.4;
  border-right: 3px solid var(--bg);
  padding: 0 12% 0 8%;
}

.plate-quarter-top {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 50%;
  background: #dbeafe;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #1e3a5f;
  line-height: 1.4;
  border-bottom: 3px solid var(--bg);
  padding: 8% 8% 0 0;
}

.plate-quarter-bottom {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 50%;
  height: 50%;
  background: #ffedd5;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #7c2d12;
  line-height: 1.4;
  padding: 0 8% 8% 0;
}

.plate-side {
  background: #fef3c7;
  color: #78350f;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.plate-side strong {
  color: inherit;
}

.plate-side span {
  font-weight: 400;
  font-size: 12px;
}

@media (prefers-color-scheme: dark) {
  .plate-half { background: #166534; color: #86efac; }
  .plate-quarter-top { background: #1e3a5f; color: #93c5fd; }
  .plate-quarter-bottom { background: #7c2d12; color: #fdba74; }
  .plate-half { border-right-color: var(--bg); }
  .plate-quarter-top { border-bottom-color: var(--bg); }
  .plate-side {
    background: #422006;
    color: #fde68a;
  }
}

/* Habits timeline */
.habit-step {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.habit-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}

.habit-text {
  padding-top: 8px;
  color: var(--text-muted);
}

/* Rules grid */
.rule {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}

.rule-num {
  flex-shrink: 0;
  color: var(--accent);
  font-weight: 700;
  font-size: 20px;
  width: 30px;
}

.rule-text {
  color: var(--text-muted);
}

/* TOC */
.toc {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 32px 0;
}

@media (min-width: 640px) {
  .toc {
    grid-template-columns: 1fr 1fr;
  }
}

.toc a {
  display: block;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 15px;
  transition: all 0.2s;
}

.toc a:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* Footer */
footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

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

/* Responsive */
@media (max-width: 640px) {
  .hero h1 {
    font-size: 28px;
  }
  .hero .subtitle {
    font-size: 17px;
  }
  section h2 {
    font-size: 22px;
  }
  body {
    font-size: 16px;
  }
  table {
    font-size: 13px;
  }
  th, td {
    padding: 8px 10px;
  }
}
