/* ==========================================================================
   components.css — shared components (Core). Features reuse these classes and
   don't restyle them. Tokens only.
   ========================================================================== */

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex: none;
  height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: var(--fs-14);
  line-height: 1;
  font-weight: var(--fw-medium);
  white-space: nowrap;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .btn:hover {
    background: var(--surface-3);
  }
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  color: var(--text-disabled);
  background: var(--surface-1);
  border-color: var(--hairline);
  transform: none;
}

.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
  font-weight: var(--fw-semibold);
}

@media (hover: hover) {
  .btn--primary:hover {
    background: var(--accent-hover);
  }
}

.btn--primary:active {
  background: var(--accent-press);
}

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

@media (hover: hover) {
  .btn--ghost:hover {
    background: var(--surface-2);
    color: var(--text-1);
  }
}

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

@media (hover: hover) {
  .btn--danger:hover {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  }
}

.btn--sm {
  height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--fs-12);
  gap: 6px;
}

.btn--lg {
  height: 44px;
  padding: 0 var(--space-6);
  font-size: var(--fs-16);
}

.btn--icon {
  width: 36px;
  padding: 0;
}

.btn--icon.btn--sm {
  width: 30px;
}

.btn--icon.btn--lg {
  width: 44px;
}

.btn[aria-pressed='true'],
.btn[data-pressed='true'] {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text-1);
}

.btn[data-action='stage-seen'][data-pressed='true'] svg {
  color: var(--seen);
}

.btn[data-action='stage-favorite'][data-pressed='true'] svg {
  color: var(--accent);
}

.btn--ghost[aria-pressed='true'],
.btn--ghost[data-pressed='true'] {
  background: var(--surface-2);
  border-color: transparent;
}

.btn .is-on {
  color: var(--seen);
}

.btn__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------------------------------------------------------------------
   Chips, segmented control
   --------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 30px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-1);
  color: var(--text-2);
  font-size: var(--fs-14);
  line-height: 1;
  font-weight: var(--fw-medium);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .chip:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    color: var(--text-1);
  }
}

.chip.is-active,
.chip--active,
.chip[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text-1);
}

.chip--sm {
  height: 24px;
  padding: 0 var(--space-2);
  font-size: var(--fs-12);
}

.chip--removable,
.chip:has(.chip__remove) {
  padding-right: 6px;
  color: var(--text-1);
}

.chip--removable {
  background: var(--surface-2);
}

.chip--removable .chip__x,
.chip .chip__remove {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  color: var(--text-2);
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .chip--removable:hover .chip__x,
  .chip .chip__remove:hover {
    background: var(--surface-3);
    color: var(--text-1);
  }
}

.chip__count {
  color: var(--text-3);
  font-size: var(--fs-12);
}

.chip.is-active .chip__count,
.chip--active .chip__count,
.chip[aria-pressed='true'] .chip__count {
  color: var(--text-2);
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: none;
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius-sm) + 2px);
  background: var(--surface-1);
}

.segmented__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  min-width: 28px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .segmented__item:hover {
    color: var(--text-1);
  }
}

.segmented__item[aria-pressed='true'],
.segmented__item[aria-selected='true'],
.segmented__item[aria-checked='true'],
.segmented__item.is-active {
  background: var(--surface-3);
  color: var(--text-1);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.35), inset 0 0 0 1px var(--border-strong);
}

.segmented__count {
  color: var(--text-3);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
}

.segmented__item.is-active .segmented__count,
.segmented__item[aria-checked='true'] .segmented__count {
  color: var(--text-2);
}

.segmented--icons .segmented__item {
  padding: 0;
  width: 30px;
}

/* ---------------------------------------------------------------------------
   Form controls
   --------------------------------------------------------------------------- */
.input {
  width: 100%;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-1);
  font-size: var(--fs-14);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.input::placeholder {
  color: var(--text-3);
}

@media (hover: hover) {
  .input:hover {
    border-color: var(--border-strong);
  }
}

.input:focus-visible,
.input:focus {
  border-color: transparent;
  box-shadow: var(--focus-ring);
}

.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: background-color var(--dur-fast) var(--ease);
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-2);
  transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.switch[aria-checked='true'] {
  background: var(--accent);
  box-shadow: none;
}

.switch[aria-checked='true']::after {
  transform: translateX(14px);
  background: var(--on-accent);
}

.switch:disabled {
  opacity: 0.5;
}

.switch:focus-visible {
  border-radius: var(--radius-full);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 36px;
  color: var(--text-2);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  color: var(--text-1);
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}

/* Header search field */
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-1);
  transition: border-color var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .search-field:hover {
    border-color: var(--border-strong);
  }
}

.search-field:focus-within {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.search-field__icon {
  display: grid;
  place-items: center;
  width: 38px;
  flex: none;
  color: var(--text-3);
}

.search-field__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  color: var(--text-1);
  font-size: var(--fs-14);
  outline: none;
}

.search-field__input::placeholder {
  color: var(--text-3);
}

.search-field__input::-webkit-search-cancel-button {
  display: none;
}

.search-field__input:focus-visible {
  box-shadow: none;
}

.search-field:has(.search-field__input:focus-visible) {
  box-shadow: var(--focus-ring);
  border-color: transparent;
}

.search-field__clear {
  margin-right: 2px;
}

.search-field__kbd {
  margin-right: 8px;
  cursor: pointer;
}

@media (hover: hover) {
  .search-field__kbd:hover {
    color: var(--text-1);
    border-color: var(--text-3);
  }
}

/* ---------------------------------------------------------------------------
   Small pieces
   --------------------------------------------------------------------------- */
.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: var(--fs-12);
  line-height: 1;
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-12);
  line-height: 1;
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.avatar {
  --avatar-size: 32px;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: var(--space-1);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.meta-line > * + *::before {
  content: '·';
  display: inline-block;
  margin: 0 6px;
  color: var(--text-3);
}

.meta-line > .meta-line__nosep::before,
.meta-line > .meta-line__nosep + *::before {
  content: none;
}

.meta-line__dot {
  display: none;
}

.link {
  color: var(--text-1);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .link:hover {
    text-decoration-color: currentColor;
  }
}

button.link {
  display: inline;
  font: inherit;
}

.link--quiet {
  color: var(--text-2);
  text-decoration: none;
}

@media (hover: hover) {
  .link--quiet:hover {
    color: var(--text-1);
    text-decoration: underline;
  }
}

/* ---------------------------------------------------------------------------
   Sections
   --------------------------------------------------------------------------- */
.section {
  margin-top: var(--space-8);
}

.section:first-child {
  margin-top: 0;
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.section__title {
  font-size: var(--fs-16);
  line-height: var(--lh-16);
  font-weight: var(--fw-semibold);
  color: var(--text-1);
}

.section__action {
  color: var(--text-2);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
}

@media (hover: hover) {
  .section__action:hover {
    color: var(--text-1);
  }
}

/* ---------------------------------------------------------------------------
   Cards (poster grid)
   --------------------------------------------------------------------------- */
.grid {
  --grid-track: calc(var(--grid-min) * 0.9);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--grid-track), 100%), 1fr));
  gap: var(--space-6) var(--grid-gap);
  align-items: start;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Room for the hover shadow inside the paint-contained box (content-visibility). */
  padding: 6px 6px 0;
  margin: -6px -6px 0;
  border-radius: calc(var(--radius-md) + 6px);
  cursor: pointer;
  outline: none;
  content-visibility: auto;
  contain-intrinsic-size: auto 280px;
  overflow-clip-margin: 16px;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

.card:focus-visible {
  box-shadow: none;
}

.card__poster {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-2);
  transition: transform var(--dur-hover) var(--ease), box-shadow var(--dur-hover) var(--ease);
}

.card__poster::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px var(--hairline);
  pointer-events: none;
  transition: box-shadow var(--dur-fast) var(--ease);
}

.card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--surface-2);
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--space-2) 0 0;
}

.card__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-1);
  font-size: var(--fs-14);
  line-height: var(--lh-14);
  font-weight: var(--fw-medium);
  letter-spacing: 0;
  text-wrap: nowrap;
}

.card__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card__meta > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
}

.card__seen {
  display: inline-flex;
  flex: none;
  color: var(--seen);
}

.card__seen-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  display: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--scrim-strong);
  color: var(--seen);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  pointer-events: none;
}

html.touch .card.is-seen .card__seen-badge {
  display: inline-grid;
}

html.touch .card__actions {
  display: none !important;
}

.card__actions {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  padding: 6px 6px 28px;
  background: linear-gradient(to bottom, var(--scrim) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--dur-hover) var(--ease);
  pointer-events: none;
}

.card__action {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  color: var(--text-1);
  transition: background-color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .card__action:hover {
    background: var(--border-strong);
  }
}

.card__action[aria-pressed='true'] {
  color: var(--seen);
}

.card__action[data-action='watchlist'][aria-pressed='true'] {
  color: var(--text-1);
}

.card__eq {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 22px;
  padding: 5px 6px;
  border-radius: var(--radius-full);
  background: var(--scrim-strong);
}

.card__eq i {
  display: block;
  width: 3px;
  height: 12px;
  border-radius: 1px;
  background: var(--accent);
  transform-origin: bottom;
  animation: eq 900ms ease-in-out infinite;
}

.card__eq i:nth-child(2) {
  animation-delay: -300ms;
  height: 8px;
}

.card__eq i:nth-child(3) {
  animation-delay: -600ms;
  height: 10px;
}

@keyframes eq {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

@media (prefers-reduced-motion: reduce) {
  .card__eq i {
    animation: none;
  }
}

.card.is-playing .card__eq {
  display: inline-flex;
}

.card.is-selected .card__poster::after {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.card:focus-visible .card__poster::after {
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 4px var(--bg);
}

.card:focus-visible .card__actions,
.card:focus-within .card__actions {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover .card__poster {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
  }

  .card:hover .card__actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.card.is-leaving {
  opacity: 0;
  transform: scale(0.92);
  transition: opacity var(--dur-base) var(--ease-exit), transform var(--dur-base) var(--ease-exit);
  pointer-events: none;
}

.card.is-restored .card__poster::after {
  box-shadow: inset 0 0 0 2px var(--text-1);
}

.card--skeleton {
  cursor: default;
  content-visibility: visible;
  gap: var(--space-2);
}

.card--skeleton .skeleton--line {
  height: 12px;
  margin-top: var(--space-2);
  width: 80%;
}

.card--skeleton .skeleton--short {
  width: 40%;
  margin-top: 0;
}

/* Horizontal strip of cards (similar films, known for, …) */
.strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--strip-card-w, 140px);
  gap: var(--space-4);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 8px 6px var(--space-3);
  margin: -8px -6px 0;
  scrollbar-width: thin;
}

.strip > .card {
  scroll-snap-align: start;
}

/* List layout */
.list {
  display: flex;
  flex-direction: column;
}

.list-head,
.row {
  display: grid;
  grid-template-columns: 40px minmax(0, 3fr) 52px minmax(0, 1.6fr) 64px 92px minmax(0, 1.4fr) 72px;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-3);
}

.list-head {
  position: sticky;
  top: calc(var(--header-h) + var(--filterbar-h));
  z-index: 2;
  height: 36px;
  border-bottom: 1px solid var(--hairline);
  background: var(--bg);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
}

.list-head__sort,
.list-head button[data-list-sort] {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  white-space: nowrap;
}

.list-head__sort[aria-sort='ascending'],
.list-head__sort[aria-sort='descending'],
.list-head button[data-list-sort][data-active='true'] {
  color: var(--text-1);
}

@media (hover: hover) {
  .list-head__sort:hover,
  .list-head button[data-list-sort]:hover {
    color: var(--text-1);
  }
}

.row {
  position: relative;
  min-height: 64px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-14);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  outline: none;
  content-visibility: auto;
  contain-intrinsic-size: auto 64px;
  transition: background-color var(--dur-fast) var(--ease);
}

.row + .row {
  box-shadow: 0 -1px 0 var(--hairline);
}

@media (hover: hover) {
  .row:hover {
    background: var(--surface-1);
  }
}

.row.is-selected {
  background: var(--surface-1);
  box-shadow: inset 2px 0 0 var(--accent);
}

.row:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.row__poster {
  position: relative;
  width: 40px;
  height: 60px;
  flex: none;
}

.row__thumb {
  display: block;
  width: 40px;
  height: 60px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface-2);
}

.row__seen-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  display: none;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--scrim-strong);
  color: var(--seen);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  pointer-events: none;
}

.row__main {
  min-width: 0;
}

.row__meta {
  display: none;
}

.row__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  color: var(--text-1);
  font-weight: var(--fw-medium);
}

.row__title > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__rating small {
  color: var(--text-3);
  font-size: var(--fs-12);
  margin-left: 4px;
}

.row__lists {
  display: flex;
  gap: 4px;
  overflow: hidden;
}

.row__toggles {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
}

.row__toggles .card__action {
  color: var(--text-3);
}

@media (hover: hover) {
  .row__toggles .card__action:hover {
    color: var(--text-1);
    background: var(--surface-2);
  }
}

.row__toggles .card__action[aria-pressed='true'] {
  color: var(--seen);
}

.row__toggles .card__action[data-action='watchlist'][aria-pressed='true'] {
  color: var(--text-1);
}

.row .is-playing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

/* ---------------------------------------------------------------------------
   Overlays: popover, menu, dialog, toast, tooltip
   --------------------------------------------------------------------------- */
.overlay-root {
  position: relative;
  z-index: var(--z-popover);
}

.popover {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-popover);
  min-width: 200px;
  max-width: min(420px, calc(100vw - 16px));
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-popover);
  color: var(--text-1);
  animation: pop-in var(--dur-base) var(--ease);
  transform-origin: var(--origin, top left);
}

.popover--over-modal {
  z-index: calc(var(--z-modal) + 2);
}

.popover__body {
  padding: var(--space-4);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.97) translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.menu {
  display: flex;
  flex-direction: column;
  min-width: 220px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: var(--fs-14);
  line-height: var(--lh-14);
  text-align: left;
  cursor: pointer;
  outline: none;
}

.menu__item:focus-visible,
.menu__item.is-active {
  background: var(--surface-3);
  box-shadow: none;
}

@media (hover: hover) {
  .menu__item:hover {
    background: var(--surface-3);
    box-shadow: none;
  }
}

.menu__item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.menu__item[aria-disabled='true'] {
  color: var(--text-disabled);
  cursor: default;
  background: none;
}

.menu__icon {
  display: grid;
  place-items: center;
  width: 18px;
  flex: none;
  color: var(--text-2);
}

.menu__check {
  display: grid;
  place-items: center;
  width: 16px;
  flex: none;
  color: var(--text-1);
}

.menu__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu__label small {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  white-space: normal;
}

.menu__count {
  flex: none;
  color: var(--text-3);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
}

.menu__item[aria-disabled='true'] .menu__count {
  color: var(--text-disabled);
}

.menu__hint {
  flex: none;
  color: var(--text-3);
  font-size: var(--fs-12);
}

.menu__heading {
  padding: 10px 10px 4px;
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-weight: var(--fw-medium);
}

.menu__heading:first-child {
  padding-top: 6px;
}

.menu__separator {
  height: 1px;
  margin: 6px 4px;
  background: var(--hairline);
  flex: none;
}

.menu__item .switch {
  pointer-events: none;
  transform: scale(0.9);
}

.menu__filter {
  padding: 4px 4px 6px;
}

.menu__filter .input {
  height: 32px;
}

.menu__empty {
  padding: 10px;
  color: var(--text-3);
  font-size: var(--fs-12);
}

/* Dialog */
.dialog-layer {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: var(--scrim-strong);
  animation: fade-in var(--dur-base) var(--ease);
}

.dialog-layer.is-closing {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-exit);
}

.dialog {
  --dialog-w: 560px;
  display: flex;
  flex-direction: column;
  width: min(100%, var(--dialog-w));
  max-height: min(88dvh, 920px);
  border-radius: var(--radius-xl);
  background: var(--surface-2);
  box-shadow: var(--shadow-modal);
  color: var(--text-1);
  animation: dialog-in var(--dur-base) var(--ease);
  outline: none;
}

.dialog--sm { --dialog-w: 420px; }
.dialog--md { --dialog-w: 560px; }
.dialog--lg { --dialog-w: 800px; }

.dialog__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-2) var(--space-6);
  min-height: 60px;
}

.dialog__title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-20);
  line-height: var(--lh-20);
  font-weight: var(--fw-semibold);
}

.dialog__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-2) var(--space-6) var(--space-6);
  color: var(--text-2);
  font-size: var(--fs-14);
  line-height: 1.55;
}

.dialog__footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--hairline);
}

.dialog__grabber {
  display: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dialog-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

body:has(.dialog-layer) .stage {
  position: relative;
  top: 0;
}

body:has(.dialog-layer) .stage__info {
  container: none;
  overflow: hidden;
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

/* Toast */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-6) + var(--safe-b));
  z-index: var(--z-toast);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  max-width: min(92vw, 560px);
  padding: 6px 6px 6px var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface-3);
  box-shadow: var(--shadow-popover);
  color: var(--text-1);
  font-size: var(--fs-14);
  pointer-events: auto;
  animation: toast-in var(--dur-base) var(--ease);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-base) var(--ease-exit), transform var(--dur-base) var(--ease-exit);
}

.toast__icon {
  display: grid;
  place-items: center;
  color: var(--text-2);
}

.toast__icon .is-on {
  color: var(--seen);
}

.toast__msg {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 0;
}

.toast__action {
  height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-weight: var(--fw-semibold);
  white-space: nowrap;
}

@media (hover: hover) {
  .toast__action:hover {
    background: var(--border);
  }
}

.toast__action .kbd {
  margin-left: 6px;
}

.toast__close {
  color: var(--text-3);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* Tooltip */
.tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-tooltip);
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 280px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  box-shadow: 0 6px 18px -6px rgb(0 0 0 / 0.6), 0 0 0 1px var(--border-strong);
  color: var(--text-1);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-weight: var(--fw-medium);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}

.tooltip.is-visible {
  opacity: 1;
}

.tooltip .kbd {
  height: 18px;
  min-width: 18px;
  background: var(--surface-2);
}

/* ---------------------------------------------------------------------------
   Loading & empty states
   --------------------------------------------------------------------------- */
.skeleton {
  display: block;
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--surface-1) 20%, var(--surface-2) 45%, var(--surface-1) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.6s linear infinite;
}

.skeleton--fill {
  position: absolute;
  inset: 0;
  border-radius: 0;
}

.skeleton--title {
  width: 70%;
  height: 28px;
  margin-bottom: var(--space-4);
}

.skeleton--line {
  height: 12px;
  margin-bottom: var(--space-3);
}

.skeleton--pill {
  width: 72px;
  height: 24px;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton {
    animation: none;
  }
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  max-width: 520px;
  margin: var(--space-12) auto;
  padding: 0 var(--space-4);
  text-align: center;
}

.empty-state__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--space-1);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
}

.empty-state__title {
  font-size: var(--fs-20);
  line-height: var(--lh-20);
  font-weight: var(--fw-semibold);
  color: var(--text-1);
}

.empty-state__body {
  color: var(--text-2);
  font-size: var(--fs-14);
  line-height: 1.55;
}

.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.error-panel {
  margin: var(--space-16) auto;
}

/* ---------------------------------------------------------------------------
   Filter bar controls
   --------------------------------------------------------------------------- */
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  height: 32px;
  padding: 0 6px 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.filter-btn[aria-expanded='true'] {
  background: var(--surface-2);
  color: var(--text-1);
}

@media (hover: hover) {
  .filter-btn:hover {
    background: var(--surface-2);
    color: var(--text-1);
  }
}

.filter-btn.is-active,
.filter-btn[data-active='true'] {
  color: var(--text-1);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.filter-btn__value {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-1);
}

.filter-btn .icon {
  color: var(--text-3);
}

/* ---------------------------------------------------------------------------
   Autocomplete panel (header search)
   --------------------------------------------------------------------------- */
.search-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: var(--z-popover);
  width: 100%;
  min-width: 440px;
  max-height: min(72vh, 640px);
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-popover);
  animation: pop-in var(--dur-base) var(--ease);
}

.search-panel__heading {
  padding: 8px 10px 4px;
  color: var(--text-3);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
}

.search-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-1);
  text-align: left;
  cursor: pointer;
}

.search-option.is-active {
  background: var(--surface-3);
}

@media (hover: hover) {
  .search-option:hover {
    background: var(--surface-3);
  }
}

.search-option__thumb {
  width: 32px;
  height: 48px;
  flex: none;
  border-radius: 4px;
  object-fit: cover;
  background: var(--surface-3);
}

.search-option__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
  color: var(--text-2);
}

.search-option__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.search-option__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--fw-medium);
}

.search-option__title mark {
  background: none;
  color: var(--text-1);
  text-decoration: underline;
  text-decoration-color: var(--text-3);
  text-underline-offset: 3px;
}

.search-option__sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  margin-top: 2px;
}

.search-option__aside {
  flex: none;
  color: var(--text-3);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
}

.search-panel__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: 4px;
  padding: 8px 10px 4px;
  border-top: 1px solid var(--hairline);
  color: var(--text-3);
  font-size: var(--fs-12);
}

.search-panel__empty {
  padding: var(--space-4) 10px;
  color: var(--text-3);
}

/* ---------------------------------------------------------------------------
   Player pane (#stage)
   --------------------------------------------------------------------------- */
.screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg);
  isolation: isolate;
}

.screen__art {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.screen__art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
}

.screen__art img.is-loaded {
  opacity: 1;
}

.screen__art .screen__poster-blur {
  filter: blur(28px) saturate(1.1);
  transform: scale(1.2);
}

.screen__art .screen__poster-blur.is-loaded {
  opacity: 0.6;
}

.screen__shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to top, color-mix(in srgb, var(--bg) 88%, transparent) 0%, transparent 55%),
    radial-gradient(120% 90% at 50% 50%, transparent 55%, color-mix(in srgb, var(--bg) 55%, transparent) 100%);
  pointer-events: none;
}

.screen__player {
  position: absolute;
  inset: 0;
  z-index: 2;
  visibility: hidden;
  background: var(--bg);
}

.screen__player iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.screen[data-state='loading'] .screen__player,
.screen[data-state='playing'] .screen__player,
.screen[data-state='paused'] .screen__player,
.screen[data-state='ended'] .screen__player,
.screen__player.is-video,
.screen.is-video .screen__player {
  visibility: visible;
}

.screen__overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  pointer-events: none;
}

.screen__overlay > * {
  pointer-events: auto;
}

.screen[data-state='loading'] .screen__overlay,
.screen[data-state='playing'] .screen__overlay,
.screen[data-state='paused'] .screen__overlay,
.screen[data-state='ended'] .screen__overlay,
.screen:has(.is-video) .screen__overlay,
.screen.is-video .screen__overlay {
  display: none;
}

.screen__play {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.5), 0 10px 30px -8px rgb(0 0 0 / 0.6);
  color: var(--text-1);
  transition: transform var(--dur-hover) var(--ease), background-color var(--dur-hover) var(--ease);
}

@media (hover: hover) {
  .screen__play:hover {
    transform: scale(1.06);
    background: color-mix(in srgb, var(--bg) 25%, transparent);
  }
}

.screen__play:focus-visible {
  border-radius: 50%;
}

.screen__play .icon {
  margin-left: 4px;
}

.screen__notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  max-width: 360px;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--scrim-strong);
  color: var(--text-1);
  text-align: center;
  font-size: var(--fs-14);
}

.screen__notice .icon {
  color: var(--text-2);
}

.screen__spinner {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  place-items: center;
  pointer-events: none;
  color: var(--text-1);
}

.screen[data-state='loading'] .screen__spinner {
  display: grid;
}

.screen__spinner .icon {
  animation: spin 900ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.screen--skeleton .skeleton--fill {
  border-radius: 0;
}

/* Stage info */
.stage__info {
  container: stage / inline-size;
}

.stage-title {
  margin: 0 0 var(--space-2);
  font-size: var(--fs-28);
  line-height: var(--lh-28);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.stage-title__logo {
  display: block;
  max-width: min(80%, 360px);
  max-height: 88px;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left center;
}

.stage-meta {
  margin-bottom: var(--space-3);
  font-size: var(--fs-14);
}

.stage-meta .chip {
  margin: -3px 0;
}

.stage-meta__genres {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}

.stage-ratings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px var(--space-4);
  margin-bottom: var(--space-4);
  color: var(--text-3);
  font-size: var(--fs-12);
  font-variant-numeric: tabular-nums;
}

.stage-ratings b {
  margin-left: 4px;
  color: var(--text-1);
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
}

.stage-synopsis {
  margin-bottom: var(--space-4);
  color: var(--text-2);
  font-size: var(--fs-14);
  line-height: 1.6;
}

.stage-synopsis__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

.stage-synopsis__text.is-expanded {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
}

.stage-synopsis__more {
  margin-top: 2px;
  color: var(--text-1);
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
}

@media (hover: hover) {
  .stage-synopsis__more:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.stage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.stage-actions .btn--icon-label .btn__label {
  display: none;
}

@container stage (min-width: 500px) {
  .stage-actions .btn--icon-label {
    width: auto;
    padding: 0 var(--space-3);
  }

  .stage-actions .btn--icon-label .btn__label {
    display: inline;
  }
}

.stage-block {
  margin-bottom: var(--space-6);
}

.stage-block__label {
  margin-bottom: var(--space-2);
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-weight: var(--fw-medium);
}

.stage-credits {
  display: grid;
  gap: 6px;
  margin-bottom: var(--space-6);
  color: var(--text-3);
  font-size: var(--fs-14);
}

.stage-credits .link {
  color: var(--text-1);
}

.stage-watch {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stage-watch .badge {
  height: 26px;
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--text-1);
  font-size: var(--fs-12);
}

.stage-watch .badge.is-mine {
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.stage-watch .badge .icon {
  color: var(--seen);
}

.stage-details {
  margin-top: var(--space-2);
  color: var(--text-3);
  font-size: var(--fs-12);
}

.stage-details summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-sm);
}

.stage-details summary::-webkit-details-marker {
  display: none;
}

.stage-details[open] summary .icon {
  transform: rotate(180deg);
}

.stage-details__body {
  margin-top: var(--space-2);
  color: var(--text-2);
  line-height: 1.6;
}

.stage-videos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stage-upnext {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  margin: var(--space-4) calc(var(--space-2) * -1) 0;
  border-radius: var(--radius-lg);
  text-align: left;
  width: calc(100% + var(--space-4));
  transition: background-color var(--dur-fast) var(--ease);
}

@media (hover: hover) {
  .stage-upnext:hover {
    background: var(--surface-1);
  }
}

.stage-upnext__thumb {
  width: 40px;
  height: 60px;
  flex: none;
  border-radius: 4px;
  object-fit: cover;
  overflow: hidden;
  background: var(--surface-2);
}

.stage-upnext__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stage-upnext__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.stage-upnext__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-1);
  font-weight: var(--fw-medium);
}

.stage-upnext__sub {
  color: var(--text-3);
  font-size: var(--fs-12);
}

.stage-hint {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  color: var(--text-2);
  font-size: var(--fs-12);
  line-height: 1.7;
}

.stage-hint p,
.stage-hint > span {
  flex: 1 1 auto;
}

.stage-hint .kbd {
  height: 18px;
  min-width: 18px;
  margin: 0 1px;
}

.stage-empty {
  padding: var(--space-8) 0;
  color: var(--text-3);
}

/* ---------------------------------------------------------------------------
   Action sheet, Quick actions, List group, Carousel (§16)
   --------------------------------------------------------------------------- */
.dialog--auto { --dialog-w: 560px; }
.dialog--full { --dialog-w: 560px; }

.dialog__header-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.dialog__header-actions:empty {
  display: none;
}

.action-sheet {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.action-sheet__filter {
  padding: 0 0 var(--space-2);
}

.action-sheet__list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  overflow: hidden;
}

.action-sheet__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 52px;
  padding: var(--space-2) var(--space-4);
  color: var(--text-1);
  font-size: var(--fs-16);
  line-height: var(--lh-16);
  font-weight: var(--fw-medium);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur-hover) var(--ease);
}

.action-sheet__item + .action-sheet__item {
  border-top: 1px solid var(--hairline);
}

.action-sheet__item.is-danger {
  color: var(--danger);
}

.action-sheet__item:disabled,
.action-sheet__item[aria-disabled='true'] {
  color: var(--text-disabled);
  cursor: default;
}

.action-sheet__icon {
  display: grid;
  place-items: center;
  width: 22px;
  flex: none;
  color: var(--text-2);
}

.action-sheet__item.is-danger .action-sheet__icon {
  color: var(--danger);
}

.action-sheet__item.is-checked .action-sheet__icon {
  color: var(--seen);
}

.action-sheet__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.action-sheet__label small {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-weight: var(--fw-regular);
}

.action-sheet__count,
.action-sheet__hint {
  flex: none;
  color: var(--text-3);
  font-size: var(--fs-14);
  font-variant-numeric: tabular-nums;
}

.action-sheet__check {
  display: grid;
  place-items: center;
  width: 20px;
  flex: none;
  color: var(--seen);
}

.action-sheet__heading {
  padding: var(--space-3) var(--space-4) var(--space-1);
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-weight: var(--fw-medium);
}

.action-sheet__separator {
  height: 6px;
  background: var(--surface-2);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

.action-sheet__empty {
  padding: var(--space-4);
  color: var(--text-3);
  font-size: var(--fs-14);
  text-align: center;
}

.action-sheet__cancel {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  color: var(--text-1);
  font-size: var(--fs-16);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur-hover) var(--ease);
}

.dialog--action-sheet .dialog__body {
  padding-top: var(--space-3);
  padding-bottom: var(--space-4);
}

/* Quick actions film header */
.quick-actions__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-2);
  border-bottom: 1px solid var(--hairline);
}

.quick-actions__poster {
  width: 48px;
  height: 72px;
  flex: none;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--surface-3);
}

.quick-actions__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.quick-actions__title {
  color: var(--text-1);
  font-size: var(--fs-16);
  line-height: var(--lh-16);
  font-weight: var(--fw-semibold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-actions__meta {
  color: var(--text-2);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* List group (iOS-style grouped rows, 52 px min) */
.list-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.list-group + .list-group {
  margin-top: var(--space-6);
}

.list-group__title {
  padding: 0 var(--space-1);
  color: var(--text-2);
  font-size: var(--fs-14);
  line-height: var(--lh-14);
  font-weight: var(--fw-semibold);
}

.list-group__card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  min-height: 52px;
  padding: var(--space-2) var(--space-4);
  color: var(--text-1);
  font-size: var(--fs-16);
  line-height: var(--lh-16);
  text-align: left;
  min-width: 0;
  transition: background-color var(--dur-fast) var(--ease), transform var(--dur-hover) var(--ease);
}

.list-row + .list-row {
  border-top: 1px solid var(--hairline);
}

.list-row--action,
.list-row--switch {
  cursor: pointer;
}

.list-row.is-danger,
.list-row.is-danger .list-row__label {
  color: var(--danger);
}

.list-row__icon {
  display: grid;
  place-items: center;
  width: 22px;
  flex: none;
  color: var(--text-2);
}

.list-row.is-danger .list-row__icon {
  color: var(--danger);
}

.list-row__main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}

.list-row__label {
  color: var(--text-1);
  font-size: var(--fs-16);
  line-height: var(--lh-16);
  font-weight: var(--fw-medium);
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-row__sub {
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
}

.list-row__end {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  max-width: 65%;
  min-width: 0;
}

.list-row--segmented {
  flex-wrap: wrap;
}

.list-row__value {
  color: var(--text-2);
  font-size: var(--fs-14);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row__chevron {
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.list-group__footer {
  padding: 0 var(--space-2);
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: 1.5;
}

/* Carousel (scroll-snap, edge fades, overscroll-behavior-x contain) */
.carousel {
  --carousel-item-w: 140px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.carousel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.carousel__titles {
  min-width: 0;
}

.carousel__title {
  color: var(--text-1);
  font-size: var(--fs-16);
  line-height: var(--lh-16);
  font-weight: var(--fw-semibold);
}

.carousel__subtitle {
  color: var(--text-3);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  margin-top: 2px;
}

.carousel__see-all {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 var(--space-2);
  margin-right: calc(var(--space-2) * -1);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  cursor: pointer;
}

.carousel__viewport {
  position: relative;
  min-width: 0;
}

.carousel__viewport::before,
.carousel__viewport::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 24px;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}

.carousel__viewport::before {
  left: 0;
  background: linear-gradient(to right, var(--bg), transparent);
}

.carousel__viewport::after {
  right: 0;
  background: linear-gradient(to left, var(--bg), transparent);
}

.carousel__viewport.has-left-fade::before {
  opacity: 1;
}

.carousel__viewport.has-right-fade::after {
  opacity: 1;
}

.carousel__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--carousel-item-w, 140px);
  gap: var(--space-3);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 4px 2px var(--space-2);
}

.carousel__track::-webkit-scrollbar {
  display: none;
}

.carousel__item,
.carousel__track > * {
  scroll-snap-align: start;
  min-width: 0;
}

.carousel__arrow {
  position: absolute;
  top: 42%;
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--scrim-strong);
  border: 1px solid var(--border-strong);
  color: var(--text-1);
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-hover) var(--ease);
}

.carousel__arrow--prev {
  left: var(--space-2);
}

.carousel__arrow--next {
  right: var(--space-2);
}

@media (hover: hover) and (pointer: fine) {
  .carousel__viewport:hover .carousel__arrow:not(:disabled) {
    opacity: 1;
    pointer-events: auto;
  }

  .action-sheet__item:hover,
  .action-sheet__cancel:hover,
  .list-row--action:hover,
  .list-row--switch:hover {
    background: var(--surface-2);
  }

  .carousel__see-all:hover {
    color: var(--text-1);
  }
}

html.touch .carousel__arrow {
  display: none !important;
}

html.touch .kbd,
html.touch .action-sheet__kbd,
html.touch .menu__item .kbd,
html.touch .toast__action .kbd {
  display: none !important;
}

/* Touch target sizing & tap feedback on html.touch */
html.touch :is(.btn, .chip, .card, .row, .list-row--action, .list-row--switch, .action-sheet__item, .action-sheet__cancel, .segmented__item, .filter-btn, .carousel__see-all) {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

html.touch :is(.btn, .chip, .card, .row, .list-row--action, .action-sheet__item, .action-sheet__cancel, .segmented__item, .filter-btn):not(:disabled):not([aria-disabled='true']):active {
  transform: scale(0.97);
  transition-duration: var(--dur-hover);
}

html.touch .switch {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  margin: -9px 0;
  background: transparent;
  box-shadow: none;
}

html.touch .switch::before {
  content: '';
  position: absolute;
  top: 9px;
  left: 0;
  width: 44px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: background-color var(--dur-fast) var(--ease);
}

html.touch .switch[aria-checked='true']::before {
  background: var(--accent);
  box-shadow: none;
}

html.touch .switch::after {
  top: 12px;
  left: 3px;
  width: 20px;
  height: 20px;
}

html.touch .switch[aria-checked='true']::after {
  transform: translateX(18px);
  background: var(--on-accent);
}

html.touch .segmented__item {
  min-height: 44px;
  min-width: 44px;
  height: 44px;
}

html.touch .segmented--icons .segmented__item {
  width: 44px;
  min-width: 44px;
  height: 44px;
}

html.touch .chip {
  position: relative;
  min-height: 40px;
  height: 40px;
}

html.touch .chip::before {
  content: '';
  position: absolute;
  inset: -2px 0;
}

html.touch .chip .chip__remove,
html.touch .chip--removable .chip__x {
  position: relative;
  width: 40px;
  height: 40px;
  margin: -11px -6px -11px -4px;
}

html.touch .chip .chip__remove::before,
html.touch .chip--removable .chip__x::before {
  content: '';
  position: absolute;
  inset: -2px;
}

html.touch .btn {
  min-height: 44px;
  height: 44px;
}

html.touch .btn--sm {
  position: relative;
  min-height: 40px;
  height: 40px;
}

html.touch .btn--sm::before {
  content: '';
  position: absolute;
  inset: -2px;
}

html.touch .btn--icon,
html.touch .btn--icon.btn--sm,
html.touch .btn--icon.btn--lg {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

html.touch .filter-btn {
  position: relative;
  min-height: 40px;
  height: 40px;
}

html.touch .filter-btn::before {
  content: '';
  position: absolute;
  inset: -2px 0;
}

html.touch .row__toggles .card__action {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

html.touch .row.is-selected {
  background: none;
  box-shadow: none;
}

html.touch .row:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

html.touch .toast__action {
  position: relative;
  min-height: 40px;
  height: 40px;
  min-width: 44px;
}

html.touch .toast__action::before {
  content: '';
  position: absolute;
  inset: -2px;
}

html.touch .toast__close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
}

html.touch .input,
html.touch .search-field__input,
html.touch .menu__filter .input,
html.touch .action-sheet__filter .input {
  min-height: 44px;
  height: 44px;
  font-size: var(--fs-16);
}

html.touch .checkbox {
  min-height: 44px;
}

/* Mobileone-line info bar under the mini player */
.stage-bar {
  display: none;
}

@media (max-width: 899px), (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  :root,
  [data-poster-size='m'] {
    --cols: 3;
  }

  [data-poster-size='s'] {
    --cols: 4;
  }

  [data-poster-size='l'] {
    --cols: 2;
  }

  .stage-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 48px;
    padding: 0 var(--space-1) 0 var(--space-3);
  }

  .stage-bar__title {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-1);
    font-size: var(--fs-14);
    font-weight: var(--fw-medium);
    text-align: left;
  }

  .stage-bar__title span {
    color: var(--text-3);
    font-weight: var(--fw-regular);
  }

  .screen__play {
    width: 56px;
    height: 56px;
  }

  .grid {
    grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
    gap: var(--space-4) var(--grid-gap);
  }

  .card {
    padding: 0;
    margin: 0;
    border-radius: var(--radius-md);
  }

  .card__actions {
    display: none !important;
  }

  .card.is-seen .card__seen-badge {
    display: inline-grid;
  }

  .card.is-selected:not(.is-playing) .card__poster::after {
    box-shadow: inset 0 0 0 1px var(--hairline);
  }

  .card.is-playing .card__poster::after {
    box-shadow: inset 0 0 0 2px var(--accent);
  }

  .card__body {
    padding-top: 6px;
  }

  .card__title {
    font-size: var(--fs-14);
    line-height: var(--lh-14);
    font-weight: var(--fw-medium);
  }

  .list-head {
    display: none;
  }

  .row {
    grid-template-columns: 40px minmax(0, 1fr) 44px;
    gap: var(--space-3);
    min-height: 72px;
    height: 72px;
    padding: 0;
    border-radius: 0;
    -webkit-touch-callout: none;
    user-select: none;
  }

  .row + .row {
    box-shadow: none;
  }

  .row.is-selected {
    background: none;
    box-shadow: none;
  }

  .row:focus-visible {
    box-shadow: inset 0 0 0 2px var(--accent);
  }

  .row + .row::before {
    content: '';
    position: absolute;
    top: 0;
    left: calc(40px + var(--space-3));
    right: 0;
    height: 1px;
    background: var(--hairline);
    pointer-events: none;
  }

  .row:active {
    background: var(--surface-1);
  }

  .row__poster,
  .row__thumb {
    border-radius: 6px;
  }

  .row.is-seen .row__seen-badge {
    display: inline-grid;
  }

  .row__title .card__seen {
    display: none;
  }

  .row__main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
  }

  .row__title {
    font-size: 15px;
    line-height: 1.3;
    font-weight: var(--fw-semibold);
  }

  .row__meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-3);
    font-size: 13px;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
  }

  .row__cell,
  .row__cell--wide,
  .row__lists {
    display: none;
  }

  .row__toggles {
    width: 44px;
    justify-content: flex-end;
  }

  .row__toggles [data-action='seen'] {
    display: none;
  }

  .row__toggles .card__action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .search-panel {
    min-width: 0;
  }

  .carousel__arrow {
    display: none !important;
  }

  .switch {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    margin: -9px 0;
    background: transparent;
    box-shadow: none;
  }

  .switch::before {
    content: '';
    position: absolute;
    top: 9px;
    left: 0;
    width: 44px;
    height: 26px;
    border-radius: var(--radius-full);
    background: var(--surface-3);
    box-shadow: inset 0 0 0 1px var(--border-strong);
    transition: background-color var(--dur-fast) var(--ease);
  }

  .switch[aria-checked='true']::before {
    background: var(--accent);
    box-shadow: none;
  }

  .switch::after {
    top: 12px;
    left: 3px;
    width: 20px;
    height: 20px;
  }

  .switch[aria-checked='true']::after {
    transform: translateX(18px);
    background: var(--on-accent);
  }

  .segmented__item {
    min-height: 44px;
    min-width: 44px;
    height: 44px;
  }

  .segmented--icons .segmented__item {
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .chip {
    position: relative;
    min-height: 40px;
    height: 40px;
  }

  .chip::before {
    content: '';
    position: absolute;
    inset: -2px 0;
  }

  .chip .chip__remove,
  .chip--removable .chip__x {
    position: relative;
    width: 40px;
    height: 40px;
    margin: -11px -6px -11px -4px;
  }

  .chip .chip__remove::before,
  .chip--removable .chip__x::before {
    content: '';
    position: absolute;
    inset: -2px;
  }

  .btn {
    min-height: 44px;
    height: 44px;
  }

  .btn--sm {
    position: relative;
    min-height: 40px;
    height: 40px;
  }

  .btn--sm::before {
    content: '';
    position: absolute;
    inset: -2px;
  }

  .btn--icon,
  .btn--icon.btn--sm,
  .btn--icon.btn--lg {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .filter-btn {
    position: relative;
    min-height: 40px;
    height: 40px;
  }

  .filter-btn::before {
    content: '';
    position: absolute;
    inset: -2px 0;
  }

  .toast__action {
    position: relative;
    min-height: 40px;
    height: 40px;
    min-width: 44px;
  }

  .toast__action::before {
    content: '';
    position: absolute;
    inset: -2px;
  }

  .toast__close {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .input,
  .search-field__input,
  .menu__filter .input,
  .action-sheet__filter .input {
    min-height: 44px;
    height: 44px;
    font-size: var(--fs-16);
  }

  .checkbox {
    min-height: 44px;
  }

  .dialog {
    overscroll-behavior: contain;
  }

  .dialog__header {
    min-height: 52px;
    padding-left: var(--space-4);
  }

  .dialog__body {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    overscroll-behavior: contain;
  }

  .dialog__footer {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }

  .toast-host {
    bottom: calc(var(--tabbar-total) + 12px);
    width: calc(100vw - calc(var(--page-x) * 2));
  }

  .toast {
    max-width: none;
  }
}

/* Tablet portrait (600–899): S=6, M=5, L=4, centered dialogs (max-width 560) */
@media (min-width: 600px) and (max-width: 899px) {
  :root,
  [data-poster-size='m'] {
    --cols: 5;
  }

  [data-poster-size='s'] {
    --cols: 6;
  }

  [data-poster-size='l'] {
    --cols: 4;
  }

  html:not(.touch) .row {
    grid-template-columns: 40px minmax(0, 1fr) 52px 64px 44px;
  }

  html:not(.touch) .row__year,
  html:not(.touch) .row__runtime {
    display: block;
    color: var(--text-3);
    font-size: var(--fs-12);
    text-align: right;
  }

  .dialog-layer {
    place-items: center;
    padding: var(--space-6);
  }

  .dialog,
  .dialog--sm,
  .dialog--md,
  .dialog--lg,
  .dialog--auto,
  .dialog--full {
    width: min(100%, 560px);
    max-width: 560px;
    max-height: min(88dvh, 920px);
    border-radius: var(--radius-xl);
    animation: dialog-in var(--dur-base) var(--ease);
  }

  .dialog__grabber {
    display: none;
  }
}

/* Phone (< 600 px wide): bottom sheets */
@media (max-width: 599px) {
  .dialog-layer {
    place-items: end stretch;
    padding: 0;
  }

  .dialog,
  .dialog--sm,
  .dialog--md,
  .dialog--lg,
  .dialog--auto,
  .dialog--full {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding-bottom: var(--safe-b);
    animation: sheet-in var(--dur-slow) var(--ease);
  }

  .dialog--full {
    height: 92dvh;
  }

  .dialog__grabber {
    display: block;
    width: 36px;
    height: 4px;
    margin: 8px auto 0;
    border-radius: var(--radius-full);
    background: var(--border-strong);
    touch-action: none;
  }
}

@media (max-width: 599px) and (prefers-reduced-motion: reduce) {
  .dialog,
  .dialog--sm,
  .dialog--md,
  .dialog--lg,
  .dialog--auto,
  .dialog--full {
    animation: fade-in var(--dur-base) var(--ease);
  }
}

/* Phone landscape (height <= 500): S=7, M=6, L=5 */
@media (max-height: 500px) and (orientation: landscape) {
  :root,
  [data-poster-size='m'] {
    --cols: 6;
  }

  [data-poster-size='s'] {
    --cols: 7;
  }

  [data-poster-size='l'] {
    --cols: 5;
  }
}

/* Filter sheet (mobile filters / sort) */
.sheet-group {
  margin-bottom: var(--space-6);
}

.sheet-group__title {
  margin-bottom: var(--space-2);
  color: var(--text-1);
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
}

.sheet-group__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Shortcuts dialog */
.shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6) var(--space-8);
}

.shortcuts__section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.shortcuts__title {
  margin-bottom: var(--space-1);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--hairline);
  color: var(--text-2);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-weight: var(--fw-semibold);
}

.shortcuts__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 30px;
  color: var(--text-2);
  font-size: var(--fs-14);
}

.shortcuts__keys {
  display: inline-flex;
  flex: none;
  gap: 4px;
}

@media (max-width: 639px) {
  .shortcuts {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}

/* About dialog */
.about p + p {
  margin-top: var(--space-3);
}

.about .shortcuts__section {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.about ul {
  margin: var(--space-2) 0 0;
  padding-left: var(--space-4);
}

.about li + li {
  margin-top: 4px;
}

.about__fineprint {
  margin-top: var(--space-4);
  color: var(--text-3);
  font-size: var(--fs-12);
}
