:root {
  color-scheme: dark;
  --void: #050505;
  --background: #131313;
  --surface-lowest: #0e0e0e;
  --surface-low: #1c1b1b;
  --surface: #201f1f;
  --surface-high: #2a2a2a;
  --surface-highest: #353534;
  --text: #e5e2e1;
  --muted: #b9ccb2;
  --outline: #84967e;
  --outline-variant: #3b4b37;
  --primary: #00ff41;
  --primary-dim: #00e639;
  --on-primary: #003907;
  --secondary: #00e0ff;
  --error: #ffb4ab;
  --gutter: 16px;
  --desktop-margin: 32px;
  --footer-height: 44px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  scroll-padding-bottom: calc(var(--footer-height) + 24px);
}

body {
  margin: 0;
  background: var(--void);
  color: var(--text);
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button,
a,
input {
  font: inherit;
}

button,
a {
  cursor: pointer;
}

.topbar {
  position: fixed;
  z-index: 20;
  inset: 0 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--desktop-margin);
  background: rgb(19 19 19 / 90%);
  border-bottom: 1px solid var(--outline-variant);
  backdrop-filter: blur(12px);
}

.brand,
.primary-action,
.secondary-action,
.status-line,
.card-meta,
.card-stat,
.side-terminal,
.upload-rules,
.form-status,
.lightbox-toolbar {
  font-size: 12px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.brand {
  color: var(--primary-dim);
  letter-spacing: 0.2em;
}

.brand-link {
  text-decoration: none;
}

.brand-link:hover,
.brand-link:focus-visible {
  color: var(--text);
}

.primary-action,
.secondary-action,
.icon-action {
  border: 1px solid var(--outline-variant);
  border-radius: 0;
  min-height: 36px;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
}

.primary-action {
  padding: 0 24px;
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.primary-action:hover,
.primary-action:focus-visible {
  background: var(--text);
  border-color: var(--text);
}

.secondary-action {
  padding: 0 18px;
}

.secondary-action:hover,
.secondary-action:focus-visible,
.icon-action:hover,
.icon-action:focus-visible {
  border-color: var(--primary-dim);
  color: var(--primary-dim);
  background: var(--surface-high);
}

.icon-action {
  width: 36px;
  height: 36px;
}

.material-symbols-outlined {
  display: inline-block;
  font-family: "Material Symbols Outlined";
  font-size: 18px;
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
  direction: ltr;
  font-feature-settings: "liga";
  -webkit-font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 20;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(100%, 1440px);
  margin: 0 auto;
  padding: 96px var(--desktop-margin) calc(var(--footer-height) + 16px + env(safe-area-inset-bottom));
}

.status-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gutter);
  padding-bottom: 8px;
  color: var(--outline);
  font-size: 10px;
  border-bottom: 1px solid var(--outline-variant);
}

.protocol-menu {
  display: flex;
  align-items: center;
  gap: 16px;
}

.protocol-menu a,
.protocol-menu button {
  appearance: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: none;
}

.protocol-menu a:hover,
.protocol-menu a:focus-visible,
.protocol-menu button:hover,
.protocol-menu button:focus-visible {
  color: var(--primary-dim);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pulse {
  width: 6px;
  height: 6px;
  background: var(--primary);
  animation: pulse 1.4s steps(2, end) infinite;
}

.meme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 32px;
}

.meme-card {
  overflow: hidden;
  background: var(--surface-lowest);
  border: 1px solid #1a1a1a;
  box-shadow: 0 0 10px rgb(0 255 65 / 10%);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--outline-variant);
}

.card-id {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.node {
  position: relative;
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  background: var(--outline-variant);
}

.node.active {
  background: var(--primary);
}

.node-score-0 {
  opacity: 0.25;
}

.node-score-1 {
  opacity: 0.4;
}

.node-score-2 {
  opacity: 0.55;
}

.node-score-3 {
  opacity: 0.72;
}

.node-score-4 {
  opacity: 0.88;
}

.node-score-5 {
  opacity: 1;
  box-shadow: 0 0 8px rgb(0 255 65 / 45%);
}

.node::after {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  border: 1px solid var(--outline-variant);
  background: #111;
  color: var(--text);
  content: attr(data-tooltip);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  text-transform: uppercase;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.node:hover::after,
.node:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.card-meta {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.age {
  flex: 0 0 auto;
  color: var(--outline);
}

.image-frame {
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #000;
}

.image-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  opacity: 0.9;
  transition: transform 700ms ease, opacity 200ms ease;
}

.meme-card:hover img {
  transform: scale(1.05);
  opacity: 1;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px;
}

.stats {
  display: flex;
  gap: 14px;
  color: var(--muted);
}

.card-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  letter-spacing: 0;
}

.card-stat .material-symbols-outlined {
  color: var(--outline);
  font-size: 16px;
}

.action-group {
  display: flex;
  gap: 8px;
}

.text-action {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #1a1a1a;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-decoration: none;
}

.icon-only-action {
  width: 36px;
  height: 36px;
  padding: 0;
}

.text-action-accent {
  border-color: var(--primary-dim);
  color: var(--primary-dim);
}

.text-action:hover,
.text-action:focus-visible {
  border-color: var(--primary-dim);
  color: var(--primary-dim);
  background: var(--surface-high);
}

.text-action.is-copied {
  border-color: var(--primary);
  background: rgb(0 255 65 / 12%);
  color: var(--primary);
}

.text-action:disabled {
  cursor: wait;
  opacity: 0.65;
}

.feed-loader {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  margin-top: 16px;
  color: var(--outline);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.loader-ring {
  display: none;
  width: 32px;
  height: 32px;
  border: 2px solid transparent;
  border-top-color: var(--primary);
  border-radius: 9999px;
}

.feed-loader.is-spinning .loader-ring {
  display: block;
  animation: spin 850ms linear infinite;
}

.repo-footer {
  position: fixed;
  z-index: 20;
  inset: auto 0 0;
  display: flex;
  min-height: calc(var(--footer-height) + env(safe-area-inset-bottom));
  align-items: center;
  justify-content: center;
  padding: 0 16px env(safe-area-inset-bottom);
  border-top: 1px solid var(--outline-variant);
  background: var(--void);
  backdrop-filter: blur(12px);
}

.repo-footer a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--outline);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  opacity: 0.45;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 120ms ease, opacity 120ms ease;
}

.repo-footer a:hover,
.repo-footer a:focus-visible {
  color: var(--primary-dim);
  opacity: 0.85;
}

.repo-footer img {
  width: auto;
  height: 20px;
  object-fit: contain;
  opacity: 0.8;
}

.side-terminal {
  position: fixed;
  left: 16px;
  top: calc(64px + (100vh - 64px) / 2);
  transform: translateY(-50%);
  width: 192px;
  padding-left: 8px;
  border-left: 1px solid var(--outline-variant);
  color: var(--outline);
  font-size: 10px;
  opacity: 0.5;
  pointer-events: none;
}

.side-terminal .active {
  margin-top: 8px;
  color: var(--primary-dim);
  text-decoration: underline;
}

.terminal-strip {
  display: none;
  margin-top: 0;
  padding: 10px 0;
  color: var(--outline);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.terminal-strip strong {
  color: var(--muted);
  font-weight: 600;
}

.terminal-strip .active {
  color: var(--primary-dim);
  text-decoration: underline;
}

.scroll-indicator {
  position: fixed;
  right: 16px;
  top: calc(64px + (100vh - 64px) / 2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateY(-50%);
  opacity: 0.3;
}

.scroll-indicator span {
  display: block;
  width: 4px;
  height: 16px;
  background: var(--outline-variant);
  transition: height 160ms ease, background-color 160ms ease;
}

.scroll-indicator span.active {
  height: 32px;
  background: var(--primary);
}

dialog {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
}

dialog[open] {
  animation: dialog-in 140ms ease-out;
}

dialog::backdrop {
  background: rgb(0 0 0 / 72%);
  backdrop-filter: blur(4px);
  animation: backdrop-in 140ms ease-out;
}

.modal-panel {
  width: min(520px, calc(100vw - 32px));
  background: #111;
  border: 1px solid var(--outline-variant);
  box-shadow: 0 0 18px rgb(0 255 65 / 12%);
}

.share-panel {
  width: min(640px, calc(100vw - 32px));
}

.pet-panel {
  width: min(580px, calc(100vw - 32px));
}

.modal-header,
.lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border-bottom: 1px solid var(--outline-variant);
  background: var(--surface);
}

.lightbox-toolbar > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.lightbox-toolbar .icon-action {
  flex: 0 0 auto;
}

.modal-header h2 {
  margin: 0;
  font-family: Geist, Inter, system-ui, sans-serif;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.file-drop {
  display: flex;
  min-height: 160px;
  margin: 16px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--outline);
  background: var(--surface-lowest);
  color: var(--muted);
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-rules,
.form-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 16px;
  color: var(--outline);
  font-size: 10px;
}

.form-status {
  min-height: 18px;
  margin-bottom: 16px;
  color: var(--error);
}

.share-body {
  padding: 18px 16px 16px;
}

.share-body label,
.share-status {
  color: var(--outline);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.share-link-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.share-link-row input {
  min-width: 0;
  flex: 1 1 auto;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--outline-variant);
  border-radius: 0;
  outline: 0;
  background: var(--surface-lowest);
  color: var(--text);
  font-size: 12px;
}

.share-link-row input:focus {
  border-color: var(--primary-dim);
}

.share-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}

.share-copy:disabled {
  cursor: wait;
  opacity: 0.65;
}

.share-status {
  min-height: 16px;
  margin: 10px 0 0;
  color: var(--primary-dim);
}

.pet-downloads {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.pet-prompt {
  margin: 0 0 4px;
  color: var(--outline);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pet-footnote {
  margin: 4px 0 0;
  color: var(--outline);
  font-size: 9px;
  line-height: 1.5;
}

.pet-footnote a {
  color: var(--muted);
  text-underline-offset: 2px;
}

.pet-footnote a:hover,
.pet-footnote a:focus-visible {
  color: var(--primary-dim);
}

.pet-download {
  display: flex;
  min-width: 0;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--outline-variant);
  background: var(--surface-lowest);
  color: var(--muted);
  text-decoration: none;
}

.pet-download:hover,
.pet-download:focus-visible {
  border-color: var(--primary-dim);
  background: var(--surface-high);
  color: var(--primary-dim);
}

.pet-download > span:first-child {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.pet-download strong,
.pet-download small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-download strong {
  font-size: 12px;
  letter-spacing: 0.1em;
}

.pet-download small {
  color: var(--outline);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.pet-download > .material-symbols-outlined {
  flex: 0 0 auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.danger-action {
  border-color: var(--error);
  color: var(--error);
}

.review-select {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.review-select input {
  accent-color: var(--primary);
}

.review-body {
  min-height: 76px;
  padding: 12px;
  border-top: 1px solid var(--outline-variant);
  color: var(--outline);
  font-size: 11px;
  line-height: 1.45;
}

.review-body p {
  margin: 0;
}

.lightbox {
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: #080808;
  border: 1px solid var(--outline-variant);
  box-shadow: 0 0 24px rgb(0 255 65 / 14%);
}

.lightbox[open] {
  display: flex;
  flex-direction: column;
}

.lightbox img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 176px);
  margin: 0 auto;
  object-fit: contain;
  background: #000;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 12px 4px;
}

.lorebox {
  width: min(760px, calc(100vw - 32px));
}

.lore-text {
  min-height: 260px;
  max-height: calc(100vh - 176px);
  margin: 0;
  overflow: auto;
  padding: 24px;
  background: #080808;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.lore-actions {
  justify-content: flex-end;
}

.viewer-status {
  min-height: 16px;
  margin: 0 12px 8px;
  color: var(--primary-dim);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.action-toast {
  position: fixed;
  z-index: 19;
  right: 16px;
  bottom: calc(var(--footer-height) + 12px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 6px 8px;
  background: var(--surface);
  color: var(--primary-dim);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.action-toast:empty {
  display: none;
}

.clipboard-fallback {
  position: fixed;
  inset: auto auto 0 -9999px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 48px 16px;
  border: 1px solid var(--outline-variant);
  color: var(--outline);
  text-align: center;
}

.not-found-page {
  min-height: 100svh;
  overflow-x: hidden;
}

.not-found-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100svh;
}

.not-found-content {
  display: grid;
  width: min(100%, 760px);
  justify-items: center;
  place-self: center;
  padding: 24px 0 48px;
  text-align: center;
}

.not-found-visual {
  position: relative;
  isolation: isolate;
  width: clamp(127px, 26vmin, 276px);
  max-width: 100%;
}

.not-found-page .pulse {
  background: #ff453a;
  box-shadow: 0 0 8px rgb(255 69 58 / 55%);
}

.not-found-visual::before {
  position: absolute;
  z-index: -1;
  inset: 7% 5% 6%;
  border-radius: 50%;
  background:
    radial-gradient(
      ellipse at 50% 47%,
      rgb(0 255 65 / 48%) 0%,
      rgb(0 230 57 / 30%) 36%,
      rgb(0 128 33 / 14%) 58%,
      transparent 76%
    ),
    radial-gradient(
      ellipse at 50% 48%,
      rgb(0 255 65 / 14%) 0%,
      transparent 72%
    );
  content: "";
  filter: blur(36px);
  transform: scale(1.24);
}

.not-found-visual img {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.06) drop-shadow(0 0 16px rgb(0 255 65 / 16%));
}

.not-found-action {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
}

[hidden] {
  display: none !important;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

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

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 1759px) and (min-width: 901px) {
  .side-terminal {
    display: none;
  }

  .terminal-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    align-items: center;
  }
}

@media (min-width: 1760px) {
  .terminal-strip {
    display: none;
  }
}

@media (max-width: 900px) {
  .topbar,
  .shell {
    padding-left: 16px;
    padding-right: 16px;
  }

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

  .side-terminal,
  .terminal-strip,
  .scroll-indicator {
    display: none;
  }
}

@media (max-width: 560px) {
  .topbar {
    height: 60px;
  }

  .brand {
    font-size: 10px;
    letter-spacing: 0.14em;
  }

  .admin-actions .secondary-action,
  .admin-actions .primary-action {
    min-height: 30px;
    padding-inline: 8px;
    font-size: 9px;
  }

  .primary-action,
  .secondary-action {
    padding-inline: 14px;
  }

  .share-link-row {
    align-items: stretch;
    flex-direction: column;
  }

  .share-copy {
    justify-content: center;
  }

  .shell {
    padding-top: 84px;
  }

  .status-line,
  .card-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .action-group,
  .stats {
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  .not-found-page .pulse {
    animation: none;
  }
}
