:root {
  --bg: #03110b;
  --bg-soft: rgba(7, 30, 18, 0.82);
  --bg-panel: rgba(4, 17, 11, 0.88);
  --line: rgba(104, 255, 160, 0.3);
  --line-strong: rgba(129, 255, 180, 0.65);
  --text: #b9ffc9;
  --text-dim: #7ccf96;
  --text-hot: #ecffd7;
  --accent: #8dff63;
  --accent-warm: #ffe07a;
  --danger: #ff8f6b;
  --danger-soft: rgba(255, 143, 107, 0.14);
  --artifact: #86f8ff;
  --film: #8dff63;
  --event: #ffb86c;
  --shadow: 0 0 24px rgba(103, 255, 137, 0.16);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  font-size: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(54, 123, 69, 0.14), transparent 38%),
    radial-gradient(circle at bottom right, rgba(181, 255, 92, 0.08), transparent 28%),
    linear-gradient(180deg, #010503 0%, #04110b 45%, #02100a 100%);
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  text-shadow: 0 0 10px rgba(132, 255, 171, 0.18);
  overflow-x: hidden;
}

body.overlay-open {
  overflow: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.32) 100%);
  pointer-events: none;
  z-index: 1;
}

body.reader-focus .layout {
  display: block;
}

body.reader-focus .sidebar,
body.reader-focus .archive-panel,
body.reader-focus .terminal-panel {
  display: none;
}

.screen-noise,
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.screen-noise {
  opacity: 0.06;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.8) 0.55px, transparent 0.8px),
    radial-gradient(rgba(255, 255, 255, 0.35) 0.55px, transparent 0.8px);
  background-position: 0 0, 13px 11px;
  background-size: 16px 16px;
  animation: noiseDrift 12s linear infinite;
}

.scanlines {
  background:
    linear-gradient(
      180deg,
      rgba(188, 255, 200, 0.045) 0,
      rgba(188, 255, 200, 0.045) 50%,
      rgba(0, 0, 0, 0.14) 50%,
      rgba(0, 0, 0, 0.14) 100%
    ),
    linear-gradient(
      90deg,
      rgba(255, 0, 76, 0.02),
      rgba(134, 255, 152, 0.015),
      rgba(0, 87, 255, 0.02)
    );
  background-size: 100% 4px, 8px 100%;
  opacity: 0.55;
}

.overlay-shell {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 4, 2, 0.72);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.overlay-shell.is-visible {
  opacity: 1;
  visibility: visible;
}

.noscript-shell {
  position: relative;
  z-index: 5;
  width: min(1080px, calc(100% - 32px));
  margin: 24px auto 0;
}

.noscript-panel {
  padding: 18px 20px;
}

.noscript-panel p {
  margin: 0;
  line-height: 1.7;
}

.overlay-panel {
  width: min(620px, 100%);
  padding: 22px;
}

.overlay-panel h2 {
  margin: 0 0 14px;
  color: var(--text-hot);
  font-size: clamp(1.9rem, 4vw, 2.8rem);
}

.overlay-panel p {
  margin: 0 0 12px;
  line-height: 1.75;
}

.overlay-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.shell {
  position: relative;
  z-index: 3;
  width: min(1080px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.panel {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(143, 255, 162, 0.05), rgba(255, 255, 255, 0) 16%),
    var(--bg-panel);
  box-shadow: inset 0 1px 0 rgba(203, 255, 212, 0.06), var(--shadow);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(130, 255, 155, 0.05), transparent 45%);
  pointer-events: none;
}

.hero {
  padding: 26px;
}

.hero-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.badge {
  padding: 6px 10px;
  border: 1px solid rgba(144, 255, 146, 0.26);
  border-radius: 999px;
  background: rgba(20, 48, 27, 0.72);
  color: var(--text-dim);
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.badge-live {
  color: #04220d;
  background: linear-gradient(90deg, var(--accent), #d4ff81);
  border-color: transparent;
  text-shadow: none;
  font-weight: 700;
}

.badge-button {
  cursor: pointer;
}

.title-block h1 {
  margin: 0;
  font-family: "VT323", monospace;
  font-size: clamp(3rem, 8vw, 6.5rem);
  line-height: 0.88;
  letter-spacing: 0.04em;
  color: var(--text-hot);
  text-shadow:
    0 0 10px rgba(194, 255, 195, 0.32),
    0 0 24px rgba(137, 255, 148, 0.25);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-warm);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.lead {
  width: min(760px, 100%);
  margin: 14px 0 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.7;
}

.boot-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.boot-cell {
  padding: 14px 16px;
  border: 1px solid rgba(145, 255, 155, 0.16);
  border-radius: 16px;
  background: rgba(10, 32, 19, 0.78);
}

.boot-label,
.panel-code,
.panel-meta,
.entry-tag,
.prompt {
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.boot-label,
.panel-meta {
  display: block;
  color: var(--text-dim);
  font-size: 0.74rem;
}

.boot-cell strong {
  display: block;
  margin-top: 8px;
  color: var(--text-hot);
  font-size: 1.05rem;
}

.status-strip {
  margin-top: 18px;
  padding: 14px 18px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-size: 0.92rem;
}

.cursor {
  display: inline-block;
  width: 0.7ch;
  animation: blink 1.1s step-end infinite;
}

.layout {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 18px;
}

.entry-panel,
.archive-panel,
.terminal-panel {
  padding: 20px;
}

.entry-panel {
  flex: 1 1 0;
  min-width: 0;
  align-self: start;
  scroll-margin-top: 18px;
}

.sidebar {
  flex: 0 0 min(360px, 34%);
  min-width: 300px;
  display: grid;
  gap: 18px;
  align-self: start;
}

.state-panel,
.about-panel,
.visit-panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px dashed rgba(146, 255, 154, 0.2);
}

.panel-code {
  color: var(--text-hot);
  font-size: 0.78rem;
}

.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.terminal-button {
  border: 1px solid rgba(146, 255, 154, 0.24);
  border-radius: 999px;
  background: rgba(12, 38, 22, 0.9);
  color: var(--text-hot);
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.terminal-button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.terminal-button.secondary {
  color: var(--accent-warm);
  background: rgba(39, 33, 13, 0.9);
}

.entry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.entry-tag {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(151, 255, 154, 0.2);
  background: rgba(16, 45, 25, 0.8);
  color: var(--accent-warm);
  font-size: 0.75rem;
}

.source-kind[data-type="film"] {
  border-color: rgba(141, 255, 99, 0.36);
  color: var(--film);
}

.source-kind[data-type="artifact"] {
  border-color: rgba(134, 248, 255, 0.3);
  color: var(--artifact);
}

.source-kind[data-type="event"] {
  border-color: rgba(255, 184, 108, 0.34);
  color: var(--event);
}

.entry-panel h2 {
  margin: 0 0 18px;
  color: var(--text-hot);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.1;
}

.entry-body {
  color: var(--text);
  line-height: 1.85;
  font-size: 0.98rem;
  white-space: pre-line;
  transition: opacity 180ms ease;
}

.entry-panel.is-flashing {
  animation: entryFlash 900ms ease;
}

.loading-copy {
  opacity: 0.8;
}

.telemetry {
  display: grid;
  gap: 10px;
  margin: 0;
}

.metric {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(143, 255, 155, 0.1);
}

.metric:last-child {
  border-bottom: none;
}

.metric-text {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.metric dt {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
}

.metric dd {
  margin: 0;
  color: var(--text-hot);
  font-family: "VT323", monospace;
  font-size: 2rem;
}

.metric small {
  margin-left: 4px;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.metric-bar {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(69, 120, 82, 0.18);
}

.metric-bar span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(141, 255, 99, 0.5), rgba(236, 255, 215, 0.92));
  transition: width 280ms ease;
}

.visit-panel {
  background:
    linear-gradient(180deg, rgba(255, 227, 119, 0.06), rgba(255, 255, 255, 0) 20%),
    rgba(17, 22, 10, 0.9);
}

.visit-copy {
  margin: 0;
  color: var(--text);
  line-height: 1.75;
}

.visit-count {
  margin: 12px 0 6px;
  font-family: "VT323", monospace;
  font-size: clamp(3rem, 7vw, 5rem);
  line-height: 0.95;
  color: var(--accent-warm);
  text-shadow:
    0 0 10px rgba(255, 224, 122, 0.2),
    0 0 20px rgba(255, 224, 122, 0.08);
}

.visit-note {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.6;
}

.about-panel p,
.archive-card p,
.console-log p {
  margin: 0;
  line-height: 1.7;
}

.about-panel {
  background:
    linear-gradient(180deg, rgba(255, 227, 119, 0.04), rgba(255, 255, 255, 0) 18%),
    rgba(17, 22, 10, 0.88);
}

.archive-toolbar {
  display: flex;
  align-items: center;
}

.archive-hint {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.archive-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.archive-card {
  width: 100%;
  text-align: left;
  padding: 16px;
  border: 1px solid rgba(148, 255, 153, 0.15);
  border-radius: 16px;
  background: rgba(9, 27, 17, 0.85);
  color: inherit;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.archive-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 0 18px rgba(114, 255, 150, 0.12);
}

.archive-card.is-active {
  border-color: var(--accent-warm);
  background: rgba(28, 34, 15, 0.9);
}

.archive-card h3 {
  margin: 0 0 10px;
  color: var(--text-hot);
  font-size: 1rem;
  line-height: 1.4;
}

.archive-card .meta {
  margin-bottom: 10px;
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.archive-type {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.archive-type[data-type="film"] {
  color: var(--film);
  border-color: rgba(141, 255, 99, 0.24);
  background: rgba(28, 59, 24, 0.52);
}

.archive-type[data-type="artifact"] {
  color: var(--artifact);
  border-color: rgba(134, 248, 255, 0.24);
  background: rgba(15, 44, 49, 0.52);
}

.archive-type[data-type="event"] {
  color: var(--event);
  border-color: rgba(255, 184, 108, 0.24);
  background: rgba(57, 39, 18, 0.52);
}

.archive-card .archive-action {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
}

.archive-empty {
  color: var(--text-dim);
}

.console-log {
  display: grid;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.console-log .prompt {
  color: var(--accent-warm);
}

.terminal-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding: 0 8px 8px;
}

.terminal-footer-link {
  color: var(--text-dim);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: color 150ms ease, text-shadow 150ms ease;
}

.terminal-footer-link:hover {
  color: var(--text-hot);
  text-shadow: 0 0 12px rgba(132, 255, 171, 0.22);
}

.boot-sequence,
.reveal {
  opacity: 1;
  transform: translateY(0);
  animation: bootIn 680ms ease both;
}

.reveal:nth-of-type(1) {
  animation-delay: 100ms;
}

.reveal:nth-of-type(2) {
  animation-delay: 180ms;
}

.reveal:nth-of-type(3) {
  animation-delay: 260ms;
}

.reveal:nth-of-type(4) {
  animation-delay: 340ms;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }

  50%,
  100% {
    opacity: 0;
  }
}

@keyframes bootIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes noiseDrift {
  from {
    transform: translate3d(0, 0, 0);
  }

  50% {
    transform: translate3d(0, 8px, 0);
  }

  to {
    transform: translate3d(0, 0, 0);
  }
}

@keyframes entryFlash {
  0% {
    box-shadow: inset 0 1px 0 rgba(203, 255, 212, 0.06), var(--shadow);
    border-color: var(--line);
  }

  35% {
    box-shadow:
      inset 0 1px 0 rgba(203, 255, 212, 0.06),
      0 0 28px rgba(255, 224, 122, 0.28);
    border-color: rgba(255, 224, 122, 0.6);
  }

  100% {
    box-shadow: inset 0 1px 0 rgba(203, 255, 212, 0.06), var(--shadow);
    border-color: var(--line);
  }
}

@media (max-width: 960px) {
  .layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-width: 0;
  }

  .boot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 18px, 100%);
    margin-top: 10px;
  }

  .hero,
  .entry-panel,
  .archive-panel,
  .terminal-panel,
  .state-panel,
  .about-panel,
  .visit-panel {
    padding: 16px;
  }

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

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .archive-list {
    grid-template-columns: 1fr;
  }

  .overlay-shell {
    padding: 14px;
  }
}
