hsaest commited on
Commit
ab142b1
·
1 Parent(s): 5d9015e

fix dark mode: class-based (html.dark-mode) + JS matchMedia detection

Browse files
Files changed (1) hide show
  1. app.py +263 -267
app.py CHANGED
@@ -1203,18 +1203,22 @@ gradio-app > div {
1203
  height: 0 !important;
1204
  }
1205
 
1206
- /* Restore and restyle the .generating animated border so the user can see
1207
- the output panel is actively streaming — styled in the Quest terracotta
1208
- accent instead of Gradio's default orange bar. */
 
1209
  [class*="gradio-container"] .generating {
1210
- border: 2px solid var(--q-accent) !important;
1211
- border-radius: var(--q-radius-md) !important;
1212
- animation: quest-pulse 1.6s ease-in-out infinite !important;
 
 
 
1213
  background: transparent !important;
1214
  }
1215
  @keyframes quest-pulse {
1216
- 0%, 100% { border-color: var(--q-accent); box-shadow: 0 0 0 0 rgba(190,91,43,0.25); }
1217
- 50% { border-color: var(--q-accent-line); box-shadow: 0 0 0 5px rgba(190,91,43,0); }
1218
  }
1219
 
1220
  /* Run Research button: show a subtle animated shimmer while research is
@@ -1472,257 +1476,247 @@ footer { display: none !important; }
1472
  }
1473
 
1474
  /* ===================================================================
1475
- DARK MODE
1476
- All --q-* palette vars are re-declared so the rest of the CSS (which
1477
- references only those vars) automatically picks up the dark theme.
1478
- A handful of hardcoded-color rules are also overridden here.
1479
  =================================================================== */
1480
- @media (prefers-color-scheme: dark) {
1481
- :root {
1482
- --q-bg: #0D1117;
1483
- --q-paper: #161B22;
1484
- --q-surface-alt: #21262D;
1485
- --q-line: rgba(240,246,252,0.08);
1486
- --q-line-strong: rgba(240,246,252,0.15);
1487
- --q-text: #E6EDF3;
1488
- --q-muted: #8B949E;
1489
- --q-accent: #D97B54;
1490
- --q-accent-soft: rgba(217,123,84,0.15);
1491
- --q-accent-line: rgba(217,123,84,0.5);
1492
- --q-mint: #39C5AC;
1493
- --q-mint-deep: #2DA897;
1494
- --q-cover-bg: #0D1117;
1495
- --q-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 8px 32px rgba(0,0,0,0.6);
1496
- --q-shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 2px 10px rgba(0,0,0,0.5);
1497
- }
1498
-
1499
- /* Page & container backgrounds */
1500
- html, body, gradio-app, [class*="gradio-container"] {
1501
- background: var(--q-bg) !important;
1502
- color: var(--q-text) !important;
1503
- }
1504
-
1505
- /* Override Gradio theme-injected CSS custom properties */
1506
- [class*="gradio-container"] {
1507
- --body-background-fill: #0D1117 !important;
1508
- --background-fill-primary: #161B22 !important;
1509
- --background-fill-secondary: #21262D !important;
1510
- --border-color-primary: rgba(240,246,252,0.08) !important;
1511
- --input-background-fill: #161B22 !important;
1512
- --input-background-fill-focus:#1C2128 !important;
1513
- --block-background-fill: #161B22 !important;
1514
- --code-background-fill: #21262D !important;
1515
- --color-accent: #D97B54 !important;
1516
- --color-accent-soft: rgba(217,123,84,0.15) !important;
1517
- --table-even-background-fill: #1C2128 !important;
1518
- --table-odd-background-fill: #161B22 !important;
1519
- }
1520
 
1521
- /* Structural cards */
1522
- .quest-header,
1523
- .section-card,
1524
- .quest-footer {
1525
- background: var(--q-paper) !important;
1526
- border-color: var(--q-line) !important;
1527
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1528
 
1529
- /* Inputs & textareas */
1530
- [class*="gradio-container"] textarea,
1531
- [class*="gradio-container"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]) {
1532
- background: var(--q-paper) !important;
1533
- color: var(--q-text) !important;
1534
- border-color: var(--q-line-strong) !important;
1535
- }
1536
- [class*="gradio-container"] textarea::placeholder,
1537
- [class*="gradio-container"] input::placeholder { color: var(--q-muted) !important; }
1538
- [class*="gradio-container"] textarea:focus,
1539
- [class*="gradio-container"] input:focus {
1540
- border-color: var(--q-accent) !important;
1541
- box-shadow: 0 0 0 3px rgba(217,123,84,0.2) !important;
1542
- }
 
 
 
 
 
 
 
 
 
1543
 
1544
- /* Dropdown */
1545
- [class*="gradio-container"] [data-testid="dropdown"],
1546
- [class*="gradio-container"] .gradio-dropdown {
1547
- background: var(--q-paper) !important;
1548
- border-color: var(--q-line-strong) !important;
1549
- }
1550
- [class*="gradio-container"] .options ul,
1551
- [class*="gradio-container"] .options {
1552
- background: var(--q-paper) !important;
1553
- border-color: var(--q-line-strong) !important;
1554
- box-shadow: 0 10px 30px rgba(0,0,0,0.4) !important;
1555
- }
1556
- [class*="gradio-container"] .options li[aria-selected="true"],
1557
- [class*="gradio-container"] .options li:hover {
1558
- background: var(--q-accent-soft) !important;
1559
- color: var(--q-accent) !important;
1560
- }
1561
 
1562
- /* Primary button: use accent color so it reads on a dark background */
1563
- [class*="gradio-container"] button.primary,
1564
- [class*="gradio-container"] .gr-button-primary {
1565
- background: var(--q-accent) !important;
1566
- color: #fff !important;
1567
- border-color: var(--q-accent) !important;
1568
- }
1569
- [class*="gradio-container"] button.primary:hover,
1570
- [class*="gradio-container"] .gr-button-primary:hover {
1571
- background: #C86840 !important;
1572
- border-color: #C86840 !important;
1573
- }
1574
- /* Shimmer during run: dark mode variant */
1575
- #quest-run-btn button[disabled],
1576
- #quest-run-btn button:disabled,
1577
- #quest-run-btn button[aria-disabled="true"] {
1578
- background: linear-gradient(
1579
- 90deg,
1580
- var(--q-accent) 0%,
1581
- #a85535 50%,
1582
- var(--q-accent) 100%
1583
- ) !important;
1584
- }
1585
 
1586
- /* Secondary button */
1587
- [class*="gradio-container"] button.secondary,
1588
- [class*="gradio-container"] .gr-button-secondary {
1589
- background: var(--q-paper) !important;
1590
- color: var(--q-text) !important;
1591
- border-color: var(--q-line-strong) !important;
1592
- }
1593
- [class*="gradio-container"] button.secondary:hover,
1594
- [class*="gradio-container"] .gr-button-secondary:hover {
1595
- background: var(--q-accent-soft) !important;
1596
- border-color: var(--q-accent-line) !important;
1597
- color: var(--q-accent) !important;
1598
- }
 
 
 
 
1599
 
1600
- /* Stop button */
1601
- [class*="gradio-container"] button.stop,
1602
- [class*="gradio-container"] .gr-button-stop {
1603
- background: var(--q-paper) !important;
1604
- color: #F87171 !important;
1605
- border-color: #7F1D1D !important;
1606
- }
1607
- [class*="gradio-container"] button.stop:hover,
1608
- [class*="gradio-container"] .gr-button-stop:hover {
1609
- background: #2D0909 !important;
1610
- color: #FCA5A5 !important;
1611
- }
 
1612
 
1613
- /* Markdown / prose */
1614
- [class*="gradio-container"] .gr-markdown,
1615
- [class*="gradio-container"] .prose,
1616
- [class*="gradio-container"] .markdown {
1617
- color: var(--q-text) !important;
1618
- }
1619
- [class*="gradio-container"] .gr-markdown a,
1620
- [class*="gradio-container"] .prose a { color: var(--q-accent) !important; }
1621
- [class*="gradio-container"] .gr-markdown h1,
1622
- [class*="gradio-container"] .gr-markdown h2,
1623
- [class*="gradio-container"] .gr-markdown h3,
1624
- [class*="gradio-container"] .prose h1,
1625
- [class*="gradio-container"] .prose h2,
1626
- [class*="gradio-container"] .prose h3 { color: var(--q-text) !important; }
1627
- [class*="gradio-container"] .gr-markdown code,
1628
- [class*="gradio-container"] .prose code {
1629
- background: var(--q-surface-alt) !important;
1630
- border-color: var(--q-line) !important;
1631
- color: var(--q-text) !important;
1632
- }
 
 
 
 
 
 
 
 
 
 
 
1633
 
1634
- /* CodeMirror (Record tab) */
1635
- [class*="gradio-container"] .codemirror-wrapper,
1636
- [class*="gradio-container"] .cm-editor,
1637
- [class*="gradio-container"] .cm-scroller,
1638
- [class*="gradio-container"] .cm-gutters,
1639
- [class*="gradio-container"] .cm-content {
1640
- background: var(--q-surface-alt) !important;
1641
- color: var(--q-text) !important;
1642
- }
1643
- [class*="gradio-container"] .cm-gutters {
1644
- border-right-color: var(--q-line) !important;
1645
- color: var(--q-muted) !important;
1646
- }
1647
 
1648
- /* Tabs */
1649
- [class*="gradio-container"] .tab-nav,
1650
- [class*="gradio-container"] .tab-wrapper {
1651
- border-bottom-color: var(--q-line) !important;
1652
- }
1653
- [class*="gradio-container"] .tab-wrapper button { color: var(--q-muted) !important; }
1654
- [class*="gradio-container"] .tab-wrapper button.selected { color: var(--q-accent) !important; }
1655
- [class*="gradio-container"] .tab-wrapper button.selected::after { background: var(--q-accent) !important; }
1656
-
1657
- /* Labels */
1658
- [class*="gradio-container"] .gr-block label,
1659
- [class*="gradio-container"] .gradio-slider label,
1660
- [class*="gradio-container"] .gradio-dropdown label,
1661
- [class*="gradio-container"] .gradio-textbox label { color: var(--q-muted) !important; }
1662
-
1663
- /* Memory strategy radio */
1664
- #quest-memory-strategy label {
1665
- color: var(--q-text) !important;
1666
- border-color: var(--q-line) !important;
1667
- }
1668
- #quest-memory-strategy label:hover { border-color: var(--q-line-strong) !important; }
1669
 
1670
- /* Slider number input */
1671
- #quest-max-turns input[type="number"],
1672
- #quest-temperature input[type="number"] { color: var(--q-text) !important; }
 
 
1673
 
1674
- /* Slider track */
1675
- [class*="gradio-container"] input[type="range"] {
1676
- background: var(--q-surface-alt) !important;
1677
- }
1678
- [class*="gradio-container"] input[type="range"]::-webkit-slider-thumb {
1679
- background: var(--q-paper) !important;
1680
- border-color: var(--q-accent) !important;
1681
- }
1682
- [class*="gradio-container"] input[type="range"]::-moz-range-thumb {
1683
- background: var(--q-paper) !important;
1684
- border-color: var(--q-accent) !important;
1685
- }
1686
 
1687
- /* Resource / icon link cards */
1688
- .resource-card, .icon-link {
1689
- background: var(--q-paper) !important;
1690
- color: var(--q-text) !important;
1691
- border-color: var(--q-line-strong) !important;
1692
- }
1693
- .resource-card:hover, .icon-link:hover {
1694
- background: var(--q-accent-soft) !important;
1695
- border-color: var(--q-accent-line) !important;
1696
- color: var(--q-accent) !important;
1697
- }
1698
- .resource-card-icon { background: var(--q-surface-alt) !important; color: var(--q-text) !important; }
1699
 
1700
- /* Example buttons */
1701
- [class*="gradio-container"] .example-btn {
1702
- background: var(--q-paper) !important;
1703
- color: var(--q-text) !important;
1704
- border-color: var(--q-line) !important;
1705
- }
1706
- [class*="gradio-container"] .example-btn:hover {
1707
- background: var(--q-accent-soft) !important;
1708
- border-color: var(--q-accent-line) !important;
1709
- color: var(--q-accent) !important;
1710
- }
1711
 
1712
- /* Memory help box */
1713
- .memory-help {
1714
- background: var(--q-surface-alt) !important;
1715
- border-color: var(--q-line) !important;
1716
- color: var(--q-muted) !important;
1717
- }
1718
- .memory-help b { color: var(--q-text) !important; }
 
 
 
 
 
 
 
1719
 
1720
- /* Footer links */
1721
- .quest-footer { color: var(--q-muted) !important; }
1722
- .quest-footer a { color: var(--q-muted) !important; }
1723
- .quest-footer a:hover { color: var(--q-text) !important; }
 
 
 
 
 
 
 
1724
 
 
 
 
 
 
1725
  }
 
 
 
 
 
 
1726
  """
1727
 
1728
 
@@ -2921,11 +2915,39 @@ def _example_label(ex: Dict[str, str]) -> str:
2921
  return f"{ex['icon']} {ex['category']} — {ex['text']}"
2922
 
2923
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2924
  with gr.Blocks(
2925
  title="QUEST · Deep Research by OSU NLP",
2926
  theme=APP_THEME,
2927
  css=CUSTOM_CSS,
2928
  fill_width=True,
 
2929
  ) as demo:
2930
  # --- Quest-style header (Q mark + title + byline) ---
2931
  gr.HTML(
@@ -3066,32 +3088,6 @@ with gr.Blocks(
3066
  <a href="https://huggingface.co/osunlp" target="_blank" rel="noopener noreferrer">Hugging Face</a>
3067
  </div>
3068
  </footer>
3069
- <script>
3070
- (function () {
3071
- function scrollToOutput() {
3072
- var el = document.getElementById('quest-output');
3073
- if (el) el.scrollIntoView({ behavior: 'smooth', block: 'start' });
3074
- }
3075
-
3076
- function attachRunBtn() {
3077
- // Gradio wraps our elem_id in a div; the actual <button> is a child.
3078
- var wrapper = document.getElementById('quest-run-btn');
3079
- if (!wrapper) { setTimeout(attachRunBtn, 400); return; }
3080
- var btn = wrapper.querySelector('button');
3081
- if (!btn) { setTimeout(attachRunBtn, 400); return; }
3082
- btn.addEventListener('click', function () {
3083
- // Small delay so Gradio has time to start streaming before we scroll.
3084
- setTimeout(scrollToOutput, 250);
3085
- });
3086
- }
3087
-
3088
- if (document.readyState === 'loading') {
3089
- document.addEventListener('DOMContentLoaded', attachRunBtn);
3090
- } else {
3091
- setTimeout(attachRunBtn, 300);
3092
- }
3093
- })();
3094
- </script>
3095
  """
3096
  )
3097
 
 
1203
  height: 0 !important;
1204
  }
1205
 
1206
+ /* Restore and restyle the .generating indicator so the user can see the
1207
+ output panel is actively streaming. Using a top-only 2px bar (classic
1208
+ "page loading" pattern) avoids the "half-border" artefact that appears
1209
+ when Gradio clips the element inside a tab pane. */
1210
  [class*="gradio-container"] .generating {
1211
+ border-top: 2px solid var(--q-accent) !important;
1212
+ border-left: 0 !important;
1213
+ border-right: 0 !important;
1214
+ border-bottom: 0 !important;
1215
+ border-radius: 0 !important;
1216
+ animation: quest-pulse 1.2s ease-in-out infinite !important;
1217
  background: transparent !important;
1218
  }
1219
  @keyframes quest-pulse {
1220
+ 0%, 100% { opacity: 1; }
1221
+ 50% { opacity: 0.35; }
1222
  }
1223
 
1224
  /* Run Research button: show a subtle animated shimmer while research is
 
1476
  }
1477
 
1478
  /* ===================================================================
1479
+ DARK MODE — JS adds html.dark-mode via matchMedia; class-based so
1480
+ it reliably overrides Gradio's theme CSS regardless of injection order.
 
 
1481
  =================================================================== */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1482
 
1483
+ /* Palette variables — set on html so they cascade to everything */
1484
+ html.dark-mode {
1485
+ --q-bg: #0D1117;
1486
+ --q-paper: #161B22;
1487
+ --q-surface-alt: #21262D;
1488
+ --q-line: rgba(240,246,252,0.08);
1489
+ --q-line-strong: rgba(240,246,252,0.15);
1490
+ --q-text: #E6EDF3;
1491
+ --q-muted: #8B949E;
1492
+ --q-accent: #D97B54;
1493
+ --q-accent-soft: rgba(217,123,84,0.15);
1494
+ --q-accent-line: rgba(217,123,84,0.5);
1495
+ --q-mint: #39C5AC;
1496
+ --q-mint-deep: #2DA897;
1497
+ --q-cover-bg: #0D1117;
1498
+ --q-shadow: 0 1px 3px rgba(0,0,0,0.5), 0 8px 32px rgba(0,0,0,0.6);
1499
+ --q-shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 2px 10px rgba(0,0,0,0.5);
1500
+ }
1501
+
1502
+ /* Page & container backgrounds */
1503
+ html.dark-mode,
1504
+ html.dark-mode body,
1505
+ html.dark-mode gradio-app,
1506
+ html.dark-mode [class*="gradio-container"] {
1507
+ background: var(--q-bg) !important;
1508
+ color: var(--q-text) !important;
1509
+ }
1510
 
1511
+ /* Override Gradio theme-injected CSS custom properties */
1512
+ html.dark-mode [class*="gradio-container"] {
1513
+ --body-background-fill: #0D1117 !important;
1514
+ --background-fill-primary: #161B22 !important;
1515
+ --background-fill-secondary: #21262D !important;
1516
+ --border-color-primary: rgba(240,246,252,0.08) !important;
1517
+ --input-background-fill: #161B22 !important;
1518
+ --input-background-fill-focus:#1C2128 !important;
1519
+ --block-background-fill: #161B22 !important;
1520
+ --code-background-fill: #21262D !important;
1521
+ --color-accent: #D97B54 !important;
1522
+ --color-accent-soft: rgba(217,123,84,0.15) !important;
1523
+ --table-even-background-fill: #1C2128 !important;
1524
+ --table-odd-background-fill: #161B22 !important;
1525
+ }
1526
+
1527
+ /* Structural cards */
1528
+ html.dark-mode .quest-header,
1529
+ html.dark-mode .section-card,
1530
+ html.dark-mode .quest-footer {
1531
+ background: var(--q-paper) !important;
1532
+ border-color: var(--q-line) !important;
1533
+ }
1534
 
1535
+ /* Inputs & textareas */
1536
+ html.dark-mode [class*="gradio-container"] textarea,
1537
+ html.dark-mode [class*="gradio-container"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]) {
1538
+ background: var(--q-paper) !important;
1539
+ color: var(--q-text) !important;
1540
+ border-color: var(--q-line-strong) !important;
1541
+ }
1542
+ html.dark-mode [class*="gradio-container"] textarea::placeholder,
1543
+ html.dark-mode [class*="gradio-container"] input::placeholder { color: var(--q-muted) !important; }
1544
+ html.dark-mode [class*="gradio-container"] textarea:focus,
1545
+ html.dark-mode [class*="gradio-container"] input:focus {
1546
+ border-color: var(--q-accent) !important;
1547
+ box-shadow: 0 0 0 3px rgba(217,123,84,0.2) !important;
1548
+ }
 
 
 
1549
 
1550
+ /* Dropdown */
1551
+ html.dark-mode [class*="gradio-container"] [data-testid="dropdown"],
1552
+ html.dark-mode [class*="gradio-container"] .gradio-dropdown {
1553
+ background: var(--q-paper) !important;
1554
+ border-color: var(--q-line-strong) !important;
1555
+ }
1556
+ html.dark-mode [class*="gradio-container"] .options ul,
1557
+ html.dark-mode [class*="gradio-container"] .options {
1558
+ background: var(--q-paper) !important;
1559
+ border-color: var(--q-line-strong) !important;
1560
+ box-shadow: 0 10px 30px rgba(0,0,0,0.4) !important;
1561
+ }
1562
+ html.dark-mode [class*="gradio-container"] .options li[aria-selected="true"],
1563
+ html.dark-mode [class*="gradio-container"] .options li:hover {
1564
+ background: var(--q-accent-soft) !important;
1565
+ color: var(--q-accent) !important;
1566
+ }
 
 
 
 
 
 
1567
 
1568
+ /* Primary button */
1569
+ html.dark-mode [class*="gradio-container"] button.primary,
1570
+ html.dark-mode [class*="gradio-container"] .gr-button-primary {
1571
+ background: var(--q-accent) !important;
1572
+ color: #fff !important;
1573
+ border-color: var(--q-accent) !important;
1574
+ }
1575
+ html.dark-mode [class*="gradio-container"] button.primary:hover,
1576
+ html.dark-mode [class*="gradio-container"] .gr-button-primary:hover {
1577
+ background: #C86840 !important;
1578
+ border-color: #C86840 !important;
1579
+ }
1580
+ html.dark-mode #quest-run-btn button[disabled],
1581
+ html.dark-mode #quest-run-btn button:disabled,
1582
+ html.dark-mode #quest-run-btn button[aria-disabled="true"] {
1583
+ background: linear-gradient(90deg, var(--q-accent) 0%, #a85535 50%, var(--q-accent) 100%) !important;
1584
+ }
1585
 
1586
+ /* Secondary button */
1587
+ html.dark-mode [class*="gradio-container"] button.secondary,
1588
+ html.dark-mode [class*="gradio-container"] .gr-button-secondary {
1589
+ background: var(--q-paper) !important;
1590
+ color: var(--q-text) !important;
1591
+ border-color: var(--q-line-strong) !important;
1592
+ }
1593
+ html.dark-mode [class*="gradio-container"] button.secondary:hover,
1594
+ html.dark-mode [class*="gradio-container"] .gr-button-secondary:hover {
1595
+ background: var(--q-accent-soft) !important;
1596
+ border-color: var(--q-accent-line) !important;
1597
+ color: var(--q-accent) !important;
1598
+ }
1599
 
1600
+ /* Stop button */
1601
+ html.dark-mode [class*="gradio-container"] button.stop,
1602
+ html.dark-mode [class*="gradio-container"] .gr-button-stop {
1603
+ background: var(--q-paper) !important;
1604
+ color: #F87171 !important;
1605
+ border-color: #7F1D1D !important;
1606
+ }
1607
+ html.dark-mode [class*="gradio-container"] button.stop:hover,
1608
+ html.dark-mode [class*="gradio-container"] .gr-button-stop:hover {
1609
+ background: #2D0909 !important;
1610
+ color: #FCA5A5 !important;
1611
+ }
1612
+
1613
+ /* Markdown / prose */
1614
+ html.dark-mode [class*="gradio-container"] .gr-markdown,
1615
+ html.dark-mode [class*="gradio-container"] .prose,
1616
+ html.dark-mode [class*="gradio-container"] .markdown { color: var(--q-text) !important; }
1617
+ html.dark-mode [class*="gradio-container"] .gr-markdown a,
1618
+ html.dark-mode [class*="gradio-container"] .prose a { color: var(--q-accent) !important; }
1619
+ html.dark-mode [class*="gradio-container"] .gr-markdown h1,
1620
+ html.dark-mode [class*="gradio-container"] .gr-markdown h2,
1621
+ html.dark-mode [class*="gradio-container"] .gr-markdown h3,
1622
+ html.dark-mode [class*="gradio-container"] .prose h1,
1623
+ html.dark-mode [class*="gradio-container"] .prose h2,
1624
+ html.dark-mode [class*="gradio-container"] .prose h3 { color: var(--q-text) !important; }
1625
+ html.dark-mode [class*="gradio-container"] .gr-markdown code,
1626
+ html.dark-mode [class*="gradio-container"] .prose code {
1627
+ background: var(--q-surface-alt) !important;
1628
+ border-color: var(--q-line) !important;
1629
+ color: var(--q-text) !important;
1630
+ }
1631
 
1632
+ /* CodeMirror (Record tab) */
1633
+ html.dark-mode [class*="gradio-container"] .codemirror-wrapper,
1634
+ html.dark-mode [class*="gradio-container"] .cm-editor,
1635
+ html.dark-mode [class*="gradio-container"] .cm-scroller,
1636
+ html.dark-mode [class*="gradio-container"] .cm-gutters,
1637
+ html.dark-mode [class*="gradio-container"] .cm-content {
1638
+ background: var(--q-surface-alt) !important;
1639
+ color: var(--q-text) !important;
1640
+ }
1641
+ html.dark-mode [class*="gradio-container"] .cm-gutters {
1642
+ border-right-color: var(--q-line) !important;
1643
+ color: var(--q-muted) !important;
1644
+ }
1645
 
1646
+ /* Tabs */
1647
+ html.dark-mode [class*="gradio-container"] .tab-nav,
1648
+ html.dark-mode [class*="gradio-container"] .tab-wrapper { border-bottom-color: var(--q-line) !important; }
1649
+ html.dark-mode [class*="gradio-container"] .tab-wrapper button { color: var(--q-muted) !important; }
1650
+ html.dark-mode [class*="gradio-container"] .tab-wrapper button.selected { color: var(--q-accent) !important; }
1651
+ html.dark-mode [class*="gradio-container"] .tab-wrapper button.selected::after { background: var(--q-accent) !important; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1652
 
1653
+ /* Labels */
1654
+ html.dark-mode [class*="gradio-container"] .gr-block label,
1655
+ html.dark-mode [class*="gradio-container"] .gradio-slider label,
1656
+ html.dark-mode [class*="gradio-container"] .gradio-dropdown label,
1657
+ html.dark-mode [class*="gradio-container"] .gradio-textbox label { color: var(--q-muted) !important; }
1658
 
1659
+ /* Memory strategy radio */
1660
+ html.dark-mode #quest-memory-strategy label {
1661
+ color: var(--q-text) !important;
1662
+ border-color: var(--q-line) !important;
1663
+ }
1664
+ html.dark-mode #quest-memory-strategy label:hover { border-color: var(--q-line-strong) !important; }
 
 
 
 
 
 
1665
 
1666
+ /* Slider number input */
1667
+ html.dark-mode #quest-max-turns input[type="number"],
1668
+ html.dark-mode #quest-temperature input[type="number"] { color: var(--q-text) !important; }
 
 
 
 
 
 
 
 
 
1669
 
1670
+ /* Slider track */
1671
+ html.dark-mode [class*="gradio-container"] input[type="range"] { background: var(--q-surface-alt) !important; }
1672
+ html.dark-mode [class*="gradio-container"] input[type="range"]::-webkit-slider-thumb {
1673
+ background: var(--q-paper) !important;
1674
+ border-color: var(--q-accent) !important;
1675
+ }
1676
+ html.dark-mode [class*="gradio-container"] input[type="range"]::-moz-range-thumb {
1677
+ background: var(--q-paper) !important;
1678
+ border-color: var(--q-accent) !important;
1679
+ }
 
1680
 
1681
+ /* Resource / icon link cards */
1682
+ html.dark-mode .resource-card,
1683
+ html.dark-mode .icon-link {
1684
+ background: var(--q-paper) !important;
1685
+ color: var(--q-text) !important;
1686
+ border-color: var(--q-line-strong) !important;
1687
+ }
1688
+ html.dark-mode .resource-card:hover,
1689
+ html.dark-mode .icon-link:hover {
1690
+ background: var(--q-accent-soft) !important;
1691
+ border-color: var(--q-accent-line) !important;
1692
+ color: var(--q-accent) !important;
1693
+ }
1694
+ html.dark-mode .resource-card-icon { background: var(--q-surface-alt) !important; color: var(--q-text) !important; }
1695
 
1696
+ /* Example buttons */
1697
+ html.dark-mode [class*="gradio-container"] .example-btn {
1698
+ background: var(--q-paper) !important;
1699
+ color: var(--q-text) !important;
1700
+ border-color: var(--q-line) !important;
1701
+ }
1702
+ html.dark-mode [class*="gradio-container"] .example-btn:hover {
1703
+ background: var(--q-accent-soft) !important;
1704
+ border-color: var(--q-accent-line) !important;
1705
+ color: var(--q-accent) !important;
1706
+ }
1707
 
1708
+ /* Memory help box */
1709
+ html.dark-mode .memory-help {
1710
+ background: var(--q-surface-alt) !important;
1711
+ border-color: var(--q-line) !important;
1712
+ color: var(--q-muted) !important;
1713
  }
1714
+ html.dark-mode .memory-help b { color: var(--q-text) !important; }
1715
+
1716
+ /* Footer */
1717
+ html.dark-mode .quest-footer { color: var(--q-muted) !important; }
1718
+ html.dark-mode .quest-footer a { color: var(--q-muted) !important; }
1719
+ html.dark-mode .quest-footer a:hover { color: var(--q-text) !important; }
1720
  """
1721
 
1722
 
 
2915
  return f"{ex['icon']} {ex['category']} — {ex['text']}"
2916
 
2917
 
2918
+ _PAGE_JS = """
2919
+ function() {
2920
+ // === Dark mode: add/remove html.dark-mode based on OS preference ===
2921
+ function applyDark(dark) {
2922
+ document.documentElement.classList.toggle('dark-mode', dark);
2923
+ }
2924
+ var mq = window.matchMedia('(prefers-color-scheme: dark)');
2925
+ applyDark(mq.matches);
2926
+ mq.addEventListener('change', function(e) { applyDark(e.matches); });
2927
+
2928
+ // === Auto-scroll to output panel when Run Research is clicked ===
2929
+ function setup() {
2930
+ var wrapper = document.getElementById('quest-run-btn');
2931
+ if (!wrapper) { setTimeout(setup, 500); return; }
2932
+ var btn = wrapper.querySelector('button');
2933
+ if (!btn) { setTimeout(setup, 500); return; }
2934
+ btn.addEventListener('click', function () {
2935
+ setTimeout(function () {
2936
+ var out = document.getElementById('quest-output');
2937
+ if (out) out.scrollIntoView({ behavior: 'smooth', block: 'start' });
2938
+ }, 300);
2939
+ });
2940
+ }
2941
+ setup();
2942
+ }
2943
+ """
2944
+
2945
  with gr.Blocks(
2946
  title="QUEST · Deep Research by OSU NLP",
2947
  theme=APP_THEME,
2948
  css=CUSTOM_CSS,
2949
  fill_width=True,
2950
+ js=_PAGE_JS,
2951
  ) as demo:
2952
  # --- Quest-style header (Q mark + title + byline) ---
2953
  gr.HTML(
 
3088
  <a href="https://huggingface.co/osunlp" target="_blank" rel="noopener noreferrer">Hugging Face</a>
3089
  </div>
3090
  </footer>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3091
  """
3092
  )
3093