:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-deep: #040a13;
  --surface: #0c1b2d;
  --surface-2: #10243a;
  --surface-3: #15304b;
  --line: rgba(183, 215, 239, 0.16);
  --text: #eef8ff;
  --muted: #91abc0;
  --accent: #42f5c5;
  --accent-2: #5fb8ff;
  --warning: #ffbd59;
  --danger: #ff5d7d;
  --success: #47e6a4;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 85% 5%, rgba(58, 168, 255, 0.16), transparent 30rem),
    radial-gradient(circle at 5% 22%, rgba(66, 245, 197, 0.08), transparent 28rem),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

button, input, select { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; }
button:not(:disabled):active { filter: brightness(1.12); transform: translateY(1px) scale(.99); }
button:focus-visible { outline: 3px solid rgba(66, 245, 197, .48); outline-offset: 3px; }
a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 1000;
  left: 1rem;
  top: -4rem;
  padding: .75rem 1rem;
  color: #061019;
  background: var(--accent);
  border-radius: .5rem;
}
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px clamp(18px, 4vw, 64px);
  background: rgba(7, 17, 31, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: #03120e;
  font-weight: 900;
  letter-spacing: -.08em;
  background: var(--accent);
  border-radius: 11px 11px 11px 3px;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: .88rem; letter-spacing: .12em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: .7rem; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }
.live-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 11px;
  color: #bcd0df;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .08em;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.live-pill i {
  width: 7px;
  height: 7px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--success);
}
.icon-button {
  width: 38px;
  height: 38px;
  cursor: pointer;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 50%;
}

.action-feedback {
  position: fixed;
  z-index: 1200;
  right: 22px;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  gap: 11px;
  align-items: center;
  width: min(430px, calc(100vw - 28px));
  padding: 14px 17px;
  color: #eafff9;
  background: rgba(9, 31, 45, .96);
  border: 1px solid rgba(66, 245, 197, .48);
  border-radius: 15px;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .46), 0 0 28px rgba(66, 245, 197, .08);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(.98);
  transition: opacity .22s ease, transform .22s ease;
  backdrop-filter: blur(15px);
}
.action-feedback.is-visible { opacity: 1; transform: translateY(0) scale(1); }
.action-feedback > span {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #041710;
  font-size: .8rem;
  font-weight: 950;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(66, 245, 197, .26);
}
.action-feedback strong { font-size: .76rem; line-height: 1.5; }

main { overflow: hidden; }
.hero, .impact-stage, .workspace, .map-section, .compiler-section, footer, .mode-tabs {
  width: min(1180px, calc(100% - 36px));
  margin-inline: auto;
}
.hero {
  position: relative;
  padding: clamp(70px, 10vw, 130px) 0 58px;
}
.hero::after {
  position: absolute;
  z-index: -1;
  top: 48px;
  right: -100px;
  width: 520px;
  height: 520px;
  content: "";
  opacity: .19;
  background-image:
    linear-gradient(rgba(107, 181, 233, .35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(107, 181, 233, .35) 1px, transparent 1px);
  background-size: 30px 30px;
  mask-image: radial-gradient(circle, black, transparent 68%);
  transform: perspective(520px) rotateX(58deg) rotateZ(-18deg);
}
.eyebrow, .section-kicker {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .2em;
}
.hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.65rem, 7vw, 6rem);
  font-weight: 850;
  line-height: 1.03;
  letter-spacing: -.06em;
}
.hero h1 em { color: var(--accent); font-style: normal; }
.hero-copy {
  max-width: 650px;
  margin: 26px 0 0;
  color: #b7cadd;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.9;
}
.hero-stat {
  display: flex;
  align-items: center;
  gap: 18px;
  width: max-content;
  max-width: 100%;
  margin-top: 38px;
  padding: 16px 22px;
  color: #b7ccdc;
  font-size: .76rem;
  line-height: 1.35;
  background: rgba(12, 27, 45, .72);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(12px);
}
.hero-stat-number { color: var(--text); font-size: 2.1rem; font-weight: 850; letter-spacing: -.05em; }
.hero-stat-number small { color: var(--muted); font-size: .9rem; }
.hero-stat-arrow { color: var(--accent); font-size: 1.3rem; }
.hero-stat-question { color: var(--warning); font-size: 1rem; font-weight: 800; }

.impact-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(420px, 1.1fr);
  gap: clamp(28px, 5vw, 70px);
  align-items: center;
  margin-bottom: 26px;
  padding: clamp(28px, 5vw, 58px);
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 20%, rgba(255, 93, 125, .14), transparent 34%),
    linear-gradient(145deg, rgba(18, 41, 66, .98), rgba(5, 14, 25, .99));
  border: 1px solid rgba(255, 93, 125, .22);
  border-radius: 30px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .32);
  transition: border-color .25s ease, background .25s ease;
}
.impact-stage.is-before, .impact-stage.is-shift { border-color: rgba(66, 245, 197, .24); }
.impact-stage.is-before { background: radial-gradient(circle at 78% 20%, rgba(66, 245, 197, .11), transparent 34%), linear-gradient(145deg, rgba(18, 41, 66, .98), rgba(5, 14, 25, .99)); }
.impact-stage::before { position: absolute; inset: 0; content: ""; pointer-events: none; opacity: .22; background-image: linear-gradient(rgba(137, 180, 210, .12) 1px, transparent 1px), linear-gradient(90deg, rgba(137, 180, 210, .12) 1px, transparent 1px); background-size: 32px 32px; mask-image: linear-gradient(90deg, transparent, black 55%); }
.impact-copy, .impact-console { position: relative; z-index: 1; }
.impact-meta { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 30px; color: var(--muted); font-size: .65rem; font-weight: 800; letter-spacing: .11em; }
.impact-meta span:first-child { color: var(--danger); }
.impact-stage.is-before .impact-meta span:first-child, .impact-stage.is-shift .impact-meta span:first-child { color: var(--accent); }
.impact-meta i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; background: currentColor; border-radius: 50%; box-shadow: 0 0 12px currentColor; }
.impact-copy h2 { margin: 0; font-size: clamp(2.25rem, 4.8vw, 4.8rem); line-height: 1.02; letter-spacing: -.065em; }
.impact-copy h2 em { color: var(--danger); font-style: normal; }
.impact-stage.is-before .impact-copy h2 em, .impact-stage.is-shift .impact-copy h2 em { color: var(--accent); }
.impact-copy > p:not(.section-kicker) { max-width: 520px; margin: 22px 0 0; color: #b9ccda; line-height: 1.8; }
.impact-timeline { display: flex; gap: 8px; align-items: center; margin-top: 30px; }
.impact-timeline > span { color: var(--muted); }
.impact-timeline button { display: grid; min-width: 92px; padding: 10px 13px; cursor: pointer; color: var(--muted); text-align: left; background: rgba(4, 13, 24, .7); border: 1px solid var(--line); border-radius: 12px; }
.impact-timeline button strong { color: var(--text); font-size: 1rem; }
.impact-timeline button small { margin-top: 2px; font-size: .61rem; }
.impact-timeline button.active { color: #330713; background: var(--danger); border-color: var(--danger); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255, 93, 125, .22); }
.impact-stage.is-before .impact-timeline button.active, .impact-stage.is-shift .impact-timeline button.active { color: #04150f; background: var(--accent); border-color: var(--accent); box-shadow: 0 8px 24px rgba(66, 245, 197, .16); }
.impact-timeline button.active strong { color: inherit; }
.impact-console { padding: clamp(20px, 3vw, 30px); background: rgba(3, 10, 19, .76); border: 1px solid var(--line); border-radius: 22px; backdrop-filter: blur(15px); }
.impact-count-wrap { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 4px 20px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.impact-count-wrap > span { color: var(--muted); font-size: .72rem; font-weight: 750; }
.impact-count-wrap > strong { grid-row: 1 / 3; grid-column: 2; color: var(--danger); font-size: clamp(4rem, 8vw, 7rem); line-height: .8; letter-spacing: -.09em; }
.impact-stage.is-before .impact-count-wrap > strong, .impact-stage.is-shift .impact-count-wrap > strong { color: var(--accent); }
.impact-count-wrap > strong small { margin-left: 5px; color: var(--muted); font-size: .9rem; letter-spacing: 0; }
.impact-count-wrap p { margin: 7px 0 0; color: var(--muted); font-size: .64rem; letter-spacing: .07em; }
.impact-count-wrap p b { color: var(--text); font-size: .92rem; }
.impact-metrics { display: grid; grid-template-columns: 1fr 1.35fr; gap: 1px; margin-top: 1px; background: var(--line); }
.impact-metrics div { padding: 16px 0; background: rgba(3, 10, 19, .92); }
.impact-metrics div + div { padding-left: 18px; }
.impact-metrics span, .impact-metrics strong { display: block; }
.impact-metrics span { color: var(--muted); font-size: .63rem; }
.impact-metrics strong { margin-top: 6px; font-size: clamp(1rem, 2vw, 1.35rem); }
.impact-stations { display: flex; flex-wrap: wrap; gap: 6px; min-height: 75px; align-content: flex-start; margin-top: 18px; }
.impact-stations span { padding: 5px 8px; color: #d9e9f3; font-size: .62rem; font-weight: 750; background: rgba(255, 255, 255, .035); border: 1px solid color-mix(in srgb, var(--station-color) 72%, transparent); border-radius: 999px; }
.impact-stations span::before { display: inline-block; width: 6px; height: 6px; margin-right: 5px; content: ""; background: var(--station-color); border-radius: 50%; box-shadow: 0 0 8px var(--station-color); }
.impact-stations .impact-clear { color: var(--accent); border-color: rgba(66, 245, 197, .25); }
.impact-stations .impact-clear::before { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.impact-od-burst { display: grid; grid-template-columns: 1fr auto; gap: 5px 14px; align-items: center; margin: 6px 0 12px; padding: 11px 13px; background: rgba(255, 93, 125, .08); border: 1px solid rgba(255, 93, 125, .22); border-radius: 10px; }
.impact-od-burst span { color: var(--muted); font-size: .64rem; }
.impact-od-burst strong { font-size: .86rem; }
.impact-od-burst b { grid-row: 1 / 3; grid-column: 2; color: var(--danger); font-size: 1.45rem; }
.impact-stage.is-before .impact-od-burst, .impact-stage.is-shift .impact-od-burst { background: rgba(66, 245, 197, .06); border-color: rgba(66, 245, 197, .2); }
.impact-stage.is-before .impact-od-burst b, .impact-stage.is-shift .impact-od-burst b { color: var(--accent); }
.impact-map-button { display: flex; justify-content: space-between; width: 100%; min-height: 48px; margin-top: 8px; padding: 0 15px; cursor: pointer; color: var(--text); font-weight: 800; background: rgba(255, 93, 125, .1); border: 1px solid rgba(255, 93, 125, .32); border-radius: 11px; }
.impact-stage.is-before .impact-map-button, .impact-stage.is-shift .impact-map-button { background: rgba(66, 245, 197, .08); border-color: rgba(66, 245, 197, .28); }
.impact-caveat { margin: 11px 0 0; color: var(--muted); font-size: .62rem; line-height: 1.55; }

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 20px;
  padding: 5px;
  background: rgba(12, 27, 45, .72);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.mode-tab {
  display: flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 750;
  background: transparent;
  border: 0;
  border-radius: 11px;
}
.mode-tab.active { color: var(--text); background: var(--surface-3); box-shadow: 0 8px 20px rgba(0, 0, 0, .18); }
.mode-tab span { color: var(--accent); font-size: 1.1rem; }

.workspace { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 20px; }
.workspace[hidden] { display: none; }
.route-card, .result-card, .ops-card, .event-list-card {
  padding: clamp(20px, 3vw, 30px);
  background: linear-gradient(145deg, rgba(18, 41, 66, .95), rgba(10, 26, 44, .96));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.route-card-head, .card-title-row, .map-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.route-card h3, .event-list-card h3, .map-head h2, .ops-card h2 { margin: 0; font-size: clamp(1.25rem, 2vw, 1.65rem); }
.prototype-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: var(--accent);
  font-size: .68rem;
  font-weight: 800;
  background: rgba(66, 245, 197, .08);
  border: 1px solid rgba(66, 245, 197, .3);
  border-radius: 999px;
}
.station-fields { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; margin-top: 26px; }
.time-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; margin-top: 14px; }
.field { display: grid; gap: 7px; }
.field > span, .profile-fieldset legend { color: var(--muted); font-size: .72rem; font-weight: 750; }
.field input, .field select {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 13px;
  color: var(--text);
  background: rgba(5, 15, 27, .72);
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(66, 245, 197, .11); }
.swap-button {
  width: 42px;
  height: 50px;
  cursor: pointer;
  color: var(--accent);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.profile-fieldset { min-width: 0; margin: 22px 0 0; padding: 0; border: 0; }
.profile-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 9px; }
.profile-options label { min-width: 0; }
.profile-options input { position: absolute; opacity: 0; pointer-events: none; }
.profile-options span {
  display: grid;
  min-height: 42px;
  padding: 7px;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
  font-size: .73rem;
  font-weight: 750;
  text-align: center;
  background: rgba(5, 15, 27, .6);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.profile-options input:checked + span { color: #041710; background: var(--accent); border-color: var(--accent); }
.profile-options input:focus-visible + span { outline: 3px solid rgba(66, 245, 197, .35); }
.primary-button, .secondary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 54px;
  margin-top: 22px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 850;
  border-radius: 13px;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.primary-button { color: #04120e; background: var(--accent); border: 0; box-shadow: 0 12px 30px rgba(66, 245, 197, .14); }
.primary-button:hover { background: #72f8d4; transform: translateY(-1px); }
.primary-button:active { transform: translateY(1px) scale(.995); }
.primary-button:disabled { cursor: progress; opacity: .92; }
.primary-button.is-calculating { background: linear-gradient(100deg, var(--accent) 0 38%, #a4ffe7 50%, var(--accent) 62% 100%); background-size: 240% 100%; animation: submitScan .7s linear infinite; }
.primary-button.is-confirmed { background: #b7ffeb; box-shadow: 0 0 0 4px rgba(66, 245, 197, .13), 0 16px 40px rgba(66, 245, 197, .2); }
.secondary-button { width: auto; margin: 0; color: var(--accent); background: rgba(66, 245, 197, .07); border: 1px solid rgba(66, 245, 197, .28); }
.secondary-button.active { color: #05150f; background: var(--accent); }
.route-submit-status { min-height: 1em; margin: 11px 0 0; color: var(--accent); font-size: .7rem; font-weight: 750; line-height: 1.5; }
.route-submit-status:empty { margin-top: 0; }
.coverage-note { min-height: 1em; margin: 7px 0 0; color: var(--muted); font-size: .69rem; line-height: 1.5; }

.result-card { position: relative; min-height: 100%; overflow: hidden; scroll-margin-top: 86px; }
.result-card.result-updated { animation: resultUpdated .78s ease-out both; }
.result-card.rescue-active { border-color: rgba(95,184,255,.42); box-shadow: 0 24px 80px rgba(0,0,0,.38), 0 0 42px rgba(95,184,255,.08); }
.result-card.rescue-active::before { position: absolute; z-index: 0; inset: -40% auto -40% -35%; width: 28%; content: ""; pointer-events: none; opacity: .32; background: linear-gradient(90deg, transparent, rgba(95,184,255,.32), transparent); transform: rotate(16deg); animation: rescueSweep 1.1s ease-out both; }
.result-card::after {
  position: absolute;
  right: -80px;
  bottom: -100px;
  width: 280px;
  height: 280px;
  content: "";
  background: radial-gradient(circle, rgba(95, 184, 255, .16), transparent 66%);
}
.empty-state { display: grid; min-height: 330px; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.empty-icon { color: var(--accent); font-size: 3rem; }
.result-headline { margin-bottom: 20px; }
.result-headline .status-label { color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .15em; }
.result-headline h3 { margin: 7px 0 9px; font-size: clamp(1.8rem, 4vw, 3.1rem); line-height: 1.08; letter-spacing: -.05em; }
.result-headline h3.danger { color: var(--danger); }
.result-headline h3.success { color: var(--success); }
.result-headline h3.rescued { color: var(--accent-2); text-shadow: 0 0 28px rgba(95, 184, 255, .22); }
.result-headline p { margin: 0; color: #b5cad9; line-height: 1.7; }
.journey-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.journey-card { position: relative; z-index: 1; padding: 16px; background: rgba(4, 13, 24, .64); border: 1px solid var(--line); border-radius: 15px; }
.journey-card.success { border-color: rgba(71, 230, 164, .28); }
.journey-card.danger { border-color: rgba(255, 93, 125, .36); }
.journey-card.rescued { background: linear-gradient(145deg, rgba(95, 184, 255, .12), rgba(4, 13, 24, .72)); border-color: rgba(95, 184, 255, .45); box-shadow: inset 0 0 35px rgba(95, 184, 255, .04); }
.journey-card-top { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.journey-card-top strong { font-size: .84rem; }
.journey-status { color: var(--muted); font-size: .68rem; font-weight: 800; }
.journey-card.success .journey-status { color: var(--success); }
.journey-card.danger .journey-status { color: var(--danger); }
.journey-card.rescued .journey-status { color: var(--accent-2); }
.journey-time { margin: 16px 0 5px; font-size: 1.8rem; font-weight: 850; letter-spacing: -.05em; }
.journey-card p { margin: 8px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.55; }
.line-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 11px; }
.line-chip { padding: 4px 7px; color: white; font-size: .63rem; font-weight: 850; border-radius: 7px; }
.result-warning { position: relative; z-index: 1; margin-top: 12px; padding: 14px; color: #ffd9df; font-size: .75rem; line-height: 1.6; background: rgba(255, 93, 125, .09); border-left: 3px solid var(--danger); border-radius: 7px 12px 12px 7px; }

.route-rescue { position: relative; z-index: 2; margin-top: 14px; padding: 20px; overflow: hidden; background: linear-gradient(145deg, rgba(17, 47, 74, .96), rgba(4, 16, 29, .98)); border: 1px solid rgba(95, 184, 255, .38); border-radius: 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, .22); }
.rescue-glow { position: absolute; top: -90px; right: -50px; width: 230px; height: 230px; pointer-events: none; background: radial-gradient(circle, rgba(95,184,255,.2), transparent 68%); }
.rescue-head { position: relative; display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.rescue-head span { color: var(--accent-2); font-size: .61rem; font-weight: 900; letter-spacing: .16em; }
.rescue-head h4 { margin: 6px 0 0; font-size: 1.2rem; letter-spacing: -.03em; }
.rescue-head b { padding: 5px 8px; color: var(--accent); font-size: .62rem; background: rgba(66,245,197,.08); border: 1px solid rgba(66,245,197,.2); border-radius: 999px; }
.route-rescue > p { margin: 12px 0 0; color: #bad0df; font-size: .72rem; line-height: 1.55; }
.rescue-diagram { display: grid; grid-template-columns: auto minmax(60px, 1fr) auto minmax(60px, 1fr) auto; gap: 8px; align-items: center; margin-top: 18px; }
.rescue-stop { min-width: 94px; padding: 11px; background: rgba(3,11,21,.72); border: 1px solid var(--line); border-radius: 12px; }
.rescue-stop small, .rescue-stop strong, .rescue-stop span { display: block; }
.rescue-stop small { color: var(--muted); font-size: .54rem; }
.rescue-stop strong { margin-top: 4px; font-size: .76rem; }
.rescue-stop span { margin-top: 4px; color: var(--muted); font-size: .53rem; }
.rescue-stop.blocked { border-color: rgba(255,93,125,.35); }
.rescue-stop.blocked strong { color: var(--danger); }
.rescue-stop.alternate { border-color: rgba(95,184,255,.48); box-shadow: 0 0 24px rgba(95,184,255,.08); }
.rescue-stop.alternate strong { color: var(--accent-2); }
.rescue-stop.home { border-color: rgba(66,245,197,.35); }
.rescue-stop.home strong { color: var(--success); }
.rescue-leg { position: relative; display: grid; place-items: center; text-align: center; }
.rescue-leg i { width: 100%; height: 2px; background: repeating-linear-gradient(90deg, var(--muted) 0 5px, transparent 5px 9px); }
.rescue-leg.rail i { height: 3px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); box-shadow: 0 0 8px rgba(95,184,255,.4); }
.rescue-leg span { margin-top: 7px; color: #cfdee8; font-size: .56rem; }
.rescue-leg span small { display: block; margin-top: 2px; color: var(--muted); font-size: .5rem; }
.route-rescue > button { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 48px; margin-top: 18px; padding: 0 15px; cursor: pointer; color: #03150f; font-weight: 900; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border: 0; border-radius: 11px; box-shadow: 0 12px 28px rgba(66,245,197,.12); }
.route-rescue > small { display: block; margin-top: 9px; color: var(--muted); font-size: .57rem; line-height: 1.45; }
.rescued-timeline { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-top: 15px; padding: 16px; background: rgba(4,13,24,.64); border: 1px solid rgba(95,184,255,.28); border-radius: 15px; }
.rescued-timeline > div { position: relative; display: grid; grid-template-columns: auto 12px 1fr; gap: 7px; align-items: start; }
.rescued-timeline > div:not(:last-child)::after { position: absolute; top: 17px; left: calc(100% - 5px); width: 18px; height: 1px; content: ""; background: var(--line); }
.rescued-timeline span { color: var(--muted); font-size: .61rem; font-weight: 850; }
.rescued-timeline i { width: 9px; height: 9px; margin-top: 3px; background: var(--success); border-radius: 50%; box-shadow: 0 0 9px var(--success); }
.rescued-timeline .alert i { background: var(--danger); box-shadow: 0 0 9px var(--danger); }
.rescued-timeline .rescued i { background: var(--accent-2); box-shadow: 0 0 9px var(--accent-2); }
.rescued-timeline p { margin: 0; color: var(--muted); font-size: .59rem; line-height: 1.45; }
.rescued-timeline p strong { display: block; color: var(--text); font-size: .66rem; }
.undo-rescue { position: relative; z-index: 1; display: block; margin: 10px 0 0 auto; cursor: pointer; color: var(--muted); font-size: .64rem; background: transparent; border: 0; text-decoration: underline; text-underline-offset: 3px; }

#opsMode { grid-template-columns: .9fr 1.1fr; }
.ops-card { grid-column: 1 / -1; }
.ops-controls { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-top: 24px; }
.time-presets { display: flex; gap: 7px; margin-top: 14px; overflow-x: auto; }
.time-presets button, .map-focus button {
  min-width: 64px;
  padding: 8px 11px;
  cursor: pointer;
  color: var(--muted);
  background: rgba(5, 15, 27, .6);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.time-presets button.active, .map-focus button.active { color: #04120e; background: var(--accent); border-color: var(--accent); }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.metric-card { padding: 20px; background: linear-gradient(145deg, rgba(18, 41, 66, .94), rgba(10, 26, 44, .94)); border: 1px solid var(--line); border-radius: 18px; }
.metric-card span { color: var(--muted); font-size: .7rem; font-weight: 750; }
.metric-card strong { display: block; margin-top: 10px; font-size: clamp(1.65rem, 4vw, 2.6rem); letter-spacing: -.05em; }
.metric-card strong small { color: var(--muted); font-size: .75rem; letter-spacing: 0; }
.metric-card.warning strong { color: var(--warning); }
.event-list-card { min-height: 310px; }
#simulationLabel { color: var(--accent); font-size: .72rem; font-weight: 800; }
.event-list { display: grid; gap: 8px; margin-top: 18px; }
.event-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px; background: rgba(5, 15, 27, .62); border: 1px solid var(--line); border-radius: 12px; }
.event-code { display: grid; width: 38px; height: 38px; place-items: center; font-size: .67rem; font-weight: 850; border: 2px solid; border-radius: 50%; }
.event-row strong, .event-row small { display: block; }
.event-row small { margin-top: 3px; color: var(--muted); font-size: .65rem; }
.event-scale { color: var(--warning); font-size: .7rem; font-weight: 800; text-align: right; }
.no-events { display: grid; min-height: 170px; place-items: center; color: var(--muted); text-align: center; }

.resilience-lab { grid-column: 1 / -1; margin-top: 2px; padding: clamp(22px, 3vw, 32px); background: linear-gradient(145deg, rgba(15, 34, 56, .98), rgba(5, 15, 27, .98)); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.resilience-head { display: flex; justify-content: space-between; gap: 22px; align-items: flex-start; }
.resilience-head h3 { margin: 0; font-size: clamp(1.45rem, 2.7vw, 2.3rem); letter-spacing: -.04em; }
.resilience-grid { display: grid; grid-template-columns: .8fr .8fr 1.4fr; gap: 10px; margin-top: 24px; }
.lab-panel { min-width: 0; padding: 20px; background: rgba(3, 11, 21, .66); border: 1px solid var(--line); border-radius: 17px; }
.lab-label { color: var(--accent); font-size: .62rem; font-weight: 850; letter-spacing: .13em; }
.lab-big-number { margin-top: 16px; color: var(--danger); font-size: clamp(2.8rem, 5vw, 4.6rem); font-weight: 850; line-height: .9; letter-spacing: -.08em; }
.lab-big-number small { margin-left: 5px; color: var(--muted); font-size: .8rem; letter-spacing: 0; }
.lab-panel > p { margin: 15px 0 0; color: #b8cad8; font-size: .74rem; line-height: 1.55; }
.lab-panel > p strong { color: var(--danger); }
.lab-panel > small { display: block; margin-top: 13px; color: var(--muted); font-size: .61rem; line-height: 1.5; }
.loss-bar { height: 8px; margin-top: 13px; overflow: hidden; background: rgba(255, 255, 255, .06); border-radius: 999px; }
.loss-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--warning), var(--danger)); border-radius: inherit; box-shadow: 0 0 12px rgba(255, 93, 125, .4); transition: width .3s ease; }
.slo-gauge { position: relative; display: grid; width: 128px; height: 128px; margin: 16px auto 6px; place-items: center; background: conic-gradient(var(--danger) var(--slo-progress), rgba(255,255,255,.06) 0); border-radius: 50%; }
.slo-gauge::after { position: absolute; inset: 9px; content: ""; background: #071321; border-radius: inherit; }
.slo-gauge strong { position: relative; z-index: 1; font-size: 1.45rem; letter-spacing: -.04em; }
.slo-gauge strong small { color: var(--muted); font-size: .7rem; }
.slo-panel > p { margin-top: 8px; text-align: center; }
.slo-panel .burn-label b { color: var(--danger); font-size: 1.15rem; }
.priority-panel { padding: 17px; }
.priority-title { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.priority-title h4 { margin: 6px 0 0; font-size: 1rem; }
.priority-title > span { color: var(--muted); font-size: .62rem; }
.priority-list { display: grid; gap: 6px; margin-top: 14px; }
.priority-row { display: grid; grid-template-columns: auto auto 1fr auto; gap: 9px; align-items: center; padding: 9px; background: rgba(255,255,255,.025); border: 1px solid transparent; border-radius: 10px; }
.priority-row.recovered { background: rgba(66,245,197,.055); border-color: rgba(66,245,197,.2); }
.priority-rank { color: var(--muted); font-size: .62rem; font-weight: 850; }
.priority-code { display: grid; width: 34px; height: 34px; place-items: center; color: var(--priority-color); font-size: .58rem; font-weight: 850; border: 2px solid var(--priority-color); border-radius: 50%; }
.priority-row strong, .priority-row small { display: block; }
.priority-row strong { font-size: .76rem; }
.priority-row small { margin-top: 2px; color: var(--muted); font-size: .57rem; }
.priority-row > b { color: var(--warning); font-size: .72rem; text-align: right; }
.priority-row.recovered > b { color: var(--accent); }
.no-priority { color: var(--muted); font-size: .75rem; }
.recovery-simulator { display: flex; justify-content: space-between; gap: 24px; align-items: center; margin-top: 10px; padding: 18px 20px; background: rgba(95,184,255,.06); border: 1px solid rgba(95,184,255,.2); border-radius: 15px; }
.recovery-simulator.active { background: rgba(66,245,197,.07); border-color: rgba(66,245,197,.25); }
.recovery-simulator span, .recovery-simulator strong { display: block; }
.recovery-simulator span { color: var(--accent-2); font-size: .6rem; font-weight: 850; letter-spacing: .12em; }
.recovery-simulator strong { margin-top: 5px; font-size: .9rem; }
.recovery-simulator p { margin: 5px 0 0; color: var(--muted); font-size: .68rem; }
.recovery-simulator button { flex: 0 0 auto; min-height: 43px; padding: 0 15px; cursor: pointer; color: #04150f; font-weight: 850; background: var(--accent); border: 0; border-radius: 10px; }

.map-section { padding: 76px 0 40px; }
.map-head { align-items: end; margin-bottom: 18px; }
.map-focus { display: flex; gap: 7px; }
.map-shell {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 45%, rgba(36, 87, 124, .2), transparent 48%),
    #06111e;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
#networkMap { display: block; width: 100%; height: auto; min-height: 420px; }
.map-grid line { stroke: rgba(116, 164, 199, .08); stroke-width: 1; }
.network-line { fill: none; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.transfer-line { stroke: rgba(218, 236, 249, .3); stroke-width: 2; stroke-dasharray: 4 5; }
.route-line { fill: none; stroke: white; stroke-width: 13; stroke-linecap: round; stroke-linejoin: round; opacity: .9; filter: drop-shadow(0 0 8px rgba(255, 255, 255, .5)); }
.route-line-color { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.rescued-map .route-line-color { stroke: var(--accent-2); stroke-dasharray: 16 9; filter: drop-shadow(0 0 7px rgba(95,184,255,.72)); animation: routeFlow 1.1s linear infinite; }
.station-node { cursor: pointer; fill: #07111f; stroke: rgba(221, 239, 251, .62); stroke-width: 2; transition: r .18s ease, fill .18s ease, opacity .18s ease; }
.station-node:hover, .station-node:focus { r: 8; fill: white; outline: none; }
.station-node.risk { fill: var(--warning); stroke: #fff1c5; stroke-width: 3; filter: drop-shadow(0 0 8px rgba(255, 189, 89, .72)); animation: pulse 1.8s infinite; }
.station-node.route { fill: var(--accent); stroke: white; }
.station-node.origin { fill: var(--accent-2); stroke: white; r: 8; }
.station-node.destination { fill: var(--danger); stroke: white; r: 8; }
.station-label { fill: #b5c9d8; font-size: 10px; font-weight: 700; paint-order: stroke; stroke: #06111e; stroke-width: 3px; pointer-events: none; }
@keyframes pulse { 50% { opacity: .48; } }
@keyframes routeFlow { to { stroke-dashoffset: -25; } }
@keyframes rescueSweep { from { transform: translateX(0) rotate(16deg); } to { transform: translateX(650%) rotate(16deg); } }
@keyframes submitScan { to { background-position: -240% 0; } }
@keyframes resultUpdated {
  0% { border-color: rgba(66, 245, 197, .95); box-shadow: 0 0 0 0 rgba(66, 245, 197, .3), var(--shadow); transform: scale(.992); }
  45% { border-color: rgba(66, 245, 197, .62); box-shadow: 0 0 0 9px rgba(66, 245, 197, 0), 0 24px 80px rgba(0, 0, 0, .4); transform: scale(1); }
  100% { border-color: var(--line); box-shadow: var(--shadow); transform: scale(1); }
}
.map-tooltip { position: absolute; z-index: 10; min-width: 190px; max-width: 260px; padding: 13px; pointer-events: none; background: rgba(5, 15, 27, .96); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 42px rgba(0, 0, 0, .4); }
.map-tooltip strong, .map-tooltip span { display: block; }
.map-tooltip span { margin-top: 5px; color: var(--muted); font-size: .68rem; line-height: 1.45; }
.map-tooltip .tooltip-warning { color: var(--warning); }
.map-legend { position: absolute; left: 18px; bottom: 16px; display: flex; flex-wrap: wrap; gap: 14px; padding: 9px 12px; color: var(--muted); font-size: .64rem; background: rgba(5, 15, 27, .78); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(10px); }
.map-legend span { display: flex; gap: 6px; align-items: center; }
.legend-dot { width: 9px; height: 9px; border: 2px solid #a9bfd0; border-radius: 50%; }
.legend-dot.warning { background: var(--warning); border-color: #fff1c5; }
.legend-line { width: 18px; height: 4px; background: var(--accent); border-radius: 4px; box-shadow: 0 0 5px var(--accent); }
.map-status-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; margin-top: 10px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; }
.map-status-item { padding: 14px 17px; background: #0a192a; }
.map-status-item span, .map-status-item strong { display: block; }
.map-status-item span { color: var(--muted); font-size: .64rem; }
.map-status-item strong { margin-top: 5px; font-size: .92rem; }
.map-status-item.warning strong { color: var(--warning); }

.compiler-section { display: grid; grid-template-columns: .9fr 1.1fr; gap: 46px; align-items: center; padding: 90px 0; }
.compiler-copy h2 { margin: 0; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.16; letter-spacing: -.045em; }
.compiler-copy > p:last-child { color: var(--muted); line-height: 1.8; }
.compiler-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 9px; align-items: center; }
.compiler-flow > div { min-height: 150px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.compiler-flow > div.accent { background: rgba(66, 245, 197, .08); border-color: rgba(66, 245, 197, .35); }
.compiler-flow span, .compiler-flow strong, .compiler-flow small { display: block; }
.compiler-flow span { color: var(--accent); font-size: .68rem; font-weight: 850; }
.compiler-flow strong { margin-top: 30px; font-size: .9rem; }
.compiler-flow small { margin-top: 7px; color: var(--muted); font-size: .64rem; line-height: 1.4; }
.compiler-flow b { color: var(--accent); }

footer { display: flex; justify-content: space-between; gap: 30px; align-items: center; padding: 34px 0 60px; border-top: 1px solid var(--line); }
footer strong { letter-spacing: .12em; }
footer p { margin: 8px 0 0; color: var(--muted); font-size: .78rem; }
.text-button { cursor: pointer; color: var(--accent); background: transparent; border: 0; text-decoration: underline; text-underline-offset: 4px; }

dialog { width: min(620px, calc(100% - 26px)); max-height: calc(100vh - 32px); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 5, 12, .74); backdrop-filter: blur(8px); }
.dialog-inner { position: relative; padding: clamp(24px, 5vw, 42px); }
.dialog-inner h2 { margin: 0 0 15px; font-size: 2rem; }
.dialog-inner h3 { margin-top: 26px; }
.dialog-inner > p, .dialog-inner li { color: #b9cbd9; line-height: 1.7; }
.dialog-inner ul { padding-left: 1.2rem; }
.dialog-inner li + li { margin-top: 7px; }
.dialog-inner a { color: var(--accent); }
.dialog-close { position: absolute; top: 16px; right: 16px; width: 38px; height: 38px; cursor: pointer; color: var(--muted); background: rgba(5, 15, 27, .7); border: 1px solid var(--line); border-radius: 50%; }
.dialog-warning { padding: 15px; background: rgba(255, 189, 89, .07); border: 1px solid rgba(255, 189, 89, .25); border-radius: 12px; }
.dialog-warning strong { color: var(--warning); }
.dialog-warning p { margin-bottom: 0; color: #c8d6df; font-size: .8rem; line-height: 1.65; }
.dialog-warning code { color: #fff0c6; }
.data-meta { font-size: .7rem; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

@media (max-width: 850px) {
  .impact-stage, .workspace, #opsMode, .compiler-section { grid-template-columns: 1fr; }
  .result-card { min-height: 340px; }
  .ops-card { grid-column: auto; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); grid-column: auto; overflow-x: auto; }
  .metric-card { min-width: 150px; }
  .resilience-grid { grid-template-columns: 1fr 1fr; }
  .priority-panel { grid-column: 1 / -1; }
  .compiler-flow { grid-template-columns: 1fr; }
  .compiler-flow b { transform: rotate(90deg); text-align: center; }
  .compiler-flow > div { min-height: 110px; }
  .compiler-flow strong { margin-top: 18px; }
}

@media (max-width: 620px) {
  .topbar { min-height: 64px; padding-inline: 15px; }
  .action-feedback { right: 14px; left: 14px; bottom: max(14px, env(safe-area-inset-bottom)); width: auto; }
  .live-pill { display: none; }
  .hero, .impact-stage, .workspace, .map-section, .compiler-section, footer, .mode-tabs { width: min(100% - 24px, 1180px); }
  .hero { padding-top: 58px; }
  .hero h1 { font-size: clamp(2.6rem, 14vw, 4.3rem); }
  .hero-stat { gap: 10px; padding: 13px; }
  .hero-stat-number { font-size: 1.55rem; }
  .hero-stat-arrow { display: none; }
  .impact-stage { gap: 24px; padding: 21px 16px; border-radius: 22px; }
  .impact-meta { margin-bottom: 22px; }
  .impact-copy h2 { font-size: clamp(2.25rem, 12.5vw, 3.35rem); }
  .impact-timeline { gap: 5px; }
  .impact-timeline > span { display: none; }
  .impact-timeline button { min-width: 0; flex: 1; padding: 9px; }
  .impact-console { padding: 17px; }
  .impact-count-wrap > strong { font-size: 4.7rem; }
  .resilience-head, .recovery-simulator { display: grid; }
  .resilience-grid { grid-template-columns: 1fr; }
  .priority-panel { grid-column: auto; }
  .recovery-simulator button { width: 100%; }
  .route-card, .result-card, .ops-card, .event-list-card { padding: 18px; border-radius: 20px; }
  .station-fields { grid-template-columns: 1fr 42px; }
  .station-fields .station-field:last-child { grid-column: 1 / -1; }
  .swap-button { grid-column: 2; grid-row: 1; }
  .time-grid { grid-template-columns: 1fr 1fr; }
  .date-field { grid-column: 1 / -1; }
  .profile-options { grid-template-columns: repeat(2, 1fr); }
  .journey-grid { grid-template-columns: 1fr; }
  .rescue-diagram { grid-template-columns: 1fr; }
  .rescue-leg { min-height: 48px; }
  .rescue-leg i { width: 2px; height: 30px; background: repeating-linear-gradient(180deg, var(--muted) 0 5px, transparent 5px 9px); }
  .rescue-leg.rail i { width: 3px; height: 30px; background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
  .rescued-timeline { grid-template-columns: 1fr; gap: 13px; }
  .rescued-timeline > div:not(:last-child)::after { display: none; }
  .ops-controls { grid-template-columns: 1fr 1fr; }
  .ops-controls .secondary-button { grid-column: 1 / -1; width: 100%; }
  .map-head { align-items: flex-start; }
  .map-focus { flex: 0 0 auto; }
  #networkMap { width: 155%; max-width: none; transform: translateX(-18%); }
  .map-legend { right: 10px; bottom: 10px; left: 10px; }
  .map-status-strip { grid-template-columns: 1fr; }
  .compiler-section { padding-block: 70px; }
  footer { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
