:root:not(.reader-document) {
  --surface: #fff;
  --on-accent: #fff;
}
:root[data-theme="dark"]:not(.reader-document) {
  color-scheme: dark;
  --ink: #e3f2e9;
  --text: #d0e1d7;
  --muted: #adc2b6;
  --green: #9adaba;
  --deep: #24483a;
  --mint: #233e32;
  --paper: #141e1b;
  --surface: #1c2923;
  --line: #3d5448;
  --danger: #ffb1a7;
  --on-accent: #102b1e;
}

/* The native menu exposes all three choices to touch, keyboard and screen readers. */
html[data-roshan-ios] select[data-appearance-picker],
html[data-roshan-ios] .studio-layout > .site-header,
html[data-roshan-ios] .studio-reader :is(.studio-navigation, .sample-studio-bar, .local-import-hint),
html[data-roshan-ios] .studio-bar > div:first-child { display: none; }
html[data-roshan-ios] .studio-layout {
  display: flex; flex-direction: column; height: 100dvh; min-height: 100dvh;
}
html[data-roshan-ios] .studio-reader { flex: 1; display: flex; flex-direction: column; min-height: 0; }
html[data-roshan-ios] .studio-reader .reader-frame { flex: 1 0 12rem; min-height: 12rem; height: 0; }
html[data-roshan-ios] .studio-bar { padding: .4rem .75rem; gap: .25rem; }

select.appearance-picker {
  width: auto;
  max-width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--line, var(--border));
  border-radius: .55rem;
  padding: .25rem .45rem;
  background: var(--surface);
  background-image: none;
  color: var(--text);
  font: 600 .825rem/1.3 system-ui, sans-serif;
  appearance: auto;
  cursor: pointer;
}
@media (max-width: 760px) {
  .header-inner .main-nav { grid-template-columns: 1.2fr 1.1fr .7fr auto; }
}
@media (max-width: 360px) {
  .main-nav select.appearance-picker { padding-inline: .1rem; }
}
[data-theme="dark"] :focus-visible { outline-color: #a5dec4; }
[data-theme="dark"] :is(.site-header, .surface, .stat, .empty-state, .price-card, .admin-card, .badge,
    .search-field input, .filter-pill, .catalog-scope button, .upload-icon, .field input, .field textarea,
    .button.secondary, .button.danger, .account-form input:not([type="hidden"])) {
  background-color: var(--surface);
}
[data-theme="dark"] :is(.surface, .price-card, .empty-state, .upload-band, .upload-icon, .shelf-icon) {
  border-color: var(--line);
  box-shadow: none;
}
[data-theme="dark"] :is(.workspace-sections, .studio-bar, .order-box, .plan-toggle, .loading-book,
    .account-form input[readonly], .recovery-code) { background: var(--mint); }
[data-theme="dark"] :is(.filter-pill, .catalog-scope button)[aria-pressed="true"],
[data-theme="dark"] .notice { background: var(--mint); border-color: var(--line); }
[data-theme="dark"] .notice.warning { background: #302b1c; color: #f5db9d; border-color: #675b38; }
[data-theme="dark"] :is(.notice.error, .auth-page [role="alert"]) {
  background: #382522; color: #ffc7b8; border-color: #795248;
}
[data-theme="dark"] .price-card.plus { background: linear-gradient(150deg, var(--mint), var(--surface) 65%); border-color: var(--green); }
[data-theme="dark"] :is(.plan-toggle button[aria-pressed="true"], .workspace-sections a:hover,
    .workspace-sections a:focus-visible, .auth-page main, .account-confirmation .actions a,
    .provider-options a, .book-save) { background: var(--surface); color: var(--ink); }
[data-theme="dark"] :is(.account-confirmation .actions a:hover, .provider-options a:hover,
    .button.secondary:hover:not(:disabled)) { background: var(--mint); color: var(--ink); }
[data-theme="dark"] :is(.button:not(.secondary, .ghost, .danger), .register-link, .auth-page button) {
  color: var(--on-accent);
  background: var(--green);
}
[data-theme="dark"] :is(.button:not(.secondary, .ghost, .danger), .register-link, .auth-page button):hover:not(:disabled) {
  background: #b5eacb;
}
[data-theme="dark"] :is(.catalog-bar select, .persian-brand) { color: var(--text); }
[data-theme="dark"] .catalog-bar select { background-color: var(--surface); }
[data-theme="dark"] .provider-options button:disabled { background: var(--surface); color: var(--muted); }
[data-theme="dark"] .reader-frame { background: var(--paper); }
[data-theme="dark"] .delete-account-reading { color: var(--danger); }
[data-theme="dark"] .private-pdf .button.ghost:hover { background: #382522; }
[data-theme="dark"].reader-document :is(.primary, .brand-mark) { color: #211a31; }
[data-theme="dark"].reader-document .status-banner.error { color: #ffb1a7; }

.provider-options a.apple-sign-in, .workspace-welcome a.apple-sign-in {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 46px;
  border: 0;
  padding: 0;
  background: transparent;
}
.apple-sign-in img { display: block; max-width: 100%; height: auto; }
@media (max-width: 480px) {
  .workspace-welcome .apple-sign-in { grid-column: 1 / -1; }
}
