:root {
  --bg: #0f1419;
  --panel: #1a2030;
  --panel-2: #232b3d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #5c9fff;
  --accent-2: #4ecdc4;
  --accent-3: #ffd93d;
  --good: #51cf66;
  --bad: #ff6b6b;
  --warn: #ff922b;
  --code-bg: #0d1117;
  --border: #30363d;
  --email-bg: #111827;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

/* ── Header ── */
header {
  padding: 28px 24px;
  border-bottom: 4px solid var(--accent);
}
header h1 { margin: 0 0 8px; font-size: 22px; color: #fff; }
.meta {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  font-size: 13px;
}
.badge {
  background: rgba(0,0,0,0.35);
  padding: 4px 12px; border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.2); color: #fff;
}
.pill { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.pill-blue   { background: var(--accent); color: #000; }
.pill-green  { background: var(--good); color: #000; }
.pill-yellow { background: var(--accent-3); color: #000; }
.pill-red    { background: var(--bad); color: #fff; }
.pill-warn   { background: var(--warn); color: #000; }

.phase-p1 { background: linear-gradient(135deg, #1864ab 0%, #5c9fff 100%); }

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}
nav.toc {
  position: sticky; top: 24px;
  height: max-content;
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  font-size: 13px;
}
nav.toc h3 { margin: 0 0 10px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
nav.toc a {
  display: block; padding: 6px 10px;
  color: var(--text); text-decoration: none; border-radius: 4px;
  border-left: 2px solid transparent; transition: all 0.15s;
}
nav.toc a:hover { background: var(--panel-2); border-left-color: var(--accent-2); }
main { min-width: 0; }

/* ── Sections ── */
section {
  background: var(--panel);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}
section h2 {
  margin: 0 0 16px;
  color: var(--accent-2);
  border-bottom: 2px solid var(--border);
  padding-bottom: 8px;
  font-size: 19px;
}
section h3 { color: var(--accent-3); font-size: 15px; margin-top: 20px; margin-bottom: 10px; }

/* ── Tables ── */
table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
  border-radius: 6px; overflow: hidden;
}
th, td {
  padding: 10px 14px; text-align: left; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
th { background: var(--panel-2); color: var(--accent-3); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
td code { font-size: 12px; }

/* ── Email Card ── */
.email-card {
  background: var(--email-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 16px 0;
}
.email-header {
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  font-size: 13px;
}
.email-header .email-row {
  display: flex; gap: 8px; margin-bottom: 4px;
}
.email-header .label {
  color: var(--muted); min-width: 60px; font-weight: 500;
}
.email-header .email-subject {
  font-size: 15px; font-weight: 700; color: var(--accent-2);
  margin-bottom: 8px;
}
.email-body { padding: 18px; line-height: 1.8; font-size: 14px; }
.email-body p { margin: 0 0 14px; }
.email-signature { color: var(--muted); font-style: italic; }

/* ── Schedule Table ── */
.schedule-header {
  font-size: 15px; font-weight: 700;
  color: var(--accent-3); margin-bottom: 8px;
}
.schedule-note { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.highlight-row td { background: rgba(92, 159, 255, 0.1) !important; }
.highlight-row td:first-child { border-left: 3px solid var(--accent); }

/* ── Questions / Quiz ── */
.question-block {
  background: var(--code-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
  overflow: hidden;
}
.question-num {
  background: var(--panel-2);
  padding: 10px 16px;
  font-size: 13px; font-weight: 700;
  color: var(--accent); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.question-text { padding: 14px 16px; font-size: 15px; font-weight: 600; }
.choices { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.choice-label {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel-2);
  transition: background 0.15s, border-color 0.15s;
  font-size: 14px;
}
.choice-label:hover { background: rgba(78, 205, 196, 0.08); border-color: var(--accent-2); }
.choice-label input { display: none; }
.choice-label.selected { border-color: var(--accent-2); background: rgba(78, 205, 196, 0.1); }
.choice-label.correct  { border-color: var(--good); background: rgba(81, 207, 102, 0.12); }
.choice-label.wrong    { border-color: var(--bad); background: rgba(255, 107, 107, 0.12); }
.choice-key {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border);
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.check-btn {
  margin: 8px 16px 14px;
  background: var(--accent-2); color: #000; border: none;
  padding: 8px 18px; border-radius: 4px; cursor: pointer;
  font-weight: 600; font-size: 13px;
}
.check-btn:hover { background: #6ee7df; }
.answer-reveal { padding: 0 16px 14px; display: none; }
.answer-reveal.show { display: block; }
.answer-reveal .correct-mark { color: var(--good); font-weight: 700; }
.answer-reveal .wrong-mark   { color: var(--bad); font-weight: 700; }
.answer-reveal .explanation {
  margin-top: 8px; padding: 10px 14px;
  background: var(--panel); border-radius: 4px;
  border-left: 3px solid var(--accent-2); font-size: 13px;
}

/* ── Strategy SVG flow ── */
.svg-wrap {
  background: var(--code-bg); border-radius: 8px;
  padding: 16px; margin: 12px 0;
  border: 1px solid var(--border); overflow-x: auto;
}

/* ── Hints ── */
.hint {
  background: var(--panel-2);
  border-radius: 6px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent-3);
}
.hint summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-3);
  user-select: none; list-style: none;
}
.hint summary::-webkit-details-marker { display: none; }
.hint summary::before { content: "▶ "; font-size: 10px; }
.hint[open] summary::before { content: "▼ "; }
.hint[open] summary { border-bottom: 1px solid var(--border); }
.hint-body { padding: 12px 16px; font-size: 14px; }

/* ── Step-by-Step ── */
.step-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.step {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--code-bg);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 4px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #000;
  width: 28px; height: 28px; min-width: 28px; border-radius: 50%;
  font-weight: bold; font-size: 13px;
}

/* ── Score counter ── */
.score-bar {
  display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0;
}
.score-box {
  flex: 1; min-width: 120px;
  background: var(--panel-2);
  border-radius: 8px; padding: 14px; text-align: center;
  border: 1px solid var(--border);
}
.score-box .num { font-size: 32px; font-weight: 700; color: var(--accent-2); }
.score-box .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Self-eval ── */
.self-eval { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.self-eval label {
  background: var(--panel-2);
  padding: 10px 16px; border-radius: 20px;
  cursor: pointer; display: inline-flex; gap: 8px; align-items: center;
  border: 1px solid var(--border);
}
.self-eval input { accent-color: var(--accent-2); }
textarea {
  width: 100%; min-height: 80px;
  background: var(--code-bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  padding: 10px; font-family: inherit; font-size: 14px;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent-2); }

/* ── Trap / Warning ── */
.trap-box {
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-left: 4px solid var(--bad);
  border-radius: 6px; padding: 12px 16px; margin: 12px 0;
  font-size: 13px;
}
.trap-box strong { color: var(--bad); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; }
  nav.toc { position: static; }
}
