/* v40: persistent light/dark theme, responsive bail-service highlights */
:root {
  color-scheme: light;
  --aa-v40-bg: #f7f9fd;
  --aa-v40-surface: #ffffff;
  --aa-v40-surface-soft: #eef3fb;
  --aa-v40-text: #14213c;
  --aa-v40-muted: #5f6879;
  --aa-v40-line: rgba(7, 22, 56, .14);
  --aa-v40-gold: #d6aa35;
  --aa-v40-gold-ink: #775408;
  --aa-v40-navy: #071638;
  --aa-v40-shadow: 0 22px 60px rgba(7, 22, 56, .11);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --aa-v40-bg: #050d20;
  --aa-v40-surface: #0a1833;
  --aa-v40-surface-soft: #0e2144;
  --aa-v40-text: #eef3ff;
  --aa-v40-muted: #bac6da;
  --aa-v40-line: rgba(205, 220, 255, .18);
  --aa-v40-gold: #e2bd55;
  --aa-v40-gold-ink: #f2d979;
  --aa-v40-shadow: 0 22px 60px rgba(0, 0, 0, .34);
  --background: 223 58% 7%;
  --foreground: 220 40% 96%;
  --card: 222 50% 12%;
  --card-foreground: 220 40% 96%;
  --popover: 222 50% 12%;
  --popover-foreground: 220 40% 96%;
  --secondary: 220 42% 17%;
  --secondary-foreground: 220 35% 94%;
  --muted: 220 35% 18%;
  --muted-foreground: 219 23% 74%;
  --border: 220 28% 27%;
  --input: 220 28% 27%;
  --glass-bg: rgba(9, 24, 51, .7);
  --glass-bg-strong: rgba(9, 24, 51, .88);
  --glass-border: rgba(205, 220, 255, .2);
  --ink: #eef3ff;
  --muted: #bac6da;
  --cream: #050d20;
  --paper: #0a1833;
  --line: rgba(205, 220, 255, .18);
  --v35-ink: #eef3ff;
  --v35-muted: #bac6da;
  --v35-paper: #0a1833;
  --v35-mist: #07142c;
  --v35-line: rgba(205, 220, 255, .18);
}

.aa-theme-toggle-v40 {
  appearance: none;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  min-width: 46px;
  height: 46px;
  min-height: 46px;
  margin-inline-start: .25rem;
  padding: 0;
  border: 1px solid rgba(184, 134, 36, .48) !important;
  border-radius: 14px !important;
  background: rgba(255, 255, 255, .72) !important;
  color: #071638 !important;
  box-shadow: inset 0 1px rgba(255,255,255,.65), 0 8px 24px rgba(7,22,56,.11);
  font: 800 1.1rem/1 system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease;
}
html[data-theme="dark"] .aa-theme-toggle-v40 {
  background: rgba(13, 32, 67, .92) !important;
  color: #f4d46f !important;
  border-color: rgba(226, 189, 85, .58) !important;
  box-shadow: inset 0 1px rgba(255,255,255,.1), 0 8px 26px rgba(0,0,0,.28);
}
.aa-theme-toggle-v40:hover { transform: translateY(-1px); }
.aa-theme-toggle-v40:focus-visible { outline: 3px solid #6d91ff !important; outline-offset: 3px; }
.aa-theme-toggle-v40 .aa-theme-icon-v40 { display: block; transform: translateY(-1px); }
.aa-theme-label-v40 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.v35-header-inner > .aa-theme-toggle-v40 { margin-left: auto; }
.v35-header nav .aa-theme-toggle-v40 { margin-left: .3rem; }
header > nav .aa-theme-toggle-v40 { margin-inline-start: auto; }

html[data-theme="dark"] body { background: var(--aa-v40-bg) !important; color: var(--aa-v40-text); }
html[data-theme="dark"] body > main,
html[data-theme="dark"] main.article,
html[data-theme="dark"] .article,
html[data-theme="dark"] .ai-page,
html[data-theme="dark"] .directory-main { background-color: var(--aa-v40-surface) !important; color: var(--aa-v40-text) !important; border-color: var(--aa-v40-line) !important; }
html[data-theme="dark"] main h1,
html[data-theme="dark"] main h2,
html[data-theme="dark"] main h3,
html[data-theme="dark"] .article h1,
html[data-theme="dark"] .article h2,
html[data-theme="dark"] .article h3,
html[data-theme="dark"] .section-heading h2,
html[data-theme="dark"] .directory-hero h1 { color: #f2d979 !important; }
html[data-theme="dark"] main p,
html[data-theme="dark"] main li,
html[data-theme="dark"] .article p,
html[data-theme="dark"] .article li { color: var(--aa-v40-text); }
html[data-theme="dark"] main .meta,
html[data-theme="dark"] main .crumb,
html[data-theme="dark"] main .updated,
html[data-theme="dark"] .hero-lead,
html[data-theme="dark"] .section-heading > p:last-child { color: var(--aa-v40-muted) !important; }
html[data-theme="dark"] main a:not(.button):not(.primary-action):not(.nav-cta),
html[data-theme="dark"] .article a { color: #f2d979; }
html[data-theme="dark"] .cards article,
html[data-theme="dark"] .issue-panel,
html[data-theme="dark"] .journey-card,
html[data-theme="dark"] .library-group,
html[data-theme="dark"] .library-toolbar,
html[data-theme="dark"] .prepare-grid article,
html[data-theme="dark"] .ai-card,
html[data-theme="dark"] .knowledge-metrics div,
html[data-theme="dark"] .blog-preview-v38__card,
html[data-theme="dark"] .aa-profile-bridge,
html[data-theme="dark"] .ai-trust-strip,
html[data-theme="dark"] .best-services-commitment { background: var(--aa-v40-surface) !important; color: var(--aa-v40-text) !important; border-color: var(--aa-v40-line) !important; }
html[data-theme="dark"] .ai-trust-strip a,
html[data-theme="dark"] .ai-trust-strip strong,
html[data-theme="dark"] .ai-trust-strip time { color: #f2d979 !important; }
html[data-theme="dark"] .group-heading,
html[data-theme="dark"] .information-banner,
html[data-theme="dark"] .service-standard.compact,
html[data-theme="dark"] .notice { background: var(--aa-v40-surface-soft) !important; color: var(--aa-v40-text) !important; border-color: var(--aa-v40-line) !important; }
html[data-theme="dark"] .library-link { color: var(--aa-v40-text); border-color: var(--aa-v40-line); }
html[data-theme="dark"] .library-link:hover { background: #10264e; }
html[data-theme="dark"] .library-link strong,
html[data-theme="dark"] .group-heading h3,
html[data-theme="dark"] .journey-card h3,
html[data-theme="dark"] .prepare-grid h3,
html[data-theme="dark"] .knowledge-metrics strong { color: #f2d979 !important; }
html[data-theme="dark"] .library-toolbar input,
html[data-theme="dark"] .library-toolbar select,
html[data-theme="dark"] .library-toolbar button { background: #081631; color: #eef3ff; border-color: var(--aa-v40-line); }
html[data-theme="dark"] .secondary-action { background: #0d2145; color: #eef3ff; border-color: var(--aa-v40-line); }
html[data-theme="dark"] #root > .min-h-screen { background: var(--aa-v40-bg) !important; }
html[data-theme="dark"] #root nav.fixed[style*="rgba(255, 255, 255"] { background: rgba(7, 18, 43, .92) !important; border-color: rgba(226,189,85,.25) !important; }
html[data-theme="dark"] #root [style*="color: hsl(var(--navy))"],
html[data-theme="dark"] #root [style*="color: rgb(10, 18, 55)"] { color: #f2d979 !important; }
html[data-theme="dark"] #root [style*="background: rgb(255, 255, 255)"],
html[data-theme="dark"] #root [style*="background: #fff"],
html[data-theme="dark"] #root .bg-white { background: #0a1833 !important; color: #eef3ff !important; }
html[data-theme="dark"] #root section:not(#home):not(#judgments) { border-color: var(--aa-v40-line); }
html[data-theme="dark"] #client-first-service-standards,
html[data-theme="dark"] #senior-citizen-will-assistance,
html[data-theme="dark"] .blog-preview-v38 { background: var(--aa-v40-bg) !important; color: var(--aa-v40-text); }

.bail-support-highlight-v40 {
  width: min(1180px, calc(100% - 2rem));
  margin: clamp(2rem, 5vw, 4rem) auto;
  padding: clamp(1.35rem, 3vw, 2.3rem);
  border: 1px solid rgba(214,170,53,.55);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(238,243,251,.94));
  color: #14213c;
  box-shadow: var(--aa-v40-shadow);
}
html[data-theme="dark"] .bail-support-highlight-v40 { background: linear-gradient(145deg,#0d2145,#081631); color: #eef3ff; }
.bail-support-highlight-v40 .bail-kicker-v40 { margin: 0 0 .5rem; color: #946a0d; font-size: .74rem; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
html[data-theme="dark"] .bail-support-highlight-v40 .bail-kicker-v40 { color: #f2d979; }
.bail-support-highlight-v40 h2 { margin: 0 0 .7rem; color: #071638; font: 800 clamp(1.75rem, 4vw, 3rem)/1.08 Georgia, serif; }
html[data-theme="dark"] .bail-support-highlight-v40 h2 { color: #f2d979; }
.bail-support-highlight-v40 p { max-width: 930px; margin: .55rem 0; line-height: 1.65; }
.bail-support-highlight-v40 ul { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .7rem; margin: 1.1rem 0; padding: 0; list-style: none; }
.bail-support-highlight-v40 li { padding: .8rem .9rem; border: 1px solid var(--aa-v40-line); border-radius: 12px; background: rgba(255,255,255,.58); font-size: .86rem; font-weight: 750; }
html[data-theme="dark"] .bail-support-highlight-v40 li { background: rgba(255,255,255,.055); color: #eef3ff; }
.bail-actions-v40 { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.15rem; }
.bail-actions-v40 a { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: .7rem 1rem; border: 1px solid rgba(214,170,53,.58); border-radius: 12px; color: #071638; background: #fff; font-weight: 850; text-decoration: none; }
.bail-actions-v40 a:first-child { background: linear-gradient(135deg,#e5bd4e,#bd8510); }
html[data-theme="dark"] .bail-actions-v40 a { background: #0d2145; color: #f2d979; }
html[data-theme="dark"] .bail-actions-v40 a:first-child { background: linear-gradient(135deg,#e2bd55,#b87e0b); color: #071638; }

.bail-page-v40 .bail-definition-grid-v40 { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 1rem; }
.bail-page-v40 .bail-definition-grid-v40 article { padding: 1rem 1.1rem; border: 1px solid var(--aa-v40-line); border-radius: 14px; background: var(--aa-v40-surface); }
.bail-page-v40 .urgent-v40 { border-inline-start: 5px solid #c45d43; background: #fff2ec; }
html[data-theme="dark"] .bail-page-v40 .urgent-v40 { background: #3b1b1b !important; }
.bail-page-v40 .scope-v40 { border-inline-start: 5px solid var(--aa-v40-gold); background: var(--aa-v40-surface-soft); }
.bail-page-v40 .source-list-v40 a { overflow-wrap: anywhere; }

@media (min-width: 901px) {
  .v35-header nav .aa-theme-toggle-v40 { order: 99; }
  .v35-header-inner > .aa-theme-toggle-v40 { order: 10; margin-left: .3rem; }
}
@media (max-width: 900px) {
  .v35-header-inner { gap: .55rem; }
  .v35-header-inner > .aa-theme-toggle-v40 { margin-left: auto; }
  .aa-theme-toggle-v40 { width: 46px; min-width: 46px; height: 46px; min-height: 46px; border-radius: 13px !important; }
  #root nav.fixed .aa-theme-toggle-v40 { position: absolute !important; top: calc(9px + env(safe-area-inset-top)); right: calc(68px + env(safe-area-inset-right)); z-index: 4; margin: 0; }
  .bail-support-highlight-v40 ul,
  .bail-page-v40 .bail-definition-grid-v40 { grid-template-columns: 1fr; }
}
@media (max-width: 540px) {
  .bail-support-highlight-v40 { width: calc(100% - 1rem); margin: 1.25rem auto; padding: 1.2rem .95rem; border-radius: 18px; }
  .bail-actions-v40 { display: grid; grid-template-columns: 1fr; }
  .bail-actions-v40 a { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .aa-theme-toggle-v40 { transition: none; }
}
