:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #16202b;
  --text-dim: #5a6874;
  --line: #d9e0e8;
  --accent: #0f6e8c;
  --accent-soft: #e3f1f6;
  --ok: #1a7f5a;
  --ok-soft: #e2f4ec;
  --warn: #a76a00;
  --warn-soft: #fdf1dc;
  --dang: #b3321f;
  --dang-soft: #fceae7;
  --shadow: 0 1px 2px rgba(16,32,43,.06), 0 6px 20px rgba(16,32,43,.05);
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "Consolas", "Menlo", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN",
          "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1419; --surface: #161e26; --surface-2: #1d2831;
    --text: #e6edf3; --text-dim: #9aa9b6; --line: #2a3742;
    --accent: #4db8d8; --accent-soft: #16303b;
    --ok: #5ad4a3; --ok-soft: #14302a;
    --warn: #e8b45c; --warn-soft: #33290f;
    --dang: #f08574; --dang-soft: #3a1d18;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.28);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1419; --surface: #161e26; --surface-2: #1d2831;
  --text: #e6edf3; --text-dim: #9aa9b6; --line: #2a3742;
  --accent: #4db8d8; --accent-soft: #16303b;
  --ok: #5ad4a3; --ok-soft: #14302a;
  --warn: #e8b45c; --warn-soft: #33290f;
  --dang: #f08574; --dang-soft: #3a1d18;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.28);
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef1f5;
  --text: #16202b; --text-dim: #5a6874; --line: #d9e0e8;
  --accent: #0f6e8c; --accent-soft: #e3f1f6;
  --ok: #1a7f5a; --ok-soft: #e2f4ec;
  --warn: #a76a00; --warn-soft: #fdf1dc;
  --dang: #b3321f; --dang-soft: #fceae7;
  --shadow: 0 1px 2px rgba(16,32,43,.06), 0 6px 20px rgba(16,32,43,.05);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.85;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 18px 70px;
}

/* ---------- header ---------- */
.masthead {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.masthead-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
.brand span { color: var(--accent); }
.deadline-chip {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--dang-soft);
  color: var(--dang);
  border: 1px solid color-mix(in srgb, var(--dang) 30%, transparent);
  white-space: nowrap;
}
.backlink {
  display: inline-block;
  margin: 22px 0 0;
  font-size: 14px;
  color: var(--text-dim);
  text-decoration: none;
}
.backlink:hover { color: var(--accent); }

/* ---------- typography ---------- */
h1 {
  font-size: clamp(25px, 6.5vw, 33px);
  line-height: 1.35;
  margin: 20px 0 8px;
  letter-spacing: -.01em;
}
.lede {
  color: var(--text-dim);
  font-size: 16px;
  margin: 0 0 26px;
}
h2 {
  font-size: clamp(19px, 5vw, 23px);
  line-height: 1.45;
  margin: 46px 0 14px;
  padding-bottom: 9px;
  border-bottom: 2px solid var(--line);
  letter-spacing: -.01em;
}
h3 { font-size: 17px; line-height: 1.55; margin: 30px 0 8px; }
h4 { font-size: 15px; margin: 22px 0 6px; color: var(--text-dim); }
p { margin: 0 0 15px; }
a { color: var(--accent); }
small { font-size: 13.5px; color: var(--text-dim); }
strong { font-weight: 700; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.stackgrid { display: grid; gap: 14px; margin: 18px 0; }

.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 15px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 20px 0;
}
.callout.danger { border-color: var(--dang); background: var(--dang-soft); }
.callout.warn   { border-color: var(--warn); background: var(--warn-soft); }
.callout.ok     { border-color: var(--ok);   background: var(--ok-soft); }
.callout > :last-child { margin-bottom: 0; }

/* ---------- tables : stack into cards on mobile ---------- */
.tablewrap {
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 11px 15px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--surface-2); font-weight: 600; font-size: 13px; color: var(--text-dim); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
tr.total td { font-weight: 700; background: var(--surface-2); }

@media (max-width: 680px) {
  .tablewrap { border: none; background: transparent; overflow: visible; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { display: none; }
  table.stack tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px 0 10px;
    margin-bottom: 12px;
  }
  table.stack td { border: none; padding: 6px 16px; }
  table.stack td::before {
    content: attr(data-l);
    display: block;
    font-size: 11.5px;
    line-height: 1.6;
    letter-spacing: .04em;
    color: var(--text-dim);
    font-weight: 700;
  }
  table.stack td:first-child {
    font-weight: 700;
    font-size: 16px;
    padding-top: 12px;
  }
  table.stack td:first-child::before { display: none; }
  table.stack td.num { text-align: left; }
  table.stack tr.total { background: var(--accent-soft); border-color: var(--accent); }
  table.stack tr.total td { background: transparent; }
}

/* ---------- badges ---------- */
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 1px 9px;
  border-radius: 999px;
  line-height: 1.75;
  white-space: nowrap;
}
.badge.ok   { background: var(--ok-soft);   color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.dang { background: var(--dang-soft); color: var(--dang); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.mute { background: var(--surface-2); color: var(--text-dim); }

/* ---------- lists ---------- */
ul, ol { margin: 0 0 15px; padding-left: 24px; }
li { margin-bottom: 8px; }
ul.check { list-style: none; padding-left: 0; }
ul.check li { padding-left: 30px; position: relative; margin-bottom: 14px; }
ul.check li::before {
  content: "☐";
  position: absolute; left: 2px; top: -1px;
  color: var(--accent); font-size: 18px;
}
ul.clean { list-style: none; padding-left: 0; }
ul.clean li { padding-left: 20px; position: relative; }
ul.clean li::before {
  content: ""; position: absolute; left: 4px; top: 13px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

/* ---------- nav cards (vertical) ---------- */
.navcards { display: grid; gap: 12px; margin: 22px 0; }
.navcard {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 17px 19px;
  box-shadow: var(--shadow);
}
.navcard:active { background: var(--surface-2); }
.navcard:hover { border-color: var(--accent); }
.navcard .kicker {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  letter-spacing: .1em; text-transform: uppercase;
}
.navcard .t { font-weight: 700; font-size: 17px; margin: 3px 0 5px; }
.navcard .d { font-size: 14px; color: var(--text-dim); line-height: 1.65; }

/* ---------- timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 22px 0; }
.timeline li {
  position: relative;
  padding: 0 0 24px 26px;
  border-left: 2px solid var(--line);
  margin: 0;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute; left: -8px; top: 7px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 3px solid var(--accent);
}
.timeline li.crit::before { border-color: var(--dang); }
.timeline li.done::before { background: var(--ok); border-color: var(--ok); }
.timeline li.rest::before { background: var(--surface-2); border-color: var(--line); }
.timeline .date {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  color: var(--accent); display: block; line-height: 1.6;
}
.timeline li.crit .date { color: var(--dang); }
.timeline li.rest .date { color: var(--text-dim); }
.timeline .what { font-weight: 700; display: block; line-height: 1.6; }
.timeline .note { font-size: 14px; color: var(--text-dim); display: block; line-height: 1.7; }

/* ---------- misc ---------- */
dl.kv { margin: 12px 0; }
dl.kv dt {
  font-size: 12px; color: var(--text-dim); font-weight: 700;
  letter-spacing: .04em; margin-top: 12px;
}
dl.kv dd { margin: 0; font-size: 15.5px; }

.script {
  font-family: var(--mono);
  font-size: 13.5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px 16px;
  white-space: pre-wrap;
  line-height: 1.85;
  margin: 14px 0;
}

.tel {
  font-family: var(--mono); font-weight: 700; font-size: 16px;
  color: var(--accent); text-decoration: none;
  display: inline-block; padding: 2px 0;
}

.bar {
  display: block; height: 9px; border-radius: 5px;
  background: var(--accent); margin: 5px 0 2px; min-width: 3px;
}
.bar.dim { background: var(--text-dim); opacity: .45; }
.bar.good { background: var(--ok); }
.bar.bad { background: var(--dang); }

footer {
  margin-top: 56px; padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--text-dim); line-height: 1.8;
}
footer a { color: var(--text-dim); }

.pagenav { display: grid; gap: 10px; margin-top: 40px; }
.pagenav a {
  font-size: 15px; text-decoration: none; font-weight: 600;
  padding: 13px 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); text-align: center;
}
.pagenav a:hover { border-color: var(--accent); }

@media (min-width: 681px) {
  .stackgrid.two { grid-template-columns: 1fr 1fr; }
  .pagenav { grid-template-columns: 1fr 1fr; }
}
