:root {
  --navy: #003a73;
  --navy-dark: #002a54;
  --indigo: #4263eb;
  --indigo-soft: #edf0fe;
  --ink: #1c2b36;
  --gray: #5b6b78;
  --line: #dde5ec;
  --bg: #f5f8fa;
  --white: #ffffff;
  --accent: #ff7a45;
  --grape: #9c36b5;
  --grape-soft: #f6ecfa;
  --green: #2bb673;
  --red: #e0443a;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(0, 42, 84, 0.08);
  --mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Noto Sans JP', 'Inter', sans-serif; color: var(--ink); background: var(--bg); line-height: 1.8; }
.container { max-width: 980px; margin: 0 auto; padding: 0 20px; }

/* ---------- header / hero ---------- */
.site-header { position: sticky; top: 0; z-index: 100; background: var(--navy); box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.header-inner { max-width: 980px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; height: 58px; }
.logo { color: #fff; font-weight: 900; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.logo-mark { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: var(--grape); color: #fff; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a { color: #cfe3f5; text-decoration: none; font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 999px; transition: .15s; }
.nav a:hover { background: rgba(255,255,255,.14); color: #fff; }
.nav .nav-home { background: rgba(255,255,255,.14); color: #fff; font-weight: 700; border: 1px solid rgba(255,255,255,.25); }
.nav .nav-home:hover { background: var(--grape); border-color: var(--grape); }

.hero { background: linear-gradient(135deg, var(--navy) 0%, #5b2b7a 76%, #9c36b5 100%); color: #fff; padding: 64px 0 56px; }
.hero-eyebrow { font-family: 'Inter', sans-serif; font-weight: 600; font-size: 12px; letter-spacing: .2em; color: #e6c4f0; margin: 0 0 10px; }
.hero h1 { font-size: 38px; font-weight: 900; margin: 0 0 16px; letter-spacing: .02em; }
.hero-lead { font-size: 15px; color: #ead9f0; margin: 0 0 28px; }
.hero-lead strong { color: #fff; }
.hero-steps { display: flex; gap: 10px; flex-wrap: wrap; }
.step-chip { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3); color: #fff; text-decoration: none; font-size: 13px; font-weight: 700; padding: 8px 16px; border-radius: 999px; transition: .15s; }
.step-chip:hover { background: var(--grape); border-color: var(--grape); }

/* ---------- lesson ---------- */
.lesson { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 36px 32px; margin: 36px 0; }
.lesson-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.step-badge { background: var(--grape); color: #fff; font-family: 'Inter', sans-serif; font-weight: 800; font-size: 12px; letter-spacing: .08em; padding: 4px 12px; border-radius: 999px; }
.lesson h2 { font-size: 23px; font-weight: 900; color: var(--navy); margin: 0; }
.lesson-desc { color: var(--gray); font-size: 14.5px; margin: 10px 0 20px; }
.lesson-desc strong { color: var(--navy); }
.sim-note { display: flex; gap: 8px; background: #fff8ef; border: 1px solid #f0c98a; border-radius: 10px; padding: 12px 15px; margin: 6px 0 18px; font-size: 12.5px; line-height: 1.75; color: #7a5327; }
.sim-note b { color: #9a5b00; }

/* ---------- STEP 1: cards ---------- */
.know-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 20px; }
.know-card { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 14px; }
.know-icon { font-size: 22px; }
.know-card h3 { font-size: 14.5px; color: var(--navy); margin: 6px 0 6px; }
.know-card p { font-size: 13px; color: var(--gray); margin: 0; line-height: 1.7; }
.know-card p strong { color: var(--navy); }

/* ---------- STEP 2: halftone sim ---------- */
.ht { margin-top: 22px; display: grid; grid-template-columns: 1.05fr 1fr; gap: 22px; align-items: start; }
.ht-stage { display: flex; align-items: center; justify-content: center; min-height: 340px; background: #eef2f7; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; padding: 10px; }
#ht-canvas { background: #fff; border-radius: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.12); image-rendering: auto; transition: width .12s; max-width: 100%; }
.ht-panel { display: flex; flex-direction: column; gap: 12px; }
.ht-mode { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ht-mode-label { font-size: 12.5px; font-weight: 800; color: var(--navy); }
.ht-mb { font-family: inherit; font-size: 12.5px; font-weight: 700; color: var(--navy); background: #fff; border: 1.5px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; transition: .12s; }
.ht-mb:hover { border-color: var(--grape); }
.ht-mb.is-on { background: var(--grape); border-color: var(--grape); color: #fff; }
.ht-toggle { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 700; color: var(--navy); cursor: pointer; }
.ht-toggle input { width: 17px; height: 17px; accent-color: var(--grape); cursor: pointer; }
.ht-slider { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 800; color: var(--navy); }
.ht-slider input { width: 100%; accent-color: var(--grape); }
.ht-cellval { font-size: 12px; color: var(--gray); margin-top: -4px; }
.ht-readout { font-size: 13px; line-height: 1.7; color: var(--navy); background: var(--grape-soft); border: 1px solid #e6cef0; border-radius: 10px; padding: 11px 14px; }
.ht-readout b { color: var(--grape); }
.ht-hint { font-size: 12.5px; color: var(--gray); margin: 0; line-height: 1.8; }
.ht-hint b { color: var(--grape); }

/* ---------- STEP 3: resolution ---------- */
.res { margin-top: 22px; display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }
.res-stage { position: relative; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; box-shadow: var(--shadow); }
#res-canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.res-tag { position: absolute; top: 8px; left: 8px; font-family: 'Inter', sans-serif; font-weight: 800; font-size: 13px; color: #fff; background: rgba(28,43,54,.82); padding: 3px 10px; border-radius: 999px; }
.res-panel { display: flex; flex-direction: column; gap: 12px; }
.res-scale { display: flex; justify-content: space-between; font-size: 11px; font-weight: 700; color: var(--gray); margin-top: -4px; }
.res-compare { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--gray); }
.res-compare b { color: var(--navy); }
.res-badge { display: inline-block; font-size: 11px; font-weight: 800; color: #fff; border-radius: 999px; padding: 2px 10px; margin-right: 4px; }
.res-badge.ok { background: var(--green); }
.res-badge.warn { background: var(--grape); }

/* ---------- quiz (4択共通) ---------- */
.quiz-box { border: 2px solid var(--line); border-radius: 14px; background: #fff; padding: 26px 28px; }
.quiz-progress { display: flex; justify-content: space-between; align-items: center; font-family: 'Inter', sans-serif; font-weight: 600; font-size: 13px; color: var(--gray); margin-bottom: 12px; }
.quiz-q { font-size: 16.5px; font-weight: 900; color: var(--navy); margin-bottom: 16px; line-height: 1.7; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-opt { font-family: inherit; font-size: 15px; font-weight: 700; color: var(--navy); background: var(--bg); border: 2px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; transition: .12s; text-align: left; }
.quiz-opt:hover { border-color: var(--grape); background: var(--grape-soft); }
.quiz-opt.is-correct { border-color: var(--green); background: #f2fbf6; }
.quiz-opt.is-wrong { border-color: var(--red); background: #fdf0ef; }
.quiz-opt:disabled { cursor: default; }
.quiz-note { margin-top: 14px; background: var(--grape-soft); border-radius: 10px; padding: 12px 16px; font-size: 13.5px; color: #6a2482; }
.quiz-note[hidden] { display: none; }
.quiz-final { text-align: center; padding: 10px 0; }
.quiz-final .qf-score { font-family: 'Inter', sans-serif; font-weight: 800; font-size: 50px; color: var(--navy); }
.quiz-final .qf-score small { font-size: 18px; }
.quiz-final p { margin: 6px 0 14px; font-weight: 900; color: var(--navy); }

/* ---------- btn / toast / table / note ---------- */
.btn { font-family: inherit; font-size: 13.5px; font-weight: 700; padding: 9px 18px; border-radius: 999px; cursor: pointer; border: 1.5px solid var(--line); background: #fff; color: var(--navy); transition: .15s; }
.btn:hover { border-color: var(--grape); color: var(--grape); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); color: #fff; }
.shortcut-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.shortcut-table th, .shortcut-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.shortcut-table th { background: var(--bg); color: var(--navy); font-size: 12.5px; }
.shortcut-table td:first-child { white-space: nowrap; font-weight: 700; color: var(--navy); }
.note { margin-top: 18px; background: var(--grape-soft); border: 1px solid #e6cef0; border-radius: 10px; padding: 16px 20px; font-size: 13.5px; color: #5c2b70; line-height: 1.9; }
.note strong { color: var(--grape); }
.note b { color: var(--navy); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--navy); color: #fff; font-size: 13.5px; font-weight: 700; padding: 10px 22px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 1000; transition: opacity .3s; max-width: 90vw; text-align: center; }
.toast[hidden] { display: none; }
.site-footer { background: var(--navy); color: #9fc0dd; text-align: center; padding: 24px 20px; font-size: 12.5px; margin-top: 48px; }
.site-footer p { margin: 0; }

/* ---------- page nav ---------- */
.page-nav { display: flex; gap: 12px; align-items: stretch; margin: 44px auto 0; }
.pgnav { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 3px; text-decoration: none; background: #fff; border: 1.5px solid #dde5ec; border-radius: 12px; padding: 14px 18px; transition: .15s; box-shadow: 0 2px 12px rgba(0,42,84,.08); }
.pgnav:hover { border-color: var(--grape); transform: translateY(-2px); }
.pgnav.prev { text-align: left; }
.pgnav.top { flex: 0 0 130px; text-align: center; background: #003a73; border-color: #003a73; }
.pgnav.top .pgnav-dir, .pgnav.top .pgnav-name { color: #fff; }
.pgnav.top:hover { background: #002a54; border-color: #002a54; }
.pgnav-dir { font-size: 12px; font-weight: 700; color: var(--grape); }
.pgnav-name { font-size: 14px; font-weight: 900; color: #003a73; }
.pgnav.is-disabled { visibility: hidden; }

@media (max-width: 760px) {
  .hero h1 { font-size: 25px; }
  .lesson { padding: 24px 18px; }
  .header-inner { flex-direction: column; height: auto; padding: 10px 20px; gap: 4px; }
  .ht, .res { grid-template-columns: 1fr; }
}
@media (max-width: 560px) { .page-nav { flex-wrap: wrap; } .pgnav.top { order: -1; flex-basis: 100%; } .quiz-opts { grid-template-columns: 1fr; } }
