:root {
  --bg: #0b0f17;
  --panel: #111827;
  --muted: #9ca3af;
  --text: #e5e7eb;
  --border: #1f2937;
  --accent: #60a5fa;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nook-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(8px);
}

.nook-brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

#nookSearch {
  flex: 1;
  min-width: 140px;
  padding: 12px 16px;
  font-size: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
}
#nookSearch:focus { outline: none; border-color: var(--accent); }

.nook-count { color: var(--muted); font-size: 14px; white-space: nowrap; }

.random-btn {
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: #172554;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.random-btn:hover { background: #1e3a8a; }
.random-btn:disabled { opacity: 0.55; cursor: default; }

#nookExit {
  color: var(--muted);
  text-decoration: none;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  white-space: nowrap;
}
#nookExit:hover { color: var(--text); border-color: #334155; }

.nook-login {
  display: none;
  gap: 10px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #0f172a;
}
.nook-login input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.nook-login button {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #172554;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.nook-grid {
  flex: 0 0 auto;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 16px;
  padding-right: 56px;
  display: grid;
  grid-template-columns: repeat(auto-fill, 200px);
  justify-content: center;
  gap: 14px;
  align-content: start;
}

.nook-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0f172a;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.nook-card:hover, .nook-card:focus-visible { border-color: var(--accent); }
.nook-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #0b1020;
  border-radius: 13px 13px 0 0;
  flex: 0 0 auto;
}
.nook-card-title { padding: 10px 12px 2px; font-weight: 600; line-height: 1.3; }
.nook-card-sub { padding: 0 12px 12px; color: var(--muted); font-size: 13px; }

.nook-muted { color: var(--muted); text-align: center; grid-column: 1 / -1; padding: 24px; }

.nook-alpha {
  position: fixed;
  top: 64px;
  bottom: 12px;
  right: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  gap: 2px;
  z-index: 40;
  padding: 6px;
  background: rgba(17, 24, 39, 0.72);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(4px);
}
.nook-alpha button {
  background: none;
  border: none;
  color: var(--muted);
  font: 600 13px/1.2 system-ui, sans-serif;
  padding: 0 7px;
  border-radius: 5px;
  cursor: pointer;
}
.nook-alpha button:hover,
.nook-alpha button:active {
  color: var(--accent);
  background: rgba(96, 165, 250, 0.14);
}

.nook-overlay { position: fixed; inset: 0; z-index: 50; }
.nook-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  animation: nook-fade 0.2s ease;
}
.nook-overlay-content {
  position: relative;
  margin: 4vh auto;
  width: min(94vw, 1080px);
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  animation: nook-pop 0.2s ease;
}

@keyframes nook-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nook-pop { from { opacity: 0; transform: scale(0.98) translateY(8px); } to { opacity: 1; transform: none; } }

.nook-overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.nook-detail-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.nook-overlay-head-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.nook-close, #nookAgain {
  padding: 10px 16px;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #111827;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.nook-close:hover, #nookAgain:hover { border-color: #334155; }
#nookAgain.primary { background: #172554; border-color: var(--accent); font-weight: 600; }

.nook-eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 12px;
  font-weight: 700;
}

.nook-detail-hero { display: flex; gap: 24px; align-items: flex-start; }
.nook-detail-art {
  width: min(36vw, 340px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.nook-detail-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0b1020;
}
.nook-detail-img-empty {
  min-height: 260px;
  background: repeating-linear-gradient(
    45deg,
    #0b1020,
    #0b1020 12px,
    #0f1526 12px,
    #0f1526 24px
  );
}
.nook-meta { color: var(--muted); }
.nook-detail-info { flex: 1; min-width: 0; }

.nook-locate {
  margin-top: 0;
  padding: 12px 14px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: rgba(23, 37, 84, 0.5);
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}
.nook-locate-label {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
}
.nook-locate-value {
  font-size: 18px;
  font-weight: 600;
}

.nook-tracks-head { margin: 22px 0 0; }

.nook-tracks { margin: 10px 0 0; padding: 0 0 0 22px; }
.nook-tracks li { margin-bottom: 8px; }
.nook-track-title { font-variant-numeric: tabular-nums; margin-right: 8px; color: var(--muted); }

@media (max-width: 700px) {
  .nook-topbar { flex-wrap: wrap; }
  .nook-alpha { top: 118px; bottom: 8px; right: 6px; }
  .nook-grid { grid-template-columns: repeat(auto-fill, 150px); height: calc(100vh - 118px); }
  #nookSearch { flex: 1 1 100%; }
  .nook-detail-hero { flex-direction: column; }
  .nook-detail-art { width: 100%; }
  .nook-detail-img { width: 100%; min-height: 0; }
  .nook-detail-title { font-size: 20px; }
}