:root {
  color-scheme: dark;
  --bg: #12100f;
  --panel: #1d1a18;
  --panel-2: #26221f;
  --text: #f4f0ea;
  --muted: #b9ada2;
  --line: #3a332e;
  --accent: #d84f35;
  --accent-2: #2aa889;
  --gold: #c79b45;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(216, 79, 53, 0.08), transparent 320px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: rgba(18, 16, 15, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

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

.mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(216, 79, 53, 0.65);
  background: #2b1713;
  border-radius: 8px;
  color: #ffe7df;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  font-size: 22px;
  line-height: 1.1;
}

.brand p,
.eyebrow,
.quick-meta,
.original-title {
  color: var(--muted);
}

.top-actions,
.detail-actions,
.segmented {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost-btn,
.segment,
.detail-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
}

.ghost-btn:hover,
.segment:hover,
.detail-actions button:hover {
  border-color: rgba(216, 79, 53, 0.75);
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100vh - 83px);
}

.sidebar {
  position: sticky;
  top: 83px;
  height: calc(100vh - 83px);
  overflow: auto;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(29, 26, 24, 0.72);
}

.searchbox,
.filter-block label,
.note-box {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.searchbox input,
.filter-block select,
.note-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #141211;
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
}

.searchbox input:focus,
.filter-block select:focus,
.note-box textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 79, 53, 0.16);
}

.filter-block {
  display: grid;
  gap: 13px;
  margin-top: 24px;
}

.filter-block h2,
.stats h2 {
  font-size: 14px;
  color: var(--text);
}

.segment {
  flex: 1;
}

.segment.active {
  border-color: var(--accent);
  background: rgba(216, 79, 53, 0.18);
}

.checkline {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkline input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.stats {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.stat-row strong {
  color: var(--text);
}

.content {
  min-width: 0;
  padding: 28px;
}

.content-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

#resultCount {
  font-size: 28px;
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 18px;
  align-items: start;
}

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

.movie-card {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.poster-button {
  position: relative;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.poster {
  display: block;
  width: 100%;
  aspect-ratio: 0.714;
  object-fit: cover;
  background: linear-gradient(135deg, #2f2925, #181513);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.poster-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 0.714;
  padding: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #2f2925, #181513);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.card-flags {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  gap: 5px;
}

.flag {
  min-width: 25px;
  min-height: 25px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(18, 16, 15, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 800;
}

.movie-title {
  min-height: 42px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.movie-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.movie-grid.list .movie-card {
  grid-template-columns: 68px 1fr;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(29, 26, 24, 0.5);
  border-radius: 8px;
}

.movie-grid.list .poster,
.movie-grid.list .poster-placeholder {
  width: 68px;
}

.movie-grid.list .movie-title {
  min-height: 0;
}

.empty-state {
  padding: 48px 24px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  text-align: center;
}

.empty-state p {
  margin-top: 8px;
  color: var(--muted);
}

dialog {
  width: min(1120px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.detail {
  position: relative;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: #141211;
  color: var(--text);
  border-radius: 8px;
  font-size: 24px;
  line-height: 1;
}

.detail-media {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
}

.detail-media img {
  width: 100%;
  border-radius: 8px;
  background: #141211;
}

.detail-body {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding-right: 30px;
}

.detail-body h2 {
  font-size: 34px;
  line-height: 1.05;
}

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

.meta-card {
  padding: 12px;
  border: 1px solid var(--line);
  background: #171412;
  border-radius: 8px;
}

.meta-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.meta-card strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.description {
  color: #ded6ce;
  line-height: 1.55;
  white-space: pre-line;
}

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

.pill {
  border: 1px solid var(--line);
  background: #171412;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
}

.note-box textarea {
  min-height: 100px;
  resize: vertical;
}

@media (max-width: 900px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .content {
    padding: 20px;
  }

  .content-head,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .detail {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .detail-body {
    padding-right: 0;
  }

  .detail-body h2 {
    font-size: 27px;
  }

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

@media (max-width: 560px) {
  .movie-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .meta-grid,
  .detail-media {
    grid-template-columns: 1fr;
  }
}
