:root {
  color-scheme: dark;
  --ink: #edf3f8;
  --muted: #94a2b1;
  --line: rgba(198, 214, 226, 0.16);
  --panel: rgba(4, 9, 15, 0.78);
  --panel-strong: rgba(3, 7, 12, 0.93);
  --accent: #d5e9fa;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #02050a; }

body {
  min-width: 320px;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, a { font: inherit; }
button { color: inherit; }

.forge {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: #02050a;
}

.space-background,
.space-shade,
.forge-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

.space-background {
  z-index: -4;
  background: #02050a url("./assets/background.jpg") center 44% / cover no-repeat;
}

.space-shade {
  z-index: -3;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(0, 2, 5, 0.18) 0%, rgba(0, 2, 5, 0.02) 38%, rgba(0, 3, 7, 0.28) 66%, rgba(0, 3, 7, 0.96) 100%),
    radial-gradient(circle at 50% 42%, transparent 0 18%, rgba(1, 4, 8, 0.08) 32%, rgba(1, 4, 8, 0.48) 78%);
}

.forge-canvas {
  z-index: -2;
  pointer-events: none;
}

.masthead {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: max(22px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left));
}

.lab-link,
.plain-button {
  color: rgba(232, 240, 246, 0.78);
  text-decoration: none;
  letter-spacing: .16em;
  font-size: 11px;
  font-weight: 600;
}

.lab-link:hover,
.plain-button:hover { color: #fff; }

.masthead-actions { display: flex; gap: 18px; }

.plain-button {
  border: 0;
  padding: 7px 0;
  background: transparent;
  cursor: pointer;
}

.plain-button:focus-visible,
.panel-close:focus-visible,
.archive-toggle:focus-visible,
.history-item:focus-visible,
.block-link:focus-visible,
.lab-link:focus-visible {
  outline: 2px solid rgba(220, 237, 250, .9);
  outline-offset: 4px;
}

.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;
}

.archive-kicker,
.panel-kicker {
  margin: 0;
  color: rgba(211, 226, 237, 0.58);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
}

#connection-state[data-state="live"] { color: #cbe9dc; }
#connection-state[data-state="retry"] { color: #dfc9a1; }
#connection-state[data-state="offline"] { color: #d9aaa5; }

.network-status {
  margin: 18px 0 20px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.network-status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 11px;
  color: rgba(199, 215, 226, .55);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .14em;
}

.network-status-line strong { font-weight: 700; }

.status-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(207, 229, 219, .7);
  box-shadow: 0 0 10px rgba(190, 230, 211, .22);
}

.network-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.network-readout span { display: grid; gap: 4px; }
.network-readout small { color: rgba(200, 214, 224, .48); font-size: 9px; letter-spacing: .12em; }
.network-readout strong { color: rgba(239, 246, 251, .88); font: 500 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }

.archive {
  position: fixed;
  z-index: 24;
  right: max(28px, env(safe-area-inset-right));
  bottom: max(44px, calc(38px + env(safe-area-inset-bottom)));
  left: max(28px, env(safe-area-inset-left));
  overflow: hidden;
  border: 1px solid rgba(199, 215, 226, .12);
  background: linear-gradient(180deg, rgba(4, 9, 15, .66), rgba(4, 9, 15, .88));
  backdrop-filter: blur(17px) saturate(115%);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

.archive-toggle {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  color: rgba(222, 233, 241, .72);
  cursor: pointer;
  text-align: left;
}

.archive-toggle::-webkit-details-marker { display: none; }
.archive-toggle::marker { content: ""; }
.archive-toggle:hover { color: #fff; }

.archive-toggle-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .2em;
}

.archive-chevron {
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(225deg) translate(-1px, -1px);
  transition: transform .24s ease;
}

.archive[open] .archive-chevron { transform: rotate(45deg) translate(-1px, -1px); }

.archive-body {
  max-height: 0;
  padding: 0 18px;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: max-height .28s ease, padding .28s ease, opacity .2s ease, transform .28s ease, visibility 0s linear .28s;
}

.archive[open] .archive-body {
  max-height: 176px;
  padding: 2px 18px 14px;
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.archive-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.archive-heading h2 {
  margin: 3px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 400;
}

.archive-note {
  margin: 0;
  color: rgba(201, 214, 224, .48);
  font-size: 10px;
}

.history-track {
  display: flex;
  gap: 8px;
  min-height: 91px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(197, 214, 225, .24) transparent;
  padding-bottom: 2px;
}

.history-loading {
  align-self: center;
  margin: 0;
  color: rgba(206, 219, 229, .5);
  font-size: 12px;
}

.history-item {
  position: relative;
  flex: 0 0 96px;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  gap: 5px;
  min-height: 88px;
  border: 1px solid rgba(190, 208, 222, .08);
  background: rgba(7, 12, 18, .36);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}

.history-item:hover {
  transform: translateY(-2px);
  border-color: rgba(204, 222, 235, .28);
  background: rgba(11, 18, 26, .64);
}

.history-item.is-new { animation: archive-arrival 1.15s ease both; }

.history-star,
.detail-star {
  --star-h: 42;
  --star-size: 30px;
  --star-alpha: .7;
  position: relative;
  width: var(--star-size);
  height: var(--star-size);
  border-radius: 50%;
  background:
    radial-gradient(circle at 37% 34%, hsla(var(--star-h), 100%, 98%, .98) 0 10%, hsla(var(--star-h), 88%, 85%, .98) 22%, hsla(var(--star-h), 82%, 63%, .93) 48%, hsla(var(--star-h), 74%, 42%, .68) 70%, transparent 72%);
  box-shadow:
    0 0 calc(var(--star-size) * .45) hsla(var(--star-h), 90%, 75%, calc(var(--star-alpha) * .55)),
    0 0 calc(var(--star-size) * 1.15) hsla(var(--star-h), 88%, 61%, calc(var(--star-alpha) * .20));
}

.history-star::after,
.detail-star::after {
  content: "";
  position: absolute;
  inset: -27%;
  border-radius: 50%;
  border: 1px solid hsla(var(--star-h), 78%, 76%, .12);
  opacity: var(--star-alpha);
}

.history-height {
  color: rgba(220, 232, 240, .58);
  font: 500 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
}

.block-panel,
.info-panel {
  position: fixed;
  z-index: 40;
  top: 72px;
  right: max(22px, env(safe-area-inset-right));
  width: min(390px, calc(100vw - 44px));
  max-height: calc(100svh - 154px);
  overflow: auto;
  padding: 25px;
  border: 1px solid rgba(202, 219, 232, .16);
  background: var(--panel-strong);
  backdrop-filter: blur(22px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .48);
}

.block-panel[hidden],
.info-panel[hidden] { display: none; }

.panel-close {
  position: absolute;
  top: 13px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  color: rgba(227, 238, 246, .62);
  font-size: 22px;
  cursor: pointer;
}

.block-panel h2,
.info-panel h2 {
  margin: 7px 34px 14px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.25;
}

.info-panel > p:not(.panel-kicker):not(.source-note) {
  color: rgba(220, 231, 239, .73);
  font-size: 13px;
  line-height: 1.75;
}

.info-panel a,
.block-link { color: #d9e9f5; text-underline-offset: 4px; }

.source-note { color: rgba(189, 204, 215, .5); font-size: 11px; line-height: 1.65; }

.mapping-list,
.block-data { margin: 17px 0; }

.mapping-list div,
.block-data div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.mapping-list div:last-child,
.block-data div:last-child { border-bottom: 1px solid var(--line); }

.mapping-list dt,
.block-data dt { color: rgba(192, 207, 218, .55); font-size: 10px; letter-spacing: .06em; }
.mapping-list dd,
.block-data dd { margin: 0; color: rgba(235, 242, 247, .82); font-size: 11px; text-align: right; }

.detail-star {
  --star-size: 66px;
  margin: 20px 0 18px;
}

#detail-hash {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.block-link { display: inline-block; margin-top: 4px; font-size: 11px; }

.site-legal--011 {
  position: fixed;
  z-index: 18;
  left: max(28px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
}

@keyframes archive-arrival {
  0% { opacity: 0; transform: translateY(-16px) scale(.9); }
  55% { opacity: 1; transform: translateY(2px) scale(1.03); }
  100% { transform: none; }
}

@media (max-width: 760px) {
  .space-background { background-position: 50% 40%; }

  .masthead { padding-right: 18px; padding-left: 18px; }
  .lab-link { letter-spacing: .12em; }
  .masthead-actions { gap: 14px; }

  .archive {
    right: 14px;
    bottom: max(42px, calc(36px + env(safe-area-inset-bottom)));
    left: 14px;
  }

  .archive-toggle { min-height: 44px; padding: 0 13px; }
  .archive[open] .archive-body { max-height: 164px; padding: 1px 12px 12px; }
  .archive-body { padding-right: 12px; padding-left: 12px; }
  .archive-heading { display: block; margin-bottom: 10px; }
  .archive-heading h2 { font-size: 16px; white-space: nowrap; }
  .archive-note { display: none !important; }
  .history-item { flex-basis: 82px; min-height: 83px; }

  .block-panel,
  .info-panel {
    top: auto;
    right: 12px;
    bottom: max(18px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-height: min(72svh, 620px);
  }

  .site-legal--011 { left: 18px; bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (max-height: 690px) and (min-width: 761px) {
  .archive[open] .archive-body { max-height: 154px; }
  .history-item { min-height: 70px; }
}

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