:root {
  --bg: #05070a;
  --bg-soft: #0b0f15;
  --scanline: rgba(0, 0, 0, 0.28);
  --ink: #c9f0d4;
  --ink-dim: #6fae83;
  --ink-faint: #3f6b52;
  --accent: #35ff87;
  --accent-2: #2ec8ff;
  --amber: #ffb454;
  --rose: #ff5c8a;
  --hair: #1c2a22;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --glow: 0 0 4px currentColor, 0 0 18px rgba(53, 255, 135, 0.25);
}

:root[data-theme="amber"] {
  --ink: #ffd9a8;
  --ink-dim: #c98f4e;
  --ink-faint: #7a5730;
  --accent: #ffb454;
  --accent-2: #ff8f3f;
  --hair: #2a2013;
  --glow: 0 0 4px currentColor, 0 0 18px rgba(255, 180, 84, 0.25);
}

:root[data-theme="paper"] {
  --bg: #f4f4f2;
  --bg-soft: #ffffff;
  --scanline: rgba(0, 0, 0, 0.03);
  --ink: #1b1e22;
  --ink-dim: #565a63;
  --ink-faint: #9a9da5;
  --accent: #1f7a3d;
  --accent-2: #1163b6;
  --amber: #b26a00;
  --rose: #b23a58;
  --hair: #dcdcd8;
  --glow: none;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: radial-gradient(120% 120% at 50% 0%, var(--bg-soft), var(--bg) 70%);
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(11px, 2.6vw, 15px);
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-2);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.crt {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 3vw, 34px);
}

.crt::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    var(--scanline) 2px 4px
  );
}

.crt::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.04),
    transparent 12%,
    transparent 88%,
    rgba(0, 0, 0, 0.25)
  );
  box-shadow: inset 0 0 140px rgba(0, 0, 0, 0.55);
}

:root[data-theme="paper"] .crt::after {
  background: none;
  box-shadow: none;
}

.starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.5;
}

:root[data-theme="paper"] .starfield {
  opacity: 0.12;
}

.header {
  position: relative;
  z-index: 8;
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--hair);
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.brand {
  color: var(--ink);
  font-weight: 600;
  text-shadow: var(--glow);
}

.header-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.header-actions a,
.header-actions button {
  color: var(--ink-dim);
}

.header-actions a:hover,
.header-actions button:hover {
  color: var(--accent);
}

.blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.terminal {
  position: relative;
  z-index: 8;
  flex: 1;
  min-height: 0;
  margin-top: 12px;
  padding: 6px 4px 0;
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
  text-shadow: var(--glow);
  cursor: text;
}

.terminal::-webkit-scrollbar {
  width: 8px;
}

.terminal::-webkit-scrollbar-thumb {
  background: var(--hair);
}

.row {
  white-space: pre-wrap;
  word-break: break-word;
}

.row.dim {
  color: var(--ink-dim);
}

.row.ls-entry {
  padding-left: 4ch;
}

.ls-row {
  display: grid;
  column-gap: 1ch;
  align-items: start;
}

.ls-row .inline-link {
  white-space: pre;
}

.ls-stack {
  white-space: nowrap;
  color: var(--ink-faint);
}

.stack-tag-js {
  color: #f0d651;
}

.stack-tag-ts {
  color: var(--accent-2);
}

.stack-tag-astro {
  color: var(--rose);
}

.stack-tag-html {
  color: #ff8a5c;
}

.stack-tag-css {
  color: #6fa8ff;
}

.stack-tag-go {
  color: var(--accent);
}

.stack-tag-pdf {
  color: var(--amber);
}

@media (max-width: 500px) {
  .row.ls-entry {
    padding-left: 2ch;
  }
}

.row.faint {
  color: var(--ink-faint);
}

.row.accent {
  color: var(--accent);
}

.row.amber {
  color: var(--amber);
}

.row.rose {
  color: var(--rose);
}

.row.big {
  font-size: clamp(0.9rem, 2.4vw, 1.15rem);
  letter-spacing: 0.02em;
}

.row.art {
  white-space: pre;
  line-height: 1.15;
  font-size: clamp(0.5rem, 1.7vw, 0.82rem);
}

.inline-link {
  color: var(--accent-2);
  border-bottom: 1px dashed currentColor;
  text-align: left;
}

.inline-link:hover {
  color: var(--accent);
}

.prompt {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 4px;
  line-height: 1.15;
}

.prompt-label {
  flex-shrink: 0;
  color: var(--accent);
}

.prompt-label .path {
  color: var(--accent-2);
}

.prompt-input {
  flex: 1;
  min-width: 1px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  caret-color: transparent;
}

.prompt-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 0.6em;
  height: 1.15em;
  line-height: 1.15;
  text-align: center;
  color: var(--bg);
  background: var(--accent);
  box-shadow: var(--glow);
  white-space: pre;
  pointer-events: none;
  animation: blink 1.05s step-end infinite;
}

.prompt-idle .prompt-cursor {
  display: none;
}

.matrix {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000;
}

.matrix-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18px;
  text-align: center;
  color: var(--accent);
  font-size: 0.8rem;
  text-shadow: var(--glow);
}

.crash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 8vw, 120px);
  background: #1041c8;
  color: #fff;
  font-size: clamp(0.85rem, 2.2vw, 1.05rem);
  line-height: 1.7;
}

.crash p {
  margin-bottom: 1em;
}

.crash-face {
  font-size: clamp(2.5rem, 9vw, 5rem);
  margin-bottom: 0.3em;
}

.crash-progress {
  margin-top: 0.4em;
}

.crash small {
  display: block;
  margin-top: 1em;
  opacity: 0.75;
  font-size: 0.8em;
}

.preview-backdrop,
.help-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.26s ease;
}

.preview-backdrop.is-open,
.help-backdrop.is-open {
  opacity: 1;
}

.help-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-left: 1px solid var(--hair);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 0.26s ease;
}

.help-panel.is-open {
  transform: translateX(0);
}

.help-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hair);
  background: var(--bg);
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.help-title {
  color: var(--ink);
  font-weight: 600;
  text-shadow: var(--glow);
}

.help-close {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink-dim);
}

.help-close:hover {
  color: var(--accent);
}

.help-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.help-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  border: 1px solid transparent;
}

.help-row:hover {
  border-color: var(--accent);
  background: rgba(127, 174, 131, 0.1);
}

.help-cmd {
  color: var(--accent);
  text-shadow: var(--glow);
}

.help-summary {
  font-size: 0.78rem;
  color: var(--ink-dim);
}

.help-foot {
  margin-top: 12px;
  padding: 0 10px;
  font-size: 0.74rem;
  color: var(--ink-faint);
}

.preview {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: clamp(680px, 50vw, 1100px);
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border-left: 1px solid var(--hair);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
  transform: translateX(100%);
  transition: transform 0.26s ease;
}

.preview.is-open {
  transform: translateX(0);
}

.preview-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hair);
  background: var(--bg);
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.preview-title {
  color: var(--ink);
  font-weight: 600;
  text-shadow: var(--glow);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.preview-open {
  color: var(--accent-2);
}

.preview-open:hover {
  color: var(--accent);
}

.preview-close {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--ink-dim);
}

.preview-close:hover {
  color: var(--accent);
}

.preview-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.preview-screen {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.preview-shot-link {
  position: relative;
  display: block;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border-radius: 4px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.preview-shot {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
}

.preview-shot-hint {
  position: absolute;
  inset: auto 0 0 0;
  padding: 10px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  color: #fff;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.preview-shot-link:hover .preview-shot-hint,
.preview-shot-link:focus-visible .preview-shot-hint {
  opacity: 1;
}

.preview-pdf {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.preview-download {
  flex-shrink: 0;
  text-align: center;
  padding: 8px;
  border-top: 1px solid var(--hair);
  background: var(--bg);
  color: var(--accent-2);
}

.preview-download:hover {
  color: var(--accent);
}

.preview-message {
  margin: auto;
  padding: 24px;
  text-align: center;
  color: var(--ink-dim);
}

.preview-message p {
  margin-bottom: 12px;
}

.preview-message a {
  color: var(--accent-2);
}

.repo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.repo-crumbs {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--hair);
  background: var(--bg);
  font-size: 0.74rem;
}

.repo-crumb {
  color: var(--accent-2);
}

.repo-crumb:hover {
  text-decoration: underline;
}

.repo-crumb-file {
  color: var(--ink);
}

.repo-sep {
  color: var(--ink-faint);
}

.repo-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px 0;
  font-size: 0.78rem;
  color: var(--ink-dim);
}

.repo-list {
  display: flex;
  flex-direction: column;
}

.repo-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  padding: 4px 14px;
  text-align: left;
  color: var(--ink);
}

.repo-row:hover {
  background: rgba(127, 174, 131, 0.12);
}

.repo-glyph {
  flex-shrink: 0;
  width: 1em;
  color: var(--ink-faint);
}

.repo-row[data-type="dir"] .repo-name {
  color: var(--accent-2);
}

.code {
  display: grid;
  grid-template-columns: auto 1fr;
  font-size: 0.74rem;
  line-height: 1.6;
  tab-size: 2;
}

.code-gutter {
  position: sticky;
  left: 0;
  padding: 12px 10px 12px 14px;
  text-align: right;
  color: var(--ink-faint);
  background: var(--bg);
  border-right: 1px solid var(--hair);
  user-select: none;
  white-space: pre;
}

.code-gutter span {
  display: block;
}

.code-text {
  margin: 0;
  padding: 12px 14px;
  white-space: pre;
  color: var(--ink);
}

.code-line {
  display: block;
}

.tok-comment {
  color: var(--ink-faint);
}

.tok-keyword {
  color: var(--rose);
}

.tok-string {
  color: var(--accent);
}

.tok-number {
  color: var(--accent-2);
}

.tok-function {
  color: var(--amber);
}

.tok-tag {
  color: var(--accent);
}

.tok-attr {
  color: var(--accent-2);
}

/* project demo: tab strip shared with the source browser */
.preview-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 2px;
  padding: 6px 10px 0;
  border-bottom: 1px solid var(--hair);
  background: var(--bg);
}

.preview-tab {
  padding: 6px 12px;
  font-size: 0.74rem;
  color: var(--ink-faint);
  border-bottom: 1px solid transparent;
}

.preview-tab:hover {
  color: var(--ink-dim);
}

.preview-tab.is-active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

.preview-pane {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
}

.preview-pane.is-active {
  display: flex;
}

.demo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.demo-scenarios {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair);
}

.demo-scenario,
.demo-replay {
  padding: 4px 10px;
  font-size: 0.72rem;
  color: var(--ink-dim);
  border: 1px solid var(--hair);
  border-radius: 2px;
}

.demo-scenario:hover,
.demo-replay:hover {
  color: var(--ink);
  border-color: var(--accent-2);
}

.demo-scenario.is-active {
  color: var(--accent-2);
  border-color: var(--accent-2);
}

.demo-replay {
  margin-left: auto;
}

.demo-screen {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  font-size: 0.76rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}

.demo-line {
  min-height: 1.2em;
}

.demo-prompt {
  color: var(--accent-2);
}

.demo-ok {
  color: var(--accent);
}

.demo-bad {
  color: var(--rose);
}

.demo-warn {
  color: var(--amber);
}

.demo-dim {
  color: var(--ink-faint);
}

[hidden] {
  display: none !important;
}

.gallery {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: clamp(10px, 3vw, 34px);
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(11px, 2.6vw, 15px);
}

.gallery-header {
  flex-shrink: 0;
  padding-left: clamp(10px, 3vw, 34px);
  padding-right: clamp(10px, 3vw, 34px);
}

.gallery-body {
  overflow-y: auto;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--hair) transparent;
}

.gallery-body::-webkit-scrollbar {
  width: 8px;
}

.gallery-body::-webkit-scrollbar-thumb {
  background: var(--hair);
}

.gallery-inner {
  padding: 32px clamp(10px, 3vw, 34px) clamp(10px, 3vw, 34px);
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-section + .gallery-section {
  margin-top: 40px;
}

.gallery-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: var(--glow);
  margin-bottom: 16px;
}

.gallery-section-title::before {
  content: "// ";
  color: var(--ink-faint);
  text-shadow: none;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.gallery-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  padding: 20px 20px 20px 44px;
  border: 1px solid var(--hair);
  border-radius: 6px;
  background: var(--bg);
  overflow: hidden;
  opacity: 0;
  animation: card-in 0.3s ease forwards;
  animation-delay: calc(var(--card-order, 0) * 40ms);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.gallery-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    var(--scanline) 2px 4px
  );
  transition: opacity 0.15s ease;
}

.gallery-card > * {
  position: relative;
  z-index: 1;
}

.gallery-card::after {
  content: attr(data-index);
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1;
  color: var(--ink-faint);
  font-size: 0.75rem;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--glow);
}

.gallery-card:hover::before {
  opacity: 1;
}

.gallery-card:hover::after {
  color: var(--accent);
}

.gallery-card-name {
  font-weight: 600;
  color: var(--ink);
  text-shadow: var(--glow);
}

.gallery-card-desc {
  color: var(--ink-dim);
  font-size: 0.82rem;
  line-height: 1.5;
}

.gallery-card-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gallery-tag {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
}

.gallery-card-open {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 0.8rem;
}

.gallery-card-open-arrow {
  display: inline-block;
  transition: transform 0.15s ease;
}

.gallery-card:hover .gallery-card-open-arrow {
  transform: translateX(4px);
}

@media (max-width: 900px) {
  .preview {
    width: 100vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  .blink,
  .preview,
  .preview-backdrop,
  .help-panel,
  .help-backdrop {
    animation: none !important;
    transition: none !important;
  }
}
