:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #687385;
  --soft: #f6f8fa;
  --line: #dbe1e8;
  --line-strong: #c8d0da;
  --accent: #c1121f;
  --accent-dark: #870d16;
  --teal: #096b72;
  --gold: #a66b00;
  --shadow: 0 18px 48px rgba(20, 28, 38, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  overflow-x: hidden;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(193, 18, 31, 0.06) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, rgba(17, 24, 39, 0.04) 0 1px, transparent 1px 100%),
    var(--bg);
  background-size: 48px 48px;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(1440px, calc(100% - 32px));
  height: 100vh;
  margin: 0 auto;
  padding: 18px 0;
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 2px 16px;
}

.mobile-controls-button,
.sidebar-header,
.sidebar-backdrop {
  display: none;
}

.mobile-controls-button {
  gap: 7px;
}

.eyebrow,
.section-label,
label,
.label-row span {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 3px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.intro,
.results-meta,
.status,
.movie-subline,
.detail-cell,
.theatre-city {
  color: var(--muted);
}

.intro {
  max-width: 28rem;
  text-align: right;
  font-size: 0.98rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.workspace {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
}

.controls-panel,
.results-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.controls-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  overscroll-behavior: contain;
  padding: 16px;
}

.zip-block,
.date-block,
.nearby-block,
.theatre-block {
  display: grid;
  gap: 10px;
}

.nearby-block {
  min-height: 0;
  overflow: hidden;
}

.theatre-block {
  min-height: 0;
}

.favorite-summary {
  display: grid;
  gap: 8px;
}

.summary-count {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px;
  border: 1px solid rgba(9, 107, 114, 0.18);
  border-radius: 6px;
  background: #eefafa;
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 800;
}

.summary-count strong {
  color: var(--ink);
  font-size: 1.35rem;
}

input[type="date"],
input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
}

input[type="date"]:focus-visible,
input[type="text"]:focus-visible,
input[type="search"]:focus-visible,
select:focus-visible,
button:focus-visible,
.theatre-option:has(input:focus-visible),
.showtime-card:focus-visible {
  outline: 3px solid rgba(193, 18, 31, 0.22);
  outline-offset: 2px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

button {
  min-height: 32px;
  border: 1px solid rgba(193, 18, 31, 0.22);
  border-radius: 6px;
  padding: 0 11px;
  background: #fff3f4;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  border-color: rgba(193, 18, 31, 0.42);
  background: #ffe7e9;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.zip-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.control-note {
  min-height: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.nearby-theatres,
.theatre-options {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nearby-theatres {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.nearby-theatre,
.theatre-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  cursor: pointer;
}

.theatre-option {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.nearby-theatre:hover,
.theatre-option:hover,
.theatre-option:has(input:checked) {
  border-color: rgba(9, 107, 114, 0.42);
  background: #eefafa;
}

.theatre-option.is-dragging {
  opacity: 0.48;
}

.theatre-option.is-drop-target {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 2px rgba(9, 107, 114, 0.2);
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  color: var(--muted);
  cursor: grab;
}

.theatre-option:active .drag-handle {
  cursor: grabbing;
}

.favorite-check {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  min-width: 0;
  cursor: pointer;
}

.favorite-check input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--teal);
}

.theatre-actions {
  display: inline-flex;
  gap: 4px;
}

.theatre-actions button,
.nearby-theatre button {
  min-width: 31px;
  min-height: 30px;
  padding: 0 8px;
  font-size: 0.78rem;
}

.nearby-theatre button {
  min-width: 54px;
}

.theatre-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.2;
}

.theatre-city {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  font-weight: 600;
}

.mini-empty {
  padding: 12px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
}

.favorites-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 48px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(20, 28, 38, 0.28);
  color: var(--ink);
}

.favorites-dialog::backdrop {
  background: rgba(17, 24, 39, 0.48);
}

.modal-header,
.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.modal-header h2 {
  font-size: 1.5rem;
}

#close-favorites {
  min-width: 36px;
  padding: 0;
  font-size: 1.3rem;
}

.modal-toolbar {
  border-bottom: 1px solid var(--line);
}

.modal-note {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

.favorites-dialog .theatre-options {
  max-height: min(520px, calc(100vh - 230px));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px 18px 18px;
}

.results-panel {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

.date-rail {
  display: flex;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  scrollbar-width: thin;
}

.date-chip {
  display: grid;
  gap: 2px;
  flex: 0 0 auto;
  min-width: 92px;
  min-height: 48px;
  padding: 7px 11px;
  border-color: var(--line);
  background: var(--soft);
  color: var(--muted);
  text-align: left;
}

.date-chip span {
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.date-chip strong {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.1;
}

.date-chip:hover {
  border-color: rgba(9, 107, 114, 0.42);
  background: #eefafa;
}

.date-chip.is-active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.date-chip.is-active strong {
  color: #ffffff;
}

.results-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.results-header > div {
  min-width: 0;
}

h2 {
  margin-top: 2px;
  font-size: clamp(1.25rem, 2vw, 1.9rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.results-meta {
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 700;
}

.filters-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.status {
  padding: 10px 18px 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.filters-bar {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(170px, 0.75fr) minmax(150px, 0.65fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

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

.view-toggle {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 4px;
  align-items: end;
  min-width: max-content;
  margin: 0;
  padding: 0;
  border: 0;
}

.view-toggle legend {
  grid-column: 1 / -1;
  padding: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view-toggle label {
  cursor: pointer;
}

.view-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.view-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  background: var(--soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.view-toggle label:first-of-type span {
  border-radius: 6px 0 0 6px;
}

.view-toggle label:last-of-type span {
  margin-left: -1px;
  border-radius: 0 6px 6px 0;
}

.view-toggle input:checked + span {
  position: relative;
  z-index: 1;
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.view-toggle input:focus-visible + span {
  outline: 3px solid rgba(193, 18, 31, 0.22);
  outline-offset: 2px;
}

.filter-field span,
.past-toggle span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input[type="search"],
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

input[type="search"] {
  padding: 0 11px;
}

select {
  padding: 0 34px 0 10px;
}

input[type="search"]::placeholder {
  color: #8b96a5;
}

.past-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--soft);
  cursor: pointer;
}

.past-toggle input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.showtimes {
  display: grid;
  align-content: start;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.showtime-card {
  display: grid;
  grid-template-columns: 86px 42px minmax(220px, 1.4fr) minmax(160px, 0.8fr) minmax(180px, 0.8fr) 24px;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease;
}

.showtime-card:first-child {
  border-top: 0;
}

.showtime-card:hover {
  background: #fff9ed;
}

.time-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  min-height: 34px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.poster-cell {
  width: 38px;
  height: 56px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: linear-gradient(135deg, #e9edf2, #f8fafc);
}

.poster-image,
.poster-fallback {
  display: block;
  width: 100%;
  height: 100%;
}

.poster-image {
  object-fit: cover;
}

.poster-fallback {
  background:
    linear-gradient(135deg, rgba(193, 18, 31, 0.14), transparent 55%),
    linear-gradient(180deg, #ffffff, #e9edf2);
}

.movie-cell {
  min-width: 0;
}

.movie-title {
  overflow: hidden;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movie-subline {
  display: block;
  margin-top: 3px;
  font-size: 0.82rem;
  font-weight: 700;
}

.detail-cell,
.theatre-chip {
  min-width: 0;
  overflow: hidden;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-cell {
  color: var(--gold);
}

.theatre-chip {
  color: var(--teal);
}

.arrow-cell {
  color: var(--line-strong);
  font-size: 1.6rem;
  line-height: 1;
  text-align: right;
}

.empty-state {
  margin: 18px;
  padding: 28px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

.movie-group-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.movie-group-card:first-child {
  border-top: 0;
}

.movie-group-poster {
  width: 74px;
  height: 110px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(135deg, #e9edf2, #f8fafc);
}

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

.movie-group-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.movie-group-heading h3 {
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.15;
}

.movie-group-heading span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.movie-theatre-group {
  display: grid;
  gap: 7px;
}

.movie-theatre-group h4 {
  margin: 0;
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.2;
}

.movie-time-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.movie-time-pill {
  display: inline-grid;
  gap: 1px;
  min-width: 92px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--soft);
  color: inherit;
  text-align: center;
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
}

.movie-time-pill:hover {
  background: #fff3f4;
  color: var(--accent-dark);
}

.movie-time-pill strong {
  font-size: 0.82rem;
  line-height: 1.1;
}

.movie-time-pill span {
  max-width: 128px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 980px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .app-shell {
    max-width: 100%;
    height: auto;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .workspace {
    grid-template-columns: 1fr;
    max-width: 100%;
    overflow-x: hidden;
  }

  .mobile-controls-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: rgba(17, 24, 39, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  .sidebar-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .controls-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(390px, calc(100vw - 28px));
    height: 100dvh;
    max-height: none;
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    border-radius: 0 8px 8px 0;
    overflow: hidden;
    transform: translateX(calc(-100% - 16px));
    transition: transform 180ms ease;
  }

  .controls-panel.is-open {
    transform: translateX(0);
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 2px;
  }

  .sidebar-header span {
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  #close-controls {
    min-width: 34px;
    padding: 0;
    font-size: 1.2rem;
  }

  .nearby-theatres {
    overflow: auto;
  }

  .results-panel {
    min-width: 0;
    max-width: 100%;
    max-height: none;
    overflow-x: hidden;
  }

  .showtimes {
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .showtime-card {
    grid-template-columns: 76px 38px minmax(0, 1fr) 20px;
  }

  .movie-group-card {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .movie-group-poster {
    width: 62px;
    height: 92px;
  }

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

  .detail-cell,
  .theatre-chip {
    grid-column: 3;
  }

  .arrow-cell {
    grid-column: 4;
    grid-row: 1 / span 3;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(calc(100% - 20px), 1440px);
    padding-top: 10px;
  }

  .app-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
  }

  .app-header > div {
    min-width: 0;
  }

  .app-header .intro {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .mobile-controls-button {
    align-self: end;
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .mobile-controls-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .results-header {
    align-items: start;
    flex-direction: column;
  }

  .intro {
    max-width: 100%;
    text-align: left;
  }

  .theatre-options {
    grid-template-columns: 1fr;
  }

  .modal-header,
  .modal-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .results-meta {
    white-space: normal;
  }

  .filters-toggle {
    display: inline-flex;
  }

  .filters-bar {
    display: none;
    padding: 12px;
  }

  .filters-bar.is-open {
    display: grid;
    grid-template-columns: 1fr;
  }

  .view-toggle {
    justify-content: start;
  }

  .past-toggle {
    justify-content: flex-start;
  }

  .showtime-card {
    gap: 9px 12px;
    min-height: 76px;
    padding: 12px;
  }

  .time-cell {
    width: 68px;
    font-size: 0.78rem;
  }

  .poster-cell {
    width: 34px;
    height: 50px;
  }

  .movie-group-card {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .movie-group-poster {
    width: 52px;
    height: 78px;
  }

  .movie-group-heading h3 {
    font-size: 1rem;
  }

  .movie-time-pill {
    min-width: 84px;
    padding: 7px 9px;
  }
}
