:root {
  color-scheme: dark;
  --ink: #f7f3ea;
  --muted: rgba(247, 243, 234, 0.62);
  --faint: rgba(247, 243, 234, 0.42);
  --paper: #0b0e13;
  --surface: #13181f;
  --surface-2: #1a1f27;
  --surface-3: #212830;
  --line: rgba(247, 243, 234, 0.10);
  --line-strong: rgba(247, 243, 234, 0.22);
  --accent: #e0b86a;
  --accent-glow: rgba(224, 184, 106, 0.22);
  --accent-ink: #17110a;
  --danger: #e06a6a;
  --success: #77c89d;
  --shadow: 0 24px 64px rgba(2, 5, 10, 0.48);
  --shadow-card: 0 12px 36px rgba(2, 5, 10, 0.34);
  --shadow-tight: 0 6px 20px rgba(2, 5, 10, 0.30);
  --ease-spring: cubic-bezier(0.22, 1, 0.32, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.24, 1);
  --font-cn: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-display: "Avenir Next Condensed", "DIN Condensed", "Arial Narrow", "Impact", var(--font-cn);
  --font-mono: "SFMono-Regular", "SF Mono", Menlo, Consolas, ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  scrollbar-color: rgba(224, 184, 106, 0.48) rgba(247, 243, 234, 0.04);
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-cn);
  line-height: 1.72;
  letter-spacing: 0;
  background:
    radial-gradient(ellipse 60% 50% at 10% 0%, rgba(224, 184, 106, 0.12), transparent 32rem),
    radial-gradient(ellipse 50% 40% at 92% 4%, rgba(145, 58, 45, 0.10), transparent 28rem),
    linear-gradient(180deg, #111721 0%, var(--paper) 320px, #0a0d12 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(247, 243, 234, 0.018) 1px, transparent 1px) 0 0 / 56px 56px,
    linear-gradient(180deg, rgba(247, 243, 234, 0.014) 1px, transparent 1px) 0 0 / 100% 56px;
  mask-image: linear-gradient(180deg, white 0%, transparent 65%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.16;
  background-image:
    radial-gradient(circle at 22% 18%, rgba(247, 243, 234, 0.14) 0 0.8px, transparent 1.2px),
    radial-gradient(circle at 65% 38%, rgba(247, 243, 234, 0.10) 0 0.8px, transparent 1.2px);
  background-size: 38px 38px, 52px 52px;
  mix-blend-mode: soft-light;
}

::selection {
  color: var(--accent-ink);
  background: var(--accent);
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

a {
  color: inherit;
}

svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
  flex: 0 0 auto;
}

/* ---- Shell ---- */

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding-top: 14px;
}

/* ---- Site Header ---- */

.site-header {
  position: sticky;
  top: 14px;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  margin-bottom: 20px;
  padding: 8px 10px 8px 14px;
  border: 1px solid rgba(247, 243, 234, 0.10);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(21, 26, 33, 0.94), rgba(16, 20, 25, 0.78));
  box-shadow:
    0 14px 42px rgba(2, 5, 10, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(20px);
  isolation: isolate;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(circle at 6% 30%, rgba(224, 184, 106, 0.08), transparent 14rem);
  opacity: 0.6;
}

.site-header > * {
  position: relative;
  z-index: 1;
}

/* ---- Brand ---- */

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 22px rgba(2, 5, 10, 0.28);
}

.brand-text strong,
.brand-text .brand-sub {
  display: block;
}

.brand-text strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.brand-text .brand-sub {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---- Chrome Actions ---- */

.chrome-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(247, 243, 234, 0.08);
  border-radius: 999px;
  background: rgba(247, 243, 234, 0.03);
}

.icon-button,
.icon-link,
.modal-close,
.search-form button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(247, 243, 234, 0.05);
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 180ms var(--ease-spring),
    border-color 200ms var(--ease-out),
    background-color 200ms var(--ease-out),
    color 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out);
}

/* Active / pressed state with subtle scale */
.icon-button:active,
.icon-link:active,
.modal-close:active,
.search-form button:active,
.user-button:active,
.state-button:active,
.primary-button:active,
.ghost-button:active,
.back-button:active,
.related-card:active,
.movie-main:active {
  transform: scale(0.97);
  transition: transform 60ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover,
  .icon-link:hover,
  .modal-close:hover {
    transform: translateY(-1px);
    border-color: rgba(224, 184, 106, 0.45);
    background: rgba(247, 243, 234, 0.10);
    box-shadow: 0 4px 14px rgba(2, 5, 10, 0.18);
  }

  .search-form button:hover,
  .user-button:hover,
  .state-button:hover:not([aria-pressed="true"]),
  .primary-button:hover,
  .ghost-button:hover,
  .back-button:hover {
    transform: translateY(-1px);
  }
}

.icon-button:focus-visible,
.icon-link:focus-visible,
.modal-close:focus-visible,
.search-form input:focus-visible,
.search-form button:focus-visible,
.user-button:focus-visible,
.movie-main:focus-visible,
.state-button:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.leaderboard-item:focus-visible,
.back-button:focus-visible,
.related-card:focus-visible,
.segmented button:focus-visible,
.auth-form input:focus-visible {
  outline: 2px solid rgba(224, 184, 106, 0.38);
  outline-offset: 3px;
}

/* Tooltip */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 5;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface-3);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -4px);
  transition:
    opacity 160ms var(--ease-out),
    transform 160ms var(--ease-out);
}

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

/* ---- Buttons ---- */

.user-button,
.ghost-button,
.primary-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  transition:
    transform 180ms var(--ease-spring),
    border-color 200ms var(--ease-out),
    background-color 200ms var(--ease-out),
    color 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out);
}

.user-button {
  max-width: 220px;
  overflow: hidden;
  padding: 0 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.primary-button {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
}

.primary-button:hover {
  box-shadow: 0 6px 20px rgba(224, 184, 106, 0.28);
}

.ghost-button {
  padding: 0 14px;
}

@media (hover: hover) and (pointer: fine) {
  .user-button:hover,
  .ghost-button:hover {
    border-color: rgba(224, 184, 106, 0.35);
    background: var(--surface-3);
    box-shadow: 0 4px 14px rgba(2, 5, 10, 0.16);
  }
}

/* ---- Page Stack ---- */

.page-stack {
  display: grid;
  gap: 20px;
}

.home-view {
  display: grid;
  gap: 20px;
}

.home-view[hidden],
.detail-page[hidden] {
  display: none;
}

/* ---- Hero Section ---- */

.hero-section {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 28px;
  align-items: end;
  overflow: hidden;
  min-height: 320px;
  padding: 42px 32px 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(11, 14, 19, 0.96) 0%, rgba(11, 14, 19, 0.78) 40%, rgba(11, 14, 19, 0.94) 100%),
    linear-gradient(180deg, rgba(224, 184, 106, 0.10), transparent 48%),
    url("/api/posters/tt0468569.webp") right 16% center / min(46vw, 520px) auto no-repeat,
    var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.hero-section::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(247, 243, 234, 0.025) 1px, transparent 1px) 0 0 / 60px 100%,
    radial-gradient(circle at 80% 24%, rgba(224, 184, 106, 0.16), transparent 22rem);
  opacity: 0.7;
}

.hero-section > * {
  position: relative;
}

body[data-route="detail"] .hero-section {
  display: none;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  animation: dot-pulse 3s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px rgba(224, 184, 106, 0.10); }
}

h1 {
  margin: 0;
  max-width: 780px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(52px, 9vw, 112px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 0.84;
  text-wrap: balance;
  text-transform: uppercase;
}

.hero-copy-block {
  position: relative;
  align-self: end;
}

.hero-copy {
  max-width: 42ch;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.68;
}

/* ---- Search ---- */

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 6px;
  align-items: center;
  padding: 6px;
  border: 1px solid rgba(247, 243, 234, 0.10);
  border-radius: 999px;
  background: rgba(11, 14, 19, 0.80);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}

.search-form:focus-within {
  border-color: rgba(224, 184, 106, 0.35);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.03),
    0 0 0 4px var(--accent-glow);
}

.search-form input {
  min-width: 0;
  height: 42px;
  padding: 0 10px 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.search-form input::placeholder {
  color: var(--faint);
}

.search-form button[type="submit"] {
  width: 42px;
  height: 42px;
  border: 0;
  color: var(--accent-ink);
  background: var(--accent);
  transition:
    transform 180ms var(--ease-spring),
    background-color 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out);
}

.search-form button[type="submit"]:hover {
  box-shadow: 0 4px 16px rgba(224, 184, 106, 0.32);
}

/* ---- Leaderboard ---- */

.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.leaderboard-grid[hidden] {
  display: none;
}

.leaderboard-panel,
.detail-page,
.movie-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(19, 24, 31, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.leaderboard-panel {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
}

.section-head .eyebrow {
  margin: 0;
  font-size: 10px;
}

.leaderboard-list {
  display: grid;
  gap: 6px;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 28px 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition:
    background-color 200ms var(--ease-out),
    transform 180ms var(--ease-spring);
}

@media (hover: hover) and (pointer: fine) {
  .leaderboard-item:hover {
    background: rgba(247, 243, 234, 0.06);
    transform: translateX(3px);
  }
}

.board-rank {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.board-poster {
  width: 42px;
  height: 54px;
  border-radius: 6px;
}

.board-title {
  min-width: 0;
}

.board-title strong,
.board-title small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-title strong {
  font-size: 14px;
  font-weight: 600;
}

.board-title small,
.empty-row {
  color: var(--muted);
  font-size: 12px;
}

.board-count {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--accent-ink);
  background: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

/* ---- Detail Page ---- */

.detail-page {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.back-button {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition:
    transform 180ms var(--ease-spring),
    border-color 200ms var(--ease-out),
    background-color 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .back-button:hover {
    border-color: rgba(224, 184, 106, 0.35);
    background: var(--surface-3);
  }
}

.detail-hero {
  position: relative;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 26px;
  align-items: end;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(90deg, rgba(19, 24, 31, 0.97), rgba(26, 31, 39, 0.68)),
    var(--surface);
}

.detail-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 18% 6%, rgba(224, 184, 106, 0.10), transparent 28rem);
}

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

.detail-poster {
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  box-shadow: 0 24px 52px rgba(2, 5, 10, 0.52);
}

.detail-copy {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding-bottom: 2px;
}

.detail-copy h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(34px, 5vw, 64px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 0.94;
  text-wrap: balance;
  text-transform: uppercase;
}

.original-title {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.rating-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 4px;
}

.rating-pill {
  display: inline-grid;
  gap: 1px;
  min-width: 104px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(247, 243, 234, 0.04);
  transition: border-color 200ms var(--ease-out);
}

.rating-pill:first-child {
  border-color: rgba(224, 184, 106, 0.35);
  background: rgba(224, 184, 106, 0.08);
}

.rating-pill span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.rating-pill strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rating-pill:first-child strong {
  color: var(--accent);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 16px;
}

/* ---- Editorial Section ---- */

.editorial-section {
  display: grid;
  gap: 22px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(224, 184, 106, 0.07), transparent 40%),
    var(--surface);
}

.editorial-lede {
  display: grid;
  gap: 10px;
  max-width: 820px;
}

.editorial-lede h3,
.editorial-lede p,
.editorial-hook {
  margin: 0;
}

.editorial-lede h3 {
  color: var(--ink);
  font-size: clamp(24px, 3.2vw, 34px);
  font-weight: 600;
  line-height: 1.18;
  text-wrap: balance;
}

.editorial-lede p {
  max-width: 74ch;
  color: rgba(247, 243, 234, 0.78);
  font-size: 15px;
  line-height: 1.78;
}

.editorial-hook {
  position: relative;
  max-width: 860px;
  margin: 4px 0;
  padding: 24px 28px;
  border: 1px solid rgba(224, 184, 106, 0.22);
  border-radius: 14px;
  color: var(--ink);
  background: linear-gradient(135deg, rgba(224, 184, 106, 0.08), rgba(247, 243, 234, 0.02));
  font-size: clamp(18px, 2vw, 21px);
  font-weight: 600;
  line-height: 1.6;
}

.quote-mark {
  position: absolute;
  top: 6px;
  right: 18px;
  color: rgba(224, 184, 106, 0.22);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

.editorial-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

/* ---- Synopsis ---- */

.synopsis-section {
  display: grid;
  gap: 12px;
  padding: 24px 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(247, 243, 234, 0.04), transparent 50%),
    var(--surface);
}

.synopsis-text {
  margin: 0;
  max-width: 78ch;
  color: rgba(247, 243, 234, 0.88);
  font-size: 15px;
  line-height: 1.88;
  text-wrap: pretty;
}

/* ---- External Links ---- */

.external-links {
  display: grid;
  gap: 12px;
}

.external-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.external-head small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

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

.link-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(247, 243, 234, 0.03);
  color: var(--ink);
  text-decoration: none;
  transition:
    border-color 200ms var(--ease-out),
    background-color 200ms var(--ease-out),
    transform 180ms var(--ease-spring),
    box-shadow 200ms var(--ease-out);
}

.link-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(247, 243, 234, 0.06);
  color: var(--accent);
  transition: background-color 200ms var(--ease-out);
}

.link-icon svg {
  width: 20px;
  height: 20px;
}

.link-card-body {
  display: grid;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.link-card strong {
  font-size: 15px;
  font-weight: 600;
}

.link-card small {
  color: var(--muted);
  font-size: 12px;
}

.link-arrow {
  flex: none;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 15px;
  opacity: 0.6;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .link-card:hover {
    border-color: rgba(224, 184, 106, 0.40);
    background: rgba(224, 184, 106, 0.06);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(2, 5, 10, 0.24);
  }

  .link-card:hover .link-icon {
    background: rgba(224, 184, 106, 0.12);
  }

  .link-card:hover .link-arrow {
    opacity: 1;
    transform: translateX(2px);
  }
}

@media (max-width: 760px) {
  .link-cards {
    grid-template-columns: 1fr;
  }
}

/* ---- Highlight Strip ---- */

.highlight-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.hl-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(224, 184, 106, 0.06), transparent 55%),
    var(--surface);
}

.hl-label {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.hl-value {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.55;
}

.hl-value small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
}

/* ---- Fit Row ---- */

.fit-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.fit-col {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.fit-for {
  background: linear-gradient(135deg, rgba(224, 184, 106, 0.06), transparent 65%);
}

.fit-caution {
  background: linear-gradient(135deg, rgba(145, 58, 45, 0.12), transparent 65%);
  border-color: rgba(145, 58, 45, 0.28);
}

.fit-label {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.fit-caution .fit-label {
  color: #e0936a;
}

.fit-body {
  margin: 0;
  color: rgba(247, 243, 234, 0.84);
  font-size: 14px;
  line-height: 1.72;
}

/* ---- Rewatch Card ---- */

.rewatch-card {
  display: grid;
  gap: 8px;
  padding: 16px 18px;
  border: 1px dashed rgba(224, 184, 106, 0.35);
  border-radius: 12px;
  background: rgba(224, 184, 106, 0.04);
}

.rewatch-tag {
  justify-self: start;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(224, 184, 106, 0.14);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.rewatch-card p {
  margin: 0;
  color: rgba(247, 243, 234, 0.86);
  font-size: 14px;
  line-height: 1.72;
}

/* ---- Research Box ---- */

.research-box {
  display: grid;
  gap: 11px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(247, 243, 234, 0.03);
}

.research-box h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.research-box h3::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.80;
}

.research-box p,
.research-box ul {
  margin: 0;
}

.research-box p,
.research-box li {
  color: rgba(247, 243, 234, 0.78);
  font-size: 13.5px;
  line-height: 1.72;
}

.research-box ul {
  display: grid;
  gap: 7px;
  padding-left: 16px;
}

.research-box li::marker {
  color: rgba(224, 184, 106, 0.5);
}

/* ---- Fact Box ---- */

.fact-box {
  grid-column: 1 / -1;
}

.fact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.fact-plot {
  color: rgba(247, 243, 234, 0.82);
  font-size: 14px;
  line-height: 1.74;
  margin: 0 0 6px;
}

.fact-grid {
  display: grid;
  gap: 1px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
}

.fact-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  padding: 9px 12px;
  font-size: 13px;
  background: rgba(247, 243, 234, 0.03);
}

.fact-row span:first-child {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  align-self: center;
}

.fact-row strong {
  min-width: 0;
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.detail-link {
  justify-self: start;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .detail-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

/* ---- Movie Grid ---- */

.movie-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 54px;
}

.movie-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  overflow: hidden;
  transition:
    transform 220ms var(--ease-spring),
    box-shadow 220ms var(--ease-spring),
    border-color 220ms var(--ease-out),
    background-color 220ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .movie-card:hover,
  .movie-card.active {
    transform: translateY(-6px);
    border-color: rgba(224, 184, 106, 0.42);
    background: rgba(26, 31, 39, 0.98);
    box-shadow: var(--shadow-card);
  }
}

.movie-main {
  display: grid;
  grid-template-rows: auto auto;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: transform 140ms var(--ease-out);
}

.poster-wrap {
  position: relative;
  display: block;
}

.poster {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(140deg, rgba(224, 184, 106, 0.18), rgba(145, 58, 45, 0.24)),
    radial-gradient(circle at 30% 18%, rgba(247, 243, 234, 0.04), transparent 60%),
    repeating-linear-gradient(135deg, transparent 0 14px, rgba(247, 243, 234, 0.03) 14px 15px),
    #13181f;
}

.movie-main .poster {
  aspect-ratio: 2 / 3;
}

.poster::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(247, 243, 234, 0.08);
}

.poster img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms var(--ease-spring);
}

@media (hover: hover) and (pointer: fine) {
  .movie-card:hover .poster img {
    transform: scale(1.04);
  }
}

.poster-fallback {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: rgba(247, 243, 234, 0.9);
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 700;
}

.rank-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--accent-ink);
  background: rgba(224, 184, 106, 0.94);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 18px rgba(2, 5, 10, 0.44);
  backdrop-filter: blur(4px);
}

/* ---- Movie Card Body ---- */

.movie-card-body {
  display: grid;
  gap: 7px;
  min-width: 0;
  padding: 14px;
}

.card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
}

.movie-card h2 {
  margin: 0;
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.24;
  text-wrap: pretty;
  transition: color 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .movie-card:hover h2 {
    color: var(--accent);
  }
}

.card-rating {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 2px 8px 2px 7px;
  border: 1px solid rgba(224, 184, 106, 0.35);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(224, 184, 106, 0.08);
  white-space: nowrap;
  transition: border-color 200ms var(--ease-out);
}

.card-rating b {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.card-rating small {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  opacity: 0.65;
}

.meta,
.mini-copy {
  color: var(--muted);
  font-size: 13px;
}

.meta {
  font-variant-numeric: tabular-nums;
}

.mini-copy {
  display: -webkit-box;
  overflow: hidden;
  margin: 2px 0 4px;
  line-height: 1.62;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 3px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: rgba(247, 243, 234, 0.65);
  font-size: 11px;
  background: rgba(247, 243, 234, 0.04);
}

/* ---- Movie Actions ---- */

.movie-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}

.movie-actions-large {
  max-width: 560px;
  padding: 0;
  border-top: 0;
}

.state-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 36px;
  gap: 5px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(247, 243, 234, 0.04);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition:
    transform 180ms var(--ease-spring),
    border-color 200ms var(--ease-out),
    background-color 200ms var(--ease-out),
    color 200ms var(--ease-out);
}

.state-button svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.state-button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-button small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 4ch;
}

.state-button-compact {
  flex: 1 1 0;
  min-height: 34px;
  height: 34px;
  padding: 0 8px;
  gap: 4px;
  overflow: hidden;
}

.state-button-compact small {
  font-size: 10px;
  max-width: 5ch;
}

.movie-actions .tooltip::after {
  z-index: 8;
  top: auto;
  bottom: calc(100% + 8px);
  transform: translate(-50%, 4px);
}

.movie-actions .tooltip:hover::after,
.movie-actions .tooltip:focus-visible::after {
  transform: translate(-50%, 0);
}

.state-button[aria-pressed="true"] {
  border-color: transparent;
  color: var(--accent-ink);
  background: var(--accent);
}

.state-button[aria-pressed="true"] small {
  color: rgba(23, 17, 10, 0.68);
}

@media (hover: hover) and (pointer: fine) {
  .state-button:hover:not([aria-pressed="true"]) {
    border-color: rgba(224, 184, 106, 0.30);
    background: rgba(247, 243, 234, 0.07);
  }
}

/* ---- Load More ---- */

.load-more-row {
  display: grid;
  justify-items: center;
  padding: 20px 0 8px;
}

.load-more-row .ghost-button {
  padding: 0 18px;
}

.scroll-sentinel {
  height: 1px;
}

.detail-loading {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 600;
}

/* ---- Related ---- */

.related-section {
  display: grid;
  gap: 14px;
  padding-top: 6px;
}

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

.related-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  min-height: 116px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(247, 243, 234, 0.04);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition:
    transform 180ms var(--ease-spring),
    border-color 200ms var(--ease-out),
    background-color 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .related-card:hover {
    transform: translateY(-3px);
    border-color: rgba(224, 184, 106, 0.38);
    background: rgba(247, 243, 234, 0.07);
  }
}

.related-poster {
  width: 72px;
  aspect-ratio: 2 / 3;
  border-radius: 7px;
}

.related-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.related-copy strong,
.related-copy small,
.related-copy span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.related-copy strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}

.related-copy small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.01em;
}

.related-copy span {
  color: rgba(247, 243, 234, 0.74);
  font-size: 13px;
  line-height: 1.55;
}

/* ---- Footer ---- */

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.footer-dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(224, 184, 106, 0.12);
}

.footer-links {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.footer-sep {
  opacity: 0.4;
}

.site-footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: opacity 160ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .site-footer a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
    opacity: 0.82;
  }
}

/* ---- Modal ---- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(2, 5, 10, 0.68);
  backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  position: relative;
  width: min(440px, 100%);
  max-height: min(720px, calc(100vh - 44px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.modal h2 {
  margin: 0 44px 18px 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
}

/* ---- QR & Auth ---- */

.qr-layout {
  display: grid;
  gap: 14px;
  justify-items: center;
  color: var(--muted);
  text-align: center;
}

.qr-layout img {
  width: min(280px, 100%);
  height: auto;
  border-radius: 10px;
}

.modal-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  color: var(--accent);
  font-weight: 600;
}

.auth-box {
  display: grid;
  gap: 16px;
}

.account-box {
  display: grid;
  gap: 18px;
  min-width: 280px;
}

.account-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.account-avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.28), transparent 60%),
    linear-gradient(135deg, var(--accent), #913828);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.account-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.account-meta strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account-meta small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.account-stats {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.account-stats > div {
  display: grid;
  gap: 2px;
}

.account-stats b {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.account-stats small {
  color: var(--muted);
  font-size: 12px;
}

.account-logout {
  justify-self: stretch;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(247, 243, 234, 0.04);
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  transition:
    background-color 200ms var(--ease-out),
    color 200ms var(--ease-out);
}

.segmented button.active {
  color: var(--accent-ink);
  background: var(--accent);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.auth-form input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(247, 243, 234, 0.04);
  color: var(--ink);
  transition: border-color 200ms var(--ease-out);
}

.auth-form input:focus {
  outline: none;
  border-color: rgba(224, 184, 106, 0.4);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

/* ---- Toast ---- */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface-3);
  box-shadow: var(--shadow-tight);
  font-size: 14px;
}

.toast[hidden] {
  display: none;
}

/* ---- A11y ---- */

.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;
}

/* ---- AI Chat FAB ---- */

.ai-fab {
  position: fixed;
  right: 24px;
  bottom: 28px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 12px 18px;
  border: 1px solid rgba(224, 184, 106, 0.38);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(224, 184, 106, 0.96), rgba(201, 155, 80, 0.96));
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 16px 38px rgba(2, 5, 10, 0.46);
  cursor: pointer;
  transition:
    transform 180ms var(--ease-spring),
    box-shadow 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .ai-fab:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 46px rgba(2, 5, 10, 0.54);
  }
}

.ai-fab-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent-ink);
  animation: ai-pulse 1.8s ease-in-out infinite;
}

@keyframes ai-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ---- AI Panel ---- */

.ai-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: 400px;
  max-width: 100vw;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11, 14, 19, 0.98), rgba(9, 12, 16, 0.98));
  backdrop-filter: blur(20px);
  box-shadow: -20px 0 60px rgba(2, 5, 10, 0.54);
  transform: translateX(0);
  transition: transform 260ms var(--ease-spring);
}

.ai-panel[hidden] {
  display: flex;
  transform: translateX(100%);
  pointer-events: none;
}

.ai-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.ai-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.ai-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(224, 184, 106, 0.18);
}

.ai-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-settings-btn {
  position: relative;
  flex: none;
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: rgba(247, 243, 234, 0.05);
  color: var(--muted);
  cursor: pointer;
  transition:
    background-color 160ms var(--ease-out),
    color 160ms var(--ease-out),
    transform 160ms var(--ease-spring);
}

.ai-settings-btn svg {
  width: 17px;
  height: 17px;
}

.ai-settings-btn:hover {
  background: rgba(224, 184, 106, 0.12);
  color: var(--accent);
}

.ai-settings-btn.active {
  background: rgba(224, 184, 106, 0.16);
  color: var(--accent);
}

.ai-settings-btn.configured::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 7px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(224, 184, 106, 0.25);
}

.ai-panel-close {
  flex: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: rgba(247, 243, 234, 0.05);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 160ms var(--ease-out),
    color 160ms var(--ease-out);
}

.ai-panel-close:hover {
  background: rgba(247, 243, 234, 0.10);
  color: var(--ink);
}

/* ---- AI Panel Body (messages or settings) ---- */

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

.ai-panel-body[hidden] {
  display: none;
}

.ai-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-empty {
  margin: auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.ai-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.7;
  word-break: break-word;
}

.ai-msg-user {
  align-self: flex-end;
  background: rgba(224, 184, 106, 0.14);
  color: var(--ink);
  border-bottom-right-radius: 4px;
}

.ai-msg-bot {
  align-self: flex-start;
  background: rgba(247, 243, 234, 0.05);
  color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.ai-msg-bot code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(247, 243, 234, 0.08);
  font-family: var(--font-mono);
  font-size: 12px;
}

.ai-msg-bot .md-h {
  margin: 0 0 6px;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.3;
}

.ai-msg-bot .md-h1 { font-size: 16px; }
.ai-msg-bot .md-h2 { font-size: 15px; }
.ai-msg-bot .md-h3 { font-size: 14px; }
.ai-msg-bot .md-h4 { font-size: 13px; color: var(--accent); }

.ai-msg-bot .md-p {
  margin: 0 0 8px;
}

.ai-msg-bot .md-p:last-child,
.ai-msg-bot .md-h:last-child {
  margin-bottom: 0;
}

.ai-msg-bot .md-ul {
  margin: 0 0 8px;
  padding-left: 18px;
}

.ai-msg-bot .md-ul li {
  margin: 2px 0;
}

.ai-msg-bot .md-ul li::marker {
  color: rgba(224, 184, 106, 0.5);
}

.ai-msg-bot .md-ol-item {
  margin: 0 0 6px;
  padding-left: 4px;
}

.ai-msg-bot .md-code-block {
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 5, 10, 0.35);
  overflow-x: auto;
}

.ai-msg-bot .md-code-block code {
  padding: 0;
  background: none;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
}

.ai-msg-bot .md-streaming::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 12px;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: ai-blink 1s steps(2) infinite;
}

.ai-msg-bot a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ai-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: ai-blink 1s steps(2) infinite;
}

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

/* ---- AI Settings View ---- */

.ai-settings-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
}

.ai-settings-view[hidden] {
  display: none;
}

.ai-settings-form {
  display: grid;
  gap: 20px;
  padding: 18px;
}

.ai-settings-group {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(247, 243, 234, 0.02);
}

.ai-settings-label {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-settings-label::before {
  content: "";
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.8;
}

.ai-settings-hint {
  color: var(--muted);
  font-size: 11px;
  margin-top: -6px;
}

.ai-field {
  display: grid;
  gap: 5px;
}

.ai-field span {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.ai-field input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 243, 234, 0.04);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-color 200ms var(--ease-out);
}

.ai-field input:focus {
  outline: none;
  border-color: rgba(224, 184, 106, 0.38);
}

.ai-field input::placeholder {
  color: var(--faint);
  font-family: var(--font-cn);
  font-size: 12px;
}

.ai-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 6px;
}

.ai-field-toggle {
  flex: none;
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 243, 234, 0.04);
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  transition:
    border-color 160ms var(--ease-out),
    background-color 160ms var(--ease-out);
}

.ai-field-toggle:hover {
  border-color: rgba(224, 184, 106, 0.35);
  background: rgba(224, 184, 106, 0.06);
}

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

.ai-save-btn {
  flex: 1;
  padding: 0 18px;
  font-size: 14px;
}

.ai-settings-note {
  margin: 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.ai-suggestions {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 18px 10px;
}

.ai-suggestion {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(247, 243, 234, 0.03);
  color: rgba(247, 243, 234, 0.76);
  font-size: 12px;
  cursor: pointer;
  transition:
    border-color 160ms var(--ease-out),
    background-color 160ms var(--ease-out);
}

.ai-suggestion:hover {
  border-color: rgba(224, 184, 106, 0.35);
  background: rgba(224, 184, 106, 0.06);
}

.ai-input-row {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
}

.ai-input-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(247, 243, 234, 0.04);
  color: var(--ink);
  font-size: 14px;
  transition: border-color 200ms var(--ease-out);
}

.ai-input-row input:focus {
  outline: none;
  border-color: rgba(224, 184, 106, 0.4);
}

.ai-input-row button {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition:
    opacity 160ms var(--ease-out),
    background-color 160ms var(--ease-out),
    transform 160ms var(--ease-spring);
}

.ai-input-row button:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.ai-input-row button[data-state="streaming"] {
  background: rgba(247, 243, 234, 0.10);
  color: var(--ink);
  font-size: 14px;
}

.ai-input-row button[data-state="streaming"]:hover {
  background: rgba(145, 58, 45, 0.25);
}

.ai-foot-note {
  flex: none;
  margin: 0;
  padding: 0 18px 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}

@media (min-width: 1100px) {
  body.ai-panel-open .detail-page {
    margin-right: 400px;
  }
}

@media (max-width: 760px) {
  .ai-panel {
    width: 100vw;
  }
  .ai-fab {
    right: 16px;
    bottom: 20px;
    padding: 11px 16px;
  }
}

/* ---- Responsive Breakpoints ---- */

@media (max-width: 980px) {
  .hero-section,
  .detail-grid,
  .editorial-grid,
  .fit-row {
    grid-template-columns: 1fr;
  }

  .hero-section {
    background:
      linear-gradient(180deg, rgba(11, 14, 19, 0.94), rgba(11, 14, 19, 0.86)),
      url("/api/posters/tt0468569.webp") right top / min(72vw, 420px) auto no-repeat,
      var(--surface);
  }

  .movie-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .related-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
    border-radius: 18px;
  }

  .chrome-actions {
    flex-wrap: wrap;
    width: 100%;
    border-radius: 14px;
  }

  .user-button {
    margin-left: auto;
  }

  .leaderboard-grid,
  .detail-hero {
    grid-template-columns: 1fr;
  }

  .detail-poster {
    width: min(220px, 62vw);
  }

  .movie-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
  }

  .hero-section {
    min-height: auto;
    padding: 24px 16px 18px;
    background:
      linear-gradient(180deg, rgba(11, 14, 19, 0.96), rgba(11, 14, 19, 0.90)),
      var(--surface);
  }

  h1 {
    font-size: clamp(42px, 18vw, 72px);
  }

  .hero-copy {
    font-size: 14px;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) 44px;
    padding: 4px;
  }

  .search-form input {
    height: 40px;
  }

  .search-form button[type="submit"] {
    width: 40px;
    height: 40px;
  }

  .detail-page {
    padding: 12px;
  }

  .detail-copy h2 {
    font-size: clamp(32px, 14vw, 54px);
  }

  .editorial-section {
    padding: 14px;
  }

  .editorial-hook {
    font-size: 16px;
  }

  .movie-actions {
    grid-template-columns: 1fr;
  }

  .movie-actions-large {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 0;
  }
}

@media (max-width: 430px) {
  .brand-text .brand-sub {
    display: none;
  }

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

  .leaderboard-item {
    grid-template-columns: 24px 38px minmax(0, 1fr) auto;
    gap: 8px;
  }

  .board-poster {
    width: 38px;
    height: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
