:root {
  --bg: #0b0d12;
  --bg-raised: #141821;
  --bg-hover: #1c2130;
  --line: #252b39;
  --text: #eef1f7;
  --muted: #949cb0;
  --accent: #f5c518;
  --accent-ink: #191b20;
  --good: #4ade80;
  --radius: 12px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a {
  color: inherit;
}

button {
  font: inherit;
  cursor: pointer;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: 24px;
  align-items: center;
  padding: 14px 28px;
  background: rgba(11, 13, 18, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand-mark {
  color: var(--accent);
  font-size: 20px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  padding: 7px 15px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.tab:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.tab.is-active {
  background: var(--text);
  color: var(--accent-ink);
}

.search {
  margin-left: auto;
  flex: 0 1 340px;
}

.search input {
  width: 100%;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  outline: 0;
}

.search input:focus {
  border-color: var(--accent);
}

/* ---------- layout ---------- */

main {
  padding: 26px 28px 60px;
  min-height: 60vh;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 30px 0 14px;
}

.section-head:first-child {
  margin-top: 6px;
}

.section-head h2 {
  margin: 0;
  font-size: 19px;
}

.section-head .hint {
  color: var(--muted);
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.chip {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.chip:hover {
  color: var(--text);
  border-color: #3a4255;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

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

/* ---------- cards ---------- */

.card {
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-art {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-raised) center/cover no-repeat;
  border: 1px solid var(--line);
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.card:hover .card-art {
  transform: translateY(-3px);
  border-color: #46506a;
}

.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(11, 13, 18, 0.85);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.card-badge.play {
  background: var(--good);
  color: #04180c;
}

.card-rating {
  position: absolute;
  right: 8px;
  top: 8px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(11, 13, 18, 0.85);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: -4px;
}

/* ---------- notices ---------- */

.notice {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--bg-raised);
  margin-bottom: 22px;
}

.notice h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.notice p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.notice code {
  background: #0b0d12;
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--accent);
}

.loading,
.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}

/* ---------- modal ---------- */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 10, 0.78);
  backdrop-filter: blur(3px);
}

.modal-panel {
  position: relative;
  width: min(940px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(11, 13, 18, 0.8);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
}

.modal-body {
  padding: 0 0 26px;
}

.detail-hero {
  position: relative;
  padding: 30px 30px 22px;
  background: var(--bg-hover) center/cover no-repeat;
}

.detail-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(11, 13, 18, 0.72), var(--bg-raised));
}

.detail-hero > * {
  position: relative;
  z-index: 1;
}

.detail-hero h2 {
  margin: 0 0 4px;
  font-size: 26px;
}

.detail-meta {
  color: var(--muted);
  font-size: 13.5px;
}

.detail-section {
  padding: 20px 30px 0;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}

.overview {
  margin: 14px 0 0;
  max-width: 68ch;
  color: #cfd5e2;
}

.player {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  display: block;
  border-bottom: 1px solid var(--line);
}

.player-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  display: block;
}

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

.provider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 13px;
}

.provider img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.provider-group + .provider-group {
  margin-top: 14px;
}

.provider-group h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.playable-list {
  display: grid;
  gap: 8px;
}

.playable {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-align: left;
}

.playable:hover {
  border-color: var(--good);
}

.playable .where {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}

.cast {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 14px;
}

.cast figure {
  margin: 0;
  text-align: center;
  font-size: 12px;
}

.cast img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 6px;
  background: var(--bg-hover);
}

.cast figcaption span {
  display: block;
  color: var(--muted);
}

/* ---------- pin keypad ---------- */

.keypad-wrap {
  display: grid;
  place-items: center;
  padding: 40px 0 60px;
}

.keypad {
  width: 320px;
  max-width: 100%;
  padding: 26px 24px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  text-align: center;
}

.keypad h2 {
  margin: 0;
  font-size: 20px;
}

.keypad-sub {
  margin: 4px 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 22px;
  min-height: 14px;
}

.pin-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid #3c4459;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.pin-dots span.on {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.12);
}

.keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.key {
  padding: 16px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 19px;
  font-weight: 600;
  transition: background 0.12s ease, transform 0.08s ease;
}

.key:hover {
  background: var(--bg-hover);
}

.key:active {
  transform: scale(0.95);
}

.key-alt,
.key-go {
  font-size: 14px;
}

.key-go {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.keypad-error {
  margin-top: 16px;
  color: #ffc2cd;
  font-size: 13px;
}

.keypad-error[hidden] {
  display: none;
}

.shake {
  animation: shake 0.34s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

@media (prefers-reduced-motion: reduce) {
  .shake { animation: none; }
}

/* ---------- settings ---------- */

.settings {
  max-width: 720px;
}

.link-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-raised);
}

.link-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 220px;
}

.link-form label span {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}

.link-form input {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  outline: 0;
}

.link-form input:focus {
  border-color: var(--accent);
}

.form-help {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.form-help code {
  background: var(--bg-raised);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--accent);
}

.form-error {
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid #6b2230;
  border-radius: 9px;
  background: #2a1119;
  color: #ffc2cd;
  font-size: 13.5px;
}

.form-error[hidden] {
  display: none;
}

.link-list {
  margin-top: 20px;
  display: grid;
  /* minmax(0, 1fr), not the default auto: an auto grid column refuses to shrink
     below its content's min-content width, so one long URL would push the whole
     page into horizontal scroll now that field lengths are unbounded. */
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.link-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-raised);
}

.link-row div {
  min-width: 0;
}

.link-row strong {
  display: block;
  font-size: 14px;
}

.link-row span {
  display: block;
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row .link-info + .chip {
  margin-left: auto;
}

.link-row .chip {
  flex: 0 0 auto;
}

.link-info {
  min-width: 0;
  flex: 1 1 auto;
}

.link-move {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 0 0 auto;
}

.list-group-head {
  margin: 18px 0 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--accent);
}

.list-group-head:first-child {
  margin-top: 4px;
}

.list-group-head.is-loose {
  color: var(--muted);
}

.drag-handle {
  flex: 0 0 auto;
  color: #4a5266;
  font-size: 16px;
  line-height: 1;
  cursor: grab;
  user-select: none;
  letter-spacing: -2px;
}

.link-row[draggable='true']:hover .drag-handle {
  color: var(--muted);
}

.link-row.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.link-row.drop-before {
  box-shadow: inset 0 3px 0 -1px var(--accent);
}

.link-row.drop-after {
  box-shadow: inset 0 -3px 0 -1px var(--accent);
}

/* Long titles and URLs must not blow out the row now that lengths are unbounded. */
.link-row strong {
  overflow-wrap: anywhere;
}

.mini {
  width: 26px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 9px;
  line-height: 1;
}

.mini:hover:not(:disabled) {
  color: var(--text);
  border-color: #46506a;
}

.mini:disabled {
  opacity: 0.3;
  cursor: default;
}

.group-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

.link-row.is-editing {
  border-color: var(--accent);
}

.link-edit {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
  align-items: flex-end;
}

.link-edit label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 180px;
}

.link-edit label span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.link-edit input {
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  outline: 0;
}

.link-edit input:focus {
  border-color: var(--accent);
}

.edit-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-form label.narrow {
  flex: 0 1 170px;
}

.link-form label em {
  font-style: normal;
  opacity: 0.65;
}

/* group blocks on the public title pages */
.link-group {
  margin-top: 14px;
}

.link-group h4 {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.added-note {
  margin-top: 12px;
  font-size: 12.5px;
  opacity: 0.8;
}

.footer {
  padding: 20px 28px 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.footer p {
  margin: 0;
  max-width: 74ch;
}

.footer .attribution {
  margin-top: 10px;
  font-size: 11.5px;
  opacity: 0.75;
}

.footer .attribution a {
  color: var(--muted);
}

@media (max-width: 760px) {
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 16px;
  }

  .search {
    flex: 1 1 100%;
    margin-left: 0;
  }

  main {
    padding: 20px 16px 50px;
  }

  .detail-hero,
  .detail-section {
    padding-left: 18px;
    padding-right: 18px;
  }
}
