:root {
  --navy-950: #04134f;
  --navy-900: #071e73;
  --navy-800: #0b2d8d;
  --navy-700: #1843a3;
  --teal-600: #078d92;
  --teal-500: #0ba8a6;
  --teal-100: #dff7f5;
  --sky-100: #eaf2ff;
  --ink: #10265a;
  --muted: #596b8e;
  --line: #ccd7e8;
  --line-strong: #aebdd4;
  --canvas: #f5f8fc;
  --surface: #ffffff;
  --stage: #030b21;
  --shadow: 0 12px 36px rgba(17, 38, 89, 0.11);
  --radius-lg: 14px;
  --radius-md: 9px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(11, 168, 166, 0.35);
  outline-offset: 2px;
}

.site-header {
  position: sticky;
  z-index: 50;
  top: 0;
  background: var(--navy-900);
  border-bottom: 4px solid var(--teal-500);
  color: white;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1460px;
  min-height: 76px;
  margin: 0 auto;
  padding: 10px 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: white;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

.brand-mark svg {
  width: 29px;
  fill: none;
  stroke: #71e2dc;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 22px;
  letter-spacing: 0.035em;
}

.brand small {
  margin-top: 3px;
  color: #c8d7ff;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-nav button {
  cursor: pointer;
  border: 0;
  background: transparent;
  color: inherit;
}

.header-nav button {
  padding: 10px 14px;
  border-radius: 6px;
  color: #dce6ff;
  font-size: 13px;
}

.header-nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.header-nav .nav-primary {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: white;
  color: var(--navy-900);
  font-weight: 750;
}

.page-shell {
  max-width: 1460px;
  margin: 0 auto;
  padding: 0 28px 34px;
}

.intro-strip {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 28px 4px 22px;
}

.intro-copy {
  min-width: 0;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--teal-600);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.intro-strip h1 {
  margin: 7px 0 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(23px, 2.2vw, 34px);
  font-weight: 700;
  line-height: 1.25;
}

.matrix-switcher {
  display: inline-flex;
  gap: 5px;
  margin-top: 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eaf0f9;
}

.matrix-switcher button {
  display: grid;
  min-width: 190px;
  cursor: pointer;
  gap: 2px;
  padding: 9px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.matrix-switcher button[aria-selected="true"] {
  background: white;
  box-shadow: 0 2px 9px rgba(17, 38, 89, 0.12);
  color: var(--navy-800);
}

.matrix-switcher span {
  font-size: 12px;
  font-weight: 800;
}

.matrix-switcher small {
  color: inherit;
  font-size: 9px;
}

.status-pill {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid #b7e4df;
  border-radius: 999px;
  background: #eefbf9;
  color: #176a6d;
  font-size: 12px;
  font-weight: 700;
}

.status-pill span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal-500);
  box-shadow: 0 0 0 4px rgba(11, 168, 166, 0.13);
}

.matrix-app {
  display: grid;
  align-items: start;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 20px;
}

.matrix-panel,
.workspace {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.matrix-panel {
  position: sticky;
  top: 100px;
  overflow: hidden;
}

.panel-heading,
.workspace-heading,
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading {
  padding: 17px 18px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2,
.workspace-heading h2,
.card-heading h3 {
  margin: 4px 0 0;
}

.panel-heading h2 {
  font-size: 18px;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  cursor: pointer;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--navy-800);
}

.icon-button:hover {
  border-color: var(--teal-500);
  color: var(--teal-600);
}

.icon-button svg,
.player-controls svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

#collapse-matrix svg {
  transition: transform 180ms ease;
}

#collapse-matrix[aria-expanded="false"] svg {
  transform: rotate(-90deg);
}

.matrix-content {
  padding: 12px 14px 14px;
}

.matrix-content[hidden] {
  display: none;
}

.matrix-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
}

.matrix-columns,
.matrix-row {
  display: grid;
  grid-template-columns: 98px repeat(var(--matrix-column-count, 4), minmax(0, 1fr));
  gap: 5px;
}

.matrix-columns {
  align-items: center;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.simulation-matrix {
  display: grid;
  gap: 4px;
}

.matrix-row {
  align-items: center;
}

.hodo-label {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.hodo-label span {
  width: 13px;
  color: var(--navy-800);
  font-size: 10px;
  font-weight: 850;
}

.hodo-label img {
  width: 78px;
  height: 21px;
  border: 1px solid #95a9c8;
  object-fit: cover;
}

.matrix-content.is-mcs .simulation-matrix {
  gap: 5px;
}

.matrix-content.is-mcs .hodo-label img {
  height: 34px;
  background: white;
  object-fit: contain;
}

.matrix-content.is-mcs .matrix-cell,
.matrix-content.is-mcs .matrix-empty {
  height: 34px;
}

.matrix-cell {
  min-width: 0;
  height: 27px;
  cursor: pointer;
  border: 1px solid #b8c5d9;
  border-radius: 5px;
  background: #edf3fb;
  color: var(--navy-800);
  font-size: 10px;
  font-weight: 850;
  transition: border-color 130ms ease, background 130ms ease, color 130ms ease, transform 130ms ease;
}

.matrix-cell:hover {
  z-index: 2;
  transform: translateY(-1px);
  border-color: var(--teal-500);
  background: var(--teal-100);
}

.matrix-cell.is-active {
  border-color: var(--teal-600);
  background: var(--teal-500);
  box-shadow: 0 0 0 2px rgba(11, 168, 166, 0.2);
  color: white;
}

.matrix-empty {
  height: 27px;
  border: 1px dashed #d7dfeb;
  border-radius: 5px;
  background: #fafbfd;
}

.column-key {
  display: grid;
  margin-top: 10px;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px 10px;
  color: var(--muted);
  font-size: 9px;
}

.column-key b {
  color: var(--navy-800);
}

.workspace {
  min-width: 0;
  overflow: hidden;
}

.workspace-heading {
  padding: 18px 22px 14px;
}

.workspace-heading h2 {
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 25px;
}

#simulation-descriptor {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.case-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.case-nav span {
  min-width: 58px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.view-tabs {
  display: flex;
  overflow-x: auto;
  padding: 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #f8faff;
  scrollbar-width: thin;
}

.view-tabs button {
  flex: 0 0 auto;
  cursor: pointer;
  padding: 13px 16px 11px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.view-tabs button:hover {
  color: var(--navy-800);
}

.view-tabs button:disabled {
  cursor: not-allowed;
  color: #aab5c7;
  text-decoration: line-through;
  opacity: 0.68;
}

.view-tabs button[aria-selected="true"] {
  border-bottom-color: var(--teal-500);
  color: var(--navy-800);
}

.media-stage {
  padding: 14px 18px 0;
  background: var(--stage);
  color: white;
}

.stage-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto 11px;
  color: #d7e2ff;
  font-size: 11px;
  font-weight: 750;
}

.player-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #9fb2dc;
  font-size: 10px;
}

.player-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8292b5;
}

.player-status.is-ready i {
  background: #36cfb8;
  box-shadow: 0 0 0 3px rgba(54, 207, 184, 0.16);
}

.player-host {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  width: min(100%, 560px);
  aspect-ratio: 8 / 9;
  margin: 0 auto;
  overflow: hidden;
  place-items: center;
  border: 1px solid #213b70;
  background: #0c3c6c;
}

.player-host ruffle-player {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

.mcs-frame,
.mcs-static-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.mcs-frame {
  width: 100%;
  height: 100%;
}

.information-stage {
  display: grid;
  place-items: center;
  gap: 10px;
  color: #e8efff;
  text-align: center;
}

.information-stage a {
  padding: 8px 12px;
  border: 1px solid #4b6b9f;
  border-radius: 6px;
  color: #7ae3dc;
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
}

.loading-card {
  display: grid;
  place-items: center;
  gap: 8px;
  color: #e8efff;
  text-align: center;
}

.loading-card small {
  color: #a2b4d8;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #61d9d4;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 720px;
  min-height: 54px;
  margin: 0 auto;
  color: #d5e1fa;
}

.player-controls button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 8px 10px;
  border: 1px solid #34507f;
  border-radius: 6px;
  background: #10234a;
  color: #e7efff;
  font-size: 11px;
}

.player-controls button:hover:not(:disabled) {
  border-color: #5ed6d1;
  color: white;
}

.player-controls button:disabled {
  cursor: wait;
  opacity: 0.45;
}

.player-controls .play-icon {
  fill: currentColor;
  stroke: none;
}

.control-note {
  margin-left: auto;
  color: #8498bf;
  font-size: 10px;
}

.player-controls .control-icon {
  padding: 8px;
}

.frame-counter {
  min-width: 48px;
  color: #aebfe0;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.speed-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #aebfe0;
  font-size: 10px;
}

.speed-control select {
  padding: 5px 7px;
  border: 1px solid #34507f;
  border-radius: 5px;
  background: #10234a;
  color: #e7efff;
  font: inherit;
}

[hidden] {
  display: none !important;
}

.context-grid {
  display: grid;
  padding: 18px;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  background: #f6f8fc;
}

.info-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
}

.info-card.is-highlighted {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 3px rgba(11, 168, 166, 0.13);
}

.card-heading h3 {
  font-size: 17px;
  line-height: 1.35;
}

.data-source,
.case-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 4px;
  background: var(--sky-100);
  color: var(--navy-700);
  font-size: 9px;
  font-weight: 800;
}

.case-badge {
  min-width: 38px;
  background: var(--teal-100);
  color: #147377;
  font-size: 11px;
  text-align: center;
}

.environment-layout {
  display: grid;
  align-items: center;
  margin-top: 14px;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.environment-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.environment-figures figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f2f5fa;
}

.environment-figures img {
  display: block;
  width: 100%;
  height: clamp(250px, 24vw, 350px);
  object-fit: contain;
  background: white;
}

.figure-zoom {
  position: relative;
  display: block;
  width: 100%;
  cursor: zoom-in;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: white;
}

.figure-zoom span {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(4, 19, 79, 0.82);
  color: white;
  font-size: 9px;
  font-weight: 750;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.figure-zoom:hover span,
.figure-zoom:focus-visible span {
  opacity: 1;
  transform: translateY(0);
}

.environment-figures figcaption {
  padding: 5px;
  color: var(--muted);
  font-size: 8px;
  text-align: center;
}

.metrics-list {
  display: grid;
  margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 6px;
}

.metric-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e1e7f0;
}

.metric-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.metric-row dt {
  color: var(--muted);
  font-size: 9px;
}

.metric-row dd {
  margin: 0;
  color: var(--navy-800);
  font-size: 10px;
  font-weight: 800;
  text-align: right;
}

.summary-text {
  margin: 16px 0 0;
  color: #344c75;
  font-size: 13px;
  line-height: 1.75;
}

.source-details {
  margin-top: 13px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
}

.source-details summary {
  padding-top: 10px;
  cursor: pointer;
  color: var(--navy-700);
  font-weight: 750;
}

.source-details p {
  margin-bottom: 0;
  line-height: 1.6;
}

.content-dialog {
  width: min(620px, calc(100vw - 32px));
  padding: 28px 30px 30px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: white;
  box-shadow: 0 24px 70px rgba(4, 19, 79, 0.3);
  color: var(--ink);
}

.content-dialog::backdrop {
  background: rgba(3, 10, 35, 0.68);
}

.image-dialog {
  width: min(1000px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 24px;
  border: 1px solid #35517f;
  border-radius: 12px;
  background: #07142f;
  box-shadow: 0 24px 70px rgba(4, 19, 79, 0.45);
  color: white;
}

.image-dialog::backdrop {
  background: rgba(3, 10, 35, 0.82);
}

.image-dialog form {
  position: absolute;
  z-index: 2;
  top: 14px;
  right: 14px;
}

.image-dialog img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 115px);
  object-fit: contain;
}

.image-dialog p {
  margin: 12px 0 0;
  color: #dbe6ff;
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.content-dialog h2 {
  margin: 7px 40px 16px 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: 25px;
}

.content-dialog p,
.content-dialog li {
  color: #40577e;
  font-size: 14px;
  line-height: 1.75;
}

.content-dialog li + li {
  margin-top: 8px;
}

.content-dialog form {
  position: absolute;
  top: 18px;
  right: 18px;
}

.dialog-close {
  display: grid;
  width: 34px;
  height: 34px;
  cursor: pointer;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--navy-800);
  font-size: 22px;
  line-height: 1;
}

.dialog-note {
  padding: 12px 14px;
  border-left: 4px solid var(--teal-500);
  background: #eef9f8;
}

noscript {
  display: block;
  padding: 16px;
  background: #fff2cc;
  color: #5d4600;
  text-align: center;
}

@media (max-width: 1080px) {
  .matrix-app {
    grid-template-columns: 350px minmax(0, 1fr);
  }

  .context-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .site-header {
    position: relative;
  }

  .header-inner {
    padding: 10px 16px;
  }

  .brand strong {
    font-size: 19px;
  }

  .brand small,
  .header-nav button:not(.nav-primary) {
    display: none;
  }

  .page-shell {
    padding: 0 14px 24px;
  }

  .intro-strip {
    align-items: stretch;
    padding: 22px 2px 16px;
    flex-direction: column;
  }

  .intro-strip h1 {
    font-size: 22px;
  }

  .matrix-switcher {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .matrix-switcher button {
    min-width: 0;
  }

  .status-pill {
    align-self: flex-start;
  }

  .matrix-app {
    display: flex;
    flex-direction: column;
  }

  .workspace {
    order: 1;
    width: 100%;
  }

  .matrix-panel {
    position: static;
    order: 2;
    width: 100%;
  }

  .matrix-panel .matrix-content {
    max-height: none;
  }

  .workspace-heading {
    padding: 16px;
  }

  .workspace-heading h2 {
    font-size: 22px;
  }

  .view-tabs {
    padding: 0 10px;
  }

  .view-tabs button {
    padding-right: 12px;
    padding-left: 12px;
  }

  .media-stage {
    padding-right: 10px;
    padding-left: 10px;
  }

  .context-grid {
    padding: 12px;
  }

}

@media (max-width: 560px) {
  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand strong {
    font-size: 17px;
  }

  .header-nav .nav-primary {
    padding: 8px 10px;
    font-size: 11px;
  }

  .status-pill {
    padding: 7px 9px;
    font-size: 10px;
  }

  .eyebrow {
    display: none;
  }

  .intro-strip h1 {
    margin: 0;
    font-size: 19px;
  }

  .matrix-switcher {
    margin-top: 13px;
  }

  .matrix-switcher button {
    padding: 8px 9px;
  }

  .matrix-switcher small {
    display: none;
  }

  .case-nav span {
    display: none;
  }

  .stage-labels {
    font-size: 10px;
  }

  .player-controls {
    flex-wrap: wrap;
    padding: 9px 0;
  }

  .control-note {
    order: 4;
    width: 100%;
    margin-left: 0;
  }

  .environment-layout {
    grid-template-columns: 1fr;
  }

  .environment-figures {
    grid-template-columns: 1fr;
  }

  .environment-figures img {
    height: min(76vw, 360px);
  }

  .metrics-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .content-dialog {
    padding: 24px 20px;
  }
}

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