/* B-side dark mode for app pages. Activated by html[data-theme="dark"] (set by the inline boot script).
   Owner-themed profile cards (.profile-root) always keep their own light/dark palette. */
:root{ --surface:#FFFFFF; }
html[data-theme="dark"]{
  color-scheme: dark;
  --cream:#141312;      /* page bg */
  --paper:#1D1B19;      /* panels */
  --surface:#25221F;    /* cards, inputs, menus */
  --ink:#F2ECDF;        /* primary text  (15.6:1 on bg) */
  --mute:#ADA79E;       /* secondary text (7.9:1 on bg, 6.8:1 on surface) */
  --line:rgba(242,236,223,0.16);
  --ruby:#EE7B73;       /* accent text/links (6.4:1 on bg) */
  --plum:#C3B4E0; --rose:#E8A097; --olive:#B4BE84;
  --field-bg:#25221F; --field-ink:#F2ECDF; --field-placeholder:#A39D94; --field-line:rgba(242,236,223,0.28); --field-ring:#D9B66A;
}
html[data-theme="dark"] body{ background:var(--cream); color:var(--ink); }
/* keep owner-themed profile previews on their own palette */
html[data-theme="dark"] .profile-root{
  --cream:#F5EFE1; --paper:#FBF7EB; --ink:#1A1918; --mute:#6B6761; --line:rgba(26,25,24,0.12); --ruby:#C73E3A; --surface:#FFFFFF;
  --field-bg:var(--bs-bg,#FFFFFF); --field-ink:var(--bs-fg,#1A1918); --field-placeholder:var(--bs-mute,#625E58); --field-line:var(--bs-line,rgba(26,25,24,0.22));
  color-scheme: light;
}
/* feed post cards: light templates get a dark card; dark templates (vinyl/neon/library) keep theirs */
html[data-theme="dark"] .post:is(.t-editorial,.t-polaroid,.t-notebook,.t-default,.t-garden,.t-concert,.t-sunset){
  --bs-bg:#1D1B19; --bs-card-bg:#25221F; --bs-fg:#F2ECDF; --bs-mute:#ADA79E; --bs-accent:#EE7B73; --bs-line:rgba(242,236,223,0.14);
  --field-bg:#25221F; --field-ink:#F2ECDF; --field-placeholder:#A39D94; --field-line:rgba(242,236,223,0.28);
}
/* buttons: --ink/--cream swap keeps primary buttons legible (dark text on light pill) */
html[data-theme="dark"] .btn:hover, html[data-theme="dark"] .btn.primary{ background:var(--ink); color:#141312; }
html[data-theme="dark"] .btn.primary:hover{ background:var(--ruby); color:#141312; border-color:var(--ruby); }
html[data-theme="dark"] .new-msg-btn, html[data-theme="dark"] .comment-submit, html[data-theme="dark"] .post-edit-row .post-edit-save{ background:var(--ink); color:#141312; border-color:var(--ink); }
html[data-theme="dark"] .notif-badge{ background:#E5554C; color:#141312; }
html[data-theme="dark"] .notif-item.unread{ background:rgba(238,123,115,0.10); }
html[data-theme="dark"] .notif-item:hover, html[data-theme="dark"] .dm-item:hover{ background:rgba(242,236,223,0.05); }
html[data-theme="dark"] .alpha-pill{ background:#E5554C; color:#141312; }
html[data-theme="dark"] .bubble.me{ background:var(--ink); color:#141312; }
html[data-theme="dark"] .bubble.them{ background:var(--surface); color:var(--ink); }
html[data-theme="dark"] .bs-footer{ color:var(--mute) !important; border-top-color:var(--line) !important; }
html[data-theme="dark"] .np-input{ background:var(--surface); color:var(--ink); }
html[data-theme="dark"] .np-dialog{ background:var(--paper); color:var(--ink); }
html[data-theme="dark"] .np-reason{ color:var(--ruby); }
html[data-theme="dark"] input, html[data-theme="dark"] textarea, html[data-theme="dark"] select{ color-scheme: dark; }
html[data-theme="dark"] .profile-root input, html[data-theme="dark"] .profile-root textarea{ color-scheme: light; }
html[data-theme="dark"] img.logo-mark{ filter:none; }
/* theme menu (nav) */
.theme-wrap{ position:relative; display:inline-flex; }
.theme-btn{ width:36px; height:36px; border-radius:50%; border:1px solid var(--line); background:transparent; color:var(--ink); cursor:pointer; display:inline-flex; align-items:center; justify-content:center; font-size:16px; }
.theme-btn:hover{ background:rgba(127,127,127,0.12); }
.theme-btn:focus-visible, .theme-menu button:focus-visible{ outline:2px solid var(--ruby); outline-offset:2px; }
.theme-menu{ display:none; position:absolute; right:0; top:calc(100% + 6px); z-index:200; min-width:150px; background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:12px; box-shadow:0 12px 32px rgba(0,0,0,0.25); padding:4px; }
.theme-menu.open{ display:block; }
.theme-menu button{ display:flex; width:100%; align-items:center; gap:8px; min-height:40px; padding:0 12px; border:0; background:none; color:inherit; font:500 14px Inter,system-ui,sans-serif; border-radius:8px; cursor:pointer; text-align:left; }
.theme-menu button:hover{ background:rgba(127,127,127,0.12); }
.theme-menu button[aria-checked="true"]::after{ content:"✓"; margin-left:auto; color:var(--ruby); }
html[data-theme="dark"] .topbar{ background:rgba(20,19,18,0.94) !important; border-bottom-color:var(--line); }
html[data-theme="dark"] :is(.dm-avatar,.post-avatar,.post-comment-avatar,.member-avatar,.notif-avatar,.composer-avatar){ box-shadow:0 0 0 1px rgba(242,236,223,0.22); }
/* avatar initials stay light on their colored discs in dark mode (they are decorative; the name is always shown beside them) */
html[data-theme="dark"] :is(.dm-avatar,.notif-avatar,.member-avatar){ color:#FBF7EB; text-shadow:0 1px 2px rgba(0,0,0,0.45); }
/* library template secondary text on feed cards: lift to AA (both modes) */
.post.t-library{ --bs-mute:#B3AA98; }

/* ===== whole-site dark (wave 2) ===== */
:root{--line2:#E4DCC8;--on-ruby:#fff;--bar-bg:rgba(245,239,225,0.92)}
html[data-theme="dark"]{--line2:rgba(242,236,223,.18);--on-ruby:#141312;--bar-bg:rgba(20,19,18,.94);--gold:#D4B26E;--g-ink:#D4B26E}
html[data-theme="dark"] body{background-color:var(--cream);color:var(--ink)}
html[data-theme="dark"] :is(input,select,textarea):not(.profile-root *){background-color:var(--field-bg,#25221F);color:var(--ink);border-color:var(--line2)}
html[data-theme="dark"] :is(input,textarea):not(.profile-root *)::placeholder{color:var(--mute);opacity:1}
/* legal pages + mod queue alerts */
html[data-theme="dark"] .staff-banner,html[data-theme="dark"] .notice,html[data-theme="dark"] .draft-banner,html[data-theme="dark"] .alert,html[data-theme="dark"] .err-banner{background:#3A1F1C !important;color:#F6C9C3 !important;border-color:#8E3B35 !important}
html[data-theme="dark"] .badge.status-escalated{background:rgba(212,178,110,.18);color:#E2C68C}
html[data-theme="dark"] .account-status.warned{background:#3A2E12;color:#F0CF84}
html[data-theme="dark"] .account-status.suspended{background:#3B2216;color:#F2B08E}
html[data-theme="dark"] .account-status.banned{background:#F2ECDF;color:#141312}
html[data-theme="dark"] .mod-state{color:#F2A49C !important}
html[data-theme="dark"] .badge.urgent{color:#141312}
/* nav bars on signed-out pages */
html[data-theme="dark"] body>nav,html[data-theme="dark"] body>.nav,html[data-theme="dark"] body>header{background-color:var(--bar-bg)}
html[data-theme="dark"] .nav-login{border-color:var(--ink);color:var(--ink)}
html[data-theme="dark"] .nav-login:hover{background:var(--ink);color:var(--cream)}
/* generic modal / toast / dropdown chrome */
html[data-theme="dark"] .modal,html[data-theme="dark"] .modal-card,html[data-theme="dark"] .dialog,html[data-theme="dark"] .sheet,html[data-theme="dark"] .notif-dropdown,html[data-theme="dark"] .notif-panel,html[data-theme="dark"] .dropdown,html[data-theme="dark"] .menu{background-color:var(--surface);color:var(--ink);border-color:var(--line)}
html[data-theme="dark"] .toast{background:var(--ink);color:var(--cream)}
html[data-theme="dark"] .profile-root .modal,html[data-theme="dark"] .profile-root .menu,html[data-theme="dark"] .profile-root .dropdown{background-color:#FFFFFF;color:#1A1918}
/* landing: inverted sections stay dark in both modes */
html[data-theme="dark"] .manifesto,html[data-theme="dark"] .final{--cream:#F5EFE1;--paper:#FBF7EB;--ink:#0B0A09;--mute:#B5AEA2;--ruby:#EE7B73;background:#0B0A09;color:#F5EFE1}
html[data-theme="dark"] .manifesto .section-label{color:#EE9A90}
html[data-theme="dark"] .manifesto .item{border-top-color:rgba(242,236,223,.15)}
/* AA: empty Top 8 tiles (all templates, both modes) */
.profile-root .ph-top8-tile.empty{opacity:1}
.profile-root .ph-top8-tile.empty .ph-top8-avatar{opacity:.45}
.profile-root .ph-top8-tile.empty .ph-top8-name{color:var(--bs-mute,var(--bs-fg));font-weight:500}
/* AA in light mode (pre-existing): deeper ruby for small text, olive accent, landing numerals */
html:not([data-theme="dark"]){--ruby:#B8342F;--olive:#5E6838}
html:not([data-theme="dark"]) .post.t-garden,html:not([data-theme="dark"]) .post[data-accent="olive"]{--bs-accent:#5E6838}
.manifesto .item .no{color:#EE7B73}
/* P0 (iOS): theme menu labels invisible + clipped. Solid explicit colours, beats page button rules. */
.theme-wrap .theme-menu{ background:#FFFFFF !important; color:#1A1918 !important; border:1px solid rgba(26,25,24,0.18); z-index:1000; opacity:1; -webkit-backdrop-filter:none; backdrop-filter:none; }
.theme-wrap .theme-menu button,.theme-wrap .theme-menu button:hover,.theme-wrap .theme-menu button:focus,.theme-wrap .theme-menu button:active{ -webkit-appearance:none; appearance:none; color:#1A1918 !important; -webkit-text-fill-color:#1A1918; background-color:transparent; border:0 !important; box-shadow:none; opacity:1; white-space:nowrap; }
.theme-wrap .theme-menu button:hover,.theme-wrap .theme-menu button:focus-visible{ background-color:rgba(26,25,24,0.08); }
.theme-wrap .theme-menu button[aria-checked="true"]::after{ color:#A8322E; -webkit-text-fill-color:#A8322E; }
html[data-theme="dark"] .theme-wrap .theme-menu{ background:#25221F !important; color:#F2ECDF !important; border-color:rgba(242,236,223,0.22); }
html[data-theme="dark"] .theme-wrap .theme-menu button{ color:#F2ECDF !important; -webkit-text-fill-color:#F2ECDF; }
html[data-theme="dark"] .theme-wrap .theme-menu button:hover,html[data-theme="dark"] .theme-wrap .theme-menu button:focus-visible{ background-color:rgba(242,236,223,0.10); }
html[data-theme="dark"] .theme-wrap .theme-menu button[aria-checked="true"]::after{ color:#FF8A80; -webkit-text-fill-color:#FF8A80; }
