:root {
  --ink: #14141c;
  --surface: #1e1e2a;
  --surface-raised: #262636;
  --gold: #e3b23c;
  --crimson: #b23a48;
  --paper: #f2ede3;
  --muted: #8d8da0;
  --line: #35354a;

  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'Work Sans', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  line-height: 1.5;
}

a { color: var(--gold); }

/* --- Sprocket divider: the signature element, echoing a film strip --- */
.sprockets {
  height: 22px;
  background-image: radial-gradient(circle, var(--ink) 4px, transparent 4.5px);
  background-size: 28px 22px;
  background-position: center;
  background-color: var(--surface-raised);
}

/* --- Marquee header --- */
.marquee {
  background: var(--surface-raised);
}
.marquee-content {
  text-align: center;
  padding: 2.5rem 1.5rem 2rem;
}
.marquee h1 {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 8vw, 4.5rem);
  letter-spacing: 0.08em;
  color: var(--gold);
  margin: 0;
  text-shadow: 0 0 18px rgba(227, 178, 60, 0.35);
  animation: glow 4s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { text-shadow: 0 0 18px rgba(227, 178, 60, 0.35); }
  50% { text-shadow: 0 0 28px rgba(227, 178, 60, 0.55); }
}
.tagline {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.panel {
  padding: 2.5rem 0;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  letter-spacing: 0.04em;
  margin: 0 0 1.25rem;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--crimson);
  letter-spacing: 0.1em;
}

.section-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}
.section-header-row h2 { margin-bottom: 0; }

.log-controls {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.control {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.control select {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
}
.control select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.empty-msg {
  color: var(--muted);
  font-size: 0.95rem;
  font-style: italic;
}

/* --- Search form --- */
#search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
#search-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 0.7rem 1rem;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 1rem;
}
#search-input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
#search-form button,
.add-btn {
  background: var(--gold);
  color: var(--ink);
  border: none;
  padding: 0.7rem 1.3rem;
  border-radius: 4px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
#search-form button:hover,
.add-btn:hover {
  background: #f0c257;
}
#search-form button:active,
.add-btn:active {
  transform: scale(0.97);
}
#search-form button:focus-visible,
.add-btn:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

/* --- Fade-in for freshly rendered cards/stubs --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeInUp 0.35s ease both;
}

/* --- Movie result cards --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.1rem;
}
.movie-card {
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.movie-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.movie-card img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--surface-raised);
  display: block;
}
.movie-card .card-body {
  padding: 0.6rem 0.7rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}
.movie-card h3 {
  font-size: 0.92rem;
  font-family: var(--font-body);
  font-weight: 600;
  margin: 0;
  line-height: 1.25;
}
.movie-card .year {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.movie-card .add-btn {
  margin-top: auto;
  font-size: 0.85rem;
  padding: 0.45rem 0.7rem;
}
.movie-card .add-btn:disabled {
  background: var(--line);
  color: var(--muted);
  cursor: default;
}

/* --- Ticket stub log entries: the torn-edge motif --- */
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.ticket-stub {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 1rem;
  background: var(--surface);
  border-radius: 6px;
  padding: 1rem;
  position: relative;
  align-items: center;
  transition: box-shadow 0.15s ease;
}
.ticket-stub:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.ticket-stub::after {
  content: "";
  position: absolute;
  right: 118px;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 2px dashed var(--line);
}
.ticket-stub img {
  width: 70px;
  aspect-ratio: 2/3;
  object-fit: cover;
  border-radius: 4px;
}
.ticket-stub .stub-main h3 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
}
.ticket-stub .stub-main .year {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 0.8rem;
}
.stars {
  display: flex;
  gap: 0.15rem;
  margin: 0.5rem 0;
}
.stars button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--line);
  padding: 0;
  line-height: 1;
  transition: transform 0.1s ease, color 0.1s ease;
}
.stars button.filled { color: var(--gold); }
.stars button:hover { transform: scale(1.15); }
.stars button:focus-visible { outline: 2px solid var(--gold); }

.stub-note {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--paper);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  resize: vertical;
  min-height: 2.2rem;
}
.stub-actions {
  min-width: 100px;
  text-align: right;
}
.remove-btn {
  background: none;
  border: 1px solid var(--crimson);
  color: var(--crimson);
  padding: 0.4rem 0.7rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.remove-btn:hover { background: rgba(178, 58, 72, 0.15); }

/* --- Stats --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
.stat-block {
  background: var(--surface);
  border-radius: 6px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stat-block-wide { grid-column: 1 / -1; }
.stat-number {
  font-family: var(--font-mono);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--gold);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-label-top { margin-bottom: 0.5rem; }

.bars { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 34px;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.bar-track {
  background: var(--surface-raised);
  border-radius: 3px;
  height: 10px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--crimson), var(--gold));
  transition: width 0.4s ease;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 2rem 1rem 3rem;
  font-family: var(--font-mono);
}

@media (max-width: 560px) {
  .ticket-stub {
    grid-template-columns: 56px 1fr;
    grid-template-areas:
      "poster main"
      "actions actions";
  }
  .ticket-stub img { grid-area: poster; width: 56px; }
  .ticket-stub .stub-main { grid-area: main; }
  .ticket-stub .stub-actions { grid-area: actions; text-align: left; margin-top: 0.5rem; }
  .ticket-stub::after { right: 0; display: none; }
  .stats-grid { grid-template-columns: 1fr; }
  .log-controls { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}