/* Follow the shared preference without recolouring contributed documents.
   Only the dark tokens change: every light fallback matches its original rule. */
@media screen {
  html[data-view="communaute"][data-theme="dark"] {
    color-scheme: dark;
    --community-page: #141226;
    --community-panel: #201c35;
    --community-panel-alt: #1a172c;
    --community-soft: #2b2540;
    --community-hover: #39304f;
    --community-border: #4e4362;
    --community-ink: #f3f0ff;
    --community-muted: #c1b5d0;
    --community-faint: #b7aac8;
    --community-input: #171326;
    --community-primary: #7950b8;
    --community-coral: #c7334e;
    --community-positive-bg: #1f382e;
    --community-positive: #b1e2bd;
    --community-warning-bg: #3a2d20;
    --community-warning: #e9d3aa;
    --community-error-bg: #442534;
    --community-error: #ffb6c4;
    --community-gold-bg: #41351e;
    --community-gold: #efd391;
    --community-shadow: #0e0b18;
    --community-image-bg: #191624;
    --community-document-bg: #fff;
    --community-highlight: #795e24;
    --community-highlight-ink: #fff3c3;
    --community-backdrop: #100c20b8;
  }
}
@media screen and (prefers-color-scheme: dark) {
  html[data-view="communaute"]:not([data-theme="light"]) {
    color-scheme: dark;
    --community-page: #141226;
    --community-panel: #201c35;
    --community-panel-alt: #1a172c;
    --community-soft: #2b2540;
    --community-hover: #39304f;
    --community-border: #4e4362;
    --community-ink: #f3f0ff;
    --community-muted: #c1b5d0;
    --community-faint: #b7aac8;
    --community-input: #171326;
    --community-primary: #7950b8;
    --community-coral: #c7334e;
    --community-positive-bg: #1f382e;
    --community-positive: #b1e2bd;
    --community-warning-bg: #3a2d20;
    --community-warning: #e9d3aa;
    --community-error-bg: #442534;
    --community-error: #ffb6c4;
    --community-gold-bg: #41351e;
    --community-gold: #efd391;
    --community-shadow: #0e0b18;
    --community-image-bg: #191624;
    --community-document-bg: #fff;
    --community-highlight: #795e24;
    --community-highlight-ink: #fff3c3;
    --community-backdrop: #100c20b8;
  }
}
@media screen {
  html[data-view="communaute"] {--cream:var(--community-panel-alt,#fffbef);--deep:var(--community-ink,#33284c);--forest:var(--community-positive,#285b49);--lavender:var(--community-soft,#eee8fc);--coral:var(--community-coral,#df3d52)}
  body.community-page {background:var(--community-page,#faf8ff);color:var(--community-ink,#33284c)}
  .skip-link {background:var(--community-panel,white);color:var(--community-ink,inherit)}
  .preview-bar {background:var(--community-soft,#ece6f9)}
  .form-preview-note {background:var(--community-soft,#eee8f8)}
  .draft-note {background:var(--community-soft,#eee6fa)}
  .upload-quota-note {background:var(--community-soft,#eee9fa)}
  .file-preview {background:var(--community-soft,#f5effa)}
  .detail-notice {background:var(--community-soft,#f3edf8)}
  .invite-card,.idea-board {background:var(--community-soft,#eee7f8)}
  .preview-bar,.preview-bar button {color:var(--community-muted,#5b4b77)}
  .form-preview-note {color:var(--community-muted,#75588b)}
  .draft-note {color:var(--community-muted,#6b557f)}
  .upload-quota-note {color:var(--community-muted,#68527a)}
  .hero-description {color:var(--community-muted,#716380)}
  .hero-notes {color:var(--community-muted,#7b6c89)}
  .eyebrow {color:var(--community-muted,#78638d)}
  .board-note {color:var(--community-muted,#79638c)}
  .gallery-heading p:not(.eyebrow),.example-note,.view-switch button,.results-row {color:var(--community-muted,#75624f)}
  .sort-label select {color:var(--community-muted,#675674)}
  .card-description {color:var(--community-muted,#746577)}
  .sample-author {color:var(--community-muted,#85728e)}
  .empty-state {color:var(--community-muted,#7c6c84)}
  .file-preview small,.field label small,.character-count,.detail-author,.upload-zone>span:not(.upload-symbol),.upload-zone small {color:var(--community-muted,#796482)}
  .how-heading>p:last-child,.how-grid p,.invite-card p:last-child,.dialog-intro,.consent,.comment-rules,.comments-empty,.comment-item time,.comment-report,.optional-note,.resource-responsibility,.resource-crop-tools small,.success-follow-up,.detail-notice {color:var(--community-muted,#75627f)}
  .success-description {color:var(--community-muted,#655773)}
  .hero-notes i {color:var(--community-positive,#37765d)}
  .highlight {color:var(--community-highlight-ink,inherit)}
  .highlight:after {background:var(--community-highlight,#ffda64)}
  /* White example sheets keep their original dark captions and illustrations. */
  .hero-paper {background:#fffdf9;color:#33284c}
  .resource-paper {color:#33284c}
  .gallery-section {border-color:var(--community-border,#f1ead8)}
  .community-footer {border-color:var(--community-border,#e9e1f2)}
  .view-switch {border-color:var(--community-border,#e9dfcc)}
  .invite-card {border-color:var(--community-border,#e6dbee)}
  #commentForm {border-color:var(--community-border,#ddcfe8)}
  .view-switch button[aria-pressed="true"] {color:var(--community-ink,var(--deep))}
  .view-switch button[aria-pressed="true"]:after {background:var(--community-ink,var(--deep))}
  .view-switch span {background:var(--community-soft,#eae1f4)}
  .comments-heading h3 span {background:var(--community-soft,#eee4f7)}
  .avatar {background:var(--community-soft,#f1e8f8);color:var(--community-muted,#87649e)}
  .category-filters button {background:var(--community-panel,#fffefb);color:var(--community-ink,#746852);border-color:var(--community-border,#e9e0d0)}
  .search-box {background:var(--community-panel,#fffefb);color:var(--community-ink,inherit);border-color:var(--community-border,#e9e0d0)}
  .creation-card {background:var(--community-panel,#fffefb);color:var(--community-ink,inherit);border-color:var(--community-border,#eae2d7)}
  .like-button {background:var(--community-panel,#fffcfa);color:var(--community-ink,#79606f);border-color:var(--community-border,#ece2e9)}
  .comment-item {background:var(--community-panel,#fff);color:var(--community-ink,inherit);border-color:var(--community-border,#e8dfef)}
  .category-filters button:hover {border-color:var(--community-muted,#ac93bc)}
  .category-filters button[aria-pressed="true"],.action-dark {background:var(--community-primary,var(--deep));border-color:var(--community-primary,var(--deep));color:#fff}
  .action-dark {box-shadow:0 3px 0 var(--community-shadow,#221a34)}
  .action-soft {background:var(--community-soft,var(--lavender));color:var(--community-ink,var(--deep))}
  .icon-button {background:var(--community-soft,#f0eaf5);color:var(--community-ink,#6e577e)}
  .search-box input {color:var(--community-ink,var(--deep))}
  .search-box svg {stroke:var(--community-muted,#8f8397)}
  input::placeholder,textarea::placeholder {color:var(--community-faint,revert)}
  .sort-label select option {background:var(--community-panel,revert);color:var(--community-ink,revert)}
  .creation-card {box-shadow:0 3px 0 var(--community-shadow,#eee6d8)}
  .creation-card:hover {box-shadow:0 4px 0 var(--community-shadow,#e9dfce),0 12px 18px #3c2d3d09}
  .card-image {background:var(--community-image-bg,#f0e9dc)}
  .card-image.is-drawing {background:var(--community-image-bg,#f3eef9)}
  .card-image.is-activity {background:var(--community-image-bg,#e8f1df)}
  .card-image.is-worksheet {background:var(--community-image-bg,#e9edf7)}
  .detail-visual {background:var(--community-image-bg,#eee8f5)}
  .creation-card .card-image img,.detail-visual img {background:var(--community-document-bg,transparent)}
  .card-open,.card-copy h3 {color:var(--community-ink,inherit)}
  .card-example {background:var(--community-panel,#fffdf6ed);border-color:var(--community-border,#ffffffa8);color:var(--community-muted,#796b5c)}
  .category-badge {background:var(--community-soft,#f1e8fb);color:var(--community-muted,#76529c)}
  .category-badge[data-category="exercice"] {background:var(--community-soft,#e4ecfb);color:var(--community-muted,#42628d)}
  .category-badge[data-category="bricolage"] {background:var(--community-warning-bg,#fce8de);color:var(--community-warning,#a2532b)}
  .category-badge[data-category="labyrinthe"] {background:var(--community-warning-bg,#fff0cb);color:var(--community-warning,#83672f)}
  .category-badge[data-category="activite"] {background:var(--community-positive-bg,#e3f0e3);color:var(--community-positive,#3e7250)}
  .pending-badge {background:var(--community-warning-bg,#fbefcf);color:var(--community-warning,#7e6438)}
  .pending-badge[data-status="approved"] {background:var(--community-positive-bg,#dfefdf);color:var(--community-positive,#386744)}
  .pending-badge[data-status="rejected"] {background:var(--community-error-bg,#f9e3e5);color:var(--community-error,#9b3d51)}
  .review-tag {background:var(--community-positive-bg,#e6efe2);color:var(--community-positive,#46643d)}
  .upload-quota-note.quota-full {background:var(--community-error-bg,#fde9e7);color:var(--community-error,#9b3d40)}
  .like-button[aria-pressed="true"] {background:var(--community-error-bg,#ffedf0);border-color:var(--community-border,#f4c6d4);color:var(--community-error,#c32b50)}
  .pdf-card {background:var(--community-error-bg,#fae8e6);color:var(--community-error,#b05e61)}
  .pdf-preview {background:var(--community-error-bg,#f9ddda);color:var(--community-error,#a9484d)}
  .step-blue {background:var(--community-soft,#e1ecff);color:var(--community-ink,#527bb7)}
  .step-orange {background:var(--community-soft,#ffead7);color:var(--community-ink,#bd8050)}
  .step-green {background:var(--community-soft,#def0e5);color:var(--community-ink,#548a68)}
  dialog {background:var(--community-panel,#fffcfa);border-color:var(--community-border,#e2d6ef);color:var(--community-ink,var(--deep))}
  .submission-success {background:var(--community-panel,#fffdf8)}
  #cropDialog {background:var(--community-panel,#fffdf8);color:var(--community-ink,#34234f)}
  dialog::backdrop {background:var(--community-backdrop,#251c3c80)}
  .upload-zone {background:var(--community-panel-alt,#f8f3fd);border-color:var(--community-border,#d8c4e6)}
  .upload-zone:hover,.upload-zone.dragging {background:var(--community-hover,#f0e8fa);border-color:var(--community-muted,#a57abc)}
  .field input,.field select,.field textarea {background:var(--community-input,#fff);border-color:var(--community-border,#dfd4e7);color:var(--community-ink,var(--deep))}
  .field>label {color:var(--community-ink,inherit)}
  .field label>span {color:var(--community-error,#cf5f70)}
  .field-error,.form-status {color:var(--community-error,#b9324d)}
  #cropError {color:var(--community-error,#a34967)}
  .delete-draft {color:var(--community-error,#af4661)}
  .gentle-note {background:var(--community-warning-bg,#f7f2e5)}
  .gentle-note p {color:var(--community-warning,#756346)}
  .gentle-note>span {color:var(--community-warning,#b7a268)}
  .community-notice {background:var(--community-warning-bg,#f8f0dc);border-color:var(--community-border,#e5d9bb);color:var(--community-warning,#736043)}
  .community-notice b {color:var(--community-warning,#614e34)}
  #receiptStorageWarning {background:var(--community-warning-bg,#fff0d8);color:var(--community-warning,#87552e)}
  .receipt-box {background:var(--community-positive-bg,#eef7eb);border-color:var(--community-border,#d5e4d5);color:var(--community-positive,#42633d)}
  .comments-section {background:var(--community-panel-alt,#fcf9ff);border-color:var(--community-border,#e8deef)}
  .card-comments {background:var(--community-panel,#fffdf8);border-color:var(--community-border,#f0e8e2);color:var(--community-muted,#75627f)}
  .card-comments:hover {background:var(--community-hover,#f3edf8)}
  .comments-section .form-status {color:var(--community-muted,#685077)}
  .comment-item.comment-admin {background:var(--community-gold-bg,#fffaf0);border-color:var(--community-gold,#dcc176);border-left-color:var(--community-gold,#d4aa42);box-shadow:0 2px 0 var(--community-shadow,#eedfb5)}
  .admin-author-badge {background:var(--community-gold-bg,#fff0bd);border-color:var(--community-gold,#e7cf8b);color:var(--community-gold,#79571e)}
  .comment-admin .comment-author>b {color:var(--community-gold,#624819)}
  .resource-crop-tools #restoreResourceImage {background:var(--community-soft,#fffdf9);border-color:var(--community-border,#e0d4e9);color:var(--community-ink,#75627f)}
  .crop-actions button {background:var(--community-soft,#f2e9fc);border-color:var(--community-border,#d8c5e8);color:var(--community-ink,#62487e)}
  .crop-actions #applyCrop {background:var(--community-primary,#8851dc);border-color:var(--community-primary,#8851dc);color:#fff}
  .success-check {background:var(--community-positive-bg,#e3f1df);color:var(--community-positive,#487953);box-shadow:0 5px 0 var(--community-shadow,#c9dfc5)}
  .success-resource {color:var(--community-positive,#51744a)}
  .toast {background:var(--community-primary,var(--deep));border-color:var(--community-border,#d8c8e8);color:#fff}

  /* External theme.js picker rules: the page intentionally disallows inline styles. */
  footer .footer-language{align-items:center;flex-wrap:wrap;gap:4px 20px}
  footer .theme-picker{order:2;display:inline-flex;align-items:center;gap:6px;position:relative;color:var(--muted);font-size:13px;font-weight:700;line-height:1.5;cursor:pointer}
  footer .theme-picker svg{width:15px;height:15px;flex:none;pointer-events:none}
  footer .theme-picker::after{content:"⌄";position:absolute;right:2px;top:50%;transform:translateY(-55%);font-size:12px;pointer-events:none}
  footer .theme-picker select{appearance:none;-webkit-appearance:none;border:0;border-radius:0;background:transparent;color:inherit;font:inherit;min-height:44px;max-width:170px;padding:4px 18px 4px 2px;box-shadow:none;cursor:pointer;outline:none}
  footer .theme-picker select:focus-visible{outline:none;text-decoration:underline;text-underline-offset:4px;text-decoration-thickness:1px}
  footer .theme-picker:hover{color:var(--ink)}
  footer .theme-picker option{background:var(--card);color:var(--ink)}
}
@media print{footer .theme-picker{display:none!important}}
