.theme-toggle {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem .7rem;
  border: 1px solid rgba(255, 250, 241, .42);
  border-radius: 999px;
  background: transparent;
  color: #fffaf1;
  font-weight: 800;
  cursor: pointer;
}
.theme-toggle:hover { background: rgba(255,255,255,.11); }
.theme-toggle:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--focus);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --forest: #a9c4ae;
  --forest-deep: #dce9df;
  --moss: #a9b9a7;
  --sage: #28372e;
  --sage-soft: #202c25;
  --paper: #20251f;
  --paper-deep: #181c19;
  --cream: #151917;
  --ink: #edf2ed;
  --muted: #bcc6be;
  --rust: #e3a285;
  --ochre: #d8b66f;
  --note: #302a1e;
  --border: #4b534c;
  --border-dark: #747d75;
  --success: #9bd1ad;
  --danger: #f09a9a;
  --focus: #ffb486;
  --shadow: 0 10px 30px rgba(0, 0, 0, .28);
}

html[data-theme="dark"] body { background: var(--cream); color: var(--ink); }
html[data-theme="dark"] a,
html[data-theme="dark"] summary { color: #b8d7ca; }
html[data-theme="dark"] .site-header,
html[data-theme="dark"] .site-footer { background: #101713; }
html[data-theme="dark"] .hero,
html[data-theme="dark"] .page-hero {
  background:
    linear-gradient(rgba(17, 22, 18, .82), rgba(17, 22, 18, .82)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(199, 218, 202, .055) 31px 32px),
    var(--paper);
  border-bottom-color: var(--border);
}
html[data-theme="dark"] .hero p,
html[data-theme="dark"] .hero-lede,
html[data-theme="dark"] .task-card p,
html[data-theme="dark"] .details-panel > p,
html[data-theme="dark"] .guide-card p,
html[data-theme="dark"] .beginner-note,
html[data-theme="dark"] .field-note,
html[data-theme="dark"] .source-panel,
html[data-theme="dark"] .verify,
html[data-theme="dark"] .guardrail,
html[data-theme="dark"] .boundary-note { color: #d2dbd4; }
html[data-theme="dark"] .hero-note {
  background: rgba(28, 35, 30, .92);
  color: var(--forest-deep) !important;
  border-color: #657068;
}
html[data-theme="dark"] .task-card,
html[data-theme="dark"] .prompt-card,
html[data-theme="dark"] .decision-card,
html[data-theme="dark"] .guide-card,
html[data-theme="dark"] .do-dont,
html[data-theme="dark"] .copy-block,
html[data-theme="dark"] .support-task-grid a,
html[data-theme="dark"] .start-steps li,
html[data-theme="dark"] .task-links a,
html[data-theme="dark"] .secondary,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .field select {
  background: var(--cream);
  color: var(--ink);
  border-color: var(--border);
}
html[data-theme="dark"] .route-intro,
html[data-theme="dark"] .term-card,
html[data-theme="dark"] .task-extra .field,
html[data-theme="dark"] .task-fields,
html[data-theme="dark"] .example,
html[data-theme="dark"] .troubleshoot-table th { background: var(--paper); }
html[data-theme="dark"] .details-panel,
html[data-theme="dark"] .route-card,
html[data-theme="dark"] .beginner-note { background: var(--sage-soft); }
html[data-theme="dark"] .field-note,
html[data-theme="dark"] .source-panel,
html[data-theme="dark"] .verify,
html[data-theme="dark"] .guardrail,
html[data-theme="dark"] .boundary-note,
html[data-theme="dark"] .recommended-badge {
  background: var(--note);
  border-color: #6f6245;
}
html[data-theme="dark"] .recommended-badge,
html[data-theme="dark"] .boundary-note strong,
html[data-theme="dark"] .guardrail strong { color: #f0d89c; }
html[data-theme="dark"] .static-prompt,
html[data-theme="dark"] .prompt-preview {
  background: #101512;
  color: #e9efea;
  border-color: var(--border);
}
html[data-theme="dark"] .primary,
html[data-theme="dark"] .copy-button {
  background: #31513f;
  border-color: #76917e;
  color: #fff;
}
html[data-theme="dark"] .primary:hover,
html[data-theme="dark"] .copy-button:hover { background: #3c604c; }
html[data-theme="dark"] .steps li::before,
html[data-theme="dark"] .start-steps li::before,
html[data-theme="dark"] .prompt-label { background: #355844; }
html[data-theme="dark"] .prompt-card.deep .prompt-label { background: #8f4e39; }
html[data-theme="dark"] .task-card::before,
html[data-theme="dark"] .trail-divider::before,
html[data-theme="dark"] .trail-divider::after,
html[data-theme="dark"] .optional-details,
html[data-theme="dark"] .task-section,
html[data-theme="dark"] .guide-section,
html[data-theme="dark"] details,
html[data-theme="dark"] .course-state-controls { border-color: #596159; }
html[data-theme="dark"] .task-card:hover,
html[data-theme="dark"] .prompt-card.recommended,
html[data-theme="dark"] .support-task-grid a:hover { border-color: #7d9181; }
html[data-theme="dark"] .field input::placeholder,
html[data-theme="dark"] .field textarea::placeholder { color: #9aa59c; opacity: 1; }

html[data-theme="light"] {
  color-scheme: light;
  --forest: #2f4638;
  --forest-deep: #213429;
  --moss: #66745e;
  --sage: #dfe6da;
  --sage-soft: #eef2eb;
  --paper: #f6f1e7;
  --paper-deep: #ece4d5;
  --cream: #fffdf8;
  --ink: #273029;
  --muted: #5c655f;
  --rust: #925337;
  --ochre: #b28b4b;
  --note: #f3e8c9;
  --border: #c9c1b3;
  --border-dark: #817a70;
  --success: #35634e;
  --danger: #9a3e3e;
  --focus: #b5522f;
  --shadow: 0 10px 30px rgba(42, 49, 43, .08);
}

html[data-theme="light"] body { background: var(--cream); color: var(--ink); }
html[data-theme="light"] a,
html[data-theme="light"] summary { color: #365c50; }
html[data-theme="light"] .site-header,
html[data-theme="light"] .site-footer { background: #213429; }
html[data-theme="light"] .hero,
html[data-theme="light"] .page-hero {
  background:
    linear-gradient(rgba(255,255,255,.74), rgba(255,255,255,.74)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(47,70,56,.055) 31px 32px),
    var(--paper);
  border-bottom-color: var(--border);
}
html[data-theme="light"] .hero p,
html[data-theme="light"] .hero-lede { color: #3f4842; }
html[data-theme="light"] .task-card p { color: #4b554e; }
html[data-theme="light"] .details-panel > p { color: #485148; }
html[data-theme="light"] .guide-card p { color: #4d564f; }
html[data-theme="light"] .beginner-note { color: #414b43; }
html[data-theme="light"] .field-note,
html[data-theme="light"] .source-panel,
html[data-theme="light"] .verify,
html[data-theme="light"] .guardrail,
html[data-theme="light"] .boundary-note { color: #403d31; }
html[data-theme="light"] .hero-note {
  background: rgba(255,253,248,.8);
  color: var(--forest-deep) !important;
  border-color: #b8ab91;
}
html[data-theme="light"] .task-card,
html[data-theme="light"] .prompt-card,
html[data-theme="light"] .decision-card,
html[data-theme="light"] .guide-card,
html[data-theme="light"] .do-dont,
html[data-theme="light"] .copy-block,
html[data-theme="light"] .support-task-grid a,
html[data-theme="light"] .start-steps li,
html[data-theme="light"] .task-links a,
html[data-theme="light"] .secondary,
html[data-theme="light"] .field input,
html[data-theme="light"] .field textarea,
html[data-theme="light"] .field select {
  background: var(--cream);
  color: var(--ink);
  border-color: var(--border);
}
html[data-theme="light"] .route-intro,
html[data-theme="light"] .term-card,
html[data-theme="light"] .task-extra .field,
html[data-theme="light"] .task-fields,
html[data-theme="light"] .example,
html[data-theme="light"] .troubleshoot-table th { background: var(--paper); }
html[data-theme="light"] .details-panel,
html[data-theme="light"] .route-card,
html[data-theme="light"] .beginner-note { background: var(--sage-soft); }
html[data-theme="light"] .field-note,
html[data-theme="light"] .source-panel,
html[data-theme="light"] .verify,
html[data-theme="light"] .guardrail,
html[data-theme="light"] .boundary-note,
html[data-theme="light"] .recommended-badge {
  background: var(--note);
  border-color: #c9b887;
}
html[data-theme="light"] .recommended-badge { color: #5f4a1c; }
html[data-theme="light"] .boundary-note strong,
html[data-theme="light"] .guardrail strong { color: #5e4b21; }
html[data-theme="light"] .static-prompt,
html[data-theme="light"] .prompt-preview {
  background: #f3efe6;
  color: #303630;
  border-color: var(--border);
}
html[data-theme="light"] .primary,
html[data-theme="light"] .copy-button {
  background: var(--forest-deep);
  border-color: var(--forest-deep);
  color: #fff;
}
html[data-theme="light"] .primary:hover,
html[data-theme="light"] .copy-button:hover { background: #17271f; }
html[data-theme="light"] .steps li::before,
html[data-theme="light"] .start-steps li::before,
html[data-theme="light"] .prompt-label { background: var(--forest); }
html[data-theme="light"] .prompt-card.deep .prompt-label { background: var(--rust); }
html[data-theme="light"] .field input::placeholder,
html[data-theme="light"] .field textarea::placeholder { color: inherit; opacity: .54; }

@media (max-width: 650px) {
  .theme-toggle { padding-inline: .65rem; }
}


/* Dark-mode QA polish: page-specific components */
html[data-theme="dark"] .community-note {
  border-color: #6f6245;
}
html[data-theme="dark"] .reset-button {
  color: #b8d7ca;
}
html[data-theme="dark"] .status-box.error {
  border-color: #8c5555;
  background: #351f1f;
  color: #f4c4c4;
}
html[data-theme="dark"] .card-top {
  border-bottom-color: #596159;
}
html[data-theme="dark"] .purpose,
html[data-theme="dark"] .experience {
  color: #d2dbd4;
}
html[data-theme="dark"] .prompt-box {
  background: #101512;
  border-color: var(--border);
}
html[data-theme="dark"] .prompt-text {
  color: #e9efea;
}
html[data-theme="dark"] .small-button.report {
  color: #efb8aa;
}
html[data-theme="dark"] .step-number {
  background: #355844;
  color: #fff;
}
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .showcase-placeholder {
  border-color: #596159;
}
html[data-theme="dark"] .padlet-frame {
  background: var(--cream);
}

/* Dark-mode QA polish: remaining shared and page-specific edges. */
html[data-theme="dark"] .details-panel,
html[data-theme="dark"] .route-card {
  border-color: var(--border);
}
html[data-theme="dark"] .steps li {
  border-top-color: #596159;
}
html[data-theme="dark"] .source-choice {
  border-bottom-color: #596159;
}
html[data-theme="dark"] .community-label {
  border-color: #59675d;
}
html[data-theme="dark"] .site-footer {
  border-top-color: #596159;
}
html[data-theme="dark"] .site-footer a,
html[data-theme="light"] .site-footer a {
  color: #f3ddab;
}

/* Transparent illustrations need a small paper plate in dark mode so their dark outlines stay visible. */
html[data-theme="dark"] .task-icon,
html[data-theme="dark"] .route-intro img,
html[data-theme="dark"] .trail-divider img {
  background: #f3efe6;
  box-shadow: inset 0 0 0 1px rgba(95, 74, 28, .28);
}
html[data-theme="dark"] .task-icon,
html[data-theme="dark"] .route-intro img {
  border-radius: 10px;
  padding: .2rem;
}
html[data-theme="dark"] .trail-divider img {
  border-radius: 999px;
  padding: 3px;
}

.theme-toggle { flex: 0 0 auto; }
@media (max-width: 650px) {
  .theme-toggle { margin-left: auto; }
}
