/* Reach dark mode — deliberate hierarchy, legible type and restrained colour. */
html[data-theme="dark"]{
  color-scheme:dark;
  --reach-evergreen:#72C995;
  --reach-evergreen-deep:#B9E4C9;
  --reach-evergreen-soft:#2A7652;
  --reach-mint:#1A3027;
  --reach-mint-strong:#244036;
  --reach-water:#253A33;
  --reach-reed:#839C90;
  --reach-gold:#E3BC60;
  --reach-paper:#121E1A;
  --reach-canvas:#0C1613;
  --reach-line:#30473D;
  --reach-ink:#F1F5F2;
  --reach-muted:#A5B6AE;
  --mallard:var(--reach-evergreen);
  --mallard-dark:var(--reach-evergreen-deep);
  --mallard-pressed:#5DB47F;
  --navy:var(--reach-ink);
  --sage:#29453A;
  --sage-2:#1B3028;
  --cream:var(--reach-canvas);
  --white:#17251F;
  --ink:var(--reach-ink);
  --muted:var(--reach-muted);
  --border:var(--reach-line);
  --danger:#F08B84;
  --danger-soft:#3B2222;
  --success:#72C995;
  --success-soft:#193227;
  --warning:#E5C56E;
  --warning-soft:#372F1D;
  --information:#83B9D8;
  --shadow:0 8px 24px rgba(0,0,0,.22);
  --shadow-lg:0 28px 72px rgba(0,0,0,.46);
}

html[data-theme="dark"],
html[data-theme="dark"] body{background:var(--reach-canvas);color:var(--reach-ink)}
html[data-theme="dark"] button:focus-visible,
html[data-theme="dark"] input:focus-visible,
html[data-theme="dark"] textarea:focus-visible,
html[data-theme="dark"] select:focus-visible,
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] summary:focus-visible{outline-color:rgba(114,201,149,.72)}

html[data-theme="dark"] .main{
  color:var(--reach-ink);
  background:
    radial-gradient(ellipse at 92% 2%,rgba(74,125,102,.17),transparent 28rem),
    linear-gradient(180deg,#101C18 0 260px,var(--reach-canvas) 600px);
}
html[data-theme="dark"] .main::before{opacity:.12;filter:brightness(1.8)}

/* The navigation belongs to the same night canvas, separated by structure rather than hue. */
html[data-theme="dark"] .reach-sidebar{
  color:var(--reach-ink);
  background:var(--reach-canvas);
  border-right-color:#21332B;
  box-shadow:8px 0 26px rgba(0,0,0,.14);
}
html[data-theme="dark"] .sidebar-collapse-control{border-color:#30473D;color:#A5B6AE}
html[data-theme="dark"] .sidebar-collapse-control:hover{background:#192B24;color:#F1F5F2}
html[data-theme="dark"] .sidebar-section-label,
html[data-theme="dark"] .sidebar-footer-label{color:#839C90}
html[data-theme="dark"] .sidebar-section-label--management{border-top-color:#21332B}
html[data-theme="dark"] .reach-sidebar .nav button{color:#B8C6C0}
html[data-theme="dark"] .reach-sidebar .nav button:hover{background:#14251E;color:#F1F5F2}
html[data-theme="dark"] .reach-sidebar .nav button.active,
html[data-theme="dark"] .reach-sidebar .nav button.active:hover{background:#1B3028;color:#F1F5F2}
html[data-theme="dark"] .reach-sidebar .nav button.active::before{background:#72C995}
html[data-theme="dark"] .reach-sidebar .message-nav-badge{background:#72C995;color:#0C1613}
html[data-theme="dark"] .sidebar-cycle{border-color:#30473D;background:#14231D;color:#F1F5F2}
html[data-theme="dark"] .sidebar-cycle span,
html[data-theme="dark"] .sidebar-cycle small{color:#8FA198}
html[data-theme="dark"] .sidebar-cycle strong{color:#F1F5F2}
html[data-theme="dark"] .sidebar-publisher{border-bottom-color:#21332B}
html[data-theme="dark"] .reach-sidebar .sidebar-identity{color:#F1F5F2}
html[data-theme="dark"] .reach-sidebar .sidebar-account-button{color:#F1F5F2!important}
html[data-theme="dark"] .reach-sidebar .sidebar-account-button:hover{background:#14251E!important}
html[data-theme="dark"] .reach-sidebar .sidebar-account-button span small,
html[data-theme="dark"] .reach-sidebar .sidebar-account-button i{color:#8FA198}
html[data-theme="dark"] .reach-sidebar #signOutBtn:not(.account-signout-replaced){border-color:#30473D;color:#F1F5F2}

html[data-theme="dark"] .topbar h1,
html[data-theme="dark"] .page-title h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .section-head h2,
html[data-theme="dark"] .mini-head h3,
html[data-theme="dark"] .goal-card h3,
html[data-theme="dark"] .teacher-card h3,
html[data-theme="dark"] .modal h2,
html[data-theme="dark"] .stat strong,
html[data-theme="dark"] .evidence-summary .card strong,
html[data-theme="dark"] .detail-metric strong{color:var(--reach-ink)}
html[data-theme="dark"] .topbar p,
html[data-theme="dark"] .page-title p,
html[data-theme="dark"] .section-head p,
html[data-theme="dark"] .subtle,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .stat span,
html[data-theme="dark"] .goal-card p,
html[data-theme="dark"] .goal-footer,
html[data-theme="dark"] .detail-copy{color:var(--reach-muted)}
html[data-theme="dark"] .eyebrow{color:var(--reach-evergreen)}
html[data-theme="dark"] .role-pill{border-color:#426454;background:#20382F;color:#D9F0E2}

html[data-theme="dark"] .card,
html[data-theme="dark"] .goal-card,
html[data-theme="dark"] .teacher-card,
html[data-theme="dark"] .all-record-card,
html[data-theme="dark"] .message-row,
html[data-theme="dark"] .modal{
  border-color:var(--reach-line);
  background:rgba(23,37,31,.96);
  color:var(--reach-ink);
  box-shadow:var(--shadow);
}
html[data-theme="dark"] .stats .stat{
  border-color:#3D6653;
  border-top-color:var(--reach-evergreen);
  background:linear-gradient(145deg,#192822,#15221D);
}
html[data-theme="dark"] .stats .stat::after{
  border-color:rgba(114,201,149,.17);
  box-shadow:0 0 0 10px rgba(114,201,149,.045),0 0 0 22px rgba(114,201,149,.025);
}
html[data-theme="dark"] .side-stack .card:first-child,
html[data-theme="dark"] .side-stack .card:nth-child(2),
html[data-theme="dark"] .side-stack .card:nth-child(3){background:linear-gradient(145deg,#1B2D26,#16241F)}
html[data-theme="dark"] .side-stack .card:first-child{border-top-color:var(--reach-evergreen)}
html[data-theme="dark"] .side-stack .card:nth-child(2){border-top-color:var(--reach-gold)}
html[data-theme="dark"] .side-stack .card:nth-child(3){border-top-color:#789486}
html[data-theme="dark"] .activity-item{border-bottom-color:#365045}
html[data-theme="dark"] .activity-item strong{color:var(--reach-ink)}
html[data-theme="dark"] .activity-item span{color:var(--reach-muted)}
html[data-theme="dark"] .timeline-rail::after{background:#365045}
html[data-theme="dark"] .timeline-dot{box-shadow:0 0 0 4px #20372E}

html[data-theme="dark"] .emergent-section{
  --emergent-glass:rgba(23,38,32,.94);
  --emergent-edge:rgba(112,151,132,.48);
  border-color:#365347;
  background:
    radial-gradient(circle at 80% 0,rgba(83,132,108,.22),transparent 25rem),
    linear-gradient(145deg,#172721,#111E19);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.055),0 20px 55px rgba(0,0,0,.14);
}
html[data-theme="dark"] .emergent-section-head h2{color:var(--reach-ink)}
html[data-theme="dark"] .emergent-demo-label{border-color:#426454;background:#1C332A;color:#CDEAD8}
html[data-theme="dark"] .emergent-surface{
  border-color:var(--emergent-edge);
  background:var(--emergent-glass);
  color:var(--reach-ink);
  box-shadow:0 18px 42px rgba(0,0,0,.2),inset 0 1px 0 rgba(255,255,255,.06);
}
html[data-theme="dark"] button.emergent-surface:hover{
  border-color:#678979;
  background:#1B2E26;
  box-shadow:0 22px 48px rgba(0,0,0,.27),inset 0 1px 0 rgba(255,255,255,.08);
}
html[data-theme="dark"] .emergent-overline{color:var(--reach-evergreen)}
html[data-theme="dark"] .emergent-surface strong{color:var(--reach-ink)}
html[data-theme="dark"] .emergent-surface small{color:var(--reach-muted)}
html[data-theme="dark"] .emergent-action,
html[data-theme="dark"] .emergent-complete{border-color:#6E887C;background:#31483E;color:#F4F7F5}
html[data-theme="dark"] .emergent-drawer{border-color:#345044;background:rgba(20,34,28,.98);color:var(--reach-ink)}
html[data-theme="dark"] .emergent-item{border-bottom-color:#314B40}
html[data-theme="dark"] .emergent-item small,
html[data-theme="dark"] .emergent-item time{color:var(--reach-muted)}
html[data-theme="dark"] .emergent-requirement-item:hover{background:#233B31}
html[data-theme="dark"] .emergent-view-action{color:#B9E4C9}

/* Preview cards remain paper-like so the stack reads as documents in either mode. */
html[data-theme="dark"] .emergent-sheet{box-shadow:0 16px 34px rgba(0,0,0,.34),inset 0 0 0 1px rgba(255,255,255,.7);color:#13263A}

html[data-theme="dark"] .area-card,
html[data-theme="dark"] .area-card[data-tone="primary"],
html[data-theme="dark"] .area-card.primary{
  border-color:var(--reach-line)!important;
  background:linear-gradient(145deg,#192A23,#14221D)!important;
  color:var(--reach-ink)!important;
  box-shadow:var(--shadow)!important;
}
html[data-theme="dark"] .area-card:hover{border-color:#557766!important;box-shadow:0 12px 28px rgba(0,0,0,.28)!important}
html[data-theme="dark"] .area-card-copy strong{color:var(--reach-ink)!important}
html[data-theme="dark"] .area-card-copy small{color:var(--reach-muted)!important}
html[data-theme="dark"] .area-card-arrow{color:var(--reach-evergreen)!important}

html[data-theme="dark"] .segmented{border-color:var(--reach-line);background:#14231D}
html[data-theme="dark"] .segmented button{color:var(--reach-muted)}
html[data-theme="dark"] .segmented button.active{background:#29473A;color:#F4F7F5;box-shadow:0 2px 8px rgba(0,0,0,.2)}
html[data-theme="dark"] .btn-secondary{border-color:#426454;background:#20382F;color:#D9F0E2}
html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .icon-btn{border-color:#496458;background:#17251F;color:var(--reach-ink)}
html[data-theme="dark"] .btn-ghost:hover,
html[data-theme="dark"] .icon-btn:hover{border-color:var(--reach-evergreen);background:#21382F;color:#DDF2E5}
html[data-theme="dark"] .btn-danger{border-color:#C65E59;background:#A94440;color:#fff}
html[data-theme="dark"] .requirements{border-color:#386149;background:#193227;color:#BCE6CB}
html[data-theme="dark"] .requirements.warn{border-color:#746139;background:#342C1C;color:#E7CB83}

html[data-theme="dark"] .field>span{color:var(--reach-ink)}
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .staff-table select,
html[data-theme="dark"] .admin-members-table select,
html[data-theme="dark"] .permission-choice select{
  border-color:#405A4F;
  background:#111E19;
  color:var(--reach-ink);
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder{color:#7F9189;opacity:1}
html[data-theme="dark"] .field input:focus,
html[data-theme="dark"] .field textarea:focus,
html[data-theme="dark"] .field select:focus{border-color:var(--reach-evergreen);box-shadow:0 0 0 3px rgba(114,201,149,.16)}

html[data-theme="dark"] .staff-table th,
html[data-theme="dark"] .admin-members-table th,
html[data-theme="dark"] .oversight-table th,
html[data-theme="dark"] .login-activity-table th{color:#9EB0A8}
html[data-theme="dark"] .staff-table td,
html[data-theme="dark"] .admin-members-table td,
html[data-theme="dark"] .oversight-table td,
html[data-theme="dark"] .login-activity-table td{border-color:var(--reach-line)!important;background:#17251F;color:var(--reach-ink)}

html[data-theme="dark"] .badge{border-color:#40594E;background:#24362F;color:#D7E5DE}
html[data-theme="dark"] .badge.professional{border-color:#426454;background:#20382F;color:#D9F0E2}
html[data-theme="dark"] .badge.faith{border-color:#806D39;background:#392F19;color:#F0D98F}
html[data-theme="dark"] .badge.support_needed{border-color:#70413F;background:#382120;color:#F2A29D}
html[data-theme="dark"] .badge.review_due{border-color:#746139;background:#342C1C;color:#E7CB83}
html[data-theme="dark"] .progress-line{background:#2A3E35}
html[data-theme="dark"] .empty{border-color:#496458;background:rgba(23,37,31,.62);color:var(--reach-muted)}
html[data-theme="dark"] .empty strong{color:var(--reach-ink)}
html[data-theme="dark"] .detail-metric,
html[data-theme="dark"] .account-profile-panel,
html[data-theme="dark"] .account-theme-options{border-color:var(--reach-line);background:#1A2D25}
html[data-theme="dark"] .account-shortcuts button{color:var(--reach-ink)}
html[data-theme="dark"] .account-shortcuts button:hover{background:#223A30}
html[data-theme="dark"] .account-ring-options button{border-color:#17251F}

html[data-theme="dark"] .message-row.is-unread{background:linear-gradient(135deg,#1A2C25,#20372E)}
html[data-theme="dark"] .message-contact{border-color:var(--reach-line);background:#1B3028;color:var(--reach-ink)}
html[data-theme="dark"] .message-contact:hover{border-color:#557766;background:#223A30}
html[data-theme="dark"] .message-contact small,
html[data-theme="dark"] .message-meta{color:var(--reach-muted)}

html[data-theme="dark"] .digest-recipient-list{
  border-color:var(--reach-line)!important;
  background:#14231D!important;
}
html[data-theme="dark"] .digest-recipient:hover{background:#223A30!important}
html[data-theme="dark"] .oversight-privacy{border-left-color:#789486;background:#1A3027!important}
html[data-theme="dark"] .permission-choice{border-color:var(--reach-line)!important;background:#14231D!important}
html[data-theme="dark"] .permission-choice button{color:var(--reach-muted)!important}
html[data-theme="dark"] .permission-choice button:hover{color:var(--reach-ink)!important}
html[data-theme="dark"] .permission-choice button[aria-pressed="true"]{
  background:#29473A!important;
  color:#F4F7F5!important;
  box-shadow:0 2px 8px rgba(0,0,0,.2)!important;
}

html[data-theme="dark"] .login-page{
  background:
    radial-gradient(circle at 82% 8%,rgba(227,188,96,.08),transparent 21rem),
    radial-gradient(circle at 13% 86%,rgba(74,125,102,.2),transparent 25rem),
    var(--reach-canvas);
}
html[data-theme="dark"] .login-card{border-color:var(--reach-line);background:#17251F}
html[data-theme="dark"] .login-auth{background:#17251F;color:var(--reach-ink)}
html[data-theme="dark"] .login-code-destination{border-color:#405A4F;background:#1A3027;color:var(--reach-muted)}
html[data-theme="dark"] .login-code-destination strong{color:#B9E4C9}
html[data-theme="dark"] .btn-passkey{border-color:#536A60;background:#F4F7F5;color:#17251F}
html[data-theme="dark"] .modal-head{border-bottom-color:var(--reach-line)}

html[data-theme="dark"] .modal-backdrop{background:rgba(3,9,7,.72)}
html[data-theme="dark"] .notice-error{border-color:#70413F;background:#382120;color:#F3AAA5}
html[data-theme="dark"] .notice-success{border-color:#386149;background:#193227;color:#BCE6CB}

@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
  html[data-theme="dark"] .emergent-surface,
  html[data-theme="dark"] .emergent-drawer{background:#17251F}
}
