/* The theme switch sits beside the brand and does not change page layout. */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 36px;
  width: 36px; height: 36px; min-height: 36px; margin: 0 auto 0 10px; padding: 8px;
  border: 1px solid var(--line, #575c59); border-radius: 50%;
  color: inherit; background: transparent; cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease;
}
@media (hover: hover) and (pointer: fine) {
  .theme-toggle:hover { background-color: rgba(128,128,128,.10); }
}
@media (prefers-reduced-motion: reduce) {
  .theme-toggle { transition: none; }
}
.theme-toggle:focus-visible { outline: 2px solid #be6756; outline-offset: 3px; }
.theme-toggle svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .theme-sun, [data-theme="dark"] .theme-toggle .theme-moon { display: none; }
[data-theme="dark"] .theme-toggle .theme-sun { display: block; }
.auth-brand .theme-toggle { margin-left: auto; margin-right: 0; }
.admin-header .theme-toggle { border-color: #59605d; }
@media (min-width: 1101px) and (max-width: 1250px) {
  .site-header .top-nav { gap: 8px; margin-left: 12px; }
}

/* The important tokens override administrator-saved light palette values only
   while dark mode is active; those saved values are never changed. */
html[data-theme="dark"] {
  --paper: #202223 !important; --paper-light: #292c2e !important; --panel: #292c2e !important;
  --ink: #e5e1d9 !important; --muted: #b2b3af !important;
  --red: #dfa99b !important; --red-dark: #e8bfb3 !important; --blue: #acc4d2 !important;
  --line: #44494b !important;
  --theme-surface: #292c2e; --theme-raised: #333739; --theme-input: #242729;
  --theme-text: #d0cdc6;
  --theme-solid: #74514a; --theme-on-solid: #f5eee6;
  background: var(--paper); color: var(--ink); color-scheme: dark;
}
html[data-theme="dark"] body { color: var(--ink); background: var(--paper); }
/* Keep the paper fibers, replace their beige hue with the dark palette,
   and dim only the background so text and media retain their colors. */
html[data-theme="dark"] body {
  background-image:
    linear-gradient(rgba(0,0,0,.42), rgba(0,0,0,.42)),
    linear-gradient(var(--paper), var(--paper)),
    url("/assets/original/116884_2f071758f0a445d09d2ecc1b89f48340~mv2.png.webp");
  background-size: auto, auto, 720px auto;
  background-blend-mode: normal, color, soft-light;
}
html[data-theme="dark"] ::selection { color: #f5eee6; background: #69514b; }
html[data-theme="dark"] :is(input, textarea, select) { color: var(--ink); border-color: var(--line); accent-color: #cf9e8f; }
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #aeb0ac; opacity: 1; }
html[data-theme="dark"] :is(input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]), textarea, select) { background-color: var(--theme-input); }
html[data-theme="dark"] :focus-visible { outline-color: #dfa99b; }
html[data-theme="dark"] :is(.site-header, .site-header.is-scrolled, .site-header.nav-open) { color: var(--ink); border-color: var(--line); background: #25282af5; }
html[data-theme="dark"] .site-header .top-nav { background: transparent; }
html[data-theme="dark"] .nav-toggle { border-color: var(--line); color: var(--ink); background: var(--theme-surface); }
html[data-theme="dark"] .back-to-top { background: var(--theme-surface); }
html[data-theme="dark"] .back-to-top:hover { background: var(--theme-solid); color: var(--theme-on-solid); }
@media (max-width: 1100px) { html[data-theme="dark"] .site-header .top-nav { background: #25282a; border-color: var(--line); } }
html[data-theme="dark"] :is(.site-footer, .notice-footer, .info-footer, .party-footer, .music-footer, .chat-footer) { color: #e5e1d9; background: #1c1e20; }
html[data-theme="dark"] .site-version { background: #1c1e20; }
html[data-theme="dark"] :is(.hero-title-wrap::before, .hero-overview > section, .guide, .guide-panel, .section.notice, .coupon-quick, .patch-note-item, .patch-note-item.is-recent, .music-catalog, .party-card, .lyrics-dialog, .chat-panel) { background: var(--theme-surface); border-color: var(--line); }
html[data-theme="dark"] :is(.hero::before, .info-hero::before) { background: transparent; }
html[data-theme="dark"] .hero-mist { opacity: .08; }
html[data-theme="dark"] .home-identity h1 { text-shadow: none; }
html[data-theme="dark"] .home-identity-links a { border-color: var(--line); }
html[data-theme="dark"] :is(.hero-overview-copy p, .hero-benefit-list p, .hero-condition-list dd, .notice-board-body, .notice-intro p, .notice-index a, .notice-article > p, .party-card-description, .party-form label, .party-role-picker legend, .party-departure-options legend, .party-departure-field-caption, .party-detail-description) { color: var(--theme-text); }
html[data-theme="dark"] :is(.about-intro-banner, .closing) { color: #e5e1d9; background: #2b3131; }
html[data-theme="dark"] :is(.about-wordmark, .closing > p, .closing > div) { color: #d9bd9f; }
html[data-theme="dark"] :is(.weekly-timetable thead th, .weekly-timetable thead th:first-child, .weekly-timetable tbody th, .weekly-timetable td) { background: var(--theme-surface); border-color: var(--line); }
html[data-theme="dark"] .weekly-timetable td.is-daily { background: #303b41; }
html[data-theme="dark"] .weekly-timetable td.is-empty { color: #aeb0ac; }
html[data-theme="dark"] .weekly-timetable td.is-battle { color: #f5eee6; background: var(--theme-solid); }
html[data-theme="dark"] :is(.notice-pagination button, .notice-page-gap) { color: var(--muted); }
html[data-theme="dark"] .notice-pagination button:disabled { opacity: .4; }
html[data-theme="dark"] :is(.roster-item, .home-news-media, .patch-note-thumbnail, .party-initial-participant, .party-participant-chip, .party-role-count, .party-departure-fields) { background: var(--theme-raised); }
html[data-theme="dark"] :is(.coupon-toolbar button, .chat-panel button) { color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .coupon-toolbar button { background: var(--theme-surface); }
html[data-theme="dark"] :is(.coupon-toolbar button:hover, .chat-panel button:hover, .chat-panel .chat-preset[aria-pressed="true"], .party-card-open:hover) { background-color: var(--theme-raised); }
html[data-theme="dark"] .party-status.is-full { color: #e7bc89; }
html[data-theme="dark"] :is(.party-progress) { background: var(--theme-raised); }
html[data-theme="dark"] .party-role-picker label > span { color: var(--ink); background: var(--theme-surface); }
html[data-theme="dark"] .party-role-picker input:checked + span { background: #394a43; }
html[data-theme="dark"] :is(.music-list-heading > span, .music-track-heading, .music-page .track-row > span, .music-page .track-row-copy small, .music-page .track-row > .track-duration, .music-page .track-empty) { color: var(--muted); }
html[data-theme="dark"] .music-page .track-row:hover { background: var(--theme-raised); }
html[data-theme="dark"] .music-page .track-row.is-active { color: var(--red); background: #3a3331; }
html[data-theme="dark"] .music-page .track-row.is-active i { color: var(--red); background: #4c3d37; }
html[data-theme="dark"] :is(.floating-banner, .floating-banner:has(.floating-banner-image) .floating-banner-close) { background: var(--theme-surface); }
html[data-theme="dark"] .floating-banner-close { color: var(--ink); }
html[data-theme="dark"] :is(#music-page-frame, #content-frame, #guidance-frame) { background: var(--paper); }
html[data-theme="dark"] #music-navigation-status { color: var(--ink); border-color: var(--line); background: var(--theme-surface); }
html[data-theme="dark"] #music-navigation-status button { color: var(--red); }

/* Board lists, editor, comments, polls and recruitment dialogs. */
html[data-theme="dark"] :is(.board-main, .board-prompt) { --board-line: var(--line); --board-muted: var(--muted); }
html[data-theme="dark"] :is(.board-row, .board-article, .board-news-card, .board-editor, .board-editor-preview, .board-prompt, .board-poll-card, .board-poll-compose, .board-poll-choice) { color: var(--ink); border-color: var(--line); background: var(--theme-surface); }
html[data-theme="dark"] :is(.board-row:hover, .board-comment-form, .board-toolbar, .board-news-poll, .board-prose blockquote, .board-poll-choice:has(input:checked)) { color: var(--ink); background: var(--theme-raised); }
html[data-theme="dark"] :is(.board-main button, .board-prompt button) { color: var(--ink); background: var(--theme-surface); }
html[data-theme="dark"] :is(.board-main button:hover, .board-prompt button:hover) { background: var(--theme-raised); }
html[data-theme="dark"] :is(.board-main .board-primary, .board-prompt .board-primary) { color: var(--theme-on-solid); background: var(--theme-solid); border-color: #997267; }
html[data-theme="dark"] :is(.board-main input, .board-main textarea, .board-main select, .board-prompt input, .board-prompt textarea) { color: var(--ink); background: var(--theme-input); }
html[data-theme="dark"] :is(.board-row-title, .board-news-title) { color: var(--ink); }
html[data-theme="dark"] .board-prose { color: var(--theme-text); }
html[data-theme="dark"] :is(.board-row-excerpt, .board-discussion-row .board-row-excerpt, .board-news-summary, .board-row-attachments, .board-thumbnail-fallback) { color: var(--theme-text); }
html[data-theme="dark"] :is(.board-row-comments, .board-news-actions a, .board-comment-number, .board-comment-heading h2 span, .board-row-title:hover, .board-news-title:hover, .board-message, .board-prompt p, .board-poll-tag, .board-poll-result.is-mine .board-poll-result-label, .board-editor-switch button[aria-pressed="true"]) { color: var(--red); }
html[data-theme="dark"] :is(.board-category-label, .board-category-label.is-staff, .board-staff-badge) { color: #d9bd9f; background: #3b3632; }
html[data-theme="dark"] .board-row .board-category-label { background: none; }
html[data-theme="dark"] .board-prose a { color: #acc4d2; }
html[data-theme="dark"] :is(.board-thumbnail, .board-poll-track) { background: #3b4143; }
html[data-theme="dark"] .board-poll-list-tag { color: #d9bd9f; border-color: #887564; }
html[data-theme="dark"] .board-poll-result.is-mine .board-poll-track span { background: #c99a87; }
html[data-theme="dark"] #board-party-view .party-card-open:hover { background: var(--theme-raised); }

/* Administrator workspace uses the same palette, including editor tools. */
html[data-theme="dark"] :is(.admin-nav, .record-form, .party-admin-card, .guidance-builder, .main-builder, .banner-live-preview, .standalone-preview, .track-audio-preview, .guidance-public-record input[readonly]) { background: var(--theme-surface); }
html[data-theme="dark"] :is(.admin-nav button, .admin-nav .admin-board-link, .admin-main label) { color: var(--ink); }
html[data-theme="dark"] :is(.admin-nav button:hover, .admin-nav button.is-active, .admin-nav .admin-board-link:hover, .record-list button:hover, .record-list button.is-active, .guidance-version-load:hover) { color: var(--red); background: var(--theme-raised); }
html[data-theme="dark"] :is(.roster-admin-grid button, .image-preview, .track-admin-list img) { background: var(--theme-raised); }
html[data-theme="dark"] button.danger { color: var(--red); }
html[data-theme="dark"] button.primary { background: var(--theme-solid) !important; border-color: #997267 !important; color: var(--theme-on-solid); }

/* Solid actions retain readable light text when accent tokens become lighter. */
html[data-theme="dark"] :is(.party-submit, .coupon-copy, .coupon-copy-all, .patch-note-item.is-recent .patch-note-date::after) { color: var(--theme-on-solid); background: var(--theme-solid); }
html[data-theme="dark"] :is(.ost, .music-player) { color: #e5e1d9; }
html[data-theme="dark"] .chat-panel :is(.chat-primary, .chat-color-actions button[aria-pressed="true"]) { color: var(--theme-on-solid); background: var(--theme-solid); }
html[data-theme="dark"] :is(#party-compose-open, .party-submit, .party-apply-form button, .coupon-quick-copy) { color: var(--theme-on-solid); background: var(--theme-solid); }
html[data-theme="dark"] :is(.coupon-toolbar button.is-active, .coupon-toolbar button:hover, .coupon-copy:hover, .coupon-use:hover, .party-card-apply:hover, .party-initial-remove:hover) { color: var(--theme-on-solid); background: var(--theme-solid); }
html[data-theme="dark"] :is(.guide-panel li, label) { color: var(--ink); }

/* Adapt the board's five text colors and three highlights for reading at night.
   These are display-only overrides: stored rich-text colors remain unchanged. */
html[data-theme="dark"] .board-prose :is([style*="color: rgb(24, 24, 18)"], [color="#181812"]) { color: #e5e1d9 !important; }
html[data-theme="dark"] .board-prose :is([style*="color: rgb(165, 40, 28)"], [color="#a5281c"]) { color: #dfa99b !important; }
html[data-theme="dark"] .board-prose :is([style*="color: rgb(52, 74, 87)"], [color="#344a57"]) { color: #acc4d2 !important; }
html[data-theme="dark"] .board-prose :is([style*="color: rgb(39, 99, 67)"], [color="#276343"]) { color: #b1ccb5 !important; }
html[data-theme="dark"] .board-prose :is([style*="color: rgb(112, 80, 138)"], [color="#70508a"]) { color: #c9bbdb !important; }
html[data-theme="dark"] .board-prose [style*="background-color: rgb(255, 240, 168)"] { background-color: #413b2d !important; }
html[data-theme="dark"] .board-prose [style*="background-color: rgb(220, 235, 207)"] { background-color: #2e4035 !important; }
html[data-theme="dark"] .board-prose [style*="background-color: rgb(220, 232, 242)"] { background-color: #2c3b46 !important; }

/* Quiet surfaces and clear interaction states across the shared dark palette. */
html[data-theme="dark"] :is(.board-main .board-primary:hover, .board-prompt .board-primary:hover) { background: #826056; }
html[data-theme="dark"] button.primary:hover { background: #826056 !important; }
html[data-theme="dark"] :is(.board-main input:focus, .board-main textarea:focus, .board-main select:focus, .board-editor:focus, .board-prompt input:focus) { outline-color: var(--red); }
html[data-theme="dark"] :is(.music-list-heading, .music-track-heading, .music-page .track-row, .music-page .track-row i) { border-color: var(--line); }
html[data-theme="dark"] :is(.music-library .music-player, .ost) { background: #252b2f; }
html[data-theme="dark"] .music-page .player-controls .play-button { color: var(--theme-on-solid); background: var(--theme-solid); border-color: #997267; }
html[data-theme="dark"] .music-page .player-controls .play-button:hover:not(:disabled) { background: #826056; }
html[data-theme="dark"] :is(.timer-heading > span, .battle-timer-next span, .battle-timer-event i, .battle-timer-event.is-next time, .battle-timer-actions button:first-child) { color: var(--red); }
html[data-theme="dark"] .battle-timer-readout { color: #e3a397; text-shadow: none; animation: none; }
html[data-theme="dark"] :is(.battle-timer-status, .battle-timer-event small, .battle-timer-sound[aria-pressed="false"]) { color: var(--muted); }
html[data-theme="dark"] .battle-timer-event.is-passed { color: var(--muted); opacity: 1; }
html[data-theme="dark"] .battle-timer-event.is-passed :is(time, i, small) { color: inherit; }
html[data-theme="dark"] .battle-timer-schedule { border-color: #997267; }

html[data-theme="dark"] :is(.home-news-placeholder, .music-artwork, .music-page .track-row i) { color: var(--muted); }
html[data-theme="dark"] :is(.about-wordmark span, .site-footer span, .footer-seal, .notice-footer span, .info-footer span, .party-footer span, .music-footer span, .chat-footer span, .timer-page .brand-home small, .auth-brand) { color: var(--red); }
html[data-theme="dark"] .auth-shell { background: transparent; }
html[data-theme="dark"] :is(.auth-panel, .admin-header) { color: var(--ink); background: var(--theme-surface); border-color: var(--line); }
html[data-theme="dark"] :is(.auth-tabs button, .public-link) { color: var(--muted); }
html[data-theme="dark"] .auth-tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--red); }
html[data-theme="dark"] :is(.auth-form > button, .dashboard-post-actions button.danger.is-confirming, .guidance-version-display:hover:not(:disabled)) { color: var(--theme-on-solid); background: var(--theme-solid); border-color: #997267; }
html[data-theme="dark"] :is(.view-heading, .dashboard-posts, .dashboard-posts-header button, .guidance-versions, .guidance-builder, .main-builder, .record-list, .record-form, .analytics-section, .audit-list) { border-color: var(--line); }
html[data-theme="dark"] #music-mini-player { color: var(--ink); background: #252b2f; border-color: var(--line); border-top-color: var(--red); }
html[data-theme="dark"] .music-mini-subtitle { color: var(--red); }
