/* Layout: sticky marquee header, one 1100px column; rankings as box-office
   ledger rows, cinema listings as perforated ticket stubs. */
:root {
  --paper: #f4f3f7;
  --card: #ffffff;
  --ink: #1c1a2b;
  --muted: #69667d;
  --line: #dcd9e5;
  --accent: #a8124a;
  --accent-soft: #f7e3ea;
  --on-accent: #ffffff;
  --watched: #1d746c;
  --watched-soft: #ddf0ed;
  --bar: #cfcadd;
  --star: #c98a00;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(28, 26, 43, .06), 0 6px 20px rgba(28, 26, 43, .06);

  --font-display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-data: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r: 10px;
  --wrap: 1100px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14121d; --card: #1d1a2a; --ink: #eeebf6; --muted: #a39fb8;
    --line: #2f2b42; --accent: #f2587f; --accent-soft: #3a1a29; --on-accent: #1a0710;
    --watched: #56c4b6; --watched-soft: #13302d; --bar: #3d3854; --star: #f0b429;
    --danger: #ff7a6e; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #14121d; --card: #1d1a2a; --ink: #eeebf6; --muted: #a39fb8;
  --line: #2f2b42; --accent: #f2587f; --accent-soft: #3a1a29; --on-accent: #1a0710;
  --watched: #56c4b6; --watched-soft: #13302d; --bar: #3d3854; --star: #f0b429;
  --danger: #ff7a6e; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { background: var(--paper); }
body {
  color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.55;
  margin: 0;
}
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { text-wrap: balance; line-height: 1.1; margin: 0; }
.wrap {
  max-width: var(--wrap); margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.mono { font-family: var(--font-data); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* Header */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--ink); }
.site-head { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 9; background: var(--ink); color: var(--paper); }
.site-head .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; flex-wrap: wrap; padding-block: 8px; }
.brand { font-family: var(--font-display); font-weight: 800; font-size: 28px; letter-spacing: .02em; text-decoration: none; text-transform: uppercase; display: flex; align-items: center; gap: 10px; }
.brand-bulbs { display: inline-flex; gap: 3px; }
.brand-bulbs i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); display: block; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a { text-decoration: none; padding: 6px 10px; border-radius: 999px; font-weight: 500; font-size: 14px; opacity: .8; }
.nav a:hover, .nav a.on { opacity: 1; background: rgba(255, 255, 255, .12); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.on-wish { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.on-watched { background: var(--watched-soft); border-color: var(--watched); color: var(--watched); }
.btn svg { width: 16px; height: 16px; flex: none; }
.site-head .btn { background: transparent; color: var(--paper); border-color: rgba(255, 255, 255, .35); }
.site-head .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.demo-bar { background: var(--accent-soft); color: var(--ink); font-size: 13px; }
.demo-bar .wrap { padding-block: 8px; }

main { padding-block: 28px 48px; min-height: 60vh; }
.section { display: grid; gap: 14px; margin-bottom: 40px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h2 { font-family: var(--font-display); font-weight: 800; font-size: 34px; text-transform: uppercase; letter-spacing: .01em; }

/* Hero */
.hero { display: grid; gap: 10px; margin-bottom: 32px; }
.hero h1 { font-family: var(--font-display); font-weight: 900; font-size: clamp(40px, 7vw, 76px); text-transform: uppercase; letter-spacing: -.005em; line-height: .95; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { max-width: 60ch; margin: 0; color: var(--muted); font-size: 17px; }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* Ledger rows */
.ledger { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.row {
  display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.rank { font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 1; color: var(--muted); text-align: right; }
.row.top .rank { color: var(--accent); }
.row-main { min-width: 0; display: grid; gap: 4px; }
.row-title { font-weight: 600; font-size: 16px; text-decoration: none; overflow-wrap: anywhere; }
.row-title:hover { color: var(--accent); }
.row-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--bar); border-radius: 3px; }
.row.top .bar > i { background: var(--accent); }
.row-actions { display: flex; gap: 6px; }
.icon-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { border-color: var(--muted); color: var(--ink); }
.icon-btn.on-wish { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.icon-btn.on-watched { color: var(--watched); border-color: var(--watched); background: var(--watched-soft); }
.icon-btn svg { width: 16px; height: 16px; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.teal { background: var(--watched-soft); color: var(--watched); }
.pill.plain { background: var(--line); color: var(--ink); }

/* Ticket stubs */
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 14px; }
.ticket {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  display: grid; grid-template-rows: 1fr auto; text-decoration: none; min-width: 0;
}
.ticket:hover { border-color: var(--accent); }
.ticket-top { padding: 14px 16px 12px; display: grid; gap: 6px; align-content: start; }
.ticket-title { font-family: var(--font-display); font-weight: 800; font-size: 22px; text-transform: uppercase; line-height: 1.02; overflow-wrap: anywhere; }
.ticket-stub {
  border-top: 2px dashed var(--line); padding: 10px 16px; display: flex; justify-content: space-between; gap: 8px;
  font-size: 12px; color: var(--muted); align-items: center;
}
.ticket::before, .ticket::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--paper);
  border: 1px solid var(--line); bottom: 33px;
}
.ticket::before { left: -8px; border-left-color: transparent; border-bottom-color: transparent; transform: rotate(45deg); }
.ticket::after { right: -8px; border-right-color: transparent; border-top-color: transparent; transform: rotate(45deg); }

.soon { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.soon a { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); text-decoration: none; align-items: baseline; }
.soon a:first-child { border-top: 0; }
.soon a:hover .t { color: var(--accent); }
.soon .d { font-family: var(--font-data); font-size: 13px; color: var(--muted); }
.soon .t { font-weight: 600; overflow-wrap: anywhere; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 24px; align-items: start; }

/* Movie page */
.movie-head { display: grid; gap: 12px; margin-bottom: 24px; }
.movie-head h1 { font-family: var(--font-display); font-weight: 900; font-size: clamp(38px, 6vw, 64px); text-transform: uppercase; line-height: .95; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: 10px; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px; }
.fact b { font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1.05; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 14px; min-width: 0; }
.panel h3 { font-size: 17px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stars { display: inline-flex; gap: 2px; }
.star { background: none; border: 0; padding: 2px; cursor: pointer; color: var(--line); }
.star svg { width: 28px; height: 28px; display: block; }
.star.lit { color: var(--star); }
.stars.readonly .star { cursor: default; }
.score-line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.score-big { font-family: var(--font-display); font-weight: 900; font-size: 44px; line-height: 1; }

/* Comments */
.composer { display: grid; gap: 8px; }
.composer textarea { width: 100%; min-height: 84px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--paper); }
.composer .row-end { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.comments { display: grid; gap: 4px; }
.comment { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.comment:first-child { border-top: 0; }
.comment .who { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.comment .who b { color: var(--ink); font-weight: 600; }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .tools { display: flex; gap: 12px; font-size: 13px; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-weight: 600; }
.linkish:hover { color: var(--accent); }
.linkish.danger:hover { color: var(--danger); }
.replies { margin-left: 18px; padding-left: 14px; border-left: 2px solid var(--line); display: grid; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--on-accent); background: var(--accent); flex: none; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-top: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-top: 0; font-weight: 600; }
td.num, th.num { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
td a { text-decoration: none; font-weight: 600; }
td a:hover { color: var(--accent); }

.empty { padding: 28px 18px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--r); }
.field { display: grid; gap: 6px; }
.field input, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; background: var(--paper); width: 100%; }
.field label { font-weight: 600; font-size: 14px; }
.note { font-size: 13px; color: var(--muted); }
.err { color: var(--danger); font-size: 13px; }

/* Dialog */
.modal-back { position: fixed; inset: 0; background: rgba(10, 8, 20, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 14px; width: min(100%, 420px); padding: 24px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal h2 { font-family: var(--font-display); font-weight: 800; text-transform: uppercase; font-size: 30px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* Footer + ad */
.site-foot { border-top: 1px solid var(--line); padding-block: 24px calc(24px + env(safe-area-inset-bottom, 0px)); }
.site-foot .wrap { display: grid; gap: 16px; }
.ad-slot { min-height: 90px; display: grid; place-items: center; }
.ad-slot.placeholder { border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted); font-size: 13px; text-align: center; padding: 12px; }
.ad-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center; }
.foot-links { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); justify-content: space-between; }
.foot-links nav { display: flex; gap: 16px; flex-wrap: wrap; }

@media (max-width: 560px) {
  .row { grid-template-columns: 2.4rem minmax(0, 1fr); }
  .row-actions { grid-column: 2; }
  .rank { font-size: 24px; }
  .nav { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .view { animation: rise .25s ease-out; }
  @keyframes rise { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}

/* Search + add a movie */
.head-search { flex: 1 1 14rem; min-width: 0; max-width: 22rem; }
.head-search input {
  width: 100%; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .08); color: var(--paper);
  border-radius: 999px; padding: 7px 14px; font-size: 14px;
}
.head-search input::placeholder { color: var(--paper); opacity: .6; }
#search-q { font-size: 17px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); width: 100%; }
.add-form { display: grid; grid-template-columns: minmax(0, 1fr) 7rem auto; gap: 10px; align-items: end; }
.admin-mini { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.admin-mini input { border: 1px solid var(--line); border-radius: 8px; padding: 5px 9px; background: var(--paper); min-width: 0; flex: 1 1 10rem; font-size: 13px; }
.admin-mini input[type="number"] { flex: 0 0 5.5rem; }
@media (max-width: 560px) {
  .add-form { grid-template-columns: 1fr 6rem; }
  .add-form .btn { grid-column: 1 / -1; justify-self: start; }
  .head-search { max-width: none; flex-basis: 100%; order: 3; }
}
