GameTheory Claude Sonnet 4.6 commited on
Commit
205d99f
·
1 Parent(s): 2ae42b0

fix: dark mode support — replace hardcoded white/light colours with CSS variables

Browse files

Safari on macOS/iOS applies system dark mode to Gradio, while custom CSS
was hardcoding 'background: white' and light hex colours causing white
islands on dark backgrounds.

Changes:
- Add color-scheme: light to :root (prevents browser auto-inversion of inputs)
- Add @media (prefers-color-scheme: dark) block with adapted brand variables
- Replace all hardcoded 'white', '#334155', '#64748b' etc with --wcc-surface,
--wcc-text, --wcc-text-muted variables that resolve correctly in both modes
- Chatbot, topic buttons, footer, input box, clear button all use variables

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +30 -9
app.py CHANGED
@@ -352,6 +352,7 @@ def inject_question(question: str, history: list[ChatMessage]):
352
  WCC_CSS = """
353
  /* ── Worcestershire Libraries brand colours ── */
354
  :root {
 
355
  --wcc-navy: #1e3a5f;
356
  --wcc-blue: #1d4ed8;
357
  --wcc-blue-light: #dbeafe;
@@ -360,10 +361,28 @@ WCC_CSS = """
360
  --wcc-green: #166534;
361
  --wcc-bg: #f8fafc;
362
  --wcc-border: #e2e8f0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
  }
364
 
365
  /* ── Page background ── */
366
- .gradio-container { background: var(--wcc-bg) !important; }
367
 
368
  /* ── Header ── */
369
  #wcc-header {
@@ -420,20 +439,20 @@ WCC_CSS = """
420
  /* ── Topic navigator ── */
421
  #topic-nav-label {
422
  font-size: 0.78rem;
423
- color: #94a3b8;
424
  margin: 0 0 6px 2px;
425
  letter-spacing: 0.02em;
426
  text-transform: uppercase;
427
  }
428
  .topic-q button {
429
- background: white !important;
430
  border: 1px solid var(--wcc-border) !important;
431
  border-radius: 8px !important;
432
  text-align: left !important;
433
  padding: 9px 14px !important;
434
  font-size: 0.88rem !important;
435
  line-height: 1.4 !important;
436
- color: #334155 !important;
437
  transition: background 0.12s ease, border-color 0.12s ease, padding-left 0.12s ease !important;
438
  margin-bottom: 4px !important;
439
  width: 100% !important;
@@ -462,10 +481,10 @@ WCC_CSS = """
462
  #wcc-chatbot {
463
  border: 1px solid var(--wcc-border) !important;
464
  border-radius: 12px !important;
465
- background: white !important;
466
  min-height: 460px;
467
  }
468
- #wcc-chatbot .message.bot { background: #eff6ff !important; }
469
  #wcc-chatbot .message.user { background: var(--wcc-blue-light) !important; }
470
 
471
  /* ── Input area ── */
@@ -473,6 +492,8 @@ WCC_CSS = """
473
  border-radius: 10px !important;
474
  border: 1.5px solid var(--wcc-border) !important;
475
  font-size: 0.95rem !important;
 
 
476
  }
477
  #msg-input textarea:focus {
478
  border-color: var(--wcc-blue) !important;
@@ -486,7 +507,7 @@ WCC_CSS = """
486
  }
487
  #clear-btn button {
488
  border-radius: 10px !important;
489
- color: #64748b !important;
490
  }
491
 
492
  /* ── Right panel ── */
@@ -508,12 +529,12 @@ WCC_CSS = """
508
 
509
  /* ── Footer ── */
510
  #wcc-footer {
511
- background: white;
512
  border: 1px solid var(--wcc-border);
513
  border-radius: 10px;
514
  padding: 10px 18px;
515
  font-size: 0.78rem;
516
- color: #64748b;
517
  margin-top: 8px;
518
  text-align: center;
519
  }
 
352
  WCC_CSS = """
353
  /* ── Worcestershire Libraries brand colours ── */
354
  :root {
355
+ color-scheme: light; /* prevent Safari/Firefox dark-mode inversion */
356
  --wcc-navy: #1e3a5f;
357
  --wcc-blue: #1d4ed8;
358
  --wcc-blue-light: #dbeafe;
 
361
  --wcc-green: #166534;
362
  --wcc-bg: #f8fafc;
363
  --wcc-border: #e2e8f0;
364
+ --wcc-surface: #ffffff;
365
+ --wcc-text: #334155;
366
+ --wcc-text-muted: #64748b;
367
+ }
368
+
369
+ /* Dark mode — keep brand integrity while respecting user preference */
370
+ @media (prefers-color-scheme: dark) {
371
+ :root {
372
+ color-scheme: dark;
373
+ --wcc-bg: #0f172a;
374
+ --wcc-border: #334155;
375
+ --wcc-surface: #1e293b;
376
+ --wcc-text: #cbd5e1;
377
+ --wcc-text-muted: #94a3b8;
378
+ --wcc-blue-light: #1e3a5f;
379
+ --wcc-gold-light: #1c1405;
380
+ --wcc-blue: #60a5fa;
381
+ }
382
  }
383
 
384
  /* ── Page background ── */
385
+ .gradio-container { background: var(--wcc-bg) !important; color: var(--wcc-text) !important; }
386
 
387
  /* ── Header ── */
388
  #wcc-header {
 
439
  /* ── Topic navigator ── */
440
  #topic-nav-label {
441
  font-size: 0.78rem;
442
+ color: var(--wcc-text-muted);
443
  margin: 0 0 6px 2px;
444
  letter-spacing: 0.02em;
445
  text-transform: uppercase;
446
  }
447
  .topic-q button {
448
+ background: var(--wcc-surface) !important;
449
  border: 1px solid var(--wcc-border) !important;
450
  border-radius: 8px !important;
451
  text-align: left !important;
452
  padding: 9px 14px !important;
453
  font-size: 0.88rem !important;
454
  line-height: 1.4 !important;
455
+ color: var(--wcc-text) !important;
456
  transition: background 0.12s ease, border-color 0.12s ease, padding-left 0.12s ease !important;
457
  margin-bottom: 4px !important;
458
  width: 100% !important;
 
481
  #wcc-chatbot {
482
  border: 1px solid var(--wcc-border) !important;
483
  border-radius: 12px !important;
484
+ background: var(--wcc-surface) !important;
485
  min-height: 460px;
486
  }
487
+ #wcc-chatbot .message.bot { background: var(--wcc-blue-light) !important; }
488
  #wcc-chatbot .message.user { background: var(--wcc-blue-light) !important; }
489
 
490
  /* ── Input area ── */
 
492
  border-radius: 10px !important;
493
  border: 1.5px solid var(--wcc-border) !important;
494
  font-size: 0.95rem !important;
495
+ background: var(--wcc-surface) !important;
496
+ color: var(--wcc-text) !important;
497
  }
498
  #msg-input textarea:focus {
499
  border-color: var(--wcc-blue) !important;
 
507
  }
508
  #clear-btn button {
509
  border-radius: 10px !important;
510
+ color: var(--wcc-text-muted) !important;
511
  }
512
 
513
  /* ── Right panel ── */
 
529
 
530
  /* ── Footer ── */
531
  #wcc-footer {
532
+ background: var(--wcc-surface);
533
  border: 1px solid var(--wcc-border);
534
  border-radius: 10px;
535
  padding: 10px 18px;
536
  font-size: 0.78rem;
537
+ color: var(--wcc-text-muted);
538
  margin-top: 8px;
539
  text-align: center;
540
  }