@font-face {
  font-family: "Rajdhani";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/rajdhani-500.woff2") format("woff2");
}
@font-face {
  font-family: "Rajdhani";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/rajdhani-600.woff2") format("woff2");
}
@font-face {
  font-family: "Rajdhani";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/rajdhani-700.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/source-sans-3-400.woff2") format("woff2");
}
@font-face {
  font-family: "Source Sans 3";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/source-sans-3-600.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/jetbrains-mono-400.woff2") format("woff2");
}

:root {
  --asphalt: #070b0e;
  --panel: #121c22;
  --panel-2: #18262d;
  --ink: #e7f6f8;
  --ink-strong: #f4fcfd;
  --muted: #c5d8de;
  --cyan: #5cefff;
  --cyan-ink: #042026;
  --chrome: #d5dee4;
  --matrix: #9ee7c2;
  --matrix-strong: #d9ffcf;
  --matrix-deep: #16351c;
  --line: rgba(160, 220, 230, 0.22);
  --danger: #ffb4b4;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.38);
  --sans: "Source Sans 3", Inter, "Segoe UI", sans-serif;
  --display: "Rajdhani", Inter, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--asphalt);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 8% -10%, rgba(18, 110, 130, 0.28), transparent 55%),
    radial-gradient(800px 380px at 110% 0%, rgba(28, 70, 52, 0.16), transparent 50%),
    var(--asphalt);
}

[hidden] { display: none !important; }

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: repeating-linear-gradient(
    -17deg,
    transparent,
    transparent 16px,
    rgba(150, 230, 240, 0.045) 16px,
    rgba(150, 230, 240, 0.045) 17px
  );
  animation: rain-drift 16s linear infinite;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 35%, rgba(0, 0, 0, 0.42) 100%);
}

@keyframes rain-drift {
  from { background-position: 0 0; }
  to { background-position: 90px 240px; }
}

.wrap {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 calc(28px + env(safe-area-inset-bottom));
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 5;
  background: var(--cyan);
  color: var(--cyan-ink);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 700;
}

.skip:focus { top: 12px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, rgba(92, 239, 255, 0.7), rgba(158, 231, 194, 0.45), transparent 80%) 1;
}

.eyebrow {
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--matrix);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8dff72;
  box-shadow: 0 0 10px #8dff72;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.1rem, 6vw, 3.5rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: var(--ink-strong);
}

.tagline {
  margin: 8px 0 0;
  max-width: 38rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.tally-card {
  min-width: 132px;
  padding: 10px 16px 12px;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(213, 222, 228, 0.14), rgba(213, 222, 228, 0.03)),
    #0d171c;
  border: 1px solid rgba(213, 222, 228, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), var(--shadow);
  text-align: right;
}

.tally {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1;
  letter-spacing: 0.03em;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

.tally-label {
  margin: 2px 0 0;
  color: var(--matrix);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.controls {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-row,
.tool-row,
.sync-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tool-row { justify-content: space-between; }

.search {
  flex: 1 1 220px;
  display: block;
}

.search input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(92, 239, 255, 0.4);
  background: #0c161b;
  color: var(--ink-strong);
  font: 1rem/1.3 var(--sans);
}

.search input::placeholder { color: #a9c3cb; }

.search input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

button,
.random-btn,
.ghost,
.show-more,
.chip {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(92, 239, 255, 0.25);
}

.random-btn,
.ghost,
.chip,
.show-more,
.actions button,
.detail-cover-actions button,
.confirm-actions button {
  min-height: 44px;
}

.random-btn {
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--cyan);
  background: rgba(92, 239, 255, 0.12);
  color: var(--ink-strong);
  font-size: 1.05rem;
}

.chip {
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(92, 239, 255, 0.38);
  background: #102026;
  color: var(--ink-strong);
  font-size: 1.05rem;
}

.chip[aria-pressed="true"] {
  background: var(--cyan);
  color: var(--cyan-ink);
  border-color: var(--cyan);
}

.chip-count {
  font-family: var(--mono);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0;
  color: var(--matrix);
}

.chip-count:not(:empty) { margin-left: 0.45em; }

.chip[aria-pressed="true"] .chip-count { color: #064048; }

.ghost,
.detail-cover-actions button,
.confirm-actions .ghost {
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(213, 222, 228, 0.4);
  background: transparent;
  color: var(--chrome);
  font-size: 1.02rem;
}

.result-meta,
.boot,
.status,
.colophon,
.year-note {
  color: var(--muted);
}

.result-meta,
.boot { margin: 0; }

.status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #10241c;
  border-left: 3px solid #8dff72;
  color: var(--matrix-strong);
}

.status[data-tone="error"] {
  background: #2a1618;
  border-left-color: var(--danger);
  color: #ffd5d5;
}

.shelf {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 26px 12px;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  scroll-margin-top: 12px;
  padding: 8px 8px 0;
  border-radius: 12px 12px 8px 8px;
  background: linear-gradient(180deg, #1a2a30, #10191e 70%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
}

.card.is-picked {
  border-color: #8dff72;
  box-shadow: 0 0 0 3px rgba(141, 255, 114, 0.28), var(--shadow);
}

.card::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -9px;
  height: 8px;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(180deg, #b7c6cc, #6d7e86 35%, #1a2428 70%, #070b0e);
  box-shadow: 0 8px 10px rgba(0, 0, 0, 0.45);
}

.cover-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  border-radius: 4px 8px 8px 4px;
}

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 3px 8px 8px 3px;
  overflow: hidden;
  background: #0b1418;
}

.cover::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: 0;
  top: 0;
  bottom: 0;
  width: 9px;
  background: linear-gradient(90deg, #8d9ea6, #d7e2e7 42%, #6a7c84 48%, #c5d0d6 70%, #4e5c63);
  pointer-events: none;
}

.cover::after {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 0;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.16), transparent 28%, transparent 60%, rgba(92, 239, 255, 0.08));
  pointer-events: none;
}

.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 10px 12px 16px;
  background:
    linear-gradient(165deg, rgba(92, 239, 255, 0.2), transparent 42%),
    linear-gradient(180deg, #1a3d46, #0c171c 72%);
}

.cover-code {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--cyan);
}

.cover-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.05;
  color: var(--ink-strong);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.photo-flag {
  position: absolute;
  z-index: 4;
  top: 8px;
  right: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(7, 16, 14, 0.82);
  color: var(--matrix-strong);
  border: 1px solid rgba(141, 255, 114, 0.7);
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  padding: 8px 2px 10px;
}

.title-btn {
  display: -webkit-box;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-strong);
  text-align: left;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.12rem;
  line-height: 1.15;
  cursor: pointer;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.meta {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
}

.tag {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(92, 239, 255, 0.08);
  color: #d5f7fb;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.actions .cover-set { grid-column: 1 / -1; }

.own,
.want,
.cover-set,
.detail-cover-actions button {
  border-radius: 10px;
  border: 1px solid rgba(92, 239, 255, 0.45);
  background: transparent;
  color: var(--ink-strong);
  font-size: 1rem;
}

.cover-set { border-color: rgba(213, 222, 228, 0.45); }

.own[aria-pressed="true"] {
  background: var(--cyan);
  color: var(--cyan-ink);
  border-color: var(--cyan);
}

.want[aria-pressed="true"] {
  background: var(--matrix-deep);
  color: var(--matrix-strong);
  border-color: #8dff72;
}

@media (hover: hover) {
  .random-btn:hover,
  .chip:hover,
  .ghost:hover,
  .own:hover,
  .want:hover,
  .cover-set:hover,
  .show-more:hover {
    filter: brightness(1.12);
  }
}

.actions button:active,
.show-more:active,
.chip:active,
.random-btn:active { transform: translateY(1px); }

.empty {
  grid-column: 1 / -1;
  padding: 28px 16px;
  border: 1px dashed rgba(92, 239, 255, 0.35);
  border-radius: 14px;
  background: rgba(12, 22, 27, 0.7);
}

.empty p { margin: 0 0 12px; }

.more-wrap { margin-top: 22px; }

.show-more {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--cyan);
  background: #0e2228;
  color: var(--ink-strong);
  font-size: 1.2rem;
}

.more-count {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--matrix);
}

.colophon {
  margin-top: 22px;
  font-size: 0.92rem;
}

.colophon p { margin: 0 0 4px; }

dialog {
  width: min(720px, calc(100vw - 20px));
  max-height: min(90vh, 920px);
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: #101a1f;
  border: 1px solid rgba(92, 239, 255, 0.4);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

dialog::backdrop {
  background: rgba(3, 8, 10, 0.76);
}

.detail-sheet,
.confirm-sheet { padding: 16px; }

.detail-sheet { overflow: auto; max-height: min(90vh, 920px); }

.detail-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 8px;
  background: linear-gradient(#101a1f, #101a1f 70%, rgba(16, 26, 31, 0));
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.detail-cover-col .cover { max-width: 240px; }

.detail-cover-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.detail-copy h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  line-height: 1.05;
  color: var(--ink-strong);
}

.detail-meta { margin: 0 0 8px; color: var(--muted); }

.detail-notes { margin: 0 0 12px; }

.year-note { margin: 0 0 8px; font-size: 0.92rem; }

.detail-copy h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--chrome);
}

.sources {
  margin: 0 0 14px;
  padding-left: 18px;
}

.sources a {
  color: #c9f8ff;
  text-underline-offset: 2px;
}

.detail-actions { max-width: 360px; }

#confirm { width: min(440px, calc(100vw - 24px)); }

.confirm-sheet h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--ink-strong);
}

.confirm-sheet p { margin: 0 0 16px; color: var(--muted); }

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

.danger-ok {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--cyan);
  background: var(--cyan);
  color: var(--cyan-ink);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
}

body.modal-open { overflow: hidden; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 720px) {
  .detail-layout { grid-template-columns: 220px 1fr; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 30px 16px; }
}

@media (max-width: 420px) {
  .random-btn { flex: 1 1 100%; }
  .sync-row { width: 100%; }
  .sync-row .ghost { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .atmosphere { animation: none; }
  .actions button:active,
  .show-more:active,
  .chip:active,
  .random-btn:active { transform: none; }
}
