/* AI Attack Strata — all spacing on an 8px grid */
:root {
  --bg: #f7f6f2;
  --panel: #ffffff;
  --side: #efede6;
  --ink: #1c1b19;
  --muted: #5f5c55;
  --line: #d9d6cc;
  --flow: #c2beb2;
  --node: #ffffff;
  --focus: #1c1b19;
  --on-layer: #ffffff;
  --harm: #b91c1c;

  --L1: #8a877f;
  --L2: #0f766e;
  --L3: #2563eb;
  --L4: #7c3aed;
  --L5: #c2410c;
  --L6: #be185d;
  --L7: #4d7c0f;

  --radius: 8px;
  font-family: "BIZ UDPGothic", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161614;
    --panel: #1f1f1c;
    --side: #1b1b19;
    --ink: #eceae4;
    --muted: #a6a39a;
    --line: #3a3934;
    --flow: #4a4843;
    --node: #262622;
    --focus: #eceae4;
    --on-layer: #161614;
    --harm: #f87171;

    --L1: #8f8c84;
    --L2: #2dd4bf;
    --L3: #60a5fa;
    --L4: #a78bfa;
    --L5: #fb923c;
    --L6: #f472b6;
    --L7: #a3e635;
  }
}

* { box-sizing: border-box; }
/* Break Japanese text between phrases, not in the middle of a word. */
:lang(ja) body { word-break: keep-all; overflow-wrap: anywhere; line-break: strict; }
/* A sentence moves to the next line as a whole when it would otherwise be split; long ones still wrap inside. */
.sent { display: inline-block; max-width: 100%; }
.ph { white-space: nowrap; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.7; font-size: 16px; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
p { margin: 0 0 8px; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
ul, ol { margin: 0; padding-left: 24px; }
li { margin-bottom: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hint { color: var(--muted); font-size: 14px; }

/* ---------- top bar + icon rail (always visible) + flyout panel ---------- */
:root { --bar: 56px; --rail-w: 96px; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; height: var(--bar);
  padding: 0 24px; background: var(--side); border-bottom: 1px solid var(--line);
}
.logo { font-size: 18px; font-weight: 700; letter-spacing: .02em; text-decoration: none; white-space: nowrap; }
.copyright { color: var(--muted); font-size: 12px; white-space: nowrap; }
.foot-mobile { display: none; }
.tagline { color: var(--muted); font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); }
.rail {
  position: sticky; top: var(--bar); height: calc(100vh - var(--bar)); overflow-y: auto;
  background: var(--side); border-right: 1px solid var(--line); padding: 8px 0;
  display: flex; flex-direction: column; gap: 2px;
}
.rail-item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: 0; padding: 8px 4px; margin: 0 6px; border-radius: 8px; color: var(--muted);
}
.rail-item:hover { background: var(--line); color: var(--ink); }
.rail-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.rail-label { font-size: 11px; line-height: 1.25; text-align: center; white-space: pre-line; }
.rail-chip { display: inline-block; min-width: 32px; padding: 1px 4px; border-radius: 6px; color: var(--on-layer); font-size: 12px; font-weight: 700; text-align: center; }
.rail-item[data-out] { opacity: .6; }
/* Current section: a bar on the left edge, like a selected tab. */
.rail-item.here { color: var(--ink); background: var(--panel); }
.rail-item.here::before { content: ""; position: absolute; left: -6px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--ink); }
.rail-item.open { background: var(--panel); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.rail-sep { height: 1px; background: var(--line); margin: 6px 14px; flex: none; }

.flyout {
  position: fixed; top: var(--bar); left: var(--rail-w); bottom: 0; z-index: 25; width: 320px; max-width: calc(100vw - var(--rail-w));
  background: var(--panel); border-right: 1px solid var(--line); box-shadow: 8px 0 24px rgba(0, 0, 0, .18); overflow-y: auto;
}
.fly-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 16px 16px 16px 24px; border-bottom: 1px solid var(--line); }
.fly-head h2 { font-size: 18px; display: flex; align-items: center; gap: 8px; }
.close-btn { background: none; border: 0; font-size: 24px; line-height: 1; padding: 4px 8px; color: var(--muted); }
.close-btn:hover { color: var(--ink); }
#fly-body ul { list-style: none; padding: 16px 12px; margin: 0; }
#fly-body li { margin: 0; }
#fly-body a { display: block; text-decoration: none; padding: 8px 12px; border-radius: 6px; font-size: 15px; }
#fly-body a.muted { font-size: 13px; }
#fly-body a:hover { background: var(--bg); }
#fly-body a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.chip { display: inline-block; width: 8px; height: 16px; border-radius: 4px; flex: none; }
.chip.big { width: 12px; height: 32px; margin-right: 16px; vertical-align: middle; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; flex: none; }
.seg button { background: none; border: 0; padding: 4px 16px; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.content { padding: 24px 24px 48px; outline: none; min-width: 0; }

/* ---------- overview: map and notes share the same top and bottom edges ---------- */
.overview { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: stretch; }
.overview .map-fig { margin: 0; }
.overview .map { max-height: calc(100vh - 272px); }
/* The map sets the row height; the notes column fits into it and scrolls if it must. */
.ov-side { display: flex; flex-direction: column; gap: 16px; height: 0; min-height: 100%; overflow-y: auto; }
.ov-side section { flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 8px; }
.ov-side h2 { font-size: 15px; margin-bottom: 8px; }
.ov-side p { font-size: 14px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 8px 16px; font-size: 15px;
  color: var(--muted); white-space: nowrap; margin-bottom: -1px;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 700; }
.tab-panel { min-height: 240px; }
.tab-panel > div > .map-fig, .tab-panel > .map-fig { max-width: 880px; }
/* Figure left, text right — always. Stacked on narrow screens with the figure first. */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 24px; align-items: start; }
.split > .map-fig { margin: 0; }
.split .map { max-height: calc(100vh - 330px); }
.h-small { font-size: 16px; margin-bottom: 16px; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.pager { display: flex; gap: 8px; }
.pager a { display: inline-block; text-decoration: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; font-weight: 700; }
.how-steps li { margin-bottom: 12px; }
.flow-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 24px; align-items: start; }
/* Fits the screen on PC; long content scrolls inside the panel. */
.flow-side { max-height: calc(100vh - 400px); min-height: 240px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.flow-side h2 { font-size: 16px; margin-bottom: 12px; }
.flow-side h3 { font-size: 14px; margin: 0 0 4px; }
.flow-side h3 a { text-decoration: none; }
.flow-side h3 .sub { display: block; margin: 0; font-size: 12px; }
.flow-side section { padding: 12px 0; border-top: 1px solid var(--line); }
.flow-side section.key { border-left: 4px solid var(--ink); padding-left: 12px; }
.flow-side ul { font-size: 14px; }
.flow-side li { margin-bottom: 4px; }
.flow-side p { font-size: 14px; margin: 0; }
.flow-side .cut-note { margin: 0 0 12px; }

/* ---------- page parts ---------- */
.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 28px; margin-bottom: 8px; }
.crumb { color: var(--muted); font-size: 14px; }
.crumb a { text-decoration: none; }
.lead { font-size: 17px; max-width: 880px; margin-top: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.tag { font-size: 12px; border: 1px solid var(--line); border-radius: 4px; padding: 0 8px; white-space: nowrap; text-decoration: none; }
.tag.layer { color: var(--on-layer); border: 0; }

.block { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.block h2 { font-size: 18px; margin-bottom: 16px; }
.block h3 { font-size: 16px; margin: 16px 0 8px; }
.sub { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.block-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.block-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.cols > .block { margin-bottom: 24px; }

.why { margin-bottom: 24px; }
.why > h2 { font-size: 18px; margin-bottom: 16px; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.why-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.why-card h3 { font-size: 15px; margin-bottom: 8px; }
.why-card h3 .sub { display: block; margin: 0; }
.why-card ul { font-size: 14px; }

.how-list { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.how-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.how-card.key { border: 2px solid var(--ink); }
.how-card h3 { margin: 0 0 4px; font-size: 16px; }
.how-card h3 a { text-decoration: none; }
.how-card p:last-child { margin: 0; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-block; border: 1px solid var(--line); border-radius: 4px; padding: 0 8px; font-size: 13px; text-decoration: none; background: var(--panel); }
.pill:hover { border-color: var(--ink); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { display: grid; gap: 8px; align-content: start; text-decoration: none; border: 1px solid var(--line); border-left-width: 8px; border-radius: var(--radius); padding: 16px; }
.card:hover { border-color: var(--ink); }
.card .name { font-weight: 700; }
.cases li { margin-bottom: 16px; }
.cases p { margin: 4px 0; }
.case-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.chain-steps li { margin-bottom: 16px; }
.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 8px; }
.pager a { text-decoration: none; font-weight: 700; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 400; }
tbody th { white-space: nowrap; width: 1%; }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0 16px; }
.bar span { display: block; height: 100%; background: var(--ink); }
.status-gap { color: var(--harm); }

/* ---------- map ---------- */
.map-fig { margin: 0 0 24px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 8px; }
.block .map-fig { border: 0; padding: 0; margin: 0; }
.map { width: 100%; height: auto; display: block; max-width: 880px; margin: 0 auto; }
.map .flow { stroke: var(--flow); stroke-width: 2; stroke-dasharray: 4 4; fill: none; }
.map .node circle { fill: var(--node); stroke: var(--ink); stroke-width: 1.5; }
.map .node text { fill: var(--ink); font-size: 14px; text-anchor: middle; font-weight: 700; paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.map .edge path { fill: none; }
.map .edge .line { stroke-width: 3; }
.map .edge .hit { stroke: transparent; stroke-width: 16; }
.map .edge.dim { opacity: .12; }
.map .edge.on .line { stroke-width: 5; }
.map .tag-label rect { stroke: var(--panel); stroke-width: 2; }
.map .tag-label text { fill: var(--on-layer); font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.map .edge:hover .line { stroke-width: 5; }

/* ---------- sequence ---------- */
.seq-scroll { overflow-x: auto; }
.seq-svg { display: block; max-width: 100%; }
.seq-svg[style] { max-width: 560px; }
.seq-svg .lifeline { stroke: var(--line); stroke-width: 2; stroke-dasharray: 4 4; }
.seq-svg .actor-box { fill: var(--node); stroke: var(--ink); stroke-width: 1.5; }
.seq-svg .actor-name.long { font-size: 10.5px; }
.seq-svg .actor-name { fill: var(--ink); font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.seq-svg .arrow { stroke-width: 3; fill: none; }
.seq-svg .k-harm .arrow { stroke-width: 4; }
.seq-svg .step-no { fill: var(--on-layer); font-size: 12px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.seq-svg .step-text { fill: var(--ink); font-size: 14px; dominant-baseline: central; }
.seq-svg .step-text.harm { fill: var(--harm); font-weight: 700; }
.seq-svg .faded { opacity: .2; }
.seq-svg .cut-bar { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.seq-svg .cut-label { fill: var(--ink); font-size: 12px; font-weight: 700; text-anchor: middle; }
.seq-svg .gap-line { stroke: var(--muted); stroke-dasharray: 8 4; }
.seq-svg .gap-label { fill: var(--muted); font-size: 12px; }
.seq-list { margin-top: 16px; font-size: 14px; }
.seq-list .harm { color: var(--harm); font-weight: 700; }
.seq-list .faded { opacity: .35; }
.cut-note { margin-top: 16px; padding: 16px; border-left: 4px solid var(--ink); background: var(--bg); border-radius: 4px; }
.cut-note p { margin: 8px 0; }

/* ---------- narrow screens ---------- */
@media (max-width: 1180px) {
  /* Still figure left, text right — just a narrower text column. */
  .overview, .split { grid-template-columns: minmax(0, 1fr) minmax(220px, 280px); gap: 16px; }
  .cols3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  :root { --rail-w: 72px; }
  .rail-label { font-size: 10px; }
  .overview, .split, .flow-split { grid-template-columns: minmax(0, 1fr); }
  .flow-side { max-height: none; }
  .overview .map { max-height: none; }
  .ov-side { height: auto; }
  .topbar { padding: 0 12px; gap: 8px; }
  .tagline, .copyright { display: none; }
  .foot-mobile { display: block; padding: 16px 16px 24px calc(var(--rail-w) + 12px); color: var(--muted); font-size: 12px; }
  .topbar .logo { font-size: 16px; flex: 1; }
  .topbar .lang button { padding: 4px 8px; font-size: 13px; }
  .content { padding: 16px 12px 48px; }
  .cols { grid-template-columns: 1fr; }
  .how-list { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 24px; }
  .block { padding: 16px; }
  tbody th { white-space: normal; }
}
