:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --text: #1c2430;
  --muted: #5d6b7e;
  --border: #dde3ea;
  --accent: #3d5a80;
  --accent-text: #ffffff;
  --accent-soft: #e3ebf5;
  --context: #7a4fb5;
  --context-soft: #efe7fa;
  --tag: #2f7d6d;
  --tag-soft: #e2f3ef;
  --danger: #b3261e;
  --danger-text: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  color-scheme: light;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a2028;
    --surface-2: #232b35;
    --text: #e6ebf1;
    --muted: #94a2b4;
    --border: #2d3743;
    --accent: #8fb3e0;
    --accent-text: #0e1620;
    --accent-soft: #24344a;
    --context: #c2a2ee;
    --context-soft: #33284a;
    --tag: #7fd1bf;
    --tag-soft: #1f3a35;
    --danger: #ff8a80;
    --danger-text: #2a0d0a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  display: flow-root; /* keep child margins from collapsing into a scrollbar */
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
}

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

input,
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  min-width: 0;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button,
.button {
  font: inherit;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  background: var(--surface-2);
  cursor: pointer;
  white-space: nowrap;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

.primary {
  background: var(--accent);
  color: var(--accent-text);
}

.ghost {
  background: transparent;
  border-color: var(--border);
}

.ghost:hover:not(:disabled) {
  background: var(--surface-2);
}

.danger,
.toast.error {
  background: var(--danger);
  color: var(--danger-text);
}

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

.icon-btn {
  padding: 2px 8px;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.link {
  background: none;
  padding: 0;
  color: var(--accent);
  text-align: left;
  white-space: normal;
}

/* Layout ------------------------------------------------------------------ */

.splash,
.empty {
  color: var(--muted);
  padding: 32px;
  text-align: center;
}

.shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "top top top"
    "side main inspector";
  height: 100vh;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  padding-left: 26px;
  background: url("/favicon.svg") left center / 20px no-repeat;
}

.search {
  flex: 1;
  max-width: 480px;
}

.search input {
  width: 100%;
}

.topbar > button {
  margin-left: auto;
}

.sidebar {
  grid-area: side;
  overflow-y: auto;
  padding: 12px 8px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text);
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active {
  background: var(--accent-soft);
  font-weight: 600;
}

.labels {
  margin-top: 18px;
}

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

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 4px 10px;
}

.section-head h2,
.picker h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.labels .inline-form {
  padding: 0 4px 6px;
}

.labels .inline-form input {
  width: 100%;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
}

.dot.context {
  background: var(--context);
  border-radius: 2px;
}

.dot.tag {
  background: var(--tag);
}

.label-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.count {
  color: var(--muted);
  font-size: 12px;
}

.main {
  grid-area: main;
  overflow-y: auto;
  padding: 16px 20px 80px;
}

/* Folder view ------------------------------------------------------------- */

.folder-view {
  min-height: 100%;
  border: 2px dashed transparent;
  border-radius: var(--radius);
}

.folder-view.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inline-form {
  display: flex;
  gap: 6px;
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-weight: 600;
}

.crumbs li + li::before {
  content: "/";
  color: var(--muted);
  margin: 0 8px;
  font-weight: 400;
}

.crumbs li:last-child a {
  color: var(--text);
}

.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 90px 170px;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  cursor: default;
  user-select: none;
}

.row.head {
  border-top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.row:not(.head):hover {
  background: var(--surface-2);
}

.row:not(.head).selected {
  background: var(--accent-soft);
}

.row .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .size,
.row .date {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.row .size {
  text-align: right;
}

.list .empty {
  margin: 0;
}

/* Icons are pure CSS so no markup or SVG is ever generated from data. */
.icon {
  width: 20px;
  height: 16px;
  position: relative;
  flex: none;
}

.icon.folder {
  background: var(--accent);
  border-radius: 2px 3px 3px 3px;
  opacity: 0.85;
}

.icon.folder::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 0;
  width: 9px;
  height: 4px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.icon.file {
  width: 14px;
  height: 18px;
  margin: 0 3px;
  border: 2px solid var(--muted);
  border-radius: 2px 6px 2px 2px;
}

.icon.small {
  transform: scale(0.75);
}

/* Label and search views -------------------------------------------------- */

.label-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.label-head .actions {
  margin-left: auto;
}

.badge {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 10px;
}

.badge.context,
.chip.context {
  background: var(--context-soft);
  color: var(--context);
}

.badge.tag,
.chip.tag {
  background: var(--tag-soft);
  color: var(--tag);
}

.description {
  width: 100%;
  resize: vertical;
  margin-bottom: 14px;
}

.search-view h1 {
  font-size: 16px;
  margin-bottom: 14px;
}

.confirm {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--danger);
}

/* Thumbnails and previews --------------------------------------------------- */

.row .thumb {
  width: 28px;
  height: 28px;
  margin: -6px 0;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface-2);
}

.preview-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  cursor: zoom-in;
}

.media-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
}

.media-fallback p {
  margin: 0;
  max-width: 60ch;
}

.fallback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* Media viewer -------------------------------------------------------------- */

.modal-open,
.modal-open body {
  overflow: hidden;
}

/* Full-screen dark stages: the media viewer and the movie page. */
.viewer,
.movie-page {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #0a0c10;
  color: #f2f4f7;
  outline: none;
}

.viewer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: linear-gradient(rgb(0 0 0 / 55%), transparent);
}

.viewer-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.viewer-count {
  color: rgb(242 244 247 / 70%);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.viewer-btn {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 8px;
  background: rgb(255 255 255 / 8%);
  color: inherit;
  text-decoration: none;
  font-size: 14px;
}

.viewer-btn:hover,
.viewer-btn[aria-pressed="true"] {
  background: rgb(255 255 255 / 18%);
}

.viewer-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 56px 24px;
  touch-action: pan-y;
  user-select: none;
}

.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}

.viewer-stage.zoomed {
  display: block;
  overflow: auto;
  padding: 0;
  touch-action: auto;
}

.viewer-stage.zoomed img {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.viewer-media {
  width: 100%;
  max-height: 100%;
  display: flex;
  justify-content: center;
}

.viewer-media.video {
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.viewer-media video {
  max-width: 100%;
  max-height: calc(100vh - 170px);
  background: #000;
}

/* Video player: subtitle picker and notes under the picture ---------------- */

.player-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 0 0;
  font-size: 13px;
}

.player-subs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.player-subs select {
  max-width: 60vw;
}

.player-note {
  margin: 0;
  color: var(--muted);
}

:is(.viewer, .movie-page) .player-bar {
  justify-content: center;
  color: rgb(242 244 247 / 85%);
}

:is(.viewer, .movie-page) :is(.player-note, .player-note a, .media-fallback) {
  color: rgb(242 244 247 / 75%);
}

/* Form controls on a dark stage. */
:is(.viewer, .movie-page) :is(select, input) {
  background: rgb(255 255 255 / 10%);
  color: #f2f4f7;
  border-color: rgb(255 255 255 / 20%);
}

:is(.viewer, .movie-page) option {
  color: initial;
}

.viewer-media.audio audio {
  width: min(560px, 100%);
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  padding: 0;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: rgb(255 255 255 / 10%);
  color: #fff;
  font-size: 32px;
  line-height: 1;
}

.viewer-nav:hover {
  background: rgb(255 255 255 / 22%);
}

.viewer-nav.prev {
  left: 8px;
}

.viewer-nav.next {
  right: 8px;
}

@media (max-width: 720px) {
  .viewer-stage {
    padding: 4px 4px 16px;
  }
  .viewer-nav {
    top: auto;
    bottom: 12px;
    transform: none;
    width: 52px;
    height: 52px;
  }
}

/* Publishing ---------------------------------------------------------------- */

.dot.public {
  background: var(--accent);
  border-radius: 2px;
}

.badge.public,
.badge.shared,
.badge.trouble {
  margin-left: 8px;
  vertical-align: 1px;
  font-size: 11px;
}

.badge.trouble {
  background: var(--surface-2);
  color: var(--muted);
}

.badge.public {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.shared {
  background: var(--tag-soft);
  color: var(--tag);
}

.publishing-body,
.publish-block {
  display: flex;
  flex-direction: column;
}

.publishing-body {
  gap: 16px;
}

.publish-block {
  gap: 8px;
}

.publish-block p,
.publish-block h4 {
  margin: 0;
  font-size: 13px;
}

.publish-block > button {
  align-self: flex-start;
}

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

.copy-field {
  display: flex;
  gap: 6px;
}

.copy-field input {
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.share-list:empty {
  display: none;
}

.share-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.publishing .inline-form select {
  flex: 1;
}

/* Inspector --------------------------------------------------------------- */

.inspector {
  grid-area: inspector;
  width: 340px;
  overflow-y: auto;
  padding: 14px 16px 80px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.inspector-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rename {
  flex: 1;
  display: flex;
}

.rename input {
  flex: 1;
  font-weight: 600;
  border-color: transparent;
  background: transparent;
}

.rename input:hover,
.rename input:focus {
  border-color: var(--border);
  background: var(--surface);
}

.preview {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-2);
}

.preview img,
.preview video {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.preview audio {
  width: 100%;
}

pre.preview {
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}

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

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

.inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.move-form {
  display: flex;
  gap: 6px;
  width: 100%;
}

.move-form select {
  flex: 1;
}

.picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.picker .inline-form input,
.picker > input {
  width: 100%;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 14px;
  padding: 2px 4px 2px 10px;
  font-size: 13px;
}

.chip a {
  color: inherit;
}

.chip button {
  padding: 0 6px;
  background: none;
  color: inherit;
  opacity: 0.7;
}

.chip button:hover {
  opacity: 1;
}


.related,
.link-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.related li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.related .link {
  flex: none;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.related .note {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.link-results .link {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Login, uploads, toast ----------------------------------------------------- */

.login {
  max-width: 340px;
  margin: 12vh auto 0;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login h1 {
  font-size: 22px;
  margin-bottom: 6px;
}

.login button {
  justify-content: center;
  margin-top: 6px;
}

.hint {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  font-size: 13px;
}

.error {
  margin: 0;
  color: var(--danger);
}

.uploads {
  position: fixed;
  z-index: 20; /* above the inspector overlay on phones */
  right: 16px;
  bottom: 16px;
  width: 340px;
  max-height: 40vh;
  overflow-y: auto;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas:
    "name status close"
    "bar bar bar";
  align-items: center;
  gap: 4px 8px;
  font-size: 13px;
}

.upload .name {
  grid-area: name;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload .status {
  grid-area: status;
  color: var(--muted);
}

.upload progress {
  grid-area: bar;
  width: 100%;
  height: 6px;
  accent-color: var(--accent);
}

.url-form {
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.url-form input {
  flex: 1 1 320px;
  min-width: 0;
}

.url-form .hint {
  flex-basis: 100%;
  margin: 0;
}

.upload.failed .status {
  color: var(--danger);
}

.upload.done .status {
  color: var(--tag);
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  max-width: min(560px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
}


/* Narrow screens -------------------------------------------------------------- */

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "top"
      "side"
      "main";
  }
  /* The sidebar becomes a horizontally scrolling strip so contexts and tags
     stay reachable on phones. */
  .sidebar {
    display: flex;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    padding: 8px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .labels,
  .labels ul {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
  }
  .section-head {
    padding: 0;
  }
  .labels .inline-form {
    padding: 0;
  }
  .labels .inline-form input {
    width: 160px;
  }
  .nav-item {
    white-space: nowrap;
  }
  .label-name {
    overflow: visible;
  }
  .inspector {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 10;
    width: min(400px, 100vw);
    box-shadow: var(--shadow);
  }
  .row {
    grid-template-columns: 28px minmax(0, 1fr) 70px;
  }
  .row > :nth-child(4) {
    display: none;
  }
  .main {
    padding: 12px 16px 80px;
  }
  .topbar {
    gap: 10px;
    padding: 8px 16px;
  }
}

/* Touch: 44px targets, and 16px inputs so iOS does not zoom on focus. */
@media (max-width: 900px), (pointer: coarse) {
  button,
  .button,
  input,
  select,
  .nav-item,
  .viewer-btn {
    min-height: 44px;
  }
  .icon-btn,
  .chip button,
  .viewer-btn {
    min-width: 44px;
  }
  .chip {
    padding-left: 12px;
  }
  .chip a {
    padding: 12px 0;
  }
  .brand {
    min-height: 44px;
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
}

/* Movies library ------------------------------------------------------------ */

.dot.movies {
  background: var(--accent);
  border-radius: 2px;
  transform: rotate(45deg) scale(0.85);
}

.library-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}

.library-head h1 {
  margin: 0;
  font-size: 20px;
}

.library-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.library-search {
  flex: 1 1 220px;
  max-width: 360px;
}

.decade-chips .chip {
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.decade-chips .chip.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.decade-chips .count {
  color: var(--muted);
  font-size: 12px;
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 16px;
}

.movie-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius);
}

.movie-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.movie-poster {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--surface-2), var(--border));
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.movie-tile:hover .movie-poster {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgb(0 0 0 / 10%), 0 10px 24px rgb(0 0 0 / 16%);
}

.movie-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  font-weight: 600;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.movie-poster .badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  margin: 0;
  background: rgb(10 12 16 / 75%);
  color: #f2f4f7;
}

.movie-title {
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.movie-meta {
  color: var(--muted);
  font-size: 13px;
}

/* Continue watching: one row that scrolls sideways. */
.continue h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.movie-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 150px;
  gap: 16px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 2px 2px 14px;
  margin-bottom: 18px;
  scroll-snap-type: x proximity;
}

.movie-row .movie-tile {
  scroll-snap-align: start;
}

.watched-mark {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgb(0 0 0 / 30%);
}

.movie-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  border: 0;
  appearance: none;
  background: rgb(0 0 0 / 45%);
}

.movie-progress::-webkit-progress-bar {
  background: rgb(0 0 0 / 45%);
}

.movie-progress::-webkit-progress-value {
  background: var(--accent);
}

.movie-progress::-moz-progress-bar {
  background: var(--accent);
}

/* The trouble badge moves up when a progress bar is shown. */
.movie-poster:has(.movie-progress) .badge {
  bottom: 12px;
}

.player-resumed .link {
  color: inherit;
  text-decoration: underline;
}

.library-empty {
  max-width: 560px;
  padding: 32px 0;
}

.library-empty p {
  margin: 0 0 8px;
}

/* Movie page: full screen over the library (a dark stage like the viewer) -- */

.movie-heading {
  margin: 0;
  font-size: 16px;
}

.movie-year {
  color: rgb(242 244 247 / 65%);
  font-weight: 400;
}

.movie-details {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin: 0 12px 8px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgb(255 255 255 / 6%);
}

.movie-details label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: rgb(242 244 247 / 75%);
}

.movie-details label:first-child {
  flex: 1 1 240px;
}

.movie-details input[inputmode="numeric"] {
  width: 7em;
}

.movie-details .hint {
  flex-basis: 100%;
  order: 3;
  margin: 0;
  color: rgb(242 244 247 / 60%);
  overflow-wrap: anywhere;
}

.movie-details-actions {
  display: flex;
  gap: 8px;
}

.movie-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px 12px;
}

.movie-player {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* The picture keeps its own shape, as large as fits, centred. */
.movie-player video {
  width: 100%;
  height: auto;
  min-height: 0;
  flex: 0 1 auto;
  max-height: calc(100% - 52px);
  background: #000;
}

@media (max-width: 720px) {
  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 18px 12px;
  }
  .movie-row {
    grid-auto-columns: 120px;
    gap: 12px;
  }
  .library-search {
    max-width: none;
  }
}
