:root {
  color-scheme: dark;
  --bg: #0c0d0e;
  --panel: #151719;
  --panel-2: #1c2023;
  --line: #2a2f33;
  --text: #f3f0e8;
  --muted: #a9adaf;
  --faint: #757b7e;
  --accent: #e4b363;
  --accent-2: #58c3b6;
  --danger: #dc6a58;
  --good: #7cc878;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --poster-width: 170px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(228, 179, 99, 0.12), transparent 28rem),
    radial-gradient(circle at 82% 8%, rgba(88, 195, 182, 0.1), transparent 26rem),
    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;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  min-height: 100vh;
  overflow: hidden;
}

.login-art {
  display: grid;
  place-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)),
    #111315;
}

.poster-stack {
  position: relative;
  width: min(52vw, 620px);
  height: min(72vh, 660px);
}

.poster-stack img {
  position: absolute;
  width: 44%;
  min-width: 190px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.1);
  object-fit: cover;
}

.poster-stack img:nth-child(1) {
  left: 8%;
  top: 15%;
  transform: rotate(-8deg);
}

.poster-stack img:nth-child(2) {
  left: 35%;
  top: 6%;
  z-index: 2;
}

.poster-stack img:nth-child(3) {
  left: 50%;
  top: 28%;
  transform: rotate(7deg);
}

.login-card {
  align-self: center;
  justify-self: center;
  width: min(430px, calc(100% - 40px));
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 23, 25, 0.9);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.login-card h1 {
  margin-bottom: 30px;
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  line-height: 0.92;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1112;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(88, 195, 182, 0.16);
}

.login-card label + label {
  margin-top: 16px;
}

.login-card button,
.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #16120a;
  font-weight: 800;
}

.danger-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--danger);
  color: #1b0d09;
  font-weight: 800;
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.login-card button {
  width: 100%;
  margin-top: 24px;
}

.login-error {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.library-screen {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(15, 17, 18, 0.92);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  aspect-ratio: 1;
  border-radius: 8px;
  background: #f3f0e8;
  color: #101112;
  font-weight: 900;
}

.brand-block h2 {
  margin-bottom: 0;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-section-title {
  margin: 12px 0 2px;
  color: var(--faint);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.nav-item,
.ghost-button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 46px;
  padding: 0 12px;
  text-align: left;
}

.nav-item strong {
  color: var(--muted);
}

.nav-item.active,
.nav-item:hover,
.ghost-button:hover {
  border-color: var(--line);
  background: var(--panel);
}

.sidebar-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-label,
.stats-grid span,
.movie-meta,
.modal-note {
  color: var(--muted);
  font-size: 0.84rem;
}

.sidebar-panel strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
}

.sidebar-panel small {
  display: block;
  color: var(--faint);
}

.ghost-button {
  min-height: 42px;
  color: var(--muted);
}

.content {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin-bottom: 0;
  font-size: clamp(2.1rem, 5vw, 4rem);
  line-height: 1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats-grid article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(150px, 180px) minmax(150px, 180px) auto minmax(130px, 170px);
  gap: 12px;
  align-items: end;
  margin-bottom: 22px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.segmented button.active {
  background: var(--panel-2);
  color: var(--text);
}

.size-control input {
  accent-color: var(--accent);
}

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

.movie-card {
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
}

.movie-card:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.poster-button {
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #17191b;
}

.poster-button img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

.movie-info {
  padding: 10px 4px 2px;
}

.movie-info h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.2;
}

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

.movie-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 4px 4px;
}

.mini-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #101213;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.mini-button.owned {
  color: var(--good);
}

.danger-text {
  color: var(--danger);
}

.compact-posters .movie-grid:not(.list-view) {
  gap: 12px;
}

.compact-posters .movie-grid:not(.list-view) .movie-info {
  padding-top: 7px;
}

.compact-posters .movie-grid:not(.list-view) .movie-info h3 {
  font-size: 0.82rem;
}

.compact-posters .movie-grid:not(.list-view) .movie-meta {
  gap: 4px;
  font-size: 0.72rem;
}

.compact-posters .movie-grid:not(.list-view) .movie-actions {
  gap: 5px;
  padding-top: 7px;
}

.compact-posters .movie-grid:not(.list-view) .mini-button {
  min-height: 28px;
  padding: 0 7px;
  font-size: 0.72rem;
}

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

.list-view .movie-card {
  display: grid;
  grid-template-columns: clamp(38px, calc(var(--poster-width) * 0.45), 74px) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 8px;
  border-color: var(--line);
  background: var(--panel);
}

.list-view .poster-button img {
  aspect-ratio: 2 / 3;
}

.list-view .movie-info {
  padding: 0;
}

.list-view .movie-actions {
  padding: 0;
}

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

.modal {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.wide-modal {
  width: min(980px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.modal-card {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121416;
  box-shadow: var(--shadow);
}

.large-modal {
  min-height: min(720px, calc(100vh - 48px));
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.modal-header h2 {
  margin-bottom: 0;
  font-size: 2rem;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1112;
  color: var(--muted);
  font-weight: 900;
}

.modal-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.modal-warning {
  margin-bottom: 0;
  color: #f1c4bb;
  line-height: 1.5;
}

.results-list {
  display: grid;
  gap: 12px;
  overflow: auto;
  padding-right: 4px;
}

.result-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.manual-result {
  border-color: rgba(228, 179, 99, 0.4);
  background: #1b1812;
}

.manual-icon {
  display: grid;
  place-items: center;
  width: 72px;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  background: rgba(228, 179, 99, 0.12);
  color: var(--accent);
  font-size: 2rem;
  font-weight: 900;
}

.result-item img {
  width: 72px;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  object-fit: cover;
  background: #0d0f10;
}

.result-item h3 {
  margin-bottom: 6px;
}

.result-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.details-card {
  padding: 0;
  overflow: hidden;
}

.close-details {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 3;
}

.details-hero {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 22px;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(18, 20, 22, 0.92), rgba(18, 20, 22, 0.78)),
    var(--backdrop);
  background-size: cover;
  background-position: center;
}

.details-hero img {
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.details-hero h2 {
  padding-right: 42px;
  margin-bottom: 10px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.98;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.tag {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.82rem;
}

.details-copy {
  color: #d9d8d2;
  line-height: 1.6;
}

.notes-copy {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.detail-grid div {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.detail-grid strong {
  display: block;
  margin-top: 5px;
}

.details-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.editor-card {
  max-height: calc(100vh - 42px);
  overflow: auto;
}

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

.full-span {
  grid-column: 1 / -1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions .ghost-button {
  min-width: 110px;
  padding: 0 16px;
}

@media (max-width: 980px) {
  .login-screen,
  .library-screen {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 44vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar {
    position: relative;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    margin-top: 0;
  }

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

@media (max-width: 680px) {
  .content {
    padding: 18px;
  }

  .topbar,
  .modal-search-row {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .stats-grid,
  .toolbar,
  .details-hero,
  .result-item,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .poster-stack {
    width: 88vw;
    height: 42vh;
  }

  .poster-stack img {
    min-width: 125px;
  }

  .list-view .movie-card {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .list-view .movie-actions {
    grid-column: 1 / -1;
  }

  .details-hero img {
    width: min(220px, 70vw);
  }
}
