/* Shared theme controls. Light stays the default, including when JavaScript is unavailable. */
.dark-only { display: none !important; }
html[data-theme='dark'] .light-only { display: none !important; }
html[data-theme='dark'] .dark-only { display: revert !important; }
html[data-theme='dark'] .hero.dark-only { display: grid !important; }
html[data-theme='dark'] .brand.dark-only { display: inline-block !important; }
.theme-switch { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; padding: 7px 2px 7px 7px; cursor: pointer; }
.theme-switch input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.theme-switch-track { position: relative; width: 54px; height: 29px; border-radius: 20px; display: flex; align-items: center; justify-content: space-between; padding: 0 7px; border: 1px solid #d2dcef; background: #e6ecf7; box-shadow: inset 0 1px 3px #5267800a; }
.theme-sun, .theme-moon { position: relative; z-index: 1; font: 16px/1 sans-serif; color: #7b89a0; user-select: none; }
.theme-sun { color: #8d6a2b; font-size: 14px; }
.theme-switch-thumb { position: absolute; left: 3px; top: 3px; width: 21px; height: 21px; background: white; border-radius: 50%; box-shadow: 0 1px 4px #35466c25; transition: transform .2s ease, background .2s ease; }
.theme-switch input:checked + .theme-switch-track .theme-switch-thumb { transform: translateX(25px); background: #ffe331; }
.theme-switch input:checked + .theme-switch-track { border-color: #777; background: #303034; }
.theme-switch input:checked + .theme-switch-track .theme-moon { color: #151515; }
.theme-switch input:checked + .theme-switch-track .theme-sun { color: #d0d0d0; }
.theme-switch input:focus-visible { outline: none; }
.theme-switch input:focus-visible + .theme-switch-track { outline: 3px solid #5065ce; outline-offset: 4px; }
html[data-theme='dark'] .theme-switch input:focus-visible + .theme-switch-track { outline-color: #ffe331; }

/* Adapt the newer content modules to the restored black/red poster theme. */
html[data-theme='dark'] .header nav { gap: 8px; }
html[data-theme='dark'] .search-open { display: inline-flex; align-items: center; gap: 8px; transform: none; }
html[data-theme='dark'] .search-open span { font-size: 14px; margin: 0; }
html[data-theme='dark'] .search-open kbd { font: 10px/1.6 Consolas,monospace; padding: 1px 4px; border: 1px solid #666; color: #ddd; }
html[data-theme='dark'] .section-caption, html[data-theme='dark'] .heading-dot { display: none; }
html[data-theme='dark'] .section-heading h2::after { content: 'LATEST NOTES'; display: block; font: italic 16px ImpactLocal,Impact,sans-serif; color: var(--yellow); letter-spacing: 1px; }
html[data-theme='dark'] .section-heading > a { font-size: 13px; color: var(--muted); }
html[data-theme='dark'] .category-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 25px; }
html[data-theme='dark'] .category-nav a { font-size: 12px; padding: 4px 9px; border: 1px solid #555; }
html[data-theme='dark'] .category-nav .active, html[data-theme='dark'] .category-nav a:hover { background: var(--yellow); color: var(--ink); }
html[data-theme='dark'] .post-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
html[data-theme='dark'] .post-tags { display: flex; flex-wrap: wrap; gap: 8px; color: #666; font-size: 11px; }
html[data-theme='dark'] .post-tags a:hover { color: var(--red); }
html[data-theme='dark'] .read-link { gap: 12px; white-space: nowrap; }
html[data-theme='dark'] .profile-head h2 { font-size: 21px; margin: 0; }
html[data-theme='dark'] .status-dot { display: inline-block; background: var(--yellow); width: 5px; height: 5px; margin-left: 8px; border-radius: 50%; vertical-align: middle; }
html[data-theme='dark'] .profile-links { margin-top: 17px; gap: 7px; }
html[data-theme='dark'] .social-links { display: flex; flex-wrap: wrap; gap: 13px; }
html[data-theme='dark'] .social-links a { color: var(--paper); font-size: 12px; }
html[data-theme='dark'] .social-links a:hover { color: var(--yellow); }
html[data-theme='dark'] .profile-links a { padding: 4px 8px; border: 1px solid #777; font-size: 11px; }
html[data-theme='dark'] .category-list { display: grid; gap: 12px; }
html[data-theme='dark'] .category-list a { display: flex; justify-content: space-between; gap: 15px; font-size: 13px; }
html[data-theme='dark'] .category-list a:hover, html[data-theme='dark'] .activity-link:hover { color: var(--yellow); }
html[data-theme='dark'] .category-list i { font-style: normal; margin-left: 8px; color: var(--muted); }
html[data-theme='dark'] .panel-heading { display: flex; justify-content: space-between; }
html[data-theme='dark'] .panel-heading > span { display: none; }
html[data-theme='dark'] .activity-summary { font-size: 11px; color: #ccc; margin: 0 0 13px; }
html[data-theme='dark'] .activity-summary b { color: var(--yellow); }
html[data-theme='dark'] .activity-grid { display: grid; grid-template-rows: repeat(7,1fr); grid-auto-flow: column; grid-template-columns: repeat(14,minmax(0,1fr)); gap: 4px; }
html[data-theme='dark'] .activity-cell { aspect-ratio: 1; background: #3d3d3d; }
html[data-theme='dark'] .activity-cell.level-1 { background: #817326; }
html[data-theme='dark'] .activity-cell.level-2 { background: #c8b235; }
html[data-theme='dark'] .activity-cell.level-3 { background: var(--yellow); }
html[data-theme='dark'] .activity-legend { margin-top: 8px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; color: var(--muted); font: 8px/1.6 Consolas,monospace; }
html[data-theme='dark'] .activity-legend i { display: inline-block; width: 7px; height: 7px; background: #3d3d3d; }
html[data-theme='dark'] .activity-legend i:nth-of-type(2) { background: #817326; }
html[data-theme='dark'] .activity-legend i:nth-of-type(3) { background: #c8b235; }
html[data-theme='dark'] .activity-legend i:nth-of-type(4) { background: var(--yellow); }
html[data-theme='dark'] .activity-link { display: block; font-size: 10px; margin-top: 15px; }
html[data-theme='dark'] .quote code { font: 10px Consolas,monospace; }
html[data-theme='dark'] footer small { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
html[data-theme='dark'] footer small code { margin-left: auto; font: 10px Consolas,monospace; }
html[data-theme='dark'] dialog input { background: white; color: #151515; }
html[data-theme='dark'] dialog .close { color: #151515; }
@media (max-width: 1000px) {
  .header nav { gap: 4px; }
  .search-open { margin-left: 6px; }
  .search-open kbd { display: none; }
  html[data-theme='dark'] .header nav { gap: 4px; }
}
@media (max-width: 760px) {
  .header { flex-wrap: wrap; }
  .header .brand-caption { display: none; }
  .header nav { margin-left: auto; }
  .theme-switch { padding-left: 5px; }
  .theme-switch-track { width: 48px; }
  .theme-switch input:checked + .theme-switch-track .theme-switch-thumb { transform: translateX(19px); }
  html[data-theme='dark'] .header nav { width: 100%; justify-content: space-between; gap: 3px; }
  html[data-theme='dark'] .header .brand { margin: auto; }
  html[data-theme='dark'] .post-bottom { flex-wrap: wrap; gap: 7px; }
  html[data-theme='dark'] .meta { flex-wrap: wrap; }
  html[data-theme='dark'] .meta > span { white-space: nowrap; }
  html[data-theme='dark'] .read-link { margin-left: auto; }
  html[data-theme='dark'] .hero-art { width: min(330px,100%); }
}
@media (max-width: 430px) {
  .header nav { width: 100%; justify-content: space-between; }
  .header .brand.light-only { margin-inline: auto; }
}
@media (max-width: 380px) {
  html[data-theme='dark'] .post-card { grid-template-columns: 80px minmax(0,1fr); }
  html[data-theme='dark'] .post-info { padding: 14px; }
  html[data-theme='dark'] .post-info h3 { font-size: 18px; line-height: 1.5; }
  html[data-theme='dark'] .code-art { font-size: 40px; }
  html[data-theme='dark'] .art-caption { font-size: 8px; }
}
@media (prefers-reduced-motion: reduce) { .theme-switch-thumb { transition: none; } }
@media print { .theme-switch { display: none; } }
