/* ==========================================================================
   Mia's List — layout and components.
   Colours and shapes all come from theme.css; nothing here hard-codes a hue
   except pure black/white overlays.
   ========================================================================== */

/* --------------------------------------------------------------- base --- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-image: var(--page-wash);
  background-attachment: fixed;
  overflow-wrap: break-word;
}

/* A faint grain over everything so the flat darks don't band on big screens. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.15;
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.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;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------- shell ---- */

.shell {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px) clamp(12px, 3vw, 28px) 96px;
}

/* ------------------------------------------------------------ header ---- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px 24px;
  margin-bottom: clamp(20px, 4vw, 36px);
}

.masthead__text {
  flex: 1 1 260px;
  min-width: 0;
}

.masthead__title {
  position: relative;
  display: inline-block;
  font-size: clamp(2.1rem, 7vw, 3.6rem);
  letter-spacing: 0.01em;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
}

/* A slow drip off the underline. Decorative only. */
.masthead__title::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.16em;
  height: 5px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-2), var(--accent) 60%, transparent);
}

.masthead__drip {
  position: absolute;
  bottom: -0.16em;
  width: 5px;
  border-radius: 0 0 var(--radius-pill) var(--radius-pill);
  background: var(--accent-2);
  animation: drip 6s var(--ease) infinite;
}

.masthead__drip:nth-of-type(1) { left: 14%;  animation-delay: 0s;    }
.masthead__drip:nth-of-type(2) { left: 42%;  animation-delay: 2.1s;  }
.masthead__drip:nth-of-type(3) { left: 71%;  animation-delay: 4.3s;  }

@keyframes drip {
  0%, 62%  { height: 4px;  opacity: 0.9; }
  78%      { height: 22px; opacity: 0.9; }
  100%     { height: 30px; opacity: 0;   }
}

.masthead__subtitle {
  margin: 10px 0 0;
  color: var(--ink-dim);
  font-size: 0.98rem;
}

/* ------------------------------------------------------------- meter ---- */

.progress {
  flex: 0 1 260px;
  min-width: 200px;
}

.progress__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--ink-dim);
}

.progress__count {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--accent);
}

.progress__track {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-hot));
  transition: width var(--speed-slow) var(--ease);
}

/* ----------------------------------------------------------- toolbar ---- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: clamp(16px, 3vw, 28px);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-dim);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background var(--speed-fast) var(--ease),
              color var(--speed-fast) var(--ease),
              border-color var(--speed-fast) var(--ease),
              transform var(--speed-fast) var(--ease);
}

.btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--glow);
}

.btn--primary:hover {
  background: var(--accent-hot);
  border-color: var(--accent-hot);
  color: var(--accent-ink);
}

.btn--ghost {
  background: transparent;
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 18%, var(--surface));
  border-color: var(--danger);
  color: var(--ink);
}

.btn--block {
  width: 100%;
  justify-content: center;
}

.btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.toolbar__spacer {
  flex: 1 1 auto;
}

.toolbar__actions {
  display: flex;
  gap: 8px;
}

/* Filter chips */
.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-faint);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chip[aria-pressed="true"] {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}

/* --------------------------------------------------------- lock gate ---- */

.gate {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate__card {
  width: min(420px, 100%);
  padding: clamp(24px, 6vw, 40px);
  border-radius: var(--radius-lg);
  border: var(--card-border-width) solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-lift);
  text-align: center;
}

.gate__glyph {
  font-size: 3.2rem;
  line-height: 1;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.6));
  animation: bob 4s var(--ease) infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0)    rotate(-3deg); }
  50%      { transform: translateY(-8px) rotate(3deg);  }
}

.gate__title {
  margin: 16px 0 6px;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
}

.gate__hint {
  margin: 0 0 22px;
  color: var(--ink-dim);
  font-size: 0.92rem;
}

.field {
  display: block;
  text-align: left;
  margin-bottom: 14px;
}

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.input,
.textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  transition: border-color var(--speed-fast) var(--ease),
              box-shadow var(--speed-fast) var(--ease);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-faint);
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.form-error {
  margin: 0 0 14px;
  min-height: 1.2em;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
}

/* -------------------------------------------------------------- grid ---- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: var(--gap);
  align-items: start;
}

.grid--dragging {
  cursor: grabbing;
}

.empty-note {
  grid-column: 1 / -1;
  padding: 48px 16px;
  text-align: center;
  color: var(--ink-faint);
}

/* -------------------------------------------------------------- card ---- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: var(--card-border-width) solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transform: rotate(var(--card-tilt));
  transition: transform var(--speed) var(--ease-bounce),
              box-shadow var(--speed) var(--ease),
              border-color var(--speed) var(--ease),
              opacity var(--speed) var(--ease);
}

/* Alternate the lean so a row of cards looks hand-placed rather than ruled.
   This has to set `transform` rather than redefining --card-tilt in terms of
   itself, which is invalid at computed-value time and silently does nothing.
   It also has to come before :hover — the two selectors have equal specificity,
   so whichever is written last wins, and :hover needs to win. */
.card:nth-child(even) {
  transform: rotate(calc(var(--card-tilt) * -1));
}

/* Scoped to a grid that isn't mid-drag: while dragging, the real cursor
   still triggers :hover on whatever card it passes over even though a
   *different* card is the one being dragged. Without this guard, moving the
   pointer across a 31-card grid fires this transform + a large blurred
   box-shadow + a border transition on every card it crosses - the actual
   cause of the sluggishness, not the drag library itself. */
.grid:not(.is-sorting) .card:hover {
  transform: rotate(0deg) translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lift);
}

.grid.is-sorting .card {
  transition: none;
}

/* An invisible button covering the whole card, so the entire thing is one
   big tap target and one stop in the tab order — while the visible content
   underneath keeps its real headings and paragraphs. The drag handle sits
   above this layer. */
.card__hit {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: none;
  border-radius: inherit;
}

.card__hit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.card__media {
  position: relative;
  display: grid;
  gap: 2px;
  aspect-ratio: 4 / 3;
  background: var(--bg-2);
}

.card__media--1 { grid-template-columns: 1fr; }
.card__media--2 { grid-template-columns: 1fr 1fr; }
.card__media--3 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.card__media--3 > :first-child { grid-row: span 2; }
.card__media--4 {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}
.card__media--4 > :first-child { grid-row: span 3; }

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.card__more {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 800;
}

/* Placeholder for a card with no pictures yet. Deliberately much shorter
   than a filled card's 4:3 media, so a brand new list of 31 blanks stays
   compact and each card visibly grows once it has something in it. */
.card__media--empty {
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(
      45deg,
      transparent 0 12px,
      color-mix(in srgb, var(--ink) 4%, transparent) 12px 24px
    ),
    var(--bg-2);
  color: var(--ink-faint);
  font-size: 1.7rem;
  aspect-ratio: 5 / 2;
  opacity: 0.85;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 16px;
  flex: 1;
}

.card__top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.card__slot {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--ink-dim);
  font-family: var(--font-display);
  font-size: 0.78rem;
}

.card__emoji {
  font-size: 1.25rem;
  line-height: 1;
}

.card__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.12rem;
  line-height: 1.25;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.card__title--empty {
  color: var(--ink-faint);
  font-style: italic;
}

.card__notes {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.88rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

.card__pip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --- done state --- */

.card--done {
  opacity: 0.72;
}

.card--done .card__media,
.card--done .card__title {
  filter: grayscale(0.55);
}

.card--done .card__title {
  text-decoration: line-through;
  text-decoration-color: var(--stamp);
  text-decoration-thickness: 2px;
}

.card__stamp {
  position: absolute;
  top: 12px;
  right: 10px;
  z-index: 3;
  padding: 4px 12px 5px;
  border: 3px solid var(--stamp);
  border-radius: 6px;
  color: var(--stamp);
  font-family: var(--font-display);
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transform: rotate(var(--stamp-rotate)) scale(1);
  opacity: 0.92;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--stamp) 40%, transparent);
}

.card__stamp--pop {
  animation: stamp-in var(--speed-slow) var(--ease-bounce);
}

@keyframes stamp-in {
  0%   { transform: rotate(var(--stamp-rotate)) scale(2.6); opacity: 0; }
  55%  { transform: rotate(var(--stamp-rotate)) scale(0.9); opacity: 1; }
  100% { transform: rotate(var(--stamp-rotate)) scale(1);   opacity: 0.92; }
}

/* --- drag handle --- */

.card__grip {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity var(--speed-fast) var(--ease),
              transform var(--speed-fast) var(--ease);
  touch-action: none;
  cursor: grab;
}

.grid:not(.is-sorting) .card:hover .card__grip,
.card__grip:focus-visible,
.card--dragging .card__grip {
  opacity: 1;
  transform: scale(1);
}

/* Touch devices get no hover, so the handle is always visible there. */
@media (hover: none) {
  .card__grip {
    opacity: 1;
    transform: scale(1);
  }
}

.card__grip:active {
  cursor: grabbing;
}

/* --- drag states --- */

.card--ghost {
  opacity: 0.28;
  filter: saturate(0.4);
}

/* The piece that follows the pointer while dragging. SortableJS positions it
   with inline styles (position, size, transform), so only appearance is set
   here — a `transform` in this block would simply be overwritten. */
.card--dragging {
  /* Cancel the base card's ambient tilt so nothing rotates the shape SortableJS
     is precisely tracking to the cursor - belt and braces alongside the swap/
     animation tuning above, which is the bigger lever for the "lag" feeling. */
  transform: none;
  pointer-events: none;
  will-change: transform;
  box-shadow: 0 26px 60px -14px rgba(0, 0, 0, 0.9), 0 0 0 2px var(--accent);
  cursor: grabbing;
  opacity: 1 !important;
}

/* Whichever card the pointer is currently over during a drag — swap mode
   has no live reordering to show, so this is the only feedback that a drop
   here would swap the two. */
.card--swap-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* The moment before a drag actually begins. */
.is-chosen {
  cursor: grabbing;
}

/* Keyboard reordering announces itself with a ring. */
.card--keyboard-move {
  box-shadow: 0 0 0 2px var(--accent), var(--shadow-lift);
}

/* -------------------------------------------------------------- sheet --- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--speed) var(--ease);
}

.sheet-backdrop--in {
  opacity: 1;
}

.sheet {
  position: fixed;
  z-index: 71;
  inset: auto 0 0 0;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: var(--card-border-width) solid var(--line-strong);
  border-bottom: none;
  background: var(--surface);
  box-shadow: 0 -20px 60px -12px rgba(0, 0, 0, 0.9);
  transform: translateY(100%);
  transition: transform var(--speed) var(--ease);
}

.sheet--in {
  transform: translateY(0);
}

@media (min-width: 720px) {
  .sheet {
    inset: 50% auto auto 50%;
    width: min(680px, calc(100vw - 48px));
    max-height: min(86dvh, 860px);
    border-radius: var(--radius-lg);
    border-bottom: var(--card-border-width) solid var(--line-strong);
    transform: translate(-50%, -46%) scale(0.96);
    opacity: 0;
    transition: transform var(--speed) var(--ease-bounce), opacity var(--speed) var(--ease);
  }

  .sheet--in {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

.sheet__grab {
  flex: none;
  width: 42px;
  height: 4px;
  margin: 10px auto 0;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

@media (min-width: 720px) {
  .sheet__grab { display: none; }
}

.sheet__head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.sheet__slot {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--ink-dim);
  font-family: var(--font-display);
  font-size: 0.84rem;
}

.sheet__heading {
  flex: 1;
  min-width: 0;
  font-size: 1.05rem;
  color: var(--ink-dim);
  font-family: var(--font-body);
  font-weight: 700;
}

.sheet__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-dim);
}

.sheet__close:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.sheet__body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
}

.sheet__row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.sheet__section {
  margin-top: 22px;
}

.sheet__section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sheet__section-title {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* emoji trigger button next to the title field */
.emoji-btn {
  flex: none;
  width: 52px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 1.4rem;
  line-height: 1;
  transition: border-color var(--speed-fast) var(--ease), background var(--speed-fast) var(--ease);
}

.emoji-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.emoji-btn--empty {
  color: var(--ink-faint);
  font-size: 1.1rem;
}

/* ------------------------------------------------------ emoji picker ---- */

.emoji-pop {
  position: absolute;
  z-index: 80;
  width: min(320px, calc(100vw - 32px));
  max-height: 300px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-lift);
}

.emoji-pop__group {
  margin-bottom: 12px;
}

.emoji-pop__group:last-child {
  margin-bottom: 0;
}

.emoji-pop__label {
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.emoji-pop__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 2px;
}

.emoji-pop__btn {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  line-height: 1;
  transition: background var(--speed-fast) var(--ease), transform var(--speed-fast) var(--ease);
}

.emoji-pop__btn:hover {
  background: var(--surface-3);
  transform: scale(1.18);
}

/* --------------------------------------------------------- moodboard ---- */

.moodboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.moodboard__tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--line);
  cursor: grab;
}

.moodboard__tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.moodboard__tile--ghost {
  opacity: 0.25;
}

.moodboard__tile--dragging {
  pointer-events: none;
  will-change: transform;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.9), 0 0 0 2px var(--accent);
  cursor: grabbing;
  opacity: 1 !important;
}

.moodboard__tile--swap-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.moodboard__zoom {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: none;
}

.moodboard__del {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0;
  transition: opacity var(--speed-fast) var(--ease), background var(--speed-fast) var(--ease);
}

.moodboard:not(.is-sorting) .moodboard__tile:hover .moodboard__del,
.moodboard__del:focus-visible {
  opacity: 1;
}

@media (hover: none) {
  .moodboard__del { opacity: 1; }
}

.moodboard__del:hover {
  background: var(--danger);
}

.moodboard__badge {
  position: absolute;
  left: 5px;
  bottom: 5px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

/* the "add" tile */
.moodboard__add {
  display: grid;
  place-items: center;
  gap: 4px;
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 2px dashed var(--line-strong);
  background: transparent;
  color: var(--ink-faint);
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
  transition: border-color var(--speed-fast) var(--ease),
              color var(--speed-fast) var(--ease),
              background var(--speed-fast) var(--ease);
}

.moodboard__add:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.moodboard__add span {
  font-size: 1.5rem;
  line-height: 1;
}

.dropzone--over {
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.url-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.url-row .input {
  flex: 1;
  min-width: 0;
}

/* uploading placeholder */
.moodboard__pending {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink-faint);
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------- lightbox ---- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity var(--speed) var(--ease);
}

.lightbox--in { opacity: 1; }

.lightbox img {
  max-width: 100%;
  max-height: 86dvh;
  border-radius: var(--radius);
  box-shadow: 0 30px 80px -20px #000;
}

.lightbox__close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  right: 16px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.2rem;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 1.4rem;
}

.lightbox__nav--prev { left: 12px; }
.lightbox__nav--next { right: 12px; }

/* ------------------------------------------------------------ toasts ---- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  z-index: 95;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow-lift);
  animation: toast-in var(--speed) var(--ease-bounce);
}

.toast--error {
  border-color: var(--danger);
  color: var(--ink);
  background: color-mix(in srgb, var(--danger) 22%, var(--surface-2));
}

.toast--out {
  animation: toast-out var(--speed) var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px) scale(0.97); }
}

/* --------------------------------------------------------- confetti ----- */

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  overflow: hidden;
}

.confetti-bit {
  position: absolute;
  font-size: 1.4rem;
  line-height: 1;
  will-change: transform, opacity;
  animation: confetti-fall var(--fall-time, 1400ms) cubic-bezier(0.25, 0.7, 0.5, 1) forwards;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(0.6);
  }
  25% {
    opacity: 1;
    transform: translate3d(calc(var(--dx) * 0.35), calc(var(--dy) * 0.4), 0)
               rotate(calc(var(--spin) * 0.4)) scale(1.1);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx), var(--dy), 0) rotate(var(--spin)) scale(0.85);
  }
}

/* ------------------------------------------------------- theme picker --- */

.theme-pop {
  position: absolute;
  z-index: 80;
  width: min(280px, calc(100vw - 32px));
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  box-shadow: var(--shadow-lift);
}

.theme-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--ink-dim);
  font-size: 0.9rem;
  font-weight: 600;
  transition: background var(--speed-fast) var(--ease), color var(--speed-fast) var(--ease);
}

.theme-opt:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.theme-opt[aria-checked="true"] {
  color: var(--ink);
}

.theme-opt[aria-checked="true"]::after {
  content: "✓";
  margin-left: auto;
  color: var(--accent);
  font-weight: 800;
}

.theme-swatch {
  flex: none;
  display: flex;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.theme-swatch i {
  flex: 1;
}

/* ----------------------------------------------------------- helpers ---- */

.row-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.muted {
  color: var(--ink-faint);
  font-size: 0.84rem;
}

.date-input {
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--ink);
  color-scheme: dark;
}

/* ------------------------------------------------------- responsive ----- */

@media (max-width: 520px) {
  /* Two columns rather than one: at 31 items, being able to scan several at
     a glance beats one enormous card filling the screen. */
  :root {
    --card-min: 148px;
    --gap: 10px;
  }

  .shell {
    padding-bottom: 64px;
  }

  .masthead {
    align-items: stretch;
    gap: 12px;
  }

  .progress {
    flex-basis: 100%;
  }

  .card__body {
    padding: 10px 12px 12px;
    gap: 4px;
  }

  .card__title {
    font-size: 0.97rem;
  }

  .card__notes {
    font-size: 0.8rem;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .card__foot {
    font-size: 0.72rem;
  }

  .card__stamp {
    top: 8px;
    right: 7px;
    padding: 2px 8px 3px;
    border-width: 2px;
    font-size: 0.68rem;
  }

  .card__grip {
    width: 30px;
    height: 30px;
  }

  .toolbar {
    gap: 6px;
  }

  .btn {
    padding: 8px 13px;
  }

  /* Force a clean break so the two action buttons wrap together onto their
     own row instead of one of them being left stranded. */
  .toolbar__spacer {
    flex-basis: 100%;
    height: 0;
  }
}

/* Two columns on a big phone in landscape / small tablets. */
@media (min-width: 521px) and (max-width: 860px) {
  :root { --card-min: 200px; }
}

/* --------------------------------------------------- reduced motion ----- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .card {
    transform: none;
  }

  .card:hover {
    transform: none;
  }
}

/* Printing the finished list as a keepsake. */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  .toolbar,
  .card__grip,
  .toasts,
  .progress {
    display: none !important;
  }

  .card {
    break-inside: avoid;
    border: 1px solid #999;
    box-shadow: none;
    transform: none;
  }
}
