/* animeList — feuille de style unique (design « galerie »).
 *
 * Thème sombre par défaut ; thème clair en option (data-theme="light" sur
 * <html>, posé par app.js et mémorisé). Titres en Space Grotesk, texte en
 * Inter (pile système si les polices ne se chargent pas).
 */

/* ---------- Couleurs ---------- */

:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #181b22;
  --surface-3: #1b1f27; /* pastilles, zones en retrait */
  --raised: #232833;
  --line: #22262e;
  --line-2: #2f3440;
  --field-line: #2a2f38;
  --ink: #ecedf0;
  --ink-2: #c9cdd4;
  --muted: #a9aeb8;
  --faint: #8a909b;
  --accent: #e0457b;
  --accent-hover: #ea5d8e;
  --accent-ink: #ffffff;
  --link: #f07aa0;
  --link-hover: #ffb3cb;
  --focus: #8ab4ff;
  --header-bg: rgb(14 16 20 / 0.92);
  --ep-bg: #0e1014;
  --cover-default: #2a2f3a;

  /* Statuts (même code couleur partout). */
  --st-completed: #3dd68c;
  --st-in_progress: #f5b942;
  --st-planning: #8ab4ff;
  --st-dropped: #a9aeb8;

  --danger: #ff7a90;
  --danger-bg: #3a1622;
  --danger-line: #6e2a3c;

  --shadow-card: 0 14px 30px rgb(0 0 0 / 0.45);
  --shadow-menu: 0 16px 40px rgb(0 0 0 / 0.5);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #eceef2;
  --raised: #e3e6ec;
  --line: #e0e3e9;
  --line-2: #c9ced8;
  --field-line: #cdd2db;
  --ink: #15171c;
  --ink-2: #2e323a;
  --muted: #545a66;
  --faint: #656b77;
  --accent: #c8336a;
  --accent-hover: #b02a5c;
  --accent-ink: #ffffff;
  --link: #b02a5c;
  --link-hover: #7f1d42;
  --focus: #2f5fd0;
  --header-bg: rgb(244 245 247 / 0.92);
  --ep-bg: #ffffff;
  --cover-default: #c7ccd6;
  --st-completed: #137a4b;
  --st-in_progress: #995f00;
  --st-planning: #2f5fd0;
  --st-dropped: #5f6570;
  --danger: #b4233f;
  --danger-bg: #fdecef;
  --danger-line: #eab0bc;
  --shadow-card: 0 14px 30px rgb(20 24 40 / 0.18);
  --shadow-menu: 0 16px 40px rgb(20 24 40 / 0.18);
  color-scheme: light;
}

/* Couleurs posées sur une couverture (fond sombre translucide) : identiques dans les deux thèmes. */
:root {
  --on-cover-bg: rgb(14 16 20 / 0.82);
  --on-cover-ink: #ecedf0;
  --on-completed: #3dd68c;
  --on-in_progress: #f5b942;
  --on-planning: #8ab4ff;
  --on-dropped: #c3c7cf;
}

/* ---------- Typographie ---------- */

:root {
  --font-display: "Space Grotesk", "Bahnschrift", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --page: 1240px;
  --gutter: 24px;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1,
h2,
h3,
p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

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

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

main:focus {
  outline: none;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 50;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

.num {
  font-variant-numeric: tabular-nums;
}

.icon {
  flex: none;
}

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--faint);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn-outline {
  border-color: #3a404c;
  background: transparent;
}

:root[data-theme="light"] .btn-outline {
  border-color: var(--line-2);
}

.btn-quiet {
  border-color: transparent;
  background: var(--surface-3);
}

.btn-quiet:hover:not(:disabled) {
  border-color: var(--line-2);
}

.btn-plain {
  border-color: transparent;
  background: transparent;
}

.btn-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-danger {
  border-color: var(--danger-line);
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-icon {
  width: 44px;
  padding: 0;
  border-radius: 50%;
  border-color: var(--field-line);
  background: var(--raised);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.btn-link:hover {
  color: var(--link-hover);
}

.btn-link-quiet {
  color: var(--muted);
}

.btn-link-quiet:hover {
  color: var(--ink);
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--link);
  font-weight: 500;
}

.link:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Petit cercle qui tourne : affiché seulement quand le bouton est occupé. */
.spinner {
  display: none;
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

[aria-busy="true"] > .spinner,
.sync-text > .spinner,
.session-writes > .spinner {
  display: inline-block;
}

[aria-busy="true"] > .icon-sync {
  display: none;
}

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

/* ---------- Pastilles (onglets, filtres) ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.pill:hover {
  border-color: var(--faint);
}

.pill[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
}

.pill-count {
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.pill-small {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.pill-small.is-done:not([aria-pressed="true"]) {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

/* ---------- En-tête ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.brand-mark {
  fill: var(--accent);
}

.typenav {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.typenav .pill {
  min-height: 36px;
  padding: 0 18px;
  border: 0;
  font-weight: 600;
  color: var(--muted);
}

.typenav .pill[aria-pressed="true"] {
  color: var(--bg);
}

.topsearch {
  flex: 1 1 240px;
  min-width: 0;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--faint);
  cursor: text;
}

.search-field:focus-within {
  border-color: var(--focus);
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
}

.search-field input::placeholder {
  color: var(--faint);
}

.topactions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.session {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--faint);
  font-size: 13px;
  white-space: nowrap;
}

.sync-text {
  display: inline;
}

.sync-text > .spinner {
  margin-right: 6px;
  vertical-align: -2px;
}

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

.session-writes {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--st-in_progress);
  font-weight: 600;
}

.session-writes.is-failed {
  color: var(--danger);
}

.session-writes:focus {
  outline: none;
}

.btn-sync {
  padding: 0 14px;
}

/* Compte */
.account {
  position: relative;
}

.account-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--field-line);
  border-radius: 50%;
  background: var(--raised);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

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

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: min(300px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-menu);
}

.menu-head {
  display: grid;
  gap: 2px;
  padding: 10px 12px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.menu-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
}

.menu-mode,
.menu-sync {
  color: var(--muted);
  font-size: 13px;
}

.menu-sync .sync-text {
  display: inline;
}

.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--surface-3);
}

.menu-item.is-danger {
  color: var(--danger);
}

/* ---------- Bandeau d'erreur ---------- */

.banner-zone:empty {
  display: none;
}

.banner-zone {
  max-width: var(--page);
  margin: 16px auto 0;
  padding: 0 var(--gutter);
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 16px;
  border: 1px solid var(--danger-line);
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
}

/* ---------- Page ---------- */

main {
  min-height: 60vh;
}

.loading,
.noscript {
  max-width: var(--page);
  margin: 48px auto;
  padding: 0 var(--gutter);
  color: var(--muted);
}

.view-gallery {
  max-width: var(--page);
  margin: 0 auto;
  padding: 28px var(--gutter) 72px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

.section-title .count {
  color: var(--faint);
  font-weight: 500;
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

/* ---------- Écrans d'accueil ---------- */

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: 72px var(--gutter) 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.screen h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 5vw, 36px);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.screen p {
  max-width: 52ch;
  color: var(--ink-2);
}

.screen .screen-note {
  padding: 10px 14px;
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
}

.screen-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.screen-art {
  position: relative;
  width: 220px;
  height: 130px;
  margin-bottom: 8px;
}

.art-cover {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 66px;
  height: 99px;
  border-radius: 9px;
  background: var(--cover);
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.35);
  transform: translateX(calc(-50% + var(--i) * 38px)) rotate(calc(var(--i) * 7deg)) translateY(calc(var(--i) * var(--i) * 4px));
}

/* ---------- Couvertures ---------- */

.cover {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--cover, var(--cover-default));
  color: var(--cover-ink, #ffffff);
}

.cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease;
}

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

.cover-label {
  position: absolute;
  inset: auto 0 0;
  padding: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Reprendre ---------- */

.resume {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.resume-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 16px;
}

.resume-card {
  min-width: 0;
  display: flex;
  align-items: stretch;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.resume-thumb {
  flex: 0 0 72px;
}

.resume-thumb .cover {
  width: 72px;
  height: 104px;
  border-radius: 8px;
}

.resume-thumb .cover-label {
  padding: 6px;
  font-size: 11px;
  line-height: 1.1;
}

.resume-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.resume-franchise {
  color: var(--faint);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resume-season {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resume-season:hover {
  text-decoration: underline;
}

.bar {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--field-line);
}

.bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.resume-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 13px;
}

.resume-action {
  align-self: center;
}

/* ---------- Ma collection ---------- */

.collection {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.collection-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px 20px;
}

.collection-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

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

.sort {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

select,
.field-number,
.field input,
.add-field input {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--ep-bg);
  color: var(--ink);
  font-size: 14px;
}

.sort select {
  min-height: 36px;
  background: var(--surface-2);
  border-color: var(--field-line);
}

.result-count:empty {
  display: none;
}

.result-count {
  margin-top: -6px;
  color: var(--muted);
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 28px 20px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-radius: 12px;
}

.card:focus-visible {
  outline-offset: 4px;
}

.card-cover {
  aspect-ratio: 2 / 3;
  border-radius: 12px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card:hover .card-cover,
.card:focus-visible .card-cover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-card);
}

.card-cover .cover-label {
  padding: 14px 14px 18px;
  font-size: 22px;
  -webkit-line-clamp: 5;
}

.cover-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--on-cover-bg);
  color: var(--on-dropped);
  font-weight: 600;
  font-size: 12px;
  line-height: 1.35;
}

.cover-badge[data-status="completed"] { color: var(--on-completed); }
.cover-badge[data-status="in_progress"] { color: var(--on-in_progress); }
.cover-badge[data-status="planning"] { color: var(--on-planning); }

.cover-score {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--on-cover-bg);
  color: var(--on-cover-ink);
  font-weight: 700;
  font-size: 12px;
  line-height: 1.35;
}

/* Barre segmentée : une case par saison. */
.segbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 2px;
  height: 6px;
  background: rgb(14 16 20 / 0.6);
}

.seg {
  flex: 1;
  background: rgb(255 255 255 / 0.35);
}

.seg-seen {
  background: var(--accent);
}

.seg-part {
  background: linear-gradient(90deg, var(--accent) var(--pct), rgb(255 255 255 / 0.35) var(--pct));
}

.seg-soon {
  background: rgb(255 255 255 / 0.12);
}

.card-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-title {
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.card-line {
  color: var(--muted);
  font-size: 13px;
}

.card-alert {
  color: var(--danger);
  font-weight: 600;
}

.card-pending {
  color: var(--st-in_progress);
}

.no-result {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 28px;
  border: 1px dashed var(--line-2);
  border-radius: 14px;
  color: var(--muted);
}

/* ---------- Sections repliables (Statistiques, Corrections) ---------- */

.fold {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.fold + .fold {
  margin-top: -28px;
}

.fold-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.fold-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
}

.fold-sub {
  color: var(--faint);
  font-size: 14px;
}

.fold-toggle .icon-chevron {
  align-self: center;
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.fold-toggle[aria-expanded="true"] .icon-chevron {
  transform: rotate(180deg);
}

.fold-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 8px 0 12px;
}

.stats {
  display: grid;
  gap: 12px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.stat {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.stat dt {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.stat[data-status] dt::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--st);
}

.stat[data-status="completed"] { --st: var(--st-completed); }
.stat[data-status="in_progress"] { --st: var(--st-in_progress); }
.stat[data-status="planning"] { --st: var(--st-planning); }
.stat[data-status="dropped"] { --st: var(--st-dropped); }

.stat dd {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat-sub {
  font-family: var(--font-body);
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.stat-empty dd {
  color: var(--faint);
}

.sub-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
}

.sub-hint {
  color: var(--faint);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
}

.corrections {
  gap: 12px;
}

.corrections-note {
  color: var(--muted);
  font-size: 14px;
}

.corrections-list {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.correction {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 14px;
  background: var(--surface);
}

.correction + .correction {
  border-top: 1px solid var(--line);
}

.correction-time {
  margin-left: 8px;
  color: var(--faint);
  font-size: 13px;
}

/* ---------- Évolution (graphiques) ---------- */

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

.evolution-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.chart-card {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
}

.chart-title {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}

.chart-key {
  width: 5px;
  height: 0.9em;
  border-radius: 2px;
}

.chart-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.chart-delta {
  color: var(--muted);
  font-size: 13px;
}

.chart {
  position: relative;
  margin-top: 6px;
  touch-action: pan-y;
  cursor: crosshair;
}

.chart svg {
  display: block;
  overflow: visible;
}

.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}

.chart-label {
  fill: var(--faint);
  font-family: var(--font-body);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-end {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-cross {
  stroke: var(--faint);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-dot {
  fill: var(--surface);
  stroke-width: 2.5;
}

.chart-tip {
  position: absolute;
  z-index: 1;
  display: flex;
  flex-direction: column;
  padding: 4px 9px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: var(--shadow-menu);
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  transform: translate(-50%, -100%);
  pointer-events: none;
}

.chart-tip-day {
  color: var(--muted);
}

.evolution-table {
  margin-top: 12px;
  font-size: 13px;
}

.evolution-table summary {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--link);
  font-weight: 500;
  cursor: pointer;
}

.table-scroll {
  max-height: 16rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.evolution-table table {
  width: 100%;
  border-collapse: collapse;
}

.evolution-table th,
.evolution-table td {
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
  font-weight: 400;
}

.evolution-table td {
  text-align: right;
}

.evolution-table thead th {
  position: sticky;
  top: 0;
  border-top: 0;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
}

/* ---------- Fiche d'une franchise ---------- */

.detail-band {
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--tint, #3b2a10) 32%, #0e1014);
  border-bottom: 1px solid var(--line);
}

.band-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Voile sombre sur la bannière : lien lisible, transition douce vers la page. */
.detail-band.has-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgb(14 16 20 / 0.55) 0%, rgb(14 16 20 / 0.15) 45%, rgb(14 16 20 / 0.7) 100%);
}

.band-inner {
  position: relative;
  z-index: 1;
  max-width: var(--page);
  margin: 0 auto;
  padding: 16px var(--gutter) 0;
  height: 200px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding-right: 12px;
  color: #f3eee6;
  font-weight: 600;
  text-shadow: 0 1px 6px rgb(0 0 0 / 0.5);
}

.back-link:hover {
  text-decoration: underline;
}

.back-link:focus-visible {
  outline-color: #ffffff;
}

.detail-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: 0 var(--gutter) 72px;
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.detail-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: -96px;
  position: relative;
  z-index: 2;
}

.hero-cover {
  flex: 0 0 200px;
  height: 300px;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.5);
}

.hero-cover .cover-label {
  padding: 16px;
  font-size: 24px;
}

.hero-body {
  flex: 1 1 520px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 104px;
}

.detail-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 4.2vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.detail-title:focus {
  outline: none;
}

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

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

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.chip-status {
  border: 1px solid var(--st);
  background: transparent;
  color: var(--st);
  font-weight: 600;
}

.chip-status[data-status="completed"] { --st: var(--st-completed); }
.chip-status[data-status="in_progress"] { --st: var(--st-in_progress); }
.chip-status[data-status="planning"] { --st: var(--st-planning); }
.chip-status[data-status="dropped"] { --st: var(--st-dropped); }

.synopsis {
  max-width: 68ch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.synopsis-text {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
  color: var(--ink-2);
  line-height: 1.6;
}

.synopsis-text p {
  white-space: pre-line;
}

.synopsis-text.is-clamped {
  max-height: calc(1.6em * 4);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 55%, transparent);
  mask-image: linear-gradient(180deg, #000 55%, transparent);
}

.synopsis.is-loading {
  gap: 8px;
  width: 100%;
}

.skeleton {
  display: block;
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: var(--surface-3);
}

.skeleton.short {
  width: 60%;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  font-size: 14px;
}

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

/* Saisons */
.seasons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px;
}

.season {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  height: 100%;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.season:hover {
  background: var(--surface);
}

.season[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--surface-3);
}

.season-cover {
  position: relative;
  display: block;
}

.season-cover .cover {
  aspect-ratio: 2 / 3;
  border-radius: 8px;
}

.season.is-offlist .season-cover .cover,
.poster.is-offlist .poster-cover .cover,
.extra.is-offlist .extra-cover {
  opacity: 0.45;
}

.tile-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgb(14 16 20 / 0.85);
  color: #c3c7cf;
  font-weight: 700;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.tile-badge[data-kind="done"] { color: var(--on-completed); }
.tile-badge[data-kind="doing"] { color: var(--on-in_progress); }
.tile-badge[data-kind="soon"] { color: var(--on-planning); }

.season-name {
  padding: 0 2px;
  font-weight: 600;
  font-size: 14px;
}

.season-meta {
  padding: 0 2px 2px;
  color: var(--muted);
  font-size: 12px;
}

/* Panneau de la saison choisie (et du film ou de l'extra ouvert) */
.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 22px;
}

.panel-titles {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-self: center;
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.panel-link:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.panel-sub {
  color: var(--muted);
  font-size: 14px;
}

.panel-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.field-number {
  width: 84px;
}

.panel-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  color: var(--faint);
  font-size: 13px;
}

.panel-remove {
  margin-left: auto;
}

.remove-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  color: var(--ink-2);
}

/* Épisodes */
.episodes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ep-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
}

.ep {
  display: grid;
  place-items: center;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--ep-bg);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

button.ep {
  cursor: pointer;
}

button.ep:hover {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.ep.is-seen {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.stepper-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}

.stepper-label {
  color: var(--muted);
  font-size: 14px;
}

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

.step-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.step-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.field-progress {
  width: 96px;
  text-align: center;
}

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

/* Films */
.posters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 22px 18px;
}

.poster {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.poster-cover {
  position: relative;
  display: block;
  width: 100%;
}

.poster-cover .cover {
  aspect-ratio: 2 / 3;
  border-radius: 10px;
}

.poster-title {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.poster-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

/* Extras et lignes de regroupement */
.extras,
.regroup-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.extra,
.regroup-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 14px;
  background: var(--surface);
}

.extra + .extra,
.regroup-item + .regroup-item {
  border-top: 1px solid var(--line);
}

.extra-cover {
  flex: 0 0 36px;
  width: 36px;
  height: 52px;
  border-radius: 6px;
}

.extra-body,
.regroup-body {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.extra-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.extra-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.extra-error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

/* Envois */
.pending-mark {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--st-in_progress);
  font-size: 12px;
  font-weight: 600;
}

.pending-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.entry-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 12px;
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 14px;
}

.entry-error .btn-link {
  color: inherit;
  font-weight: 700;
}

/* Notes */
.notes-hint {
  margin-top: -10px;
  color: var(--muted);
  font-size: 13px;
}

.note-editor {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-label {
  color: var(--muted);
  font-size: 13px;
}

.note-input {
  width: 100%;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  resize: vertical;
}

.note-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  color: var(--faint);
  font-size: 13px;
}

.note-bar .btn {
  margin-left: auto;
}

.note-count.is-near {
  color: var(--st-in_progress);
}

.note-status.is-error {
  color: var(--danger);
}

.note-read {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.note-read + .note-read {
  margin-top: 8px;
}

.note-text {
  white-space: pre-wrap;
}

.note-meta {
  margin-top: 4px;
  color: var(--faint);
  font-size: 13px;
}

/* Corriger le regroupement */
.regroup-hint {
  max-width: 72ch;
  color: var(--muted);
  font-size: 14px;
}

.tag-fixed {
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--link);
  font-weight: 600;
}

.fix-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  color: var(--muted);
  font-size: 13px;
}

.fix-panel {
  flex-basis: 100%;
  display: grid;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  background: var(--bg);
}

.fix-block {
  display: grid;
  gap: 6px;
  justify-items: start;
}

.fix-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.fix-hint {
  max-width: 60ch;
  color: var(--muted);
  font-size: 13px;
}

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

.segment {
  min-width: 72px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.segment[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--bg);
  cursor: default;
}

.fix-action {
  white-space: normal;
  text-align: left;
}

.fix-picker,
.picker {
  display: grid;
  gap: 8px;
  width: 100%;
}

.field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 100%;
  background: var(--surface);
}

.picker-list {
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overscroll-behavior: contain;
}

.picker-list li + li {
  border-top: 1px solid var(--line);
}

.picker-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.picker-option:hover {
  background: var(--surface-3);
}

.picker-option:focus-visible {
  outline-offset: -3px;
}

.picker-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

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

.picker-empty {
  padding: 10px 12px;
}

.picker-cancel {
  justify-self: start;
}

.detail-tools {
  display: grid;
  gap: 10px;
  justify-items: start;
}

.merge-panel {
  width: 100%;
}

/* ---------- Notes par épisode (tableau « heatmap ») ----------
 * Échelle : 9–10 vert foncé, 8 vert, 7 jaune, 6 orange, 5 et moins rouge.
 * Contraste du chiffre sur sa case : 7,0 / 7,2 / 10,3 / 7,5 / 5,3 (≥ 4,5:1), dans les deux thèmes.
 */

:root {
  --hm-a: #17663b;
  --hm-a-ink: #ffffff;
  --hm-b: #3dbe6e;
  --hm-b-ink: #08200f;
  --hm-c: #e9c23a;
  --hm-c-ink: #1f1800;
  --hm-d: #f08a3c;
  --hm-d-ink: #200e00;
  --hm-e: #c8323f;
  --hm-e-ink: #ffffff;
  --hm-empty: #262b34;
  --hm-empty-hover: #313744;
  --hm-empty-ink: #9aa0aa; /* 4,6:1 sur --hm-empty */
}

:root[data-theme="light"] {
  --hm-empty: #e4e7ec;
  --hm-empty-hover: #d6dae2;
  --hm-empty-ink: #555b66; /* 5,5:1 sur --hm-empty */
}

[data-level="a"] { --lv: var(--hm-a); --lv-ink: var(--hm-a-ink); }
[data-level="b"] { --lv: var(--hm-b); --lv-ink: var(--hm-b-ink); }
[data-level="c"] { --lv: var(--hm-c); --lv-ink: var(--hm-c-ink); }
[data-level="d"] { --lv: var(--hm-d); --lv-ink: var(--hm-d-ink); }
[data-level="e"] { --lv: var(--hm-e); --lv-ink: var(--hm-e-ink); }

.hm-section {
  position: relative;
}

.hm-head {
  align-items: baseline;
  justify-content: flex-start;
}

.hm-summary {
  color: var(--muted);
  font-size: 14px;
}

.hm-scroll {
  width: fit-content;
  max-width: 100%;
  max-height: min(70vh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.heatmap {
  border-collapse: separate;
  border-spacing: 0;
}

.heatmap th,
.heatmap td {
  padding: 2px;
  font-weight: 400;
}

/* En-tête de colonnes et ligne « Moy. » collants en haut, colonne des épisodes collante à gauche. */
.hm-head-row th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 44px;
  padding-top: 6px;
  background: var(--surface);
  vertical-align: bottom;
}

.hm-avg-row th,
.hm-avg-row td {
  position: sticky;
  top: 44px;
  z-index: 2;
  padding-bottom: 6px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.hm-row {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 46px;
  padding: 2px 8px 2px 10px !important;
  background: var(--surface);
  color: var(--faint);
  font-size: 12px;
  font-weight: 600 !important;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hm-corner,
.hm-avg-row .hm-row {
  left: 0;
  z-index: 3 !important;
}

.hm-corner {
  position: sticky;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600 !important;
  text-align: right;
  padding-right: 8px !important;
}

.hm-col {
  min-width: 44px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600 !important;
  line-height: 1.2;
  text-align: center;
}

.hm-col-short,
.hm-col-range {
  display: block;
}

.hm-col-range {
  color: var(--faint);
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hm-avg-value {
  display: block;
  min-width: 40px;
  padding: 3px 0;
  border-radius: 6px;
  background: var(--lv);
  color: var(--lv-ink);
  font-weight: 700;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.hm-avg-value.is-empty {
  background: none;
  color: var(--faint);
}

.hm-cell {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--lv, var(--hm-empty));
  color: var(--lv-ink, var(--hm-empty-ink));
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.hm-cell.is-empty:hover {
  background: var(--hm-empty-hover);
}

.hm-cell:not(.is-empty):hover {
  filter: brightness(1.08);
}

.hm-cell:focus-visible,
.hm-cell[aria-expanded="true"] {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.hm-cell.is-pending {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--lv-ink, var(--hm-empty-ink)) 45%, transparent);
}

/* Colonnes découpées (saison très longue) : numéro d'épisode en petit dans chaque case. */
.hm-ep {
  position: absolute;
  top: 1px;
  left: 4px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  opacity: 0.85;
}

.hm-ep + .hm-score {
  margin-top: 6px;
  font-size: 14px;
}

.hm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  color: var(--muted);
  font-size: 13px;
}

.hm-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hm-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--lv);
}

.hm-swatch.is-empty {
  background: var(--hm-empty);
  box-shadow: inset 0 0 0 1px var(--line-2);
}

/* Sélecteur de note */
.hm-picker {
  position: absolute;
  z-index: 15;
  width: 252px;
  padding: 12px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: var(--shadow-menu);
}

.hm-picker-title {
  font-weight: 600;
  font-size: 14px;
}

.hm-options {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.hm-option {
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: var(--lv);
  color: var(--lv-ink);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

.hm-option[aria-pressed="true"] {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.hm-option:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.hm-picker-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hm-picker-hint {
  color: var(--faint);
  font-size: 12px;
}

/* Note d'un épisode dans la grille de la saison : petite pastille dans le coin. */
.ep {
  position: relative;
}

.ep-score {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--lv);
  color: var(--lv-ink);
  box-shadow: 0 0 0 2px var(--surface);
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  pointer-events: none;
}

/* ---------- Fenêtre « Ajouter » (recherche AniList) ---------- */

.add-dialog {
  width: min(640px, calc(100vw - 24px));
  max-height: min(86vh, 900px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-menu);
}

.add-dialog::backdrop {
  background: rgb(5 6 8 / 0.65);
}

.add-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  overflow: hidden;
}

.add-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.add-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
}

.add-field input {
  width: 100%;
  background: var(--bg);
  font-size: 15px;
}

.add-status {
  color: var(--muted);
  font-size: 14px;
}

.add-confirm {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--st-completed) 45%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--st-completed) 10%, transparent);
  font-size: 14px;
}

.add-results {
  overflow-y: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

.add-results[aria-busy="true"] {
  opacity: 0.6;
}

.add-result {
  display: flex;
  gap: 14px;
  padding: 12px 0;
}

.add-result + .add-result {
  border-top: 1px solid var(--line);
}

.search-cover {
  flex: 0 0 52px;
  width: 52px;
  height: 74px;
  border-radius: 6px;
}

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

.entry-title {
  font-weight: 600;
  overflow-wrap: anywhere;
}

a.entry-title:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

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

.add-action {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.add-action select {
  min-height: 36px;
}

.add-in-list {
  color: var(--muted);
  font-size: 13px;
}

.add-in-list.is-new {
  color: var(--st-completed);
  font-weight: 600;
}

/* ---------- Écrans moyens et petits ---------- */

@media (max-width: 1080px) {
  .btn-sync .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .btn-sync {
    width: 44px;
    padding: 0;
  }
}

@media (max-width: 860px) {
  /* En-tête sur deux lignes : logo et actions, puis onglets et recherche. */
  .topbar-inner {
    gap: 10px 8px;
  }

  .topactions {
    display: contents;
  }

  .brand {
    order: 1;
    margin-right: auto;
  }

  .btn-sync {
    order: 2;
  }

  .btn-add {
    order: 3;
  }

  .account {
    order: 4;
  }

  .typenav {
    order: 5;
  }

  .topsearch {
    order: 6;
    flex-basis: 200px;
  }

  /* L'état de synchro ordinaire est dans le menu du compte ; les alertes (envois
     en attente ou en échec, synchro en cours) restent visibles sur leur propre ligne. */
  .session:not(.has-alert) {
    display: none;
  }

  .session.has-alert {
    order: 7;
    flex-basis: 100%;
    white-space: normal;
  }

  .collection-tools {
    margin-left: 0;
    width: 100%;
  }
}

@media (max-width: 640px) {
  :root {
    --gutter: 16px;
  }

  .topbar-inner {
    padding-top: 8px;
    padding-bottom: 10px;
  }

  .brand {
    font-size: 18px;
  }

  .btn-add {
    padding: 0 14px;
  }

  .typenav .pill {
    padding: 0 14px;
  }

  .view-gallery {
    padding-top: 20px;
    gap: 32px;
  }

  .resume-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .topsearch {
    flex: 1 1 140px;
  }

  .typenav .pill {
    min-height: 36px;
  }

  .resume-card {
    gap: 12px;
  }

  .resume-thumb {
    flex-basis: 60px;
  }

  .resume-thumb .cover {
    width: 60px;
    height: 88px;
  }

  .resume-action {
    padding: 0 12px;
  }

  /* Galerie sur deux colonnes. */
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 14px;
  }

  .card-cover .cover-label {
    font-size: 18px;
    padding: 12px 12px 16px;
  }

  .cover-badge {
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    font-size: 11px;
  }

  .cover-score {
    top: 8px;
    right: 8px;
    padding: 3px 6px;
    font-size: 11px;
  }

  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    width: 100%;
    margin: 0 calc(-1 * var(--gutter));
    padding: 2px var(--gutter);
    scrollbar-width: none;
  }

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

  .band-inner {
    height: 150px;
    padding-top: 8px;
  }

  .detail-hero {
    gap: 18px;
    margin-top: -80px;
  }

  .hero-cover {
    flex-basis: 120px;
    height: 180px;
  }

  .hero-cover .cover-label {
    font-size: 16px;
    padding: 10px;
  }

  .hero-body {
    flex-basis: 100%;
    padding-top: 0;
  }

  .detail-inner {
    gap: 36px;
  }

  .seasons {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
  }

  .panel {
    padding: 16px;
  }

  .panel-controls {
    width: 100%;
  }

  .panel-plus {
    flex: 1;
  }

  .ep-grid {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 6px;
  }

  .posters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 14px;
  }

  .add-dialog[open] {
    padding: 16px;
  }

  .hm-cell {
    width: 36px;
    height: 32px;
    font-size: 14px;
  }

  .hm-col {
    min-width: 40px;
  }

  .hm-row {
    min-width: 40px;
    padding-left: 6px !important;
  }
}

@media (max-width: 380px) {
  .btn-add .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .btn-add {
    width: 44px;
    padding: 0;
  }
}

/* ---------- Mouvement réduit ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
