:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f4f6fa;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.site-header,
main {
  width: min(100% - 1.5rem, 90rem);
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-block: .65rem;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .4rem;
}

h1, h2, h3, p { margin-block: 0; }
h1 { font-size: 1.05rem; }
h2 { font-size: 1.3rem; }

.eyebrow {
  margin-bottom: .1rem;
  color: #526078;
  font-size: .66rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.signed-in-user { font-size: .82rem; font-weight: 700; }
.logout-form { margin: 0; }
.settings-link { display: inline-flex; flex: 0 0 1.9rem; width: 1.9rem; height: 1.9rem; align-items: center; justify-content: center; border: 1px solid #b8c2d1; border-radius: .4rem; background: #fff; color: #394860; }
.settings-link svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }

.login-body { background: #eaf0fa; }
.login-page { width: min(100% - 2rem, 64rem); min-height: 100vh; display: grid; place-items: center; margin: 0 auto; padding: 1.25rem 0; }
.login-shell { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(20rem, .8fr); width: 100%; overflow: hidden; border: 1px solid #cbd5e1; border-radius: 1rem; background: #fff; box-shadow: 0 1.5rem 4rem rgb(23 32 51 / 14%); }
.login-welcome { min-height: 29rem; padding: clamp(2rem, 6vw, 4.5rem); color: #fff; background: linear-gradient(135deg, #14233c 0%, #244b8e 53%, #285ac2 100%); }
.login-welcome .eyebrow { color: #bdd5ff; }
.login-welcome h1 { white-space: nowrap; font-size: clamp(2.25rem, 4.25vw, 3.5rem); line-height: .98; letter-spacing: -.05em; }
.login-introduction { max-width: 37rem; margin: 1.25rem 0 0; color: #e7efff; font-size: 1.04rem; line-height: 1.55; }
.login-moments { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .65rem; margin-top: clamp(2rem, 6vw, 4.5rem); }
.login-moment { min-height: 8.25rem; display: flex; flex-direction: column; justify-content: end; padding: .85rem; border: 1px solid rgb(255 255 255 / 27%); border-radius: .7rem; background: rgb(5 16 41 / 22%); }
.login-moment span { color: #c9dcff; font-size: .69rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.login-moment strong { margin-top: .35rem; font-size: .92rem; line-height: 1.2; }
.login-moment.next-up { background: linear-gradient(160deg, rgb(207 96 191 / 65%), rgb(87 30 126 / 50%)); }
.login-moment.film { background: linear-gradient(160deg, rgb(194 109 60 / 52%), rgb(62 22 75 / 42%)); }
.login-moment.recommendation { background: linear-gradient(160deg, rgb(41 171 134 / 55%), rgb(14 49 75 / 42%)); }
.login-panel { align-self: center; padding: clamp(1.5rem, 4vw, 3rem); background: #fff; }
.login-panel h2 { margin-top: .25rem; font-size: 1.5rem; letter-spacing: -.025em; }
.login-panel .editor { margin-top: 1.5rem; }
.password-field { display: flex; gap: .4rem; }
.password-field input { min-width: 0; flex: 1; }
.password-toggle { flex: 0 0 auto; min-height: 2.05rem; border: 1px solid #b8c2d1; border-radius: .4rem; background: #fff; color: #394860; }
.simple-account-page { width: min(100% - 2rem, 32rem); }
.account-panel { width: 100%; padding: clamp(1.5rem, 4vw, 2.5rem); border: 1px solid #cbd5e1; border-radius: .8rem; background: #fff; box-shadow: 0 1.5rem 4rem rgb(23 32 51 / 14%); }
.account-panel h1 { margin-bottom: .7rem; font-size: 1.5rem; }
.account-panel > p:not(.eyebrow):not(.notice) { margin-bottom: 1rem; line-height: 1.45; }
.account-panel .editor { display: grid; gap: .75rem; }

:root[data-theme="dark"] .login-body { background: #111827; }
:root[data-theme="dark"] .login-shell { border-color: #41516a; background: #202c3d; box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 30%); }
:root[data-theme="dark"] .login-panel { background: #202c3d; }
:root[data-theme="dark"] .account-panel { border-color: #41516a; background: #202c3d; box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 30%); }
:root[data-theme="dark"] .password-toggle { color: #e5eaf2; border-color: #59677c; background: #111827; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .login-body { background: #111827; }
  :root:not([data-theme="light"]) .login-shell { border-color: #41516a; background: #202c3d; box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 30%); }
  :root:not([data-theme="light"]) .login-panel { background: #202c3d; }
  :root:not([data-theme="light"]) .account-panel { border-color: #41516a; background: #202c3d; box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 30%); }
  :root:not([data-theme="light"]) .password-toggle { color: #e5eaf2; border-color: #59677c; background: #111827; }
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: .65rem;
  padding: .65rem .75rem;
  border: 1px solid #dce2eb;
  border-radius: .55rem;
  background: #fff;
  box-shadow: 0 2px 8px rgb(23 32 51 / 5%);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.05rem;
  border: 0;
  border-radius: .4rem;
  padding: .35rem .65rem;
  font: inherit;
  font-size: .85rem;
  font-weight: 750;
  cursor: pointer;
}

button.primary,
.button.primary { color: #fff; background: #1d4ed8; }
button.danger,
.button.danger { color: #fff; background: #b42318; }
button.secondary,
.button.secondary { color: #26334a; background: #e8edf5; }
button.quiet,
.button.quiet { color: #26334a; background: #fff; box-shadow: inset 0 0 0 1px #b8c2d1; }
button.small,
.button.small { min-height: 1.9rem; padding: .25rem .5rem; font-size: .78rem; }
button:disabled { opacity: .45; cursor: not-allowed; }

.text-link { color: #1d4ed8; font-weight: 700; text-decoration: underline; }

.notice {
  margin-top: .55rem;
  border: 1px solid #86b99a;
  border-radius: .45rem;
  background: #ecfdf3;
  padding: .45rem .65rem;
}
.notice.warning { border-color: #d6a14c; background: #fff8e7; }

.media-list { display: grid; gap: .55rem; margin-top: .55rem; }

.media-card {
  overflow: hidden;
  border: 1px solid #dce2eb;
  border-radius: .55rem;
  background: #fff;
}

.media-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .45rem .7rem .35rem;
}
.media-heading-text { min-width: 0; flex: 1; }
.media-heading h3 { font-size: 1.3rem; }
.media-title-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: .2rem .65rem; }
.media-watching-on { color: #64748b; font-size: .8rem; }
.media-watching-on strong { color: #172033; font-size: 1.08rem; font-weight: 800; }
.media-heading-actions { display: flex; flex-shrink: 0; align-items: center; gap: .4rem; }
.track-list { border-top: 1px solid #e5eaf1; }

.track { min-width: 0; }
.track-content {
  display: grid;
  grid-template-columns: minmax(11rem, 1fr) minmax(15rem, 1.25fr) 19rem;
  gap: .45rem .8rem;
  min-width: 0;
  padding: .5rem .7rem;
}

.track + .track { border-top: 1px solid #edf0f5; }
.track-main { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; align-self: center; }
.track-source { color: #334155; font-size: .76rem; }
.track-source span { font-weight: 750; }
.last-watched { flex-basis: 100%; margin-top: .3rem; color: #526078; font-size: .75rem; }
.watchers { display: inline-flex; gap: .3rem; }

.watcher,
.watcher-option span {
  border-left: .35rem solid var(--watcher-colour, #64748b);
  border-radius: .35rem;
  background: #eef2f7;
  padding: .18rem .38rem;
  font-size: .76rem;
  font-weight: 800;
}

.position { font-size: .86rem; font-weight: 750; }

.unconfirmed-source {
  border-left: .35rem solid #d6a14c;
  border-radius: .35rem;
  background: #fff8e7;
  padding: .18rem .38rem;
  color: #854d0e;
  font-size: .72rem;
  font-weight: 750;
}

.status {
  border-radius: 999px;
  background: #e8edf5;
  padding: .18rem .4rem;
  color: #394860;
  font-size: .7rem;
  font-weight: 800;
}

.status-ready { color: #155e3f; background: #dff7e9; }
.status-in_progress { color: #1e40af; background: #dbeafe; }
.status-pending { color: #854d0e; background: #fef3c7; }
.status-finished { color: #5b21b6; background: #ede9fe; }
.status-abandoned { color: #9a3412; background: #fde8d3; }
.status-binned { color: #991b1b; background: #fee2e2; }

.progress-form {
  display: grid;
  gap: .2rem;
  align-self: center;
}

.progress-stats { display: flex; justify-content: space-between; font-size: .76rem; font-weight: 750; }
.progress-stats output { color: #172033; }
.progress-stats .progress-total { color: #172033; }
.progress-slider { min-height: 1.2rem; padding: 0; touch-action: pan-y; user-select: none; }
.progress-form button { justify-self: end; }
.progress-change-prompt { display: flex; align-items: center; justify-self: end; flex-wrap: wrap; gap: .35rem; border: 1px solid #9aa7ba; border-radius: .45rem; background: #fff; padding: .35rem .45rem; color: #394860; font-size: .76rem; font-weight: 750; }
.progress-change-prompt button { justify-self: auto; }

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: end;
  gap: .35rem;
  align-self: center;
}
.quick-actions form { margin: 0; }
.quick-actions button { touch-action: pan-y; user-select: none; }

.toolbar-actions {
  display: grid;
  grid-template-columns: auto minmax(9rem, 1fr) auto auto auto;
  grid-template-areas: "find source viewers suggestions more";
  align-items: end;
  gap: .5rem;
  width: 100%;
}
.list-controls { display: contents; }
.toolbar-actions > .button.primary { grid-area: find; }
.toolbar-source { grid-area: source; min-width: 0; }
.toolbar-source select { width: 100%; }
.viewer-filter-field { grid-area: viewers; }
.toolbar-actions > .button.quiet { grid-area: suggestions; }
.search-field, .sort-field { display: grid; gap: .2rem; color: #526078; font-size: .72rem; font-weight: 750; }
.search-field input { width: min(18rem, 40vw); min-height: 2.05rem; }
button.toolbar-more-toggle {
  grid-area: more;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.05rem;
  border: 1px solid #e6b75a;
  border-radius: .4rem;
  background: #fef3c7;
  box-shadow: none;
  padding: .38rem .55rem;
  color: #854d0e;
  font-size: .8rem;
  font-weight: 750;
  cursor: pointer;
}
button.toolbar-more-toggle[aria-expanded="true"] { border-color: #b7791f; background: #fde68a; }
.toolbar-more-content {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: .15rem;
  padding-top: .7rem;
  border-top: 1px solid #dce2eb;
}
.visibility-options { display: flex; align-items: end; gap: .7rem; }
.visibility-option { display: flex; align-items: center; gap: .3rem; min-height: 2.05rem; font-size: .78rem; font-weight: 750; }
.visibility-option input { width: auto; min-height: auto; }
.viewer-filter-field { display: grid; gap: .2rem; align-self: end; }
.viewer-filter { position: relative; }
.viewer-filter > summary {
  min-height: 2.05rem;
  min-width: 8rem;
  max-width: 14rem;
  overflow: hidden;
  border: 1px solid #9aa7ba;
  border-radius: .4rem;
  background: #fff;
  padding: .38rem .55rem;
  font-size: .8rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}
.viewer-filter-label { color: #526078; font-size: .72rem; font-weight: 750; }
.viewer-filter > summary::-webkit-details-marker { display: none; }
.viewer-filter[open] > summary { border-color: #1d4ed8; }
.viewer-filter form {
  position: absolute;
  z-index: 10;
  right: 0;
  width: max-content;
  min-width: 12rem;
  margin-top: .3rem;
  border: 1px solid #b8c2d1;
  border-radius: .45rem;
  background: #fff;
  padding: .55rem;
  box-shadow: 0 .5rem 1.5rem rgb(23 32 51 / 18%);
}
.viewer-filter fieldset { border: 0; margin: 0 0 .5rem; padding: 0; }
.viewer-filter-actions { display: flex; gap: .4rem; }
.viewer-filter-actions > button { flex: 1 1 0; }
.viewer-filter legend { margin-bottom: .35rem; color: #526078; font-size: .75rem; font-weight: 750; }
.viewer-filter-options { display: grid; gap: .25rem; }
.viewer-filter-options label { position: relative; cursor: pointer; }
.viewer-filter-options input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.viewer-filter-options span {
  display: block;
  border: 1px solid #b8c2d1;
  border-radius: .35rem;
  background: #fff;
  padding: .25rem .4rem;
  font-size: .75rem;
  font-weight: 700;
}
.viewer-filter-options input:checked + span { color: #fff; border-color: #1d4ed8; background: #1d4ed8; }
.viewer-filter-options input:focus-visible + span { outline: .2rem solid #93c5fd; outline-offset: .15rem; }

select {
  min-height: 2.05rem;
  border: 1px solid #9aa7ba;
  border-radius: .4rem;
  background: #fff;
  padding: .3rem .5rem;
  font: inherit;
  font-size: .85rem;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .6rem;
}

.editor {
  position: relative;
  display: grid;
  gap: .75rem;
  max-width: 38rem;
  border: 1px solid #dce2eb;
  border-radius: .55rem;
  background: #fff;
  padding: .8rem;
}

.confirmation-panel {
  display: grid;
  gap: .75rem;
  max-width: 42rem;
  border: 1px solid #dce2eb;
  border-radius: .55rem;
  background: #fff;
  padding: .9rem;
}

.search-online-shortcut { margin-bottom: 1rem; }
.search-online-shortcut label { display: block; margin-bottom: .3rem; font-weight: 750; }
.search-online-row { display: flex; gap: .5rem; }
.search-online-row input { flex: 1; }

.catalogue-results { display: grid; gap: .6rem; margin-top: .6rem; }
.catalogue-result {
  display: flex;
  gap: .8rem;
  border: 1px solid #dce2eb;
  border-radius: .55rem;
  background: #fff;
  padding: .7rem;
}
.catalogue-result-detail { max-width: 42rem; }
.catalogue-poster { width: 5.5rem; height: auto; border-radius: .35rem; flex-shrink: 0; }
.catalogue-result-body { display: grid; gap: .3rem; align-content: start; }
.catalogue-description { font-size: .82rem; line-height: 1.4; }

/* The poster stays pinned to its natural size and centres in the row: a taller card
   (from wrapped text/buttons on narrow screens) adds balanced space above and below
   the poster rather than stretching it wider to match, which would eat into the
   content column. */
.track.has-poster { display: grid; grid-template-columns: clamp(4.6rem, 6vw, 5.75rem) minmax(0, 1fr); align-items: center; }
.track-poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  height: auto;
  object-fit: cover;
  background: #eef2f7;
  border-radius: .35rem;
}

.field { display: grid; gap: .25rem; border: 0; padding: 0; }
.field label, .field legend { font-size: .84rem; font-weight: 750; }

input {
  width: 100%;
  min-height: 2.15rem;
  border: 1px solid #9aa7ba;
  border-radius: .4rem;
  padding: .35rem .5rem;
  font: inherit;
  font-size: .9rem;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid #9aa7ba;
  border-radius: .4rem;
  padding: .4rem .5rem;
  font: inherit;
  font-size: .9rem;
}

input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible {
  outline: .2rem solid #93c5fd;
  outline-offset: .15rem;
}

input[aria-invalid="true"] { border-color: #b42318; }
.field-error { color: #b42318; font-size: .875rem; }
.optional { color: #64748b; font-size: .8rem; font-weight: 500; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; }
.watcher-options { display: flex; flex-wrap: wrap; gap: .4rem; }
.watcher-option { position: relative; cursor: pointer; }
.watcher-option input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.watcher-option input:focus-visible + span { outline: .2rem solid #93c5fd; outline-offset: .15rem; }
.watcher-option input:checked + span {
  color: #1e3a8a;
  background: #dbeafe;
  box-shadow: inset 0 0 0 2px #2563eb;
}

.form-actions { display: flex; gap: .5rem; }

.finish-action {
  color: #713f12;
  border: 1px solid #a16207;
  background: #fffbeb;
}
.finish-dialog {
  width: min(calc(100% - 2rem), 32rem);
  border: 1px solid #b8c2d1;
  border-radius: .55rem;
  background: #fff;
  color: #172033;
  padding: 1rem;
}
.finish-dialog::backdrop { background: rgb(16 22 34 / 55%); }
.finish-dialog form { display: grid; gap: .7rem; }
.finish-dialog h2 { margin: 0; font-size: 1.2rem; }
.finish-dialog p { margin: 0; color: #526078; font-size: .9rem; line-height: 1.45; }
.finish-confirm { background: #a16207; }
.finish-confirm:hover { background: #854d0e; }

.empty-state {
  margin-top: .55rem;
  padding: 1.5rem .75rem;
  border: 1px dashed #b8c2d1;
  border-radius: .55rem;
  text-align: center;
}
.empty-state p { margin-top: .5rem; color: #526078; }

.suggestion-list { display: grid; gap: .55rem; margin-top: .55rem; }
.suggestion-section + .suggestion-section { margin-top: 2rem; border-top: 1px solid #e5eaf1; padding-top: 1.5rem; }
.suggestion-section-title { font-size: 1.05rem; }
.suggestion-section-help, .suggestion-section-empty { margin-top: .2rem; color: #526078; font-size: .8rem; }
.suggestion-card { display: grid; gap: .45rem; border: 1px solid #dce2eb; border-radius: .55rem; background: #fff; padding: .7rem; }
.suggestion-status-row { display: flex; justify-content: flex-end; }
.suggestion-columns { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: .3rem 1.25rem; }
.suggestion-main { display: flex; gap: .7rem; min-width: 0; }
.suggestion-poster { width: 4.2rem; height: 6.3rem; flex: 0 0 auto; border-radius: .3rem; object-fit: cover; background: #e5eaf1; }
.suggestion-copy { min-width: 0; }
.suggestion-main h3 { margin-top: 0; font-size: 1.05rem; }
.suggestion-year { font-weight: 400; color: #526078; }
.suggestion-targets, .suggestion-description, .suggestion-comment { font-size: .8rem; line-height: 1.4; }
.suggestion-meta .eyebrow { margin-bottom: .3rem; }
.suggestion-targets { color: #526078; }
.suggestion-actions { display: flex; align-items: end; flex-wrap: wrap; gap: .45rem; margin-top: .2rem; }
.suggestion-actions form { display: flex; align-items: end; gap: .4rem; }
.resolved-suggestions { margin-block: .8rem 1.25rem; }
.resolved-suggestions > summary { cursor: pointer; color: #394860; font-weight: 750; }

.detail-options { display: flex; align-items: end; gap: .7rem; margin-left: auto; }
.track-detail-preview { display: none; flex-basis: 100%; margin-top: .3rem; border: 0; padding: 0; overflow: hidden; background: transparent; color: #394860; font: inherit; font-size: .76rem; line-height: 1.35; text-align: left; cursor: pointer; }
.track-detail-preview:hover, .track-detail-preview:focus-visible { text-decoration: underline; }
.show-comments .track-detail-comment, .show-descriptions .track-detail-description { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.text-detail-dialog { width: min(34rem, calc(100% - 2rem)); border: 1px solid #9aa7ba; border-radius: .6rem; padding: 1rem; color: #172033; background: #fff; }
.text-detail-dialog::backdrop { background: rgb(15 23 42 / .55); }
.text-detail-dialog h2 { margin-top: 0; font-size: 1.05rem; }
.text-detail-dialog p { white-space: pre-wrap; line-height: 1.5; }
.bin-reason { color: #7f1d1d; }

.page-heading { display: flex; align-items: start; justify-content: space-between; gap: .75rem; margin-bottom: .8rem; }
.page-links { display: flex; flex-wrap: wrap; justify-content: end; gap: .45rem; }
.settings-panel { display: grid; gap: .8rem; max-width: 38rem; margin-bottom: .8rem; border: 1px solid #dce2eb; border-radius: .55rem; background: #fff; padding: .8rem; }
.settings-divider { max-width: 38rem; margin: .25rem 0 1rem; border: 0; border-top: 1px solid #b8c2d1; }
.settings-help, .settings-status { margin-top: .25rem; color: #526078; font-size: .8rem; line-height: 1.4; }
.theme-options { display: flex; flex-wrap: wrap; gap: .4rem; border: 0; padding: 0; }
.theme-options legend { width: 100%; margin-bottom: .25rem; font-size: .84rem; font-weight: 750; }
.theme-options label { position: relative; cursor: pointer; }
.theme-options input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.theme-options span { display: block; min-width: 5rem; border: 1px solid #b8c2d1; border-radius: .4rem; padding: .4rem .65rem; text-align: center; font-size: .82rem; font-weight: 750; }
.theme-options input:checked + span { color: #fff; border-color: #2563eb; background: #2563eb; }
.theme-options input:focus-visible + span { outline: 2px solid #2563eb; outline-offset: 2px; }
.field-pair { display: flex; align-items: end; gap: .6rem; }
.field { display: grid; flex: 1 1 14rem; gap: .25rem; }
.field label { color: #526078; font-size: .78rem; font-weight: 750; }
.field-label { color: #526078; font-size: .78rem; font-weight: 750; }
.editor-readonly-key { position: absolute; top: .86rem; right: .85rem; margin: 0; color: #526078; font-size: .72rem; }
.editor #title { font-size: 1.05rem; font-weight: 650; }
.readonly-muted { border-width: 2px; border-style: dashed; border-color: #94a3b8; background: #f1f5f9; color: #475569; cursor: default; }
.track-edit-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: .6rem; }
.track-edit-details.is-film { grid-template-columns: minmax(0, 1fr); }
.edit-detail-group { min-width: 0; margin: 0; border: 1px solid #9aa7ba; border-radius: .4rem; padding: .45rem .5rem .5rem; }
.edit-detail-group legend { padding: 0 .2rem; color: #526078; font-size: .78rem; font-weight: 750; }
.readonly-group { border-width: 2px; border-style: dashed; border-color: #94a3b8; background: #f1f5f9; }
.readonly-group-value { color: #475569; background: #fff; cursor: default; }
.series-episode-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; max-width: none; }
.series-episode-fields .field { min-width: 0; }
.runtime-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; max-width: none; }
.runtime-inputs label { display: grid; gap: .25rem; color: #526078; font-size: .78rem; font-weight: 750; }
.source-type-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: .6rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.compact-list { display: grid; gap: .25rem; margin: 0; padding-left: 1.2rem; }
.field-error { margin: 0; color: #b42318; font-size: .84rem; font-weight: 700; }
.settings-choice-list { display: grid; gap: .35rem; margin: 0; border: 1px solid #9aa7ba; border-radius: .4rem; padding: .55rem .65rem; }
.settings-choice-list legend { padding: 0 .2rem; color: #526078; font-size: .78rem; font-weight: 750; }
.settings-choice-list label { display: flex; align-items: center; gap: .5rem; color: #172033; font-size: .84rem; cursor: pointer; }
.settings-choice-list input[type="checkbox"] { width: 1rem; min-height: 1rem; flex: 0 0 auto; margin: 0; }
.shared-viewer-management-panel { max-width: 44rem; }
.shared-viewer-move { border: 1px solid #dce2eb; border-radius: .45rem; padding: .55rem .7rem; }
.shared-viewer-move + .shared-viewer-move { margin-top: .5rem; }
.shared-viewer-move summary { cursor: pointer; color: #172033; font-size: .9rem; }
.shared-viewer-move .editor { max-width: none; margin-top: .65rem; border: 0; padding: 0; }
.shared-viewer-move .danger { margin-left: auto; }
.settings-warning { margin: 0; border-left: .25rem solid #b45309; border-radius: .25rem; background: #fff7ed; color: #7c2d12; padding: .55rem .7rem; font-size: .82rem; line-height: 1.45; }
.source-remove-dialog { width: min(calc(100% - 2rem), 28rem); border: 1px solid #b8c2d1; border-radius: .55rem; padding: 1rem; color: #172033; background: #fff; }
.source-remove-dialog::backdrop { background: rgb(16 22 34 / 55%); }
.source-remove-dialog form { display: grid; gap: .7rem; }
.source-remove-dialog p { color: #526078; font-size: .85rem; line-height: 1.4; }
.feedback-visibility { display: flex; justify-content: end; margin: -.2rem 0 .65rem; }
.feedback-visibility label { display: inline-flex; align-items: center; gap: .4rem; color: #526078; font-size: .84rem; font-weight: 750; cursor: pointer; }
.feedback-visibility input { width: auto; min-height: 0; margin: 0; }

.conflict-banner {
  display: none;
  flex-basis: 100%;
  margin-top: .3rem;
  color: #b42318;
  font-size: .76rem;
  font-weight: 750;
}
.conflict-banner.visible { display: block; }

[hidden] { display: none !important; }

/* Dark is an explicit choice, or the System choice when the device prefers dark. */
:root[data-theme="dark"] { color-scheme: dark; color: #e5eaf2; background: #101622; }
:root[data-theme="dark"] body { background: #101622; }
:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .last-watched,
:root[data-theme="dark"] .search-field,
:root[data-theme="dark"] .sort-field,
:root[data-theme="dark"] .empty-state p { color: #aeb9ca; }
:root[data-theme="dark"] .viewer-filter-label { color: #aeb9ca; }
:root[data-theme="dark"] .suggestion-targets,
:root[data-theme="dark"] .suggestion-section-help,
:root[data-theme="dark"] .suggestion-section-empty { color: #aeb9ca; }
:root[data-theme="dark"] .suggestion-year { color: #aeb9ca; }
:root[data-theme="dark"] .toolbar,
:root[data-theme="dark"] .media-card,
:root[data-theme="dark"] .editor,
:root[data-theme="dark"] .confirmation-panel,
:root[data-theme="dark"] .settings-panel { border-color: #3a465a; background: #182131; }
:root[data-theme="dark"] .suggestion-card { border-color: #3a465a; background: #182131; }
:root[data-theme="dark"] .track-list,
:root[data-theme="dark"] .track + .track,
:root[data-theme="dark"] select,
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .viewer-filter > summary,
:root[data-theme="dark"] .viewer-filter form,
:root[data-theme="dark"] .toolbar-more-content,
:root[data-theme="dark"] .viewer-filter-options span,
:root[data-theme="dark"] .settings-link,
:root[data-theme="dark"] button.quiet,
:root[data-theme="dark"] .button.quiet { color: #e5eaf2; border-color: #59677c; background: #111827; }
:root[data-theme="dark"] .viewer-filter-options input:checked + span {
  color: #fff;
  border-color: #3b82f6;
  background: #1d4ed8;
}
:root[data-theme="dark"] .progress-change-prompt { border-color: #59677c; background: #111827; color: #e5eaf2; }
:root[data-theme="dark"] button.toolbar-more-toggle {
  color: #fde68a;
  border-color: #a16207;
  background: #713f12;
}
:root[data-theme="dark"] button.toolbar-more-toggle[aria-expanded="true"] {
  border-color: #f59e0b;
  background: #854d0e;
}
:root[data-theme="dark"] button.secondary,
:root[data-theme="dark"] .button.secondary,
:root[data-theme="dark"] .watcher,
:root[data-theme="dark"] .watcher-option span,
:root[data-theme="dark"] .status { color: #dbe4f2; background: #2b3749; }
:root[data-theme="dark"] .track-source,
:root[data-theme="dark"] .track-detail-preview { color: #c2ccda; }
:root[data-theme="dark"] .text-detail-dialog { color: #e5eaf2; border-color: #59677c; background: #182131; }
:root[data-theme="dark"] .progress-stats output,
:root[data-theme="dark"] .progress-stats .progress-total { color: #e5eaf2; }
:root[data-theme="dark"] .media-watching-on { color: #aeb9ca; }
:root[data-theme="dark"] .media-watching-on strong { color: #e5eaf2; }
:root[data-theme="dark"] .notice { color: #c8f5d8; border-color: #31724b; background: #153525; }
:root[data-theme="dark"] .notice.warning { color: #ffe8a3; border-color: #8a6425; background: #352911; }
:root[data-theme="dark"] .catalogue-result { border-color: #3a465a; background: #182131; }
:root[data-theme="dark"] .unconfirmed-source { color: #ffe8a3; border-left-color: #8a6425; background: #352911; }
:root[data-theme="dark"] .finish-action { color: #fde68a; border-color: #a16207; background: #713f12; }
:root[data-theme="dark"] .finish-dialog { border-color: #59677c; background: #182131; color: #e5eaf2; }
:root[data-theme="dark"] .resolved-suggestions > summary { color: #c2ccda; }
:root[data-theme="dark"] .finish-dialog p { color: #aeb9ca; }
:root[data-theme="dark"] .status-ready { color: #9ce9bd; background: #174c35; }
:root[data-theme="dark"] .status-in_progress { color: #bfdbfe; background: #1e3a8a; }
:root[data-theme="dark"] .status-pending { color: #fde68a; background: #713f12; }
:root[data-theme="dark"] .status-finished { color: #ddd6fe; background: #4c1d95; }
:root[data-theme="dark"] .status-abandoned { color: #fdba74; background: #7c2d12; }
:root[data-theme="dark"] .status-binned { color: #fecaca; background: #7f1d1d; }
:root[data-theme="dark"] .watcher-option input:checked + span {
  color: #fff;
  background: #1e3a8a;
  box-shadow: inset 0 0 0 2px #60a5fa;
}
:root[data-theme="dark"] .empty-state { border-color: #59677c; }
:root[data-theme="dark"] .settings-help,
:root[data-theme="dark"] .settings-status,
:root[data-theme="dark"] .field label,
:root[data-theme="dark"] .settings-choice-list label,
:root[data-theme="dark"] .settings-choice-list legend,
:root[data-theme="dark"] .shared-viewer-move summary,
:root[data-theme="dark"] .settings-warning,
:root[data-theme="dark"] .runtime-inputs label,
:root[data-theme="dark"] .edit-detail-group legend,
:root[data-theme="dark"] .source-remove-dialog p { color: #aeb9ca; }
:root[data-theme="dark"] .settings-choice-list label { color: #e5eaf2; }
:root[data-theme="dark"] .editor-readonly-key { color: #aeb9ca; }
:root[data-theme="dark"] .readonly-muted { border-color: #64748b; background: #151e2d; color: #aeb9ca; }
:root[data-theme="dark"] .readonly-group { border-color: #64748b; background: #151e2d; }
:root[data-theme="dark"] .readonly-group-value { color: #aeb9ca; background: #111827; }
:root[data-theme="dark"] .editor input:not([readonly]),
:root[data-theme="dark"] .editor select,
:root[data-theme="dark"] .editor textarea,
:root[data-theme="dark"] .editor .edit-detail-group:not(.readonly-group) { border-color: #a3b4d0; }
:root[data-theme="dark"] .feedback-visibility label { color: #aeb9ca; }
:root[data-theme="dark"] .source-remove-dialog { color: #e5eaf2; border-color: #59677c; background: #182131; }
:root[data-theme="dark"] .edit-detail-group { border-color: #59677c; background: #111827; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; color: #e5eaf2; background: #101622; }
  :root:not([data-theme="light"]) body { background: #101622; }
  :root:not([data-theme="light"]) .eyebrow,
  :root:not([data-theme="light"]) .last-watched,
  :root:not([data-theme="light"]) .search-field,
  :root:not([data-theme="light"]) .sort-field,
  :root:not([data-theme="light"]) .empty-state p,
  :root:not([data-theme="light"]) .suggestion-targets,
  :root:not([data-theme="light"]) .suggestion-section-help,
  :root:not([data-theme="light"]) .suggestion-section-empty { color: #aeb9ca; }
  :root:not([data-theme="light"]) .viewer-filter-label { color: #aeb9ca; }
  :root:not([data-theme="light"]) .toolbar,
  :root:not([data-theme="light"]) .media-card,
  :root:not([data-theme="light"]) .editor,
  :root:not([data-theme="light"]) .confirmation-panel,
  :root:not([data-theme="light"]) .suggestion-card,
  :root:not([data-theme="light"]) .settings-panel { border-color: #3a465a; background: #182131; }
  :root:not([data-theme="light"]) .track-list,
  :root:not([data-theme="light"]) .track + .track,
  :root:not([data-theme="light"]) select,
  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) textarea,
  :root:not([data-theme="light"]) .viewer-filter > summary,
  :root:not([data-theme="light"]) .viewer-filter form,
  :root:not([data-theme="light"]) .toolbar-more-content,
  :root:not([data-theme="light"]) .viewer-filter-options span,
  :root:not([data-theme="light"]) .settings-link,
  :root:not([data-theme="light"]) button.quiet,
  :root:not([data-theme="light"]) .button.quiet { color: #e5eaf2; border-color: #59677c; background: #111827; }
  :root:not([data-theme="light"]) .viewer-filter-options input:checked + span {
    color: #fff;
    border-color: #3b82f6;
    background: #1d4ed8;
  }
  :root:not([data-theme="light"]) .progress-change-prompt { border-color: #59677c; background: #111827; color: #e5eaf2; }
  :root:not([data-theme="light"]) button.toolbar-more-toggle {
    color: #fde68a;
    border-color: #a16207;
    background: #713f12;
  }
  :root:not([data-theme="light"]) button.toolbar-more-toggle[aria-expanded="true"] {
    border-color: #f59e0b;
    background: #854d0e;
  }
  :root:not([data-theme="light"]) button.secondary,
  :root:not([data-theme="light"]) .button.secondary,
  :root:not([data-theme="light"]) .watcher,
  :root:not([data-theme="light"]) .watcher-option span,
  :root:not([data-theme="light"]) .status { color: #dbe4f2; background: #2b3749; }
  :root:not([data-theme="light"]) .track-source,
  :root:not([data-theme="light"]) .viewing-comment { color: #c2ccda; }
  :root:not([data-theme="light"]) .track-detail-preview { color: #c2ccda; }
  :root:not([data-theme="light"]) .text-detail-dialog { color: #e5eaf2; border-color: #59677c; background: #182131; }
  :root:not([data-theme="light"]) .progress-stats output,
  :root:not([data-theme="light"]) .progress-stats .progress-total { color: #e5eaf2; }
  :root:not([data-theme="light"]) .media-watching-on { color: #aeb9ca; }
  :root:not([data-theme="light"]) .media-watching-on strong { color: #e5eaf2; }
  :root:not([data-theme="light"]) .notice { color: #c8f5d8; border-color: #31724b; background: #153525; }
  :root:not([data-theme="light"]) .notice.warning { color: #ffe8a3; border-color: #8a6425; background: #352911; }
  :root:not([data-theme="light"]) .catalogue-result { border-color: #3a465a; background: #182131; }
  :root:not([data-theme="light"]) .unconfirmed-source { color: #ffe8a3; border-left-color: #8a6425; background: #352911; }
  :root:not([data-theme="light"]) .finish-action { color: #fde68a; border-color: #a16207; background: #713f12; }
  :root:not([data-theme="light"]) .finish-dialog { border-color: #59677c; background: #182131; color: #e5eaf2; }
  :root:not([data-theme="light"]) .finish-dialog p { color: #aeb9ca; }
  :root:not([data-theme="light"]) .resolved-suggestions > summary { color: #c2ccda; }
  :root:not([data-theme="light"]) .status-ready { color: #9ce9bd; background: #174c35; }
  :root:not([data-theme="light"]) .status-in_progress { color: #bfdbfe; background: #1e3a8a; }
  :root:not([data-theme="light"]) .status-pending { color: #fde68a; background: #713f12; }
  :root:not([data-theme="light"]) .status-finished { color: #ddd6fe; background: #4c1d95; }
  :root:not([data-theme="light"]) .status-abandoned { color: #fdba74; background: #7c2d12; }
  :root:not([data-theme="light"]) .status-binned { color: #fecaca; background: #7f1d1d; }
  :root:not([data-theme="light"]) .watcher-option input:checked + span {
    color: #fff;
    background: #1e3a8a;
    box-shadow: inset 0 0 0 2px #60a5fa;
  }
  :root:not([data-theme="light"]) .empty-state { border-color: #59677c; }
  :root:not([data-theme="light"]) .settings-help,
  :root:not([data-theme="light"]) .settings-status,
  :root:not([data-theme="light"]) .field label,
  :root:not([data-theme="light"]) .settings-choice-list label,
  :root:not([data-theme="light"]) .shared-viewer-move summary,
  :root:not([data-theme="light"]) .runtime-inputs label,
  :root:not([data-theme="light"]) .edit-detail-group legend,
  :root:not([data-theme="light"]) .source-remove-dialog p { color: #aeb9ca; }
  :root:not([data-theme="light"]) .settings-choice-list label { color: #e5eaf2; }
  :root:not([data-theme="light"]) .settings-warning { color: #ffe8a3; border-left-color: #f59e0b; background: #352911; }
  :root:not([data-theme="light"]) .editor-readonly-key { color: #aeb9ca; }
  :root:not([data-theme="light"]) .readonly-muted { border-color: #64748b; background: #151e2d; color: #aeb9ca; }
  :root:not([data-theme="light"]) .readonly-group { border-color: #64748b; background: #151e2d; }
  :root:not([data-theme="light"]) .readonly-group-value { color: #aeb9ca; background: #111827; }
  :root:not([data-theme="light"]) .editor input:not([readonly]),
  :root:not([data-theme="light"]) .editor select,
  :root:not([data-theme="light"]) .editor textarea,
  :root:not([data-theme="light"]) .editor .edit-detail-group:not(.readonly-group) { border-color: #a3b4d0; }
  :root:not([data-theme="light"]) .source-remove-dialog { color: #e5eaf2; border-color: #59677c; background: #182131; }
  :root:not([data-theme="light"]) .edit-detail-group { border-color: #59677c; background: #111827; }
}

@media (max-width: 62rem) {
  .toolbar { align-items: stretch; flex-direction: column; }
  /* Source is taller because its label sits above the select. Keep the other
     controls bottom-aligned until the intentional compact grid takes over. */
  .toolbar-actions { align-items: end; }
  .track-content { grid-template-columns: minmax(11rem, 1fr) minmax(14rem, 1.2fr); }
  .quick-actions { grid-column: 1 / -1; justify-content: start; }
}

@media (max-width: 40rem) {
  .login-page { width: min(100% - 1rem, 32rem); padding: .5rem 0; }
  .login-shell { grid-template-columns: 1fr; border-radius: .8rem; }
  .login-welcome { min-height: 0; padding: 1.75rem; }
  .login-welcome h1 { font-size: clamp(2.05rem, 9.3vw, 2.65rem); }
  .login-introduction { font-size: .98rem; }
  .login-moments { display: none; }
  .login-panel { padding: 1.75rem; }
  .site-header { align-items: start; }
  .field-pair { align-items: stretch; flex-direction: column; }
  .field-pair .field { flex: 0 1 auto; }
  .series-episode-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: none; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions {
    grid-template-columns: minmax(0, 10rem) minmax(1rem, 1fr) 8rem;
    grid-template-areas:
      "find find find"
      "source . viewers"
      "suggestions . more";
    align-items: stretch;
  }
  .toolbar-source select { width: 100%; }
  .viewer-filter-field, button.toolbar-more-toggle { justify-self: stretch; }
  .toolbar-more-content {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .toolbar-more-content .search-field,
  .toolbar-more-content .visibility-options { grid-column: 1 / -1; }
  .toolbar-more-content .sort-field,
  .toolbar-more-content .detail-options { grid-column: 1 / -1; }
  .toolbar-more-content .sort-field select { width: 100%; }
  .visibility-options { align-self: start; }
  .detail-options { justify-self: start; margin-left: 0; flex-wrap: wrap; }
  .search-field input { width: 100%; }
  .viewer-filter-field { align-self: stretch; }
  .viewer-filter > summary { max-width: none; }
  .viewer-filter form {
    left: auto;
    right: 0;
    width: min(16rem, calc(100vw - 2rem));
    min-width: 0;
  }
  .toolbar-actions > .button { width: 100%; }
  .toolbar-actions > .button.quiet {
    justify-self: stretch;
    width: 100%;
  }
  .page-heading { align-items: start; flex-direction: column; }
  .page-links { width: 100%; justify-content: space-between; }
  .track.has-poster { grid-template-columns: clamp(4.6rem, 18vw, 5.75rem) minmax(0, 1fr); }
  .track-content { grid-template-columns: 1fr; }
  .quick-actions > *, .quick-actions button, .quick-actions .button { flex: 1 1 8rem; width: 100%; }
  .suggestion-columns { grid-template-columns: 1fr; }
}
