:root {
  --border: rgba(227, 218, 201, 0.1);
  --border-strong: rgba(227, 218, 201, 0.22);
  --cream-dim: rgba(227, 218, 201, 0.55);
  --gray-mid: rgba(227, 218, 201, 0.55);
  --cream-hover: rgba(227, 218, 201, 0.06);
  --input-fill: rgba(227, 218, 201, 0.04);
  --popover-surface: #171614;
}
body { background: var(--color-primary); color: var(--color-base); }
/* Shared dark tab-bar surface (matches the page shell, not the old cream). */
.tab-bar { background: var(--color-primary); }

/* ── SHELL ── */
.wl-page { min-height: 100vh; background: var(--color-primary); }
.wl-toprule { height: 3px; background: var(--color-accent); }
.wl-col { max-width: 1320px; margin: 0 auto; padding: 24px 20px 56px; }
.wl-title { font-family: "Playfair Display", serif; font-weight: 700; font-size: 2rem; color: var(--color-base); line-height: 1; margin: 0; }

/* ── TAB ROW + SEARCH ── */
.wl-tabrow { display: flex; align-items: center; gap: 28px; margin-top: 22px; border-bottom: 1px solid var(--border); }
.wl-tab { font-family: "Inter", sans-serif; font-size: 13px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--cream-dim); background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding-bottom: 14px; cursor: pointer; }
.wl-tab.active { color: var(--color-base); border-bottom-color: var(--color-accent); }
.wl-tab:hover { color: var(--color-base); }
.wl-searchbox { margin-left: auto; display: flex; align-items: center; gap: 8px; padding-bottom: 6px; }
.wl-search { background: transparent; border: none; border-bottom: 1px solid var(--border-strong); color: var(--color-base);
  font-family: "Inter", sans-serif; font-size: 14px; padding: 6px 4px; width: 220px; outline: none; }
.wl-search:focus { border-bottom-color: var(--color-base); }
.wl-search::placeholder { color: var(--cream-dim); }
.wl-search-toggle { min-width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 8px;
  border: none; background: transparent; color: var(--cream-dim); cursor: pointer; }
.wl-search-toggle:hover { color: var(--color-base); background: var(--cream-hover); }

/* ── BODY: rail + gallery ── */
.wl-body { display: flex; flex-direction: column; gap: 24px; margin-top: 24px; align-items: stretch; }
.wl-rail { flex: none; }
.wl-rail-eyebrow { font-family: "Inter", sans-serif; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--red-text); margin: 0 4px 10px; }
.wl-rail-rows { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; } /* mobile = horizontal chips */
.wl-listrow { flex: 0 0 auto; display: flex; align-items: baseline; gap: 8px; padding: 8px 13px; border-radius: var(--radius-sm);
  background: transparent; -webkit-appearance: none; appearance: none; border: 1px solid var(--border); cursor: pointer;
  transition: background var(--dur) var(--ease-out); white-space: nowrap; }
.wl-listrow:hover { background: var(--cream-hover); }
.wl-listrow.active { background: var(--cream-hover); box-shadow: inset 2px 0 0 var(--color-accent); border-color: transparent; }
.wl-listrow-name { font-family: "Inter", sans-serif; font-size: 14.5px; color: var(--cream-dim); }
.wl-listrow.active .wl-listrow-name { color: var(--color-base); font-weight: 600; }
.wl-listrow-count { font-family: "Inter", sans-serif; font-size: 12px; color: var(--cream-dim); }
.wl-rail-foot { margin-top: 8px; }
.wl-rail-create { display: flex; align-items: center; gap: 8px; padding: 11px 16px;
  border: 1.5px solid var(--color-accent); border-radius: var(--radius-sm); background: var(--input-fill); }
.wl-rail-create input { flex: 1; min-width: 0; background: none; border: none; outline: none; padding: 0;
  font-family: "Inter", sans-serif; font-size: 15px; font-weight: 600; color: var(--color-base); caret-color: var(--color-accent); }
.wl-rail-create input::placeholder { font-weight: 400; color: var(--cream-dim); }
.wl-rail-hint { display: flex; justify-content: space-between; padding: 6px 16px 0;
  font-family: "Inter", sans-serif; font-size: 12px; color: var(--cream-dim); }
.wl-gallery { flex: 1; min-width: 0; }
.wl-loading { font-family: "Inter", sans-serif; color: var(--cream-dim); padding: 8px 4px; }

/* ── GALLERY HEADER ── */
.wl-head { display: flex; align-items: center; gap: 10px; }
.wl-head-title { font-family: "Playfair Display", serif; font-weight: 700; font-size: 1.8rem; color: var(--color-base); line-height: 1.05; margin: 0; }
.wl-head-opts { background: none; border: none; color: var(--cream-dim); cursor: pointer; padding: 4px; border-radius: 6px; }
.wl-head-opts:hover { color: var(--color-base); background: var(--cream-hover); }
.wl-listnote { font-family: "Lora", serif; font-size: 15px; color: var(--cream-dim); line-height: 1.6; max-width: 580px;
  border-left: 2px solid var(--color-accent); padding: 12px 0 12px 18px; margin-top: 14px; cursor: text; }
.wl-listnote-add { margin-top: 12px; display: inline-block; }
.wl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-top: 18px;
  font-family: "Inter", sans-serif; font-size: 12px; letter-spacing: .06em; color: var(--cream-dim); }

/* ── GRID + TILE ── */
.wl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 28px 18px; margin-top: 24px; }
.wl-tile { display: flex; flex-direction: column; gap: 10px; }
/* The unconditional `display: flex` above outranks the browser's default
   [hidden] styling (author rules always beat the UA stylesheet at equal
   specificity), so search's applyFilter() setting the hidden attribute had
   no visual effect without this override. */
.wl-tile[hidden] { display: none; }
.wl-poster { position: relative; aspect-ratio: 2/3; border-radius: var(--radius-sm); overflow: hidden;
  border: 1px solid var(--border-strong); background: #171717; transition: border-color var(--dur) var(--ease-out); }
.wl-poster:hover { border-color: var(--color-base); }
.wl-poster-link { display: block; width: 100%; height: 100%; }
.wl-poster-img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.92); transition: filter var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
.wl-poster:hover .wl-poster-img { filter: saturate(1); transform: scale(1.03); }
.wl-poster-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 18px; box-sizing: border-box;
  font-family: "Playfair Display", serif; font-weight: 600; font-size: 1.15rem; line-height: 1.2; color: var(--color-base); text-align: center; text-wrap: balance; }
.wl-grip { position: absolute; bottom: 9px; left: 11px; color: var(--cream-dim); cursor: grab; line-height: 0; }
.wl-cap { display: flex; flex-direction: column; gap: 5px; }
.wl-cap-meta { font-family: "Inter", sans-serif; font-size: 13px; color: var(--cream-dim); }
.wl-tile-note { font-family: "Lora", serif; font-size: 13px; color: var(--cream-dim); line-height: 1.5; cursor: pointer; }
.wl-tile-note-add { font-size: 13px; }

/* ── TILE CONTROLS ── */
.wl-tile-ctrls { position: absolute; top: 9px; right: 9px; display: flex; flex-direction: column; gap: 6px; }
.wl-ctrl { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 7px;
  border: 1px solid var(--border-strong); background: rgba(15,15,15,.6); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  color: var(--cream-dim); cursor: pointer; padding: 0; transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out); }
.wl-ctrl:hover { color: var(--color-base); border-color: var(--color-base); }
.wl-ctrl:disabled { opacity: .3; cursor: default; }

/* Reveal chevrons/overflow on hover/focus for pointer devices; keep grip always visible. */
@media (hover: hover) and (pointer: fine) {
  .wl-tile-ctrls { opacity: 0; transition: opacity var(--dur) var(--ease-out); }
  .wl-tile:hover .wl-tile-ctrls,
  .wl-tile:focus-within .wl-tile-ctrls { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { .wl-tile-ctrls { transition: none; } }

/* ── LINKS / EMPTY ── */
.wl-link { background: none; border: none; padding: 0; font-family: "Inter", sans-serif; font-size: 13px; letter-spacing: .02em;
  color: var(--cream-dim); cursor: pointer; transition: color var(--dur) var(--ease-out); text-align: left; }
.wl-link:hover { color: var(--color-base); }
.wl-empty { padding: 48px 4px; }
.wl-empty-title { font-family: "Playfair Display", serif; font-size: 1.4rem; color: var(--color-base); margin-bottom: 10px; }
.wl-search-empty { font-family: "Lora", serif; color: var(--cream-dim); padding: 32px 4px; }

/* ── FOCUS (all controls) ── */
.wl-page :focus-visible, [data-action]:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 4px; }
.ml-modal :focus-visible, .ml-menu :focus-visible, .ml-move :focus-visible, .ml-add :focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 4px; }
/* These inputs already show a persistent crimson border while open — the generic focus-visible
   outline above would stack a second ring on top of it, so suppress it here specifically. */
.wl-rail-create input:focus-visible, .ml-move-create input:focus-visible { outline: none; }

/* ── VISUALLY HIDDEN UTILITY ── */
.wl-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── MOBILE: 44px touch targets ── */
@media (max-width: 768px) {
  /* Keep the VISIBLE control compact (28px) so it reads as a light affordance
     instead of a heavy grey slab dominating the poster, but preserve a ≥44px
     TOUCH target via an invisible, centered hit-area (::before). Only the "…"
     menu shows on mobile (chevrons are hidden below), so this is the one button. */
  .wl-ctrl { width: 28px; height: 28px; border-radius: 6px; position: relative; }
  .wl-ctrl::before {
    content: ""; position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%); width: 44px; height: 44px;
  }
  .wl-tile-ctrls { top: 8px; right: 8px; gap: 4px; }
  /* Reordering on mobile happens by dragging .wl-grip (always visible, bottom-left) — the
     up/down chevrons are a desktop affordance that only appears on hover there. Stacked and
     forced permanently visible on touch (no hover state to gate them), they covered a third
     of the poster. Keep only the "…" menu, since it's the sole mobile path to Watched/Move/Remove. */
  .wl-ctrl[data-action="ml-move-up"], .wl-ctrl[data-action="ml-move-down"] { display: none; }
  .wl-search-toggle, .wl-listrow, .wl-rail-create, .ml-move-row, .ml-move-create { min-height: 44px; }
  .wl-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 22px 14px; }
}

/* ── DESKTOP: rail beside gallery ── */
@media (min-width: 769px) {
  .wl-col { padding: 30px 48px 64px; }
  .wl-title { font-size: 2.4rem; }
  .wl-body { flex-direction: row; gap: 48px; align-items: flex-start; }
  .wl-rail { width: 236px; position: sticky; top: 24px; }
  .wl-rail-rows { flex-direction: column; gap: 2px; overflow: visible; }
  .wl-listrow { width: 100%; box-sizing: border-box; border-color: transparent; justify-content: space-between; }
  .wl-head-title { font-size: 2.2rem; }
  .wl-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 34px 26px; }
}

/* ── DRAG GHOST + GRIP ACTIVE ── */
.wl-tile--ghost { opacity: .4; }
.wl-grip:active { cursor: grabbing; }

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  .wl-poster-img, .wl-poster, .wl-ctrl, .wl-listrow, .wl-search-toggle, .wl-link { transition: none; }
  .wl-poster:hover .wl-poster-img { transform: none; }
}

/* ── INLINE PROMPT MODAL ──
   Dark card convention, matching .film-modal / .wm-card / this file's own
   .ml-move and .ml-add popovers — NOT the inverted light-on-cream treatment
   this used to have. */
.ml-modal { position: fixed; inset: 0; background: rgba(15,15,15,.6); display: flex;
  align-items: center; justify-content: center; z-index: 1000; }
.ml-modal-box { background: var(--color-primary); color: var(--color-base); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: 0 4px 24px rgba(15,15,15,.6); padding: var(--space-6); width: min(420px, 90vw); }
.ml-modal-title { font-family: "Playfair Display", serif; font-size: 1.2rem; margin-bottom: var(--space-3); }
.ml-modal-input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-family: "Inter", sans-serif; font-size: 1rem; box-sizing: border-box; background: var(--cream-hover); color: var(--color-base); }
.ml-modal-input::placeholder { color: var(--cream-dim); }
.ml-modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }
.ml-btn { background: var(--color-base); color: var(--color-primary); border: none; padding: var(--pad-button);
  border-radius: var(--radius-sm); font-family: "Inter", sans-serif; cursor: pointer; }
.ml-btn-ghost { background: transparent; border: none; color: var(--cream-dim); cursor: pointer; padding: var(--pad-button); }
.ml-btn-ghost:hover { color: var(--color-base); }
.ml-btn--danger { background: var(--color-accent); color: var(--color-base-bright); }

/* ── ROW MENU ── */
.ml-menu { position: absolute; background: var(--color-primary); color: var(--color-base); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: 0 4px 24px rgba(15,15,15,.6); display: flex; flex-direction: column; min-width: 180px; z-index: 1000; }
.ml-menu button { background: none; border: none; text-align: left; padding: 10px 14px; cursor: pointer;
  color: inherit; font-family: "Inter", sans-serif; font-size: .9rem; width: 100%; }
.ml-menu button:hover { background: var(--cream-hover); }

/* ── MOVE TO LIST POPOVER ── */
.ml-move { position: absolute; width: 230px; background: var(--popover-surface); color: var(--color-base);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px;
  display: flex; flex-direction: column; gap: 2px; z-index: 1000; }
.ml-move-caret { position: absolute; left: -5px; top: 14px; width: 10px; height: 10px; background: var(--popover-surface);
  border-left: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); transform: rotate(45deg); }
.ml-move--left .ml-move-caret { left: auto; right: -5px;
  border-left: none; border-bottom: none; border-right: 1px solid var(--border-strong); border-top: 1px solid var(--border-strong); }
.ml-move-eyebrow { font-family: "Inter", sans-serif; font-weight: 500; font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--cream-dim); padding: 8px 10px 6px; }
.ml-move-row { display: flex; align-items: center; justify-content: space-between; padding: 10px;
  border-radius: var(--radius-sm); font-family: "Inter", sans-serif; font-size: 14px; color: var(--color-base);
  cursor: pointer; background: none; border: none; text-align: left; width: 100%; }
.ml-move-row:hover { background: var(--cream-hover); }
.ml-move-row.current { font-weight: 600; background: var(--cream-hover); cursor: default; }
.ml-move-check { color: var(--color-accent); }
.ml-move-divider { height: 1px; background: var(--border); margin: 6px 2px; }
.ml-move-new { color: var(--cream-dim); }
.ml-move-create { display: flex; align-items: center; gap: 6px; padding: 9px 10px; margin-top: 2px;
  border: 1.5px solid var(--color-accent); border-radius: var(--radius-sm); background: var(--input-fill); }
.ml-move-create input { flex: 1; min-width: 0; background: none; border: none; outline: none; padding: 0;
  font-family: "Inter", sans-serif; font-size: 14px; color: var(--color-base); caret-color: var(--color-accent); }
.ml-move-create input::placeholder { color: var(--cream-dim); }
.ml-move-hint { display: flex; justify-content: space-between; padding: 8px 10px 4px;
  font-family: "Inter", sans-serif; font-size: 11.5px; color: var(--cream-dim); }

/* ── ADD FILMS POPOVER ── */
.ml-add { position: absolute; width: 320px; max-width: 90vw; background: var(--popover-surface); color: var(--color-base);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 12px; z-index: 1000; }
.ml-add-caret { position: absolute; left: -5px; top: 14px; width: 10px; height: 10px; background: var(--popover-surface);
  border-left: 1px solid var(--border-strong); border-bottom: 1px solid var(--border-strong); transform: rotate(45deg); }
.ml-add--left .ml-add-caret { left: auto; right: -5px;
  border-left: none; border-bottom: none; border-right: 1px solid var(--border-strong); border-top: 1px solid var(--border-strong); }

/* ── NOTE EDITORS ── */
.ml-note-edit { width: 100%; min-height: 64px; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-family: "Lora", serif; font-size: .95rem; resize: vertical; box-sizing: border-box;
  background: var(--cream-hover); color: var(--color-base); }
.ml-note-edit::placeholder { color: var(--cream-dim); }
.ml-note-edit:focus, .ml-note-edit:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-color: transparent; }

/* ── ADD FILMS SEARCH ── */
.ml-addresults { margin-top: 8px; max-height: 320px; overflow-y: auto; }
.ml-addrow { display: flex; justify-content: space-between; width: 100%; background: none; border: none;
  border-bottom: 1px solid var(--border); padding: 10px 4px; text-align: left; cursor: pointer;
  font-family: "Inter", sans-serif; color: inherit; }
.ml-addrow:hover { background: var(--cream-hover); }

/* ── ERROR TOAST ──
   Was background: var(--color-primary) on a page whose body is also
   var(--color-primary) — effectively invisible. Give it its own dark card. */
.ml-toast { position: fixed; bottom: 24px; right: 24px; background: var(--color-primary);
  color: var(--color-base); border: 1px solid var(--border-strong); box-shadow: 0 4px 24px rgba(15,15,15,.6);
  padding: 12px 18px; border-radius: var(--radius-sm); font-family: "Inter", sans-serif;
  font-size: .9rem; opacity: 0; transition: opacity 200ms ease-out; z-index: 2000; pointer-events: none; }
.ml-toast.show { opacity: 1; }
/* Mobile: confirmations appear at the top (banner-style, below the sticky top
   bar), centered — away from the bottom nav. Desktop keeps bottom-right. */
@media (max-width: 767px) {
  .ml-toast { bottom: auto; top: calc(env(safe-area-inset-top) + 64px);
    right: auto; left: 50%; transform: translateX(-50%);
    width: max-content; max-width: calc(100vw - 32px); }
}
