/* Hallmark — mobile-first styles. No framework, no build step. */

:root {
  color-scheme: dark;
  --bg: #0a1120;
  --bg-soft: #0f192c;
  --surface: #14203a;
  --surface-2: #1b2a49;
  --border: #263859;
  --text: #e9effb;
  --muted: #94a5c4;
  --accent: #e84a6f;
  --accent-press: #c93a5c;
  --ok: #3ecf8e;
  --info: #5b9dff;
  --warn: #f3b64b;
  --danger: #ff6b6b;
  --radius: 14px;
  --tap: 44px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 50% -10%, #17233d 0%, var(--bg) 60%);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.4em;
}

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

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

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1em 0.35em;
  border-radius: 5px;
  overflow-wrap: anywhere;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

/* --- shell -------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  background: rgba(10, 17, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav__link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 0.5rem 0.6rem;
  border-radius: 9px;
  white-space: nowrap;
}

.nav__link.is-active {
  color: var(--text);
  background: var(--surface-2);
}

.nav__logout {
  margin: 0;
}

.main {
  padding: 1rem 0.9rem 6rem;
  max-width: 1200px;
  margin: 0 auto;
}

.main--auth {
  padding-bottom: 2rem;
}

.footer {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  padding: 1rem 1rem 2rem;
}

.dryrun {
  margin: 0;
  padding: 0.4rem 0.9rem;
  background: rgba(243, 182, 75, 0.16);
  border-bottom: 1px solid rgba(243, 182, 75, 0.35);
  color: var(--warn);
  font-size: 0.82rem;
  text-align: center;
}

/* --- page head ---------------------------------------------------------- */

.page-head {
  margin: 0.4rem 0 1rem;
}

.page-title {
  font-size: 1.55rem;
  letter-spacing: -0.01em;
}

.page-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

/* --- buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--tap);
  padding: 0.55rem 0.95rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.65;
  cursor: default;
  transform: none;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:active {
  background: var(--accent-press);
}

.btn--ghost {
  background: transparent;
}

.btn--small {
  min-height: 34px;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.btn--block {
  width: 100%;
}

.btn--add {
  margin-top: 0.5rem;
}

.btn--add.is-done {
  background: rgba(62, 207, 142, 0.16);
  border-color: rgba(62, 207, 142, 0.5);
  color: var(--ok);
}

/* --- toolbar / chips ---------------------------------------------------- */

.toolbar {
  display: grid;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.chips {
  display: flex;
  gap: 0.4rem;
}

.chips--scroll {
  overflow-x: auto;
  padding-bottom: 0.15rem;
  scrollbar-width: none;
}

.chips--scroll::-webkit-scrollbar {
  display: none;
}

.chips--wrap {
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip__count {
  color: var(--muted);
  font-size: 0.78rem;
}

.chip.is-active .chip__count {
  color: rgba(255, 255, 255, 0.85);
}

.search {
  display: flex;
  gap: 0.45rem;
}

.input {
  flex: 1;
  min-height: var(--tap);
  padding: 0.5rem 0.7rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
}

.input--small {
  min-height: 38px;
  max-width: 12rem;
}

.input:focus-visible,
.btn:focus-visible,
.chip:focus-visible,
.nav__link:focus-visible {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

.resultbar {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

/* --- movie grid --------------------------------------------------------- */

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

@media (min-width: 480px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 720px) {
  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 1rem;
  }
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.poster {
  position: relative;
  aspect-ratio: 2 / 3;
  background: var(--surface-2);
}

.poster__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(150deg, #223255, #131d31 70%);
  color: rgba(233, 239, 251, 0.55);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.55rem 0.6rem 0.7rem;
  flex: 1;
}

.card__title {
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.25;
}

.card__meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.card__body .btn--add {
  margin-top: auto;
}

/* --- badges / pills ----------------------------------------------------- */

.badge {
  align-self: flex-start;
  margin-top: 0.2rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.badge--downloaded {
  color: var(--ok);
  background: rgba(62, 207, 142, 0.14);
  border-color: rgba(62, 207, 142, 0.4);
}

.badge--in {
  color: var(--info);
  background: rgba(91, 157, 255, 0.14);
  border-color: rgba(91, 157, 255, 0.4);
}

.badge--none {
  color: var(--muted);
  background: rgba(148, 165, 196, 0.1);
  border-color: var(--border);
}

.badge--error {
  color: var(--danger);
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.4);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.pill--running,
.pill--queued,
.pill--added {
  color: var(--info);
  border-color: rgba(91, 157, 255, 0.4);
  background: rgba(91, 157, 255, 0.12);
}

.pill--done {
  color: var(--ok);
  border-color: rgba(62, 207, 142, 0.4);
  background: rgba(62, 207, 142, 0.12);
}

.pill--failed {
  color: var(--danger);
  border-color: rgba(255, 107, 107, 0.4);
  background: rgba(255, 107, 107, 0.12);
}

.pill--skipped {
  color: var(--warn);
  border-color: rgba(243, 182, 75, 0.4);
  background: rgba(243, 182, 75, 0.12);
}

.pill--pending {
  color: var(--muted);
}

/* --- sticky action bar -------------------------------------------------- */

.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem calc(0.7rem + env(safe-area-inset-bottom));
  background: rgba(10, 17, 32, 0.94);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.actionbar__text {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.actionbar .btn {
  margin-left: auto;
}

/* --- panels, batches, admin --------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem;
  margin-bottom: 0.9rem;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.panel__head h2 {
  font-size: 1.05rem;
  margin: 0;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot--ok {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(62, 207, 142, 0.16);
}

.dot--bad {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.16);
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.9rem;
  margin: 0.4rem 0;
  font-size: 0.88rem;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.batch {
  border-top: 1px solid var(--border);
  padding: 0.75rem 0 0.5rem;
}

.batch:first-of-type {
  border-top: 0;
}

.batch__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.batch__title {
  font-size: 0.95rem;
  margin: 0;
}

.batch__counts {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.progress {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress__fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--info), var(--ok));
  transition: width 300ms ease;
}

.batch-items {
  margin-top: 0.9rem;
}

.batch-items h3 {
  font-size: 0.88rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.items__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(38, 56, 89, 0.6);
  font-size: 0.86rem;
}

.items__title {
  flex: 1;
  min-width: 8rem;
}

.items__message {
  flex-basis: 100%;
  font-size: 0.78rem;
}

.unresolved-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.unresolved {
  padding: 0.7rem 0;
  border-top: 1px solid var(--border);
}

.unresolved:first-child {
  border-top: 0;
}

.unresolved__source {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}

.unresolved__form {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.details {
  margin-top: 0.6rem;
  font-size: 0.85rem;
}

.details summary {
  cursor: pointer;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.empty,
.empty-inline {
  color: var(--muted);
  text-align: center;
  padding: 1.2rem 0.5rem;
}

.empty h2 {
  color: var(--text);
  font-size: 1.05rem;
}

/* --- alerts / auth ------------------------------------------------------ */

.alert {
  border-radius: 11px;
  padding: 0.6rem 0.75rem;
  font-size: 0.88rem;
  margin: 0.6rem 0;
  border: 1px solid transparent;
}

.alert--error {
  color: #ffd5d5;
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.4);
}

.alert--warn {
  color: #ffe6b8;
  background: rgba(243, 182, 75, 0.12);
  border-color: rgba(243, 182, 75, 0.4);
}

.auth-card,
.error-card {
  max-width: 26rem;
  margin: 1.5rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.auth-card__title {
  font-size: 1.6rem;
  margin-bottom: 0.2rem;
}

.form {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}

.form__label {
  font-size: 0.85rem;
  color: var(--muted);
}

.steps {
  margin: 1rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.55rem;
  font-size: 0.9rem;
}

.error-card__code {
  font-size: 3rem;
  font-weight: 800;
  margin: 0;
  color: var(--accent);
}

/* --- pagination --------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 1.2rem 0 0;
}

.pagination__label {
  color: var(--muted);
  font-size: 0.82rem;
}

/* --- dialog sheet ------------------------------------------------------- */

.sheet {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: 30rem;
  width: calc(100% - 1.5rem);
}

.sheet::backdrop {
  background: rgba(3, 7, 15, 0.7);
  backdrop-filter: blur(2px);
}

.sheet__inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.sheet__title {
  font-size: 1.2rem;
}

.sheet__text {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.3rem 0 0.8rem;
}

.sheet__list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
  font-size: 0.88rem;
}

.sheet__list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(38, 56, 89, 0.6);
}

.sheet__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.sheet__progress {
  margin-top: 0.9rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.sheet__link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.88rem;
}
.sheet__link[hidden] {
  display: none;
}

/* --- toasts ------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(5.2rem + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  background: #1c2740;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}

.toast--ok {
  border-color: rgba(62, 207, 142, 0.5);
}

.toast--error {
  border-color: rgba(255, 107, 107, 0.55);
}

.toast__text {
  flex: 1;
  overflow-wrap: anywhere;
}

.toast__close,
.toast__retry {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.2rem 0.5rem;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

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

/* Category overview (/). */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 1rem 1rem 6rem;
}

@media (min-width: 640px) {
  .cat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.cat-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--text);
  text-decoration: none;
}

.cat-card:hover,
.cat-card:focus-visible {
  border-color: var(--accent);
}

.cat-card__name {
  font-size: 1.15rem;
  font-weight: 700;
}

.cat-card__desc {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.cat-card__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.cat-card__stats strong {
  color: var(--text);
}

.nav__logout .btn {
  white-space: nowrap;
}

@media (max-width: 430px) {
  .brand {
    font-size: 0.95rem;
  }

  .nav {
    gap: 0.1rem;
  }

  .nav__link {
    font-size: 0.85rem;
    padding: 0.45rem 0.45rem;
  }

  .nav__logout .btn {
    padding: 0.45rem 0.55rem;
    font-size: 0.8rem;
  }
}
