/* ---- the Save window (list-modal.js) ---- */
.lm-back {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 280; /* above the phone tab bar (250), which otherwise sat over the Save button */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  animation: fade 0.18s ease;
}
.lm-back[hidden] {
  display: none;
}
.lm-modal {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  border: 1px solid var(--line-2);
  border-radius: 20px;
  background: var(--surface-1);
  color: var(--text);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  animation: lm-pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.lm-modal::-webkit-scrollbar {
  display: none;
}
html.lm-open {
  overflow: hidden;
}
@keyframes lm-pop {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }
}

/* header: the cover, blurred, behind the round buttons; the sharp cover and title overlap its lower edge */
.lm-hero {
  position: relative;
  height: 96px;
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 22%, var(--surface-2));
}
.lm-hero-img {
  position: absolute;
  top: -30px;
  right: -30px;
  bottom: -30px;
  left: -30px;
  background: center 30% / cover;
  filter: blur(22px) saturate(1.3);
  opacity: 0.7;
}
.lm-hero::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.1), var(--surface-1));
}
.lm-hero-btns {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  display: flex;
  gap: 8px;
}
.lm-round {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.38);
  color: #fff;
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}
@media (hover: hover) {
  .lm-round:hover {
    background: rgba(0, 0, 0, 0.6);
  }
}
.lm-round:active {
  transform: scale(0.92);
}
.lm-heart.on {
  color: var(--accent-hi);
}
.lm-heart.on svg {
  fill: currentColor;
}

.lm-id {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-top: -52px;
  padding: 0 20px;
}
.lm-cover {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 90px;
  border-radius: 10px;
  background: var(--surface-3) center/cover;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 10px 24px rgba(0, 0, 0, 0.45);
  color: var(--muted);
  font-size: 22px;
  font-weight: 800;
}
.lm-who {
  flex: 1;
  min-width: 0;
  padding-bottom: 4px;
}
.lm-who h3 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-hi);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.lm-sub {
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.lm-sub:empty {
  display: none;
}

.lm-body {
  padding: 18px 20px 4px;
}

/* status: six tiles, the chosen one in the theme's colour */
.lm-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.lm-status button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 66px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
.lm-status button span {
  color: var(--text-2);
}
@media (hover: hover) {
  .lm-status button:not(.on):hover {
    border-color: var(--line-2);
    background: var(--surface-3);
    color: var(--text-hi);
  }
}
.lm-status button.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, var(--surface-2));
  color: var(--accent-hi);
}
.lm-status button.on span {
  color: var(--text-hi);
}

/* episodes + score, one quiet panel */
.lm-panel {
  margin-top: 14px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
}
.lm-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
}
.lm-score-line {
  border-top: 1px solid var(--line);
}
.lm-label {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-2);
}
.lm-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.lm-step {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-4);
  color: var(--text-hi);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    transform 0.12s ease;
}
@media (hover: hover) {
  .lm-step:hover {
    background: var(--line-3);
  }
}
.lm-step:active {
  transform: scale(0.9);
}
.lm-stepper input {
  width: 46px;
  padding: 4px 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-hi);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  text-align: right;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
  appearance: textfield;
}
.lm-stepper input:focus {
  outline: none;
  background: var(--surface-3);
}
.lm-stepper input::-webkit-outer-spin-button,
.lm-stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.lm-of {
  min-width: 34px;
  margin-right: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lm-of:empty {
  display: none;
}
.lm-bar {
  display: block;
  height: 4px;
  margin: -6px 0 12px;
  border-radius: 2px;
  background: var(--surface-4);
  overflow: hidden;
}
.lm-bar[hidden] {
  display: none;
}
.lm-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}

.lm-scorebox {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lm-stars {
  display: flex;
  gap: 2px;
  border-radius: 6px;
  cursor: pointer;
}
.lm-stars:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.lm-star {
  position: relative;
  display: block;
  width: 24px;
  height: 22px;
  color: var(--line-3);
}
.lm-star svg {
  display: block;
  margin: 0 auto;
  fill: currentColor;
  stroke: none;
}
.lm-star i {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0;
  overflow: hidden;
  color: var(--score);
}
.lm-star i svg {
  margin: 0 0 0 1px;
}
.lm-stars.preview .lm-star i {
  opacity: 0.75;
}
.lm-score-val {
  min-width: 58px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lm-score-val b {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-hi);
}

/* more details */
.lm-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 6px;
  padding: 12px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.lm-more svg {
  transition: transform 0.2s ease;
}
.lm-more.open svg {
  transform: rotate(180deg);
}
@media (hover: hover) {
  .lm-more:hover {
    color: var(--text-hi);
  }
}
.lm-extra {
  display: grid;
  grid-template-columns: 1fr 1fr 92px;
  gap: 10px;
  padding-bottom: 6px;
}
.lm-extra[hidden] {
  display: none;
}
.lm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.lm-wide {
  grid-column: 1 / -1;
}
.lm-field input,
.lm-field textarea {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-hi);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: border-color 0.15s ease;
}
.lm-field textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.45;
}
.lm-field input:focus,
.lm-field textarea:focus {
  outline: none;
  border-color: var(--line-3);
}

/* footer */
.lm-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 18px;
  background: var(--surface-1);
}
.lm-spacer {
  flex: 1;
}
.lm-remove {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s ease;
}
.lm-remove[hidden] {
  display: none;
}
@media (hover: hover) {
  .lm-remove:hover {
    color: var(--danger);
  }
}
.lm-btn {
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--text-hi);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    opacity 0.15s ease,
    transform 0.12s ease;
}
@media (hover: hover) {
  .lm-btn:hover {
    background: var(--surface-4);
  }
  .lm-primary:not(:disabled):hover {
    background: var(--accent-hi);
  }
}
.lm-btn:active:not(:disabled) {
  transform: scale(0.97);
}
.lm-primary {
  min-width: 92px;
  background: var(--accent);
  color: #fff;
}
.lm-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* phones: a compact sheet from the bottom (never the whole screen) */
@media (max-width: 560px) {
  .lm-back {
    align-items: flex-end;
    padding: 0;
  }
  .lm-modal {
    max-width: none;
    max-height: 88vh;
    max-height: 88dvh; /* iPhone's URL bar shrinks what's visible: vh counts the bit hiding under it */
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    animation: lm-up 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .lm-modal::before {
    content: "";
    position: sticky;
    top: 10px;
    z-index: 5;
    display: block;
    width: 40px;
    height: 4px;
    margin: 10px auto -14px;
    border-radius: 2px;
    background: var(--line-3);
  }
  .lm-hero {
    height: 76px;
  }
  .lm-round {
    width: 40px;
    height: 40px;
  }
  .lm-id {
    margin-top: -44px;
    padding: 0 16px;
  }
  .lm-cover {
    width: 56px;
    height: 78px;
  }
  .lm-who h3 {
    font-size: 16px;
  }
  .lm-body {
    padding: 14px 16px 4px;
  }
  .lm-status button {
    min-height: 60px;
    font-size: 12px;
  }
  .lm-foot {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  }
  .lm-field input,
  .lm-field textarea {
    font-size: 16px; /* smaller auto-zooms the page on iPhone, stranding the close button off screen */
  }
  .lm-extra {
    grid-template-columns: 1fr 1fr;
  }
  .lm-extra .lm-small {
    grid-column: 1 / -1;
  }
  .lm-btn {
    flex: 1;
  }
  .lm-spacer {
    display: none;
  }
}
@keyframes lm-up {
  from {
    transform: translateY(60px);
    opacity: 0;
  }
}
