/* v36: enforce readable contrast by page region; nested elements are transparent unless controls */
html[data-theme="dark"] { color-scheme: dark !important; }
html[data-theme="dark"] body { background: #0b111a !important; color: #f3f6fb !important; }
html[data-theme="dark"] body main,
html[data-theme="dark"] body main .content-area,
html[data-theme="dark"] body main .content-area.wrap {
  background: #0b111a !important; color: #f3f6fb !important;
}
html[data-theme="dark"] body main .content-area .panel,
html[data-theme="dark"] body main .content-area .library-panel,
html[data-theme="dark"] body main .content-area .library-citation-panel,
html[data-theme="dark"] body main .content-area .last-read-panel,
html[data-theme="dark"] body main .content-area .saved-item,
html[data-theme="dark"] body main .content-area .matrix-toolbar,
html[data-theme="dark"] body main .content-area .table-scroll {
  background: #172333 !important; background-color: #172333 !important;
  color: #f3f6fb !important; border-color: #43546a !important;
}
html[data-theme="dark"] body main .content-area .notice,
html[data-theme="dark"] body main .content-area .result-box,
html[data-theme="dark"] body main .content-area .access-status,
html[data-theme="dark"] body main .content-area .status-legend-item {
  background: #202f42 !important; background-color: #202f42 !important;
  color: #f3f6fb !important; border-color: #52657d !important;
}
html[data-theme="dark"] body main .content-area .status-green,
html[data-theme="dark"] body main .content-area .legend-green { background: #153c2c !important; }
html[data-theme="dark"] body main .content-area .status-red,
html[data-theme="dark"] body main .content-area .legend-red { background: #49232a !important; }
html[data-theme="dark"] body main .content-area .status-yellow,
html[data-theme="dark"] body main .content-area .legend-yellow { background: #4a3b17 !important; }
html[data-theme="dark"] body main .content-area .panel *,
html[data-theme="dark"] body main .content-area .saved-item *,
html[data-theme="dark"] body main .content-area .notice *,
html[data-theme="dark"] body main .content-area .result-box *,
html[data-theme="dark"] body main .content-area .access-status *,
html[data-theme="dark"] body main .content-area .status-legend-item * {
  color: #f3f6fb !important;
  border-color: #43546a !important;
}
html[data-theme="dark"] body main .content-area h1,
html[data-theme="dark"] body main .content-area h2,
html[data-theme="dark"] body main .content-area h3,
html[data-theme="dark"] body main .content-area h4,
html[data-theme="dark"] body main .content-area p,
html[data-theme="dark"] body main .content-area label,
html[data-theme="dark"] body main .content-area li,
html[data-theme="dark"] body main .content-area strong,
html[data-theme="dark"] body main .content-area span,
html[data-theme="dark"] body main .content-area small,
html[data-theme="dark"] body main .content-area td,
html[data-theme="dark"] body main .content-area th {
  color: #f3f6fb !important;
}
html[data-theme="dark"] body main .content-area .small-note,
html[data-theme="dark"] body main .content-area .muted,
html[data-theme="dark"] body main .content-area .note-saved {
  color: #c2cede !important;
}
html[data-theme="dark"] body main .content-area input,
html[data-theme="dark"] body main .content-area select,
html[data-theme="dark"] body main .content-area textarea,
html[data-theme="dark"] body main .content-area .citation-output {
  background: #080e16 !important; background-color: #080e16 !important;
  color: #ffffff !important; -webkit-text-fill-color: #ffffff !important;
  border: 1px solid #71839a !important;
}
html[data-theme="dark"] body main .content-area input::placeholder,
html[data-theme="dark"] body main .content-area textarea::placeholder {
  color: #bdcadd !important; -webkit-text-fill-color: #bdcadd !important; opacity: 1 !important;
}
html[data-theme="dark"] body main .content-area .literature-table,
html[data-theme="dark"] body main .content-area .literature-table td,
html[data-theme="dark"] body main .content-area .literature-table tbody tr {
  background: #172333 !important; background-color: #172333 !important;
  color: #f3f6fb !important; border-color: #43546a !important;
}
html[data-theme="dark"] body main .content-area .literature-table th {
  background: #30445d !important; background-color: #30445d !important; color: #ffffff !important;
}
html[data-theme="dark"] body main .content-area a:not(.button) {
  color: #a6ceff !important; -webkit-text-fill-color: #a6ceff !important;
}
html[data-theme="dark"] body main .content-area button,
html[data-theme="dark"] body main .content-area .button {
  color: #ffffff !important; -webkit-text-fill-color: #ffffff !important;
}
html[data-theme="dark"] body main .content-area .button.primary,
html[data-theme="dark"] body main .content-area button.primary { background: #1769d2 !important; }
html[data-theme="dark"] body main .content-area .button.secondary,
html[data-theme="dark"] body main .content-area button.secondary { background: #2a3b50 !important; }
.saved-apa7-citation, .saved-all-citations, .apa7-citation-cell, .all-citations-cell {
  overflow-wrap: anywhere; white-space: normal; line-height: 1.5;
}
.saved-all-citations { margin-top: .5rem; font-size: .92rem; }
.all-citations-cell { min-width: 300px; max-width: 520px; }
@media print {
  html[data-theme="dark"] body, html[data-theme="dark"] body * {
    color: #111 !important; background: #fff !important; -webkit-text-fill-color: #111 !important;
  }
  .site-header, .site-footer, .theme-toggle, .matrix-toolbar, .library-actions { display: none !important; }
}


/* v52: aggregate research reading progress indicator */
.research-progress-panel{margin:1.25rem 0;padding:1.1rem 1.2rem;border:1px solid var(--border-color,#d7dee8);border-radius:16px;background:var(--panel-bg,#f8fafc)}
.research-progress-heading{display:flex;align-items:center;justify-content:space-between;gap:1rem}
.research-progress-heading h2{margin:0 0 .3rem;font-size:1.2rem}
.research-progress-heading .small-note{margin:.2rem 0 .7rem}
#research-progress-percent{font-size:1.6rem;white-space:nowrap;font-variant-numeric:tabular-nums}
.research-progress-track{height:14px;border-radius:999px;overflow:hidden;background:#dfe6ef;border:1px solid #c8d3e1}
#research-progress-fill{display:block;height:100%;width:0;border-radius:999px;background:linear-gradient(90deg,#3982d8,#25a879);transition:width .25s ease}
.research-progress-stats{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem 1rem;margin-top:.8rem}
.progress-stat{display:inline-flex;align-items:center;gap:.35rem;padding:.35rem .6rem;border-radius:999px;font-size:.9rem;background:#edf2f7}
.progress-stat strong{font-size:1rem}
.progress-to-read{border-left:4px solid #8795a8}.progress-reading{border-left:4px solid #d6a12b}.progress-completed{border-left:4px solid #26976d}
.progress-method{font-size:.82rem;opacity:.8;flex:1 1 260px}
html[data-theme="dark"] .research-progress-panel{background:#172333;border-color:#43546a}
html[data-theme="dark"] .research-progress-track{background:#29384b;border-color:#52657d}
html[data-theme="dark"] .progress-stat{background:#26364a;color:#f3f6fb}
@media(max-width:600px){.research-progress-panel{padding:.9rem}.research-progress-heading{align-items:flex-start}.research-progress-heading h2{font-size:1.05rem}.research-progress-stats{gap:.45rem}.progress-method{flex-basis:100%}}
@media(prefers-reduced-motion:reduce){#research-progress-fill{transition:none}}

/* v53: polished, segmented Literature Matrix reading progress dashboard */
.research-progress-panel{margin:1.35rem 0;padding:1.35rem 1.4rem;border:1px solid #dce4ee;border-radius:18px;background:linear-gradient(135deg,#fff 0%,#f6f9fc 100%);box-shadow:0 8px 24px rgba(26,47,75,.06)}
.research-progress-heading{display:flex;align-items:center;justify-content:space-between;gap:1.25rem;margin-bottom:1.1rem}
.progress-eyebrow{display:block;margin-bottom:.35rem;color:#52718e;font-size:.7rem;font-weight:800;letter-spacing:.13em}
.research-progress-heading h2{margin:0 0 .3rem;font-size:1.28rem;letter-spacing:-.025em}
.research-progress-heading .small-note{margin:0;color:#64748b;line-height:1.5}
.progress-percent-wrap{display:flex;flex-direction:column;align-items:flex-end;flex-shrink:0}
#research-progress-percent{font-size:2rem;line-height:1.05;font-weight:800;letter-spacing:-.055em;color:#24364b;font-variant-numeric:tabular-nums}
.progress-percent-wrap>span{margin-top:.22rem;color:#6b7c90;font-size:.76rem;font-weight:700;text-transform:uppercase;letter-spacing:.08em}
.research-progress-track{display:flex;gap:4px;width:100%;height:16px;overflow:hidden;border-radius:999px;background:#e8edf3;box-shadow:inset 0 1px 2px rgba(15,23,42,.08)}
.progress-segment{display:block;height:100%;width:0;transition:width .25s ease}
.progress-segment:first-child{border-radius:999px 0 0 999px}.progress-segment:last-child{border-radius:0 999px 999px 0}
.segment-completed{background:#6a9f2b}.segment-reading{background:#4789e8}.segment-to-read{background:repeating-linear-gradient(135deg,#e5e9ee 0,#e5e9ee 4px,#aeb8c4 4px,#aeb8c4 6px)}
.research-progress-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr)) minmax(125px,.85fr);gap:.7rem;margin-top:1rem}
.progress-stat,.progress-total{display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto auto;align-items:center;column-gap:.55rem;row-gap:.15rem;min-width:0;padding:.75rem .85rem;border:1px solid #e1e7ef;border-radius:12px;background:#fff}
.progress-dot{grid-row:1/3;width:10px;height:10px;border-radius:3px}
.progress-completed .progress-dot{background:#6a9f2b}.progress-reading .progress-dot{background:#4789e8}.progress-to-read .progress-dot{background:repeating-linear-gradient(135deg,#aeb8c4 0,#aeb8c4 2px,#eef1f4 2px,#eef1f4 4px)}
.progress-stat-label,.progress-total>span{color:#64748b;font-size:.78rem;font-weight:600}
.progress-stat strong,.progress-total strong{grid-column:2;grid-row:2;font-size:1.25rem;line-height:1.2;color:#24364b;font-variant-numeric:tabular-nums}
.progress-total{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:.15rem;background:#f0f5fa;border-color:#dbe5ef}
.progress-total strong{font-size:1.45rem}
.progress-method{display:block;margin:.8rem 0 0;color:#718096;font-size:.78rem;line-height:1.45}
html[data-theme="dark"] .research-progress-panel{background:linear-gradient(135deg,#172333 0%,#1c2c40 100%);border-color:#43546a;box-shadow:0 8px 24px rgba(0,0,0,.15)}
html[data-theme="dark"] .progress-eyebrow{color:#9dc6f2}html[data-theme="dark"] #research-progress-percent{color:#f3f6fb}html[data-theme="dark"] .progress-percent-wrap>span,html[data-theme="dark"] .research-progress-heading .small-note,html[data-theme="dark"] .progress-stat-label,html[data-theme="dark"] .progress-total>span,html[data-theme="dark"] .progress-method{color:#c2cede}
html[data-theme="dark"] .progress-stat{background:#202f42;border-color:#43546a}html[data-theme="dark"] .progress-stat strong,html[data-theme="dark"] .progress-total strong{color:#f3f6fb}html[data-theme="dark"] .progress-total{background:#26384d;border-color:#43546a}
@media(max-width:700px){.research-progress-panel{padding:1rem;border-radius:15px}.research-progress-heading h2{font-size:1.1rem}.progress-eyebrow{font-size:.64rem}.research-progress-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.progress-stat,.progress-total{padding:.7rem}.progress-total{min-height:75px}}
@media(max-width:390px){.research-progress-heading{gap:.5rem}.progress-percent-wrap{align-self:flex-start}#research-progress-percent{font-size:1.65rem}.progress-stat-label{font-size:.72rem}}
@media(prefers-reduced-motion:reduce){.progress-segment{transition:none}}

/* v54 — Literature Matrix visual polish: clearer hierarchy, calmer controls, and readable table framing. */
.content-area:has(.literature-table) > .panel{padding:clamp(1rem,2.4vw,2rem);border:1px solid var(--line,#dce4ee);border-radius:20px;box-shadow:0 12px 34px rgba(25,48,77,.07)}
.content-area:has(.literature-table) .export-citation-style-picker{margin:0 0 1rem;padding:1rem 1.1rem;border-radius:14px;border-color:#dbe5f0;background:linear-gradient(135deg,#f8fbff,#fff)}
.content-area:has(.literature-table) .export-citation-style-picker label{color:#24364b;font-size:.93rem}
.content-area:has(.literature-table) .research-progress-panel{margin:1rem 0 1.15rem}
.content-area:has(.literature-table) .matrix-filter-toolbar{padding:1rem;border-radius:14px;background:#f6f9fd;border-color:#dce6f1}
.content-area:has(.literature-table) .matrix-filter-toolbar label{color:#33465d;font-size:.88rem}
.content-area:has(.literature-table) .matrix-filter-toolbar input:focus-visible,.content-area:has(.literature-table) .matrix-filter-toolbar select:focus-visible,.content-area:has(.literature-table) .export-citation-style-picker select:focus-visible{outline:3px solid rgba(59,130,246,.28);outline-offset:1px;border-color:#4789e8}
.content-area:has(.literature-table) .matrix-selection-toolbar{padding:.15rem 0 .75rem}
.content-area:has(.literature-table) .matrix-selection-toolbar .button{border-radius:10px}
.content-area:has(.literature-table) .matrix-toolbar{padding:1rem;gap:.55rem;border:1px solid #dce6f1;border-radius:14px;background:#fbfcfe}
.content-area:has(.literature-table) .matrix-toolbar p{font-size:.85rem;font-weight:700;color:#40546b}
.content-area:has(.literature-table) .matrix-toolbar .button{border-radius:9px;min-height:40px}
.content-area:has(.literature-table) .table-scroll{border-radius:14px;border-color:#dce4ee;box-shadow:0 4px 14px rgba(25,48,77,.04)}
.content-area:has(.literature-table) .literature-table{font-size:12.5px}
.content-area:has(.literature-table) .literature-table th{padding:13px 12px;background:#edf3fa;color:#24364b;font-size:.72rem;letter-spacing:.035em;text-transform:uppercase;border-bottom:1px solid #d4dfeb}
.content-area:has(.literature-table) .literature-table td{padding:13px 12px;line-height:1.6}
.content-area:has(.literature-table) .literature-table tbody tr:nth-child(even){background:#f9fbfd}
.content-area:has(.literature-table) .literature-table tbody tr:hover{background:#eff6ff}
.content-area:has(.literature-table) .literature-table td a{font-weight:600;text-decoration-thickness:1px;text-underline-offset:2px}
.content-area:has(.literature-table) .literature-table textarea,.content-area:has(.literature-table) .literature-table select{border-color:#d5dfeb;border-radius:8px}
.content-area:has(.literature-table) .panel > .small-note:last-child{margin-top:1rem;line-height:1.65}
html[data-theme="dark"] .content-area:has(.literature-table) > .panel{background:#111c2a;border-color:#34465c;box-shadow:0 12px 34px rgba(0,0,0,.18)}
html[data-theme="dark"] .content-area:has(.literature-table) .export-citation-style-picker{background:linear-gradient(135deg,#172333,#1b293b);border-color:#34465c}
html[data-theme="dark"] .content-area:has(.literature-table) .export-citation-style-picker label,html[data-theme="dark"] .content-area:has(.literature-table) .matrix-filter-toolbar label{color:#e2eaf4}
html[data-theme="dark"] .content-area:has(.literature-table) .matrix-filter-toolbar{background:#172333;border-color:#34465c}
html[data-theme="dark"] .content-area:has(.literature-table) .matrix-toolbar{background:#172333;border-color:#34465c}
html[data-theme="dark"] .content-area:has(.literature-table) .matrix-toolbar p{color:#d4deeb}
html[data-theme="dark"] .content-area:has(.literature-table) .table-scroll{border-color:#34465c}
html[data-theme="dark"] .content-area:has(.literature-table) .literature-table th{background:#25364b;color:#edf4fc;border-color:#3b4f66}
html[data-theme="dark"] .content-area:has(.literature-table) .literature-table tbody tr:nth-child(even){background:#172333}
html[data-theme="dark"] .content-area:has(.literature-table) .literature-table tbody tr:hover{background:#24364c}
html[data-theme="dark"] .content-area:has(.literature-table) .literature-table textarea,html[data-theme="dark"] .content-area:has(.literature-table) .literature-table select{border-color:#465a72}
@media(max-width:700px){.content-area:has(.literature-table) > .panel{padding:.8rem;border-radius:15px}.content-area:has(.literature-table) .matrix-toolbar{padding:.8rem}.content-area:has(.literature-table) .matrix-toolbar .button{justify-content:center}.content-area:has(.literature-table) .matrix-selection-toolbar{padding-bottom:.35rem}}
@media(prefers-reduced-motion:reduce){.content-area:has(.literature-table) *{scroll-behavior:auto!important}}

/* v55: detailed research metrics, status quick-filters, and save feedback */
.research-detail-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:.7rem;margin:1rem 0 .45rem}
.research-detail-stats>div{display:flex;flex-direction:column;gap:.35rem;padding:.8rem 1rem;border:1px solid #dce4ee;border-radius:12px;background:rgba(255,255,255,.72)}
.research-detail-stats span{font-size:.78rem;color:#5b6b80}.research-detail-stats strong{font-size:1.25rem;color:#183b63}
.matrix-status-filters{display:flex;align-items:center;flex-wrap:wrap;gap:.5rem;margin:1rem 0 .6rem}.matrix-status-filters>span{font-size:.88rem;font-weight:700;margin-right:.25rem}.matrix-status-filters button.active{background:#1d4ed8;color:#fff;border-color:#1d4ed8}
.matrix-save-status{font-size:.82rem;color:#26734d;padding:.45rem .7rem;margin:.35rem 0 .8rem;border-left:3px solid #22a06b;background:#effaf4;border-radius:0 8px 8px 0}
html[data-theme="dark"] .research-detail-stats>div{background:#1b2a3b;border-color:#43546a}html[data-theme="dark"] .research-detail-stats span{color:#c0ccda}html[data-theme="dark"] .research-detail-stats strong{color:#b7d7ff}html[data-theme="dark"] .matrix-save-status{background:#153326;color:#a9f0c8}
@media(max-width:700px){.research-detail-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.matrix-status-filters{align-items:stretch}.matrix-status-filters button{flex:1 1 auto}}
@media(max-width:420px){.research-detail-stats>div{padding:.65rem}.research-detail-stats strong{font-size:1.05rem}}


/* v56 smart-tag filtering and reference-manager export controls */
#matrix-tag-filter { min-width: 150px; }
.matrix-filter-toolbar { align-items: end; }
.matrix-filter-toolbar label { min-width: 180px; }
@media (max-width: 640px) { .matrix-filter-toolbar label, #matrix-tag-filter { width: 100%; min-width: 0; } }

/* v57 research project field */
.paper-metadata-editor label{display:flex;flex-direction:column;gap:.35rem;min-width:180px;flex:1}.paper-metadata-editor input{width:100%;max-width:100%;box-sizing:border-box}.matrix-filter-toolbar label{min-width:180px}

/* v62.2: close remaining light-surface gaps across all pages in dark mode */
html[data-theme="dark"] body .site-header,
html[data-theme="dark"] body .main-nav,
html[data-theme="dark"] body .site-footer,
html[data-theme="dark"] body .home-bottom,
html[data-theme="dark"] body .home-tool-card,
html[data-theme="dark"] body .contact-card,
html[data-theme="dark"] body .faq-item,
html[data-theme="dark"] body .channel-button,
html[data-theme="dark"] body .research-progress-panel,
html[data-theme="dark"] body .progress-stat,
html[data-theme="dark"] body .progress-total,
html[data-theme="dark"] body .citation-output,
html[data-theme="dark"] body .library-backup-panel,
html[data-theme="dark"] body .library-citation-panel,
html[data-theme="dark"] body .last-read-panel,
html[data-theme="dark"] body .paper-note,
html[data-theme="dark"] body .matrix-toolbar,
html[data-theme="dark"] body .table-scroll {
  background: #172333 !important;
  background-color: #172333 !important;
  color: #f3f6fb !important;
  border-color: #43546a !important;
}
html[data-theme="dark"] body .hero,
html[data-theme="dark"] body .page-hero,
html[data-theme="dark"] body .trust-section,
html[data-theme="dark"] body .section,
html[data-theme="dark"] body .cta,
html[data-theme="dark"] body .home-tools,
html[data-theme="dark"] body .faq-section,
html[data-theme="dark"] body .content-area {
  background: #0b111a !important;
  background-color: #0b111a !important;
  color: #f3f6fb !important;
}
html[data-theme="dark"] body .home-tool-card *,
html[data-theme="dark"] body .contact-card *,
html[data-theme="dark"] body .faq-item *,
html[data-theme="dark"] body .channel-button *,
html[data-theme="dark"] body .research-progress-panel *,
html[data-theme="dark"] body .progress-stat *,
html[data-theme="dark"] body .progress-total *,
html[data-theme="dark"] body .library-backup-panel *,
html[data-theme="dark"] body .library-citation-panel *,
html[data-theme="dark"] body .last-read-panel * {
  color: #f3f6fb !important;
  border-color: #43546a !important;
}
html[data-theme="dark"] body .home-tool-card a,
html[data-theme="dark"] body .contact-card a,
html[data-theme="dark"] body .faq-item a,
html[data-theme="dark"] body .site-footer a,
html[data-theme="dark"] body .main-nav a {
  color: #a6ceff !important;
}
html[data-theme="dark"] body .contact-form input,
html[data-theme="dark"] body .contact-form select,
html[data-theme="dark"] body .contact-form textarea,
html[data-theme="dark"] body .citation-tools select,
html[data-theme="dark"] body .form-row input,
html[data-theme="dark"] body .form-row select,
html[data-theme="dark"] body .field,
html[data-theme="dark"] body .literature-table textarea {
  background: #080e16 !important;
  background-color: #080e16 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border-color: #71839a !important;
}
html[data-theme="dark"] body .progress-eyebrow,
html[data-theme="dark"] body .research-progress-heading .small-note,
html[data-theme="dark"] body .progress-stat-label,
html[data-theme="dark"] body .progress-total > span,
html[data-theme="dark"] body .progress-percent-wrap > span {
  color: #c2cede !important;
}


/* v65: consistent dark-mode surfaces, contact/message area and readable controls */
html[data-theme="dark"] body :is(
  .contact-grid, .contact-card, .contact-form, .contact-hero,
  .channel-button, .support-card, .support-panel, .message-us,
  .message-us-card, .contact-method, .contact-method-card,
  .form-card, .form-panel, .feedback-card, .faq-item,
  .home-tool-card, .home-bottom, .site-footer, .footer-inner,
  .research-progress-panel, .progress-stat, .progress-total,
  .library-backup-panel, .library-citation-panel, .last-read-panel,
  .paper-note, .citation-output, .matrix-toolbar, .table-scroll,
  .panel, .card, .notice, .result-box, .access-status, .status-legend-item
) {
  background-color: #172333 !important;
  color: #f3f6fb !important;
  border-color: #43546a !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
html[data-theme="dark"] body :is(
  .contact-hero, .contact-grid, .contact-section, .faq-section,
  .home-tools, .home-bottom, .section, .content-area, .page-hero
) {
  color: #f3f6fb !important;
}
html[data-theme="dark"] body :is(
  .contact-card, .contact-card *, .contact-form, .contact-form *,
  .channel-button, .channel-button *, .support-card, .support-card *,
  .support-panel, .support-panel *, .message-us, .message-us *,
  .message-us-card, .message-us-card *, .contact-method, .contact-method *,
  .contact-method-card, .contact-method-card *, .form-card, .form-card *,
  .form-panel, .form-panel *, .feedback-card, .feedback-card *,
  .faq-item, .faq-item *, .home-tool-card, .home-tool-card *,
  .library-backup-panel, .library-citation-panel, .last-read-panel
) {
  border-color: #43546a !important;
}
html[data-theme="dark"] body :is(
  .contact-card h1, .contact-card h2, .contact-card h3,
  .contact-hero h1, .contact-hero h2, .contact-hero p,
  .contact-card p, .contact-card label, .contact-card strong,
  .contact-card span, .contact-card small, .channel-button strong,
  .channel-button span, .message-us h1, .message-us h2, .message-us p,
  .message-us label, .message-us strong, .message-us span,
  .support-card h2, .support-card h3, .support-card p,
  .faq-item h2, .faq-item h3, .faq-item p
) {
  color: #f3f6fb !important;
  -webkit-text-fill-color: #f3f6fb !important;
}
html[data-theme="dark"] body :is(
  .contact-form input, .contact-form select, .contact-form textarea,
  .message-us input, .message-us select, .message-us textarea,
  .message-us-card input, .message-us-card select, .message-us-card textarea,
  .form-card input, .form-card select, .form-card textarea,
  .form-panel input, .form-panel select, .form-panel textarea,
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select, textarea
) {
  background-color: #080e16 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border: 1px solid #71839a !important;
  box-shadow: none !important;
}
html[data-theme="dark"] body input::placeholder,
html[data-theme="dark"] body textarea::placeholder {
  color: #bdcadd !important;
  -webkit-text-fill-color: #bdcadd !important;
  opacity: 1 !important;
}
html[data-theme="dark"] body :is(
  button, .button, a.button, input[type="submit"], input[type="button"],
  .contact-form button, .contact-form input[type="submit"],
  .message-us button, .message-us .button,
  .channel-button, .contact-card button
) {
  background-color: #26384d !important;
  color: #f7faff !important;
  -webkit-text-fill-color: #f7faff !important;
  border: 1px solid #627891 !important;
  box-shadow: none !important;
  text-shadow: none !important;
}
html[data-theme="dark"] body :is(
  button:hover, .button:hover, a.button:hover,
  input[type="submit"]:hover, input[type="button"]:hover,
  .contact-form button:hover, .channel-button:hover
) {
  background-color: #354d68 !important;
  color: #ffffff !important;
  border-color: #91a9c5 !important;
}
html[data-theme="dark"] body :is(
  .button.primary, button.primary, .contact-form button[type="submit"],
  .contact-form input[type="submit"], .message-us button[type="submit"],
  .message-us input[type="submit"]
) {
  background-color: #1769d2 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border-color: #4e9aff !important;
}
html[data-theme="dark"] body :is(
  a:not(.button):not(.brand):not(.sa-sidebar-brand),
  .contact-card a, .contact-hero a, .site-footer a
) {
  color: #a6ceff !important;
  -webkit-text-fill-color: #a6ceff !important;
}
html[data-theme="dark"] body :is(
  .notice, .result-box, .access-status, .status-legend-item
) * {
  color: #f3f6fb !important;
}
html[data-theme="dark"] body .site-footer,
html[data-theme="dark"] body .site-footer * {
  border-color: #43546a !important;
}


/* v67: CONTACT PAGE READABILITY FIX — explicit colors for BOTH themes.
   Avoid inherited pale text on white contact cards. */
html[data-theme="light"] body .contact-grid .contact-card,
html:not([data-theme="dark"]) body .contact-grid .contact-card {
  background: #ffffff !important;
  background-color: #ffffff !important;
  color: #243247 !important;
  border: 1px solid #d5dfeb !important;
}
html[data-theme="light"] body .contact-grid .contact-card *,
html:not([data-theme="dark"]) body .contact-grid .contact-card * {
  color: #243247 !important;
  -webkit-text-fill-color: #243247 !important;
}
html[data-theme="light"] body .contact-grid .contact-card .eyebrow,
html:not([data-theme="dark"]) body .contact-grid .contact-card .eyebrow {
  color: #52657c !important;
  -webkit-text-fill-color: #52657c !important;
}
html[data-theme="light"] body .contact-grid .contact-card .channel-button,
html:not([data-theme="dark"]) body .contact-grid .contact-card .channel-button {
  background: #263b53 !important;
  background-color: #263b53 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border: 1px solid #526a85 !important;
}
html[data-theme="light"] body .contact-grid .contact-card .channel-button *,
html:not([data-theme="dark"]) body .contact-grid .contact-card .channel-button * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
html[data-theme="dark"] body .contact-grid .contact-card {
  background: #172333 !important;
  background-color: #172333 !important;
  color: #f3f6fb !important;
  border: 1px solid #43546a !important;
}
html[data-theme="dark"] body .contact-grid .contact-card *,
html[data-theme="dark"] body .contact-grid .contact-card h1,
html[data-theme="dark"] body .contact-grid .contact-card h2,
html[data-theme="dark"] body .contact-grid .contact-card h3,
html[data-theme="dark"] body .contact-grid .contact-card p,
html[data-theme="dark"] body .contact-grid .contact-card span,
html[data-theme="dark"] body .contact-grid .contact-card strong {
  color: #f3f6fb !important;
  -webkit-text-fill-color: #f3f6fb !important;
}
html[data-theme="dark"] body .contact-grid .contact-card .eyebrow {
  color: #c2cede !important;
  -webkit-text-fill-color: #c2cede !important;
}
html[data-theme="dark"] body .contact-grid .contact-card .channel-button {
  background: #26384d !important;
  background-color: #26384d !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border: 1px solid #627891 !important;
}
html[data-theme="dark"] body .contact-grid .contact-card .channel-button * {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
html[data-theme="dark"] body .contact-grid .contact-card .channel-button:hover {
  background: #354d68 !important;
  background-color: #354d68 !important;
}


/* v70 FIX: the white inset panels are .message-channel, not .contact-card.
   Explicitly theme these nested panels and their text in both themes. */
html:not([data-theme="dark"]) body .contact-grid .message-us-card .message-channel,
html[data-theme="light"] body .contact-grid .message-us-card .message-channel {
  background: #f5f8fc !important;
  background-color: #f5f8fc !important;
  color: #243247 !important;
  border: 1px solid #d5dfeb !important;
  box-shadow: none !important;
}
html:not([data-theme="dark"]) body .contact-grid .message-us-card .message-channel h3,
html:not([data-theme="dark"]) body .contact-grid .message-us-card .message-channel .channel-address,
html:not([data-theme="dark"]) body .contact-grid .message-us-card .message-channel p,
html[data-theme="light"] body .contact-grid .message-us-card .message-channel h3,
html[data-theme="light"] body .contact-grid .message-us-card .message-channel .channel-address,
html[data-theme="light"] body .contact-grid .message-us-card .message-channel p {
  color: #243247 !important;
  -webkit-text-fill-color: #243247 !important;
}
html[data-theme="dark"] body .contact-grid .message-us-card .message-channel {
  background: #101c2b !important;
  background-color: #101c2b !important;
  color: #f3f6fb !important;
  border: 1px solid #43546a !important;
  box-shadow: none !important;
}
html[data-theme="dark"] body .contact-grid .message-us-card .message-channel h3,
html[data-theme="dark"] body .contact-grid .message-us-card .message-channel .channel-address,
html[data-theme="dark"] body .contact-grid .message-us-card .message-channel p {
  color: #f3f6fb !important;
  -webkit-text-fill-color: #f3f6fb !important;
}
html[data-theme="dark"] body .contact-grid .message-us-card .message-channel .channel-button {
  background: #26384d !important;
  background-color: #26384d !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border: 1px solid #627891 !important;
}
html:not([data-theme="dark"]) body .contact-grid .message-us-card .message-channel .channel-button,
html[data-theme="light"] body .contact-grid .message-us-card .message-channel .channel-button {
  background: #263b53 !important;
  background-color: #263b53 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  border: 1px solid #526a85 !important;
}


/* v71: final explicit contact-page theme colors + square-corner layout */
html[data-theme="light"] body .contact-grid .contact-card,
html:not([data-theme="dark"]) body .contact-grid .contact-card {
  background: #ffffff !important;
  color: #172b43 !important;
  border: 1px solid #d4deea !important;
  border-radius: 0 !important;
}
html[data-theme="light"] body .contact-grid .contact-card h1,
html[data-theme="light"] body .contact-grid .contact-card h2,
html[data-theme="light"] body .contact-grid .contact-card h3,
html[data-theme="light"] body .contact-grid .contact-card p,
html[data-theme="light"] body .contact-grid .contact-card label,
html[data-theme="light"] body .contact-grid .contact-card .channel-address,
html:not([data-theme="dark"]) body .contact-grid .contact-card h1,
html:not([data-theme="dark"]) body .contact-grid .contact-card h2,
html:not([data-theme="dark"]) body .contact-grid .contact-card h3,
html:not([data-theme="dark"]) body .contact-grid .contact-card p,
html:not([data-theme="dark"]) body .contact-grid .contact-card label,
html:not([data-theme="dark"]) body .contact-grid .contact-card .channel-address {
  color: #172b43 !important;
  -webkit-text-fill-color: #172b43 !important;
}
html[data-theme="light"] body .contact-grid .message-channel,
html:not([data-theme="dark"]) body .contact-grid .message-channel {
  background: #f2f6fb !important;
  color: #172b43 !important;
  border: 1px solid #cbd8e7 !important;
  border-radius: 0 !important;
}
html[data-theme="light"] body .contact-grid .message-channel *,
html:not([data-theme="dark"]) body .contact-grid .message-channel * {
  color: #172b43 !important;
  -webkit-text-fill-color: #172b43 !important;
}
html[data-theme="dark"] body .contact-grid .contact-card {
  background: #111d2b !important;
  color: #f3f7fc !important;
  border: 1px solid #42566d !important;
  border-radius: 0 !important;
}
html[data-theme="dark"] body .contact-grid .contact-card h1,
html[data-theme="dark"] body .contact-grid .contact-card h2,
html[data-theme="dark"] body .contact-grid .contact-card h3,
html[data-theme="dark"] body .contact-grid .contact-card p,
html[data-theme="dark"] body .contact-grid .contact-card label,
html[data-theme="dark"] body .contact-grid .contact-card .channel-address {
  color: #f3f7fc !important;
  -webkit-text-fill-color: #f3f7fc !important;
}
html[data-theme="dark"] body .contact-grid .message-channel {
  background: #17283b !important;
  color: #f3f7fc !important;
  border: 1px solid #526a83 !important;
  border-radius: 0 !important;
}
html[data-theme="dark"] body .contact-grid .message-channel * {
  color: #f3f7fc !important;
  -webkit-text-fill-color: #f3f7fc !important;
}
html[data-theme="light"] body .contact-grid .contact-card input,
html[data-theme="light"] body .contact-grid .contact-card select,
html[data-theme="light"] body .contact-grid .contact-card textarea,
html:not([data-theme="dark"]) body .contact-grid .contact-card input,
html:not([data-theme="dark"]) body .contact-grid .contact-card select,
html:not([data-theme="dark"]) body .contact-grid .contact-card textarea {
  background: #ffffff !important;
  color: #172b43 !important;
  -webkit-text-fill-color: #172b43 !important;
  border: 1px solid #9aacc1 !important;
  border-radius: 0 !important;
}
html[data-theme="light"] body .contact-grid .contact-card input::placeholder,
html[data-theme="light"] body .contact-grid .contact-card textarea::placeholder,
html:not([data-theme="dark"]) body .contact-grid .contact-card input::placeholder,
html:not([data-theme="dark"]) body .contact-grid .contact-card textarea::placeholder {
  color: #61748b !important;
  -webkit-text-fill-color: #61748b !important;
  opacity: 1 !important;
}
html[data-theme="dark"] body .contact-grid .contact-card input,
html[data-theme="dark"] body .contact-grid .contact-card select,
html[data-theme="dark"] body .contact-grid .contact-card textarea {
  background: #0b1725 !important;
  color: #f3f7fc !important;
  -webkit-text-fill-color: #f3f7fc !important;
  border: 1px solid #60758d !important;
  border-radius: 0 !important;
}
html[data-theme="dark"] body .contact-grid .contact-card input::placeholder,
html[data-theme="dark"] body .contact-grid .contact-card textarea::placeholder {
  color: #b6c4d5 !important;
  -webkit-text-fill-color: #b6c4d5 !important;
  opacity: 1 !important;
}
html[data-theme="light"] body .contact-grid .channel-button,
html:not([data-theme="dark"]) body .contact-grid .channel-button,
html[data-theme="dark"] body .contact-grid .channel-button {
  border-radius: 0 !important;
}


/* v1.2: AI Research Assistant provider cards must follow the active theme. */
html[data-theme="dark"] body main .sa-ai-hub .sa-ai-provider,
html[data-theme="dark"] body main .sa-ai-hub .sa-ai-provider:visited {
  background: #172333 !important;
  background-color: #172333 !important;
  color: #f3f6fb !important;
  border-color: #43546a !important;
}
html[data-theme="dark"] body main .sa-ai-hub .sa-ai-provider *,
html[data-theme="dark"] body main .sa-ai-hub .sa-ai-provider strong,
html[data-theme="dark"] body main .sa-ai-hub .sa-ai-provider small {
  color: #f3f6fb !important;
  -webkit-text-fill-color: #f3f6fb !important;
}
html[data-theme="dark"] body main .sa-ai-hub .sa-ai-provider-mark {
  background: #263b57 !important;
  color: #b9d8ff !important;
  -webkit-text-fill-color: #b9d8ff !important;
}
html[data-theme="dark"] body main .sa-ai-hub .sa-ai-provider:hover {
  background: #20334a !important;
  border-color: #79aef5 !important;
}
html[data-theme="light"] body main .sa-ai-hub .sa-ai-provider {
  background: #ffffff;
  color: #14233b;
}


/* v1.3: Dark mode background for the complete AI Research Assistant page.
   The previous patch themed provider tiles but left the page canvas/panel white. */
html[data-theme="dark"] body:has(.sa-ai-hub),
html[data-theme="dark"] body:has(.sa-ai-hub) .scholaraccess-theme-content {
  background: #0b111a !important;
  background-color: #0b111a !important;
}
html[data-theme="dark"] body:has(.sa-ai-hub) main,
html[data-theme="dark"] body:has(.sa-ai-hub) main .page-hero,
html[data-theme="dark"] body:has(.sa-ai-hub) main .content-area {
  background: #0b111a !important;
  background-color: #0b111a !important;
  color: #f3f6fb !important;
}
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-hub,
html[data-theme="dark"] body:has(.sa-ai-hub) main .content-area .panel {
  background: #101c2b !important;
  background-color: #101c2b !important;
  color: #f3f6fb !important;
  border-color: #34485f !important;
  box-shadow: 0 12px 32px rgba(0,0,0,.22) !important;
}
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-hub h1,
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-hub h2,
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-hub h3,
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-hub p,
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-hub small,
html[data-theme="dark"] body:has(.sa-ai-hub) main .page-hero h1,
html[data-theme="dark"] body:has(.sa-ai-hub) main .page-hero p,
html[data-theme="dark"] body:has(.sa-ai-hub) main .page-hero .eyebrow {
  color: #e8eff8 !important;
  -webkit-text-fill-color: #e8eff8 !important;
}
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-task-grid article {
  background: #172638 !important;
  background-color: #172638 !important;
  color: #e8eff8 !important;
  border-color: #3a5069 !important;
}
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-task-grid article * {
  color: #e8eff8 !important;
  -webkit-text-fill-color: #e8eff8 !important;
}
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-hub .notice {
  background: #172638 !important;
  color: #dce8f5 !important;
  border-color: #3a5069 !important;
}
html[data-theme="dark"] body:has(.sa-ai-hub) main .sa-ai-hub .notice * {
  color: #dce8f5 !important;
  -webkit-text-fill-color: #dce8f5 !important;
}

