/* Shared appearance controls, served alongside the existing frontend assets. */
:root {
  --theme-control-bg: #ffffff;
  --theme-control-ink: #52647d;
  --theme-control-line: #d8e3f0;
  --theme-control-active: #e8f1ff;
  --theme-control-accent: #1e5fc4;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f5f8fd;
  --panel-2: #edf3fb;
  --ink: #172b48;
  --muted: #5f718a;
  --blue: #2468d6;
  --cyan: #086fa4;
  --line: rgba(36, 70, 112, .16);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --theme-control-bg: #14243b;
  --theme-control-ink: #b3c4db;
  --theme-control-line: #38506e;
  --theme-control-active: #244777;
  --theme-control-accent: #a6d8ff;
}
.site-theme-switcher {
  position: fixed;
  z-index: 90;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px;
  border: 1px solid var(--theme-control-line);
  border-radius: 999px;
  background: var(--theme-control-bg);
  color: var(--theme-control-ink);
  box-shadow: 0 6px 24px rgba(17, 42, 77, .15);
  font-family: 'Noto Sans SC', sans-serif;
}
.site-theme-switcher button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--theme-control-ink);
  font: 500 12px/1.2 'Noto Sans SC', sans-serif;
  cursor: pointer;
}
.site-theme-switcher button:hover { background: var(--theme-control-active); }
.site-theme-switcher button[aria-pressed="true"] { background: var(--theme-control-active); color: var(--theme-control-accent); }
.site-theme-switcher button:focus-visible { outline: 2px solid var(--theme-control-accent); outline-offset: 2px; }
.theme-switch-icon { font: 18px/1 Georgia, serif; }
@media (max-width: 700px) {
  .site-theme-switcher { right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); }
  .site-theme-switcher button { min-height: 38px; padding: 6px 11px; }
}

/* White surfaces, blue accents and readable text across the public site. */
html[data-theme="light"] body { background: #fff; color: var(--ink); }
html[data-theme="light"] :is(.topbar, .portal-header, .download-header.portal-header, .ac-header.portal-header) {
  background: rgba(255, 255, 255, .97);
  border-color: var(--line);
  box-shadow: 0 6px 24px rgba(34, 65, 105, .07);
}
html[data-theme="light"] :is(.nav a, .portal-nav a, .download-header.portal-header .download-nav a, .ac-header.portal-header .portal-nav a, .auth a, .auth-logout) { color: #51637d; border-color: var(--line); }
html[data-theme="light"] :is(.nav a:hover, .nav a.active, .portal-nav a:hover, .portal-nav a.active, .auth a:hover, .auth-logout:hover) { color: var(--blue); }
html[data-theme="light"] .topbar .auth a.signup { background: var(--blue); border-color: var(--blue); color: #fff; }
html[data-theme="light"] :is(.hero, .portal-hero, .case-hero, .download-hero) { background: #f4f8fd; }
html[data-theme="light"] .hero-bg,
html[data-theme="light"] .portal-hero::before,
html[data-theme="light"] .case-hero::before,
html[data-theme="light"] .release-detail-hero::before,
html[data-theme="light"] .download-hero-bg {
  background: linear-gradient(90deg, rgba(250, 252, 255, .99) 0%, rgba(247, 251, 255, .96) 39%, rgba(240, 247, 255, .76) 60%, rgba(237, 245, 255, .2) 100%), url('/assets/hero-legend-night.png') center center/cover;
}
html[data-theme="light"] .hero-bg::after,
html[data-theme="light"] .portal-hero::after,
html[data-theme="light"] .case-hero::after,
html[data-theme="light"] .release-detail-hero::after { background: linear-gradient(180deg, transparent 55%, #f4f8fd 100%); }
html[data-theme="light"] .release-detail-hero { background: #f4f8fd; }
html[data-theme="light"] .release-detail-hero::before { opacity: 1; }
html[data-theme="light"] .hero-brand-line { color: #173659; text-shadow: none; }
html[data-theme="light"] :is(.hero h1, .portal-hero h1, .case-hero h1, .release-detail-hero h1, .download-hero h1) { color: #132d4d; }
html[data-theme="light"] :is(.hero-lead, .hero-download-head, .hero-stat span, .hero-aside) { color: #526984; }
/* Keep the blue surface stable while the hovered download button moves and shines. */
html[data-theme] .hero-download,
html[data-theme] .hero-download:is(:hover, :focus-visible) {
  overflow: hidden;
  border-color: #83b4ff #2863bc #2863bc;
  background: linear-gradient(180deg, #4086ee 0%, #2c72de 46%, #205bc1 100%);
  color: #fff;
  text-shadow: 0 1px 1px rgba(8, 45, 110, .28);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .36);
  transform: translateY(0);
  transition: transform .2s ease;
}
html[data-theme] .hero-download::before { border-color: rgba(255, 255, 255, .18); background: linear-gradient(180deg, rgba(255, 255, 255, .12), transparent 38%); }
html[data-theme] .hero-download::after {
  inset: 0;
  height: auto;
  border-radius: inherit;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .28) 50%, transparent 70%);
  opacity: 0;
  transform: translateX(-100%);
}
html[data-theme] .hero-download :is(.hero-download-no, .hero-download-copy strong, .hero-download-copy small, .hero-download-copy time, b) { color: #fff; }
html[data-theme] .hero-download:is(:hover, :focus-visible) { transform: translateY(-3px); }
html[data-theme] .hero-download:is(:hover, :focus-visible)::after { animation: hero-download-sheen .75s ease-out; }
html[data-theme] .hero-download:focus-visible { outline: 2px solid #2468d6; outline-offset: 3px; }
html[data-theme] .hero-download:active { transform: translateY(1px); box-shadow: none; transition-duration: .08s; }
@keyframes hero-download-sheen {
  0% { opacity: 0; transform: translateX(-100%); }
  15% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(100%); }
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme] .hero-download:is(:hover, :focus-visible, :active) { transform: none; }
  html[data-theme] .hero-download:is(:hover, :focus-visible)::after { animation: none; }
}
html[data-theme="light"] :is(.security-band, .tutorials, .portal-process, .security-deploy, .protection-flow, .case-gallery) { background: #f5f8fd; }
html[data-theme="light"] .ai-band { background: linear-gradient(180deg, #fff, #f0f6fe); }
html[data-theme="light"] :is(.portal-page, .case-page, .protection-showcase, .release-detail-page) { background: #fff; }
html[data-theme="light"] .notice { background: #f0f5fc; }
html[data-theme="light"] .home-news-section { background: #f5f8fd; }
html[data-theme="light"] :is(.promo-track a, .notice-title) { color: #294461; }
html[data-theme="light"] .home-news-list time { color: #596d86; }
html[data-theme="light"] :is(.footer, .portal-footer, .download-footer) { background: #eef3fa; color: #526780; border-color: var(--line); }
html[data-theme="light"] :is(.footer-links strong, .portal-footer > .wrap:first-child > div a) { color: #294461; }
@media (max-width: 1080px) {
  html[data-theme="light"] .portal-nav { background: #fff; box-shadow: 0 12px 24px rgba(34, 65, 105, .1); }
}
@media (max-width: 700px) { html[data-theme="light"] .nav { background: #fff; } }

/* Component surfaces and copy for the white appearance. */
html[data-theme="light"] :is(h1, h2, h3, h4) { color: #172b48; }
html[data-theme="light"] :is(.ai-card, .portal-tool, .security-directory-card, .protection-feature-grid article, .release-detail-content-card, .release-download-panel, .news-detail, .protection-showcase-link, .case-missing-card, .case-meta > div, .case-thumb, .ac-download-panel, .download-card) {
  background: #fff;
  border-color: var(--line);
  box-shadow: 0 8px 28px rgba(34, 65, 105, .05);
}
html[data-theme="light"] :is(.ai-card:hover, .portal-tool:hover, .security-directory-card:hover, .case-thumb:hover, .case-thumb.active) { background: #edf5ff; border-color: #91b8e8; }
html[data-theme="light"] :is(.advantage-section, .edition-tabs, .ac-switch, .ac-status, .download-note) { background: #f5f8fd; }
html[data-theme="light"] :is(.contact, .portal-cta) { background: linear-gradient(110deg, #e8f1ff, #f8fbff 75%); }
html[data-theme="light"] .tutorial-feature { background: linear-gradient(135deg, rgba(232, 243, 255, .96), rgba(246, 250, 255, .92)), url('https://images.unsplash.com/photo-1542751371-adc38448a05e?auto=format&fit=crop&w=1200&q=85') center/cover; }
html[data-theme="light"] .ac-hero { background: linear-gradient(90deg, rgba(250, 252, 255, .98) 0%, rgba(245, 249, 255, .93) 45%, rgba(237, 245, 255, .35)), url('/assets/hero-legend-night.png') center center/cover; }
html[data-theme="light"] :is(.portal-hero-copy > p:last-child, .case-hero-copy > p:last-child, .release-detail-hero-inner > p:not(.portal-kicker), .download-hero-inner > div:first-child > p:last-child, .ac-hero-copy > p:last-of-type, .contact-copy p, .tutorial-feature p, .release-download-panel > span, .download-meta, .security-directory-card li, .news-detail > p, .protection-showcase-copy li) { color: #526984; }
html[data-theme="light"] :is(.portal-tool > b, .security-directory-actions a, .release-detail-meta strong, .news-list-content > strong, .news-list-meta b, .news-overview strong, .release-log-date time, .protection-showcase-copy > strong, .case-meta strong, .case-thumb strong, .case-facts strong, .brand-fallback) { color: #1c385b; }
html[data-theme="light"] .portal-page.portal-updates :is(.release-log-main > p, .release-log-main li),
html[data-theme="light"] .portal-page.portal-updates .release-log-main li::before,
html[data-theme="light"] .release-detail-page .release-detail-changes p,
html[data-theme="light"] .release-detail-page .release-detail-changes p span { color: #000; }
html[data-theme="light"] :is(.release-detail-back, .case-back, .security-no) { color: #526984; }
html[data-theme="light"] :is(.home-news-more:hover, .promo-track a:hover, .download-header.portal-header .download-nav a:hover, .ac-header.portal-header .portal-nav a:hover) { color: var(--blue); }
html[data-theme="light"] :is(.version-tab.active, .version-tab:hover, .portal-filters button:hover, .portal-filters button.active, .news-filters button:hover, .news-filters button.active, .edition-tabs button:hover, .edition-tabs button.active) { color: #205eb9; background: #e8f1ff; }
html[data-theme="light"] .btn-secondary { background: #fff; border-color: #bdcfe5; color: #275790; }
html[data-theme="light"] .btn-secondary:hover { background: #eaf2ff; border-color: var(--blue); color: var(--blue); }
html[data-theme="light"] .contact .btn-primary { background: var(--blue); color: #fff; }
html[data-theme="light"] .docs-search input { color: #172b48; background: #fff; border-color: #c6d6e9; }
html[data-theme="light"] :is(.case-facts, .case-meta > div, .case-thumb, .release-detail-meta, .release-download-panel, .security-directory-icon, .ai-orb, .download-note) { border-color: #c6d6e9; }
html[data-theme="light"] .advantage:hover { background: linear-gradient(145deg, #e8f1ff, #f5f9ff); }
html[data-theme="light"] .hero-aside i { background: #9bafc7; }

/* Account and member pages use the same semantic palette in both appearances. */
html[data-theme="light"] :is(.account-kicker, .account-admin-link a, .center-kicker, .center-user, .center-hero h1 em, .center-stat strong, .product-tabs .active, .product-tabs button.active, .legacy-news-row small, .data-panel-head a, .product-menu-title, .profile-grid a) { color: #1c64bd; }
html[data-theme="light"] :is(.account-footnote, .center-hero-meta small, .center-state, .center-stat small, .profile-grid small, .data-panel-head span, .data-row strong small, .message-row > small, .message-row p, .support-footer span) { color: #60738b; }
html[data-theme="light"] :is(.center-hero-meta strong, .product-side > strong, .data-panel-head strong, .row-right b, .message-row strong, .support-footer strong) { color: #203c5c; }
html[data-theme="light"] :is(.account-message.error, .amount.down, .pill.red) { color: #b42334; }
html[data-theme="light"] :is(.account-message.success, .message-row p.reply, .amount.up, .pill.green) { color: #14774c; }
html[data-theme="light"] .pill.blue { color: #205eb9; }
html[data-theme="light"] .pill.yellow { color: #88590b; }
html[data-theme="light"] .pill.muted { color: #60738b; }
html[data-theme="light"] :is(.account-back:hover, .account-admin-link a:hover) { color: #1c64bd; }
html[data-theme="dark"] :is(.account-header, .center-header) { background: #122139; border-color: rgba(190, 218, 255, .22); }
html[data-theme="dark"] :is(.account-panel h1, .account-aside h2) { color: #f4f8ff; }
html[data-theme="dark"] .account-agreement a { color: #8ec5ff; }
html[data-theme="dark"] .account-agreement a:hover { color: #b8deff; }
html[data-theme="dark"] :is(.protection-apply-section, .protection-application-section, .protection-upload-card, .protection-application-list article) { background: #14263e; border-color: #354d6c; }
html[data-theme="dark"] :is(.protection-apply-form input, .protection-apply-form select, .protection-apply-form textarea, .center-secondary) { background: #101c2e; color: #e5eefc; border-color: #3d5676; }
html[data-theme="dark"] :is(.protection-apply-form label, .protection-upload-card, .application-description, .upload-empty, .application-main > p) { color: #a9b9cf; }
html[data-theme="dark"] .application-heading h3 { color: #e5eefc; }
html[data-theme="dark"] :is(.protection-apply-hero h1 span, .center-secondary:hover) { color: #8ec5ff; }
html[data-theme="dark"] :is(.protection-cover-preview, .protection-screenshot-list figure, .application-cover, .protection-notice) { color: #b5c9e3; background: #203650; border-color: #3d5676; }

/* Legal pages and administration also follow the saved preference. */
:root[data-theme="dark"] {
  --bg: #101c2e;
  --panel: #172943;
  --panel-2: #1d3554;
  --ink: #f4f8ff;
  --muted: #a9b9cf;
  --blue: #438bff;
  --cyan: #5de5ff;
  --line: rgba(190, 218, 255, .22);
  --green: #69d8a3;
  --amber: #edc07e;
  --danger: #ff9d9d;
  --legal-ink: #e5eefc;
  --legal-muted: #a9b9cf;
  --legal-line: #344b68;
  --legal-blue: #8ec5ff;
  --legal-bg: #101c2e;
  --admin-bg: #101c2e;
  --surface: #16283f;
  --sidebar: #122139;
  --sidebar-2: #203650;
  --text: #e5eefc;
  --border: #344b68;
  --blue-soft: #203b60;
}
html[data-theme="dark"] :is(.legal-header, .legal-card) { background: #16283f; border-color: var(--legal-line); box-shadow: 0 12px 30px rgba(0, 0, 0, .12); }
html[data-theme="dark"] :is(.legal-card h1, .legal-card h2, .legal-card strong) { color: #e5eefc; }
html[data-theme="dark"] :is(.legal-card p, .legal-card li, .legal-footer) { color: #a9b9cf; }
html[data-theme="dark"] .legal-contact { background: #203650; color: #b5c9e3; }
html[data-theme="dark"] .legal-back:hover { color: #b8deff; }
html[data-theme="dark"] :is(.admin-topbar, .admin-card, .admin-record, .form-section, .metric-grid article, .form-panel, .login-sms-hint) { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] :is(.admin-workspace, .admin-content) { background: var(--admin-bg); }
html[data-theme="dark"] :is(.admin-shell input, .admin-shell textarea, .admin-shell select) { background: #101c2e; color: var(--text); border-color: var(--border); }
html[data-theme="dark"] :is(.login-page .form-error, .form-error) { color: #ff9d9d; }
html[data-theme="dark"] :is(.mobile-nav-toggle, .admin-btn.secondary, .icon-btn, .dashboard-band, .recent-log, .choice-options button, .iocp-group, .iocp-product-options button, .issue-result textarea, .upload-zone, .uploaded-list article, .log-table, .log-search, .row-actions button, .data-search, .order-range-dates label, .admin-toast, .home-download-admin-card, .screenshot-upload, .data-toolbar) { background: var(--surface); color: var(--text); border-color: var(--border); }
html[data-theme="dark"] :is(.log-head, .download-list-head, .protection-list-head, .admin-data-head, .product-icon-preview, .screenshot-thumb, .protection-list-cover, .case-cover > div, .case-media-editor .case-cover > div) { background: #203650; color: #b5c9e3; border-color: var(--border); }
html[data-theme="dark"] :is(.admin-shell label, .choice-field, .choice-loading, .choice-empty, .iocp-product-options small, .iocp-product-options .iocp-cap, .product-icon-editor, .screenshot-upload-head span, .protection-list-row, .admin-data-row, .login-sms-hint small) { color: #b5c9e3; }
html[data-theme="dark"] :is(.product-category-options button, .iocp-product-options button:hover, .iocp-product-options button.active, .choice-options button:hover, .upload-zone:hover) { background: #244777; color: #cae2ff; border-color: #476993; }
html[data-theme="dark"] :is(.status-good, .admin-data-row .amount-up, .issue-result strong) { color: #69d8a3; }
html[data-theme="dark"] :is(.status-bad, .admin-data-row .amount-down, .iocp-product-options .iocp-price) { color: #ff9d9d; }
html[data-theme="dark"] .issue-result { background: #153c32; border-color: #307657; }
@media print { .site-theme-switcher { display: none; } }
