/* Identité du carnet × luminosité. Les composants utilisent les mêmes rôles. */
body {
  --surface: #fffaf0;
  --surface-raised: #fffdf8;
  --surface-soft: #fff1d6;
  --page-background: linear-gradient(180deg, #fffaf0, #fff5df 42%, #f5ddb5);
  --intro-background: #fff9ed;
  --catalog-background: #fff0d3;
  --text: #3c2b26;
  --text-secondary: #5d4840;
  --text-muted: #67544b;
  --accent: #9b354e;
  --accent-strong: #813047;
  --accent-soft: #f8dadd;
  --action-background: #a13c54;
  --action-hover: #813047;
  --action-text: #fffaf5;
  --header-background: linear-gradient(135deg, #713246, #8f4357);
  --header-border: #552333;
  --header-text: #fff8ed;
  --header-muted: #f5dfe5;
  --border: #d6bca6;
  --border-strong: #9d7d72;
  --sun-surface: #ffe9aa;
  --sun-text: #62440b;
  --rain-surface: #d9edf2;
  --rainbow-surface: linear-gradient(110deg, #ffe3e2, #fff1bd, #e3f2d9, #e3f3f4, #eee6f3);
  --season-base: linear-gradient(145deg, #ffe9df, #f8d6d6);
  --season-whales: linear-gradient(145deg, #e7f6fa, #cce9f2);
  --season-frost: linear-gradient(145deg, #edf6ff, #dfe8fa);
  --season-streets: linear-gradient(145deg, #fff1d4, #f5d59a);
  --season-dream: linear-gradient(145deg, #f7e9f8, #ebd8f0);
  --season-ancients: linear-gradient(145deg, #f8edda, #e7d0ab);
  --season-generic: linear-gradient(145deg, #f3efe9, #e6ddd2);
  --tip-background: #fff0cf;
  --notice-background: #3c2b26;
  --notice-text: #fffaf0;
  /* Alias de compatibilité des composants existants. */
  --cream-50: var(--surface);
  --cream-100: var(--surface-soft);
  --cream-200: var(--border);
  --ink-900: var(--text);
  --ink-700: var(--text-secondary);
  --ink-500: var(--text-muted);
  --coral-700: var(--accent-strong);
  --coral-600: var(--accent);
  --coral-500: var(--action-background);
  --coral-300: var(--border);
  --coral-100: var(--accent-soft);
  --sage-800: var(--accent-strong);
  --sage-700: var(--accent);
  --sage-500: var(--action-background);
  --sage-300: var(--border);
  --sage-100: var(--accent-soft);
  --sun-100: var(--sun-surface);
  --sky-100: var(--rain-surface);
  --lavender-100: var(--season-dream);
  --header-zone: var(--intro-background);
  --body-zone: var(--catalog-background);
  --line: var(--border);
  --line-strong: var(--border-strong);
  --bird-media-background: linear-gradient(145deg, var(--accent-soft), var(--surface-soft));
}

body[data-catalog="insects"] {
  --surface-soft: #f7eed5;
  --page-background: linear-gradient(180deg, #fffaf0, #edf5e8 44%, #d4e8d8);
  --intro-background: #fffaf0;
  --catalog-background: #e6f2e9;
  --text: #203c34;
  --text-secondary: #35584d;
  --text-muted: #456054;
  --accent: #2f6655;
  --accent-strong: #24463d;
  --accent-soft: #d9eee3;
  --action-background: #2f6655;
  --action-hover: #24463d;
  --header-background: linear-gradient(135deg, #24463d, #2f6655);
  --header-border: #18382f;
  --header-muted: #dcefe3;
  --border: #b7cabc;
  --border-strong: #6a8d7b;
}

body[data-catalog="fish"] {
  --surface: #f6f8ff;
  --surface-raised: #fcfcff;
  --surface-soft: #e8edfc;
  --page-background: linear-gradient(180deg, #f6f8ff, #e4effb 45%, #d9ddf6);
  --intro-background: #f3f5ff;
  --catalog-background: #e4edfc;
  --text: #233451;
  --text-secondary: #3d5273;
  --text-muted: #4c5c79;
  --accent: #415c99;
  --accent-strong: #354c83;
  --accent-soft: #dfe3f9;
  --action-background: #40578f;
  --action-hover: #303f72;
  --header-background: linear-gradient(135deg, #283d68, #51578e);
  --header-border: #22375d;
  --header-muted: #e1e8ff;
  --border: #bdc9e4;
  --border-strong: #798eb7;
  --tip-background: #e8edfc;
}

html[data-theme="dark"] { color-scheme: dark; }
html:not([data-theme="dark"]) { color-scheme: light; }
html[data-theme="dark"] body {
  --surface: #261f27;
  --surface-raised: #302630;
  --surface-soft: #392d36;
  --page-background: linear-gradient(180deg, #1b171e, #251b24 60%, #2c2029);
  --intro-background: #201a22;
  --catalog-background: #1b171e;
  --text: #fff3f7;
  --text-secondary: #ecdae3;
  --text-muted: #d3c0cb;
  --accent: #f2abc1;
  --accent-strong: #ffc1d3;
  --accent-soft: #51313f;
  --action-background: #a34160;
  --action-hover: #88324e;
  --header-background: linear-gradient(135deg, #281b23, #422634);
  --header-border: #785364;
  --header-muted: #f5dfe5;
  --border: #60515f;
  --border-strong: #a48a9b;
  --sun-surface: #493b21;
  --sun-text: #ffe2a3;
  --rain-surface: #243e4a;
  --rainbow-surface: linear-gradient(110deg, #48313e, #433b28, #293f33, #283c48, #3b304c);
  --season-base: linear-gradient(145deg, #493039, #4a2a38);
  --season-whales: linear-gradient(145deg, #243c49, #254451);
  --season-frost: linear-gradient(145deg, #2c394c, #2e4055);
  --season-streets: linear-gradient(145deg, #463923, #4c3e26);
  --season-dream: linear-gradient(145deg, #3e2d49, #483454);
  --season-ancients: linear-gradient(145deg, #41362b, #4a3e2e);
  --season-generic: linear-gradient(145deg, #353138, #423945);
  --tip-background: #372c33;
  --notice-background: #f4e8ef;
  --notice-text: #291e26;
  --shadow-soft: 0 10px 26px #0003;
  --shadow-card: 0 17px 40px #0005;
  --shadow-float: 0 26px 80px #0008;
}
html[data-theme="dark"] body[data-catalog="insects"] {
  --surface: #1c2b25;
  --surface-raised: #26382f;
  --surface-soft: #2e4136;
  --page-background: linear-gradient(180deg, #15211b, #182b23 60%, #21352b);
  --intro-background: #19271f;
  --catalog-background: #15211b;
  --text: #f0fff5;
  --text-secondary: #daeade;
  --text-muted: #bfd6c7;
  --accent: #96d4b3;
  --accent-strong: #b6e8ca;
  --accent-soft: #314c3d;
  --action-background: #346953;
  --action-hover: #28543f;
  --header-background: linear-gradient(135deg, #152d26, #244335);
  --header-border: #527863;
  --border: #4b6655;
  --border-strong: #8bac98;
  --tip-background: #293c30;
}
html[data-theme="dark"] body[data-catalog="fish"] {
  --surface: #1d2a40;
  --surface-raised: #263650;
  --surface-soft: #2e3e5b;
  --page-background: linear-gradient(180deg, #131e33, #1a2944 60%, #252846);
  --intro-background: #19263f;
  --catalog-background: #141f34;
  --text: #f2f5ff;
  --text-secondary: #dbe6fd;
  --text-muted: #c0cfea;
  --accent: #b6c7ff;
  --accent-strong: #d1d4ff;
  --accent-soft: #3b4164;
  --action-background: #495fa0;
  --action-hover: #3a4c87;
  --header-background: linear-gradient(135deg, #19263f, #33355b);
  --header-border: #61769b;
  --border: #526481;
  --border-strong: #92a8d0;
  --tip-background: #2c3655;
}

body, body.seo-bird-page { background: var(--page-background); color: var(--text); }
.skip-link { background: var(--action-background); color: var(--action-text); }
body::before { opacity: .07; }
body[data-catalog="insects"]::before {
  background-image: radial-gradient(circle at 8px 8px, #639577 0 2px, transparent 2.5px), radial-gradient(circle at 30px 30px, #b57922 0 1.5px, transparent 2px);
  background-size: 64px 64px;
}
body[data-catalog="fish"]::before {
  background-image: radial-gradient(circle at 20px 20px, transparent 10px, #90a7df 11px 12px, transparent 13px);
  background-size: 88px 88px;
}
.intro-zone { background: var(--intro-background); }
.catalog-zone, .tips-zone { background: var(--catalog-background); }
.seo-guide-zone { background: var(--surface-soft); border-color: var(--border); }
.site-header, .site-footer, .seo-bird-header { background: var(--header-background); color: var(--header-text); border-color: var(--header-border); }
.brand-copy small, .header-progress small, .footer-brand p, .footer-credit, .legal-note, .seo-bird-brand small { color: var(--header-muted); }
.seo-bird-footer p { color: var(--header-muted); }
.catalog-switcher { background: #0002; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seo-bird-header .catalog-switcher { width: min(100%, 370px); flex-basis: 370px; }
.seo-bird-header .catalog-switcher-link { min-width: 0; }
.catalog-switcher-link { color: var(--header-text); }
.catalog-switcher-link[aria-current="page"] { color: var(--text); background: var(--surface); }
.header-progress { color: var(--header-text); text-align: left; }
.header-progress, .footer-credit { background: #0002; }
.header-progress > span:nth-child(2) { display: grid; line-height: 1.15; }
.hero-tagline { color: var(--accent-strong); }
.footer-contributor {
  display: inline-grid;
  justify-items: start;
  margin-top: 8px;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 16px;
  white-space: normal;
  gap: 6px;
  line-height: 1.4;
}
.footer-contributor-person { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 4px 6px; max-width: 100%; }
.footer-contributor-person > strong { min-width: 4.5em; }
.footer-contributor-person > span { white-space: nowrap; }
.seo-footer-thanks { display: grid; justify-content: center; justify-items: start; gap: 4px; }
.seo-about-contributors { display: grid; gap: 6px; }
.seo-about-contributors .footer-contributor-person { font-size: .85rem; }

.theme-toggle {
  width: 44px; height: 44px; flex: 0 0 44px; padding: 0;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px solid #fff7; background: #0002; color: var(--header-text);
}
.theme-toggle:hover { background: #fff2; }
.theme-toggle .theme-sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-sun { display: block; }
html[data-theme="dark"] .theme-toggle .theme-moon { display: none; }
.progress-help { position: relative; }
.progress-help-panel {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 85;
  width: min(350px, calc(100vw - 32px)); max-height: 65dvh; overflow: auto;
  padding: 18px; border: 1px solid var(--border-strong); border-radius: 18px;
  background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-float);
  font-size: .88rem; line-height: 1.55; text-align: left;
}
.progress-help-panel::before { content: ""; position: absolute; bottom: 100%; right: 0; width: 100%; height: 12px; }
.progress-help-panel strong { color: var(--accent-strong); }
.progress-help-panel p { margin: 8px 0 0; color: var(--text-secondary); }
.progress-help::after { content: ""; position: absolute; top: 100%; left: 0; right: 0; height: 12px; }
.theme-notice { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 150; width: min(460px, calc(100vw - 32px)); padding: 15px 20px; border-radius: 18px; box-shadow: var(--shadow-float); }
.toast, .theme-notice { background: var(--notice-background); color: var(--notice-text); }
[hidden] { display: none !important; }

.finder, .sort-menu, .hero-stats, .filter-panel, .collection-card, .bird-card,
.seo-guide-card, .seo-bird-sheet, .seo-sitemap-section, .seo-related, .seo-about-card,
.seo-hub-section, .seo-sitemap-about, .seo-directory:has(> *), .dialog-actions,
.sort-control select, .sort-trigger, .dialog-shell, .bird-dialog-shell {
  background: var(--surface-raised); border-color: var(--border);
}
.search-box input:focus, .search-box input:focus-visible { background: var(--surface-raised); border-color: var(--accent); }
.sort-trigger:hover, .sort-trigger:focus-visible { border-color: var(--accent); }
.hero-summary .freshness, .seo-hub-table th, .seo-hub-table td { border-color: var(--border); }
.hero-stats div { border-color: var(--border); }
.hero-summary, .hero-stats div { background: var(--surface-raised); }
.seo-directory-hubs a, .seo-directory-details li a { background: var(--surface-soft); }
.seo-guide-crosslink, .seo-entry-advice, .seo-entry-pagination a,
.seo-sitemap-grid a, .seo-hub-summary div, .seo-hub-related, .detail-fact,
.detail-map-button, .active-filter, .sort-option-icon, .availability-badge {
  background: var(--surface-soft); border-color: var(--border); color: var(--text-secondary);
}
.seo-sitemap-grid a:hover { background: var(--accent-soft); border-color: var(--accent); }
.seo-guide-icon, .sort-trigger-icon, .button-primary, .button-filter,
.collection-view-button[aria-pressed="true"], .observe-button[aria-pressed="true"], .observe-fab[aria-pressed="true"] {
  background: var(--action-background); color: var(--action-text); border-color: var(--action-background);
}
.button-primary:hover { background: var(--action-hover); }
.sort-option[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.sort-option[aria-selected="true"]::after { background-color: var(--action-background); }
.view-bird-button, .view-bird-button:hover { background: var(--accent-soft); color: var(--accent-strong); }
.observe-button, .observe-fab, .detail-close { background: var(--surface); color: var(--accent-strong); border-color: var(--border); }
.level-badge { background: var(--sun-surface); color: var(--sun-text); }
.condition-pill.weather-rainbow { background: var(--rainbow-surface); }
.game-tip { background: var(--tip-background); border-color: var(--border); }
.detail-media.has-cutout-image { background: var(--bird-media-background); }
html[data-theme="dark"] :is(.bird-card-media, .detail-media, .seo-bird-visual) {
  background: var(--surface-soft);
  border-color: var(--border);
  box-shadow: none;
}
html[data-theme="dark"] .bird-card-media::after { display: none; }
html[data-theme="dark"] :is(.bird-card-media, .detail-media, .seo-bird-visual) img {
  filter: none;
}
.detail-facts dt > span[aria-hidden="true"], .detail-map-icon { background: var(--surface); }
.detail-fact-zone, .detail-fact-time { background: var(--sun-surface); }
.detail-fact-weather { background: var(--rain-surface); }
.detail-fact-availability { background: var(--accent-soft); }
.condition-pill.silhouette-gold, .detail-fact.silhouette-gold, .seo-bird-facts .silhouette-gold {
  background: var(--sun-surface);
  color: var(--sun-text);
  border-color: var(--sun-500);
}
.silhouette-gold dt, .silhouette-gold dd { color: var(--sun-text); }
.seo-hub-table thead th { background: var(--accent-soft); color: var(--accent-strong); }
.catalog-tabs-shell { background: var(--surface); border-color: var(--border); }
.catalog-tab { color: var(--text); }
.catalog-tab-copy small { color: var(--text-secondary); }
.catalog-tab-icon, .filter-choice-icon { background: var(--surface); border-color: var(--border); }
.event-tab-base { --event-background: var(--season-base); }
.event-tab-whales { --event-background: var(--season-whales); }
.event-tab-frost { --event-background: var(--season-frost); }
.event-tab-streets { --event-background: var(--season-streets); }
.event-tab-dream { --event-background: var(--season-dream); }
.event-tab-ancients { --event-background: var(--season-ancients); }
.event-tab-generic, .event-tab-nest { --event-background: var(--season-generic); }
.weather-tile-all { --tile-background: var(--surface-soft); }
.weather-tile-sun { --tile-background: var(--sun-surface); }
.weather-tile-rain { --tile-background: var(--rain-surface); }
.weather-tile-rainbow { --tile-background: var(--rainbow-surface); }
.period-filter-tile:nth-child(1), .period-filter-tile:nth-child(2) { --tile-background: var(--sun-surface); }
.period-filter-tile:nth-child(3) { --tile-background: var(--season-base); }
.period-filter-tile:nth-child(4) { --tile-background: var(--season-dream); }
.filter-choice[aria-pressed="true"] { border-color: var(--accent); }
.filter-choice[aria-pressed="true"] .filter-choice-icon::after { background-color: var(--action-background); }
.empty-state-coming-soon { background: var(--surface); border-color: var(--border); }
.empty-state-coming-soon h3 { color: var(--accent-strong); max-width: 30ch; }
.empty-state-coming-soon::before, .empty-state-coming-soon::after { background: var(--accent-soft); opacity: .45; }
.empty-mascot { display: block; margin: 0 auto 10px; object-fit: contain; position: relative; z-index: 1; }
.empty-state-coming-soon .empty-mascot { width: 220px; height: 220px; }
.catalog-is-empty :is(.search-box input, .select-field, .sort-trigger, .sort-native, .button-filter) { cursor: not-allowed; opacity: 1; color: var(--text-muted); }
.catalog-is-empty .filter-panel, .catalog-is-empty .collection-card, .catalog-is-empty .sort-control { opacity: 1; }
.catalog-is-empty .button-filter { background: var(--surface-soft); border-color: var(--border); }
.detail-map-button:disabled { opacity: 1; }
:is(button, a, input, select, summary):focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.site-header :is(button, a):focus-visible, .seo-bird-header :is(button, a):focus-visible, .site-footer a:focus-visible { outline-color: #ffdf86; }

@media (min-width: 1040px) {
  .catalog-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .catalog-tab-copy strong { font-size: .78rem; }
  .catalog-tab-copy small { font-size: .7rem; }
}

@media (max-width: 719px) {
  .progress-help-panel { right: -52px; }
  .seo-bird-header { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 10px; }
  .seo-bird-header .seo-bird-brand { width: auto; grid-column: 1; grid-row: 1; }
  .seo-bird-header .theme-toggle { grid-column: 2; grid-row: 1; }
  .seo-bird-header .catalog-switcher { grid-column: 1 / -1; width: 100%; }
}
@media (max-width: 380px) {
  .theme-toggle { width: 40px; height: 40px; flex-basis: 40px; }
  .header-progress > .progress-icon { display: none; }
  .header-progress { padding: 6px 10px; }
  .progress-help-panel { right: -48px; }
}
