/* (c) 2024-2026 ASSISTUK Lars Tiedemann. All Rights Reserved.
   Licensed for use exclusively on www.assistuk-apps.net */
/* =========================================================================
   dp-theme.css — DigitalPainters Central Theme System
   3 Themes: Dark (default), Light, High Contrast
   All variables prefixed --dp- to avoid conflicts.
   ========================================================================= */

/* === Theme: Dark (Default) === */
:root, body.theme-dark {
  --dp-bg:             #0a0a1a;
  --dp-bg-card:        linear-gradient(135deg, #1a1a2e, #2a2a45);
  --dp-bg-card-active: linear-gradient(135deg, #0a1a3a, #1a2a55);
  --dp-bg-overlay:     rgba(0,0,0,0.90);
  --dp-text:           #fff;
  --dp-text-dim:       rgba(255,255,255,0.7);
  --dp-text-muted:     rgba(255,255,255,0.45);
  --dp-accent:         #f39c12;
  --dp-accent-glow:    rgba(243,156,18,0.15);
  --dp-border:         rgba(255,255,255,0.06);
  --dp-border-active:  #f39c12;
  --dp-radius:         min(16px, 1.5vw);
  --dp-radius-sm:      clamp(8px, 1.2vw, 14px);
  --dp-shadow-hover:   0 6px 24px rgba(0,0,0,0.4);
  --dp-shadow-active:  0 0 16px rgba(243,156,18,0.15);
  --dp-tts-color:      #6ec6ff;
  --dp-heart:          #ff6b9d;
  --dp-ok:             #4CAF50;
  --dp-cancel:         #F44336;
  --dp-gap:            6px;
  --dp-font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --dp-text-align:     center;
  --dp-text-valign:    center;
  --dp-text-size:      inherit;
  --dp-text-weight:    600;
  --dp-text-color:     var(--dp-text);
  --dp-icon-size:      calc(100vh / var(--grid-rows, 6) * 0.35);
}

/* === Theme: Light === */
body.theme-light {
  --dp-bg:             #f0f0f5;
  --dp-bg-card:        linear-gradient(135deg, #ffffff, #e8e8f0);
  --dp-bg-card-active: linear-gradient(135deg, #d0e0ff, #c0d0f0);
  --dp-bg-overlay:     rgba(240,240,245,0.95);
  --dp-text:           #1a1a2e;
  --dp-text-dim:       rgba(26,26,46,0.7);
  --dp-text-muted:     rgba(26,26,46,0.45);
  --dp-accent:         #0066cc;
  --dp-accent-glow:    rgba(0,102,204,0.15);
  --dp-border:         rgba(0,0,0,0.08);
  --dp-border-active:  #0066cc;
  --dp-shadow-hover:   0 6px 24px rgba(0,0,0,0.15);
  --dp-shadow-active:  0 0 16px rgba(0,102,204,0.15);
  --dp-tts-color:      #0066cc;
  --dp-heart:          #e0436b;
}

/* === Theme: High Contrast === */
body.theme-contrast {
  --dp-bg:             #000000;
  --dp-bg-card:        linear-gradient(135deg, #1a1a1a, #2a2a2a);
  --dp-bg-card-active: linear-gradient(135deg, #003366, #004488);
  --dp-bg-overlay:     rgba(0,0,0,0.95);
  --dp-text:           #ffffff;
  --dp-text-dim:       rgba(255,255,255,0.9);
  --dp-text-muted:     rgba(255,255,255,0.7);
  --dp-accent:         #4da6ff;
  --dp-accent-glow:    rgba(77,166,255,0.3);
  --dp-border:         rgba(255,255,255,0.15);
  --dp-border-active:  #4da6ff;
  --dp-shadow-hover:   0 6px 24px rgba(0,0,0,0.6);
  --dp-shadow-active:  0 0 20px rgba(77,166,255,0.3);
}

/* === Theme: Gray === */
body.theme-gray {
  --dp-bg:             #1f2328;
  --dp-bg-card:        linear-gradient(135deg, #2f343a, #3a4047);
  --dp-bg-card-active: linear-gradient(135deg, #4b535d, #5a646f);
  --dp-bg-overlay:     rgba(28,31,36,0.94);
  --dp-text:           #f1f3f5;
  --dp-text-dim:       rgba(241,243,245,0.78);
  --dp-text-muted:     rgba(241,243,245,0.52);
  --dp-accent:         #a0acb8;
  --dp-accent-glow:    rgba(160,172,184,0.22);
  --dp-border:         rgba(255,255,255,0.10);
  --dp-border-active:  #bec8d2;
  --dp-shadow-hover:   0 6px 24px rgba(0,0,0,0.45);
  --dp-shadow-active:  0 0 16px rgba(190,200,210,0.28);
}

/* === Theme: Colorful === */
body.theme-colorful {
  --dp-bg:             #0d1026;
  --dp-bg-card:        linear-gradient(140deg, #1c2f5b 0%, #4b2a68 45%, #7a2a4d 100%);
  --dp-bg-card-active: linear-gradient(140deg, #0f6ab4 0%, #7b3db8 50%, #e64d7a 100%);
  --dp-bg-overlay:     rgba(9,12,28,0.92);
  --dp-text:           #ffffff;
  --dp-text-dim:       rgba(255,255,255,0.84);
  --dp-text-muted:     rgba(255,255,255,0.58);
  --dp-accent:         #4dd0ff;
  --dp-accent-glow:    rgba(77,208,255,0.30);
  --dp-border:         rgba(255,255,255,0.14);
  --dp-border-active:  #8cf2ff;
  --dp-shadow-hover:   0 8px 28px rgba(0,0,0,0.42);
  --dp-shadow-active:  0 0 18px rgba(140,242,255,0.36);
}

/* === Theme: Modern === */
body.theme-modern {
  --dp-bg:             #f8f9fc;
  --dp-bg-card:        linear-gradient(135deg, #ffffff, #f0f1f8);
  --dp-bg-card-active: linear-gradient(135deg, #eef0ff, #dde0ff);
  --dp-bg-overlay:     rgba(248,249,252,0.96);
  --dp-text:           #1e1e2e;
  --dp-text-dim:       rgba(30,30,46,0.72);
  --dp-text-muted:     rgba(30,30,46,0.45);
  --dp-accent:         #6366f1;
  --dp-accent-glow:    rgba(99,102,241,0.15);
  --dp-border:         rgba(0,0,0,0.06);
  --dp-border-active:  #6366f1;
  --dp-shadow-hover:   0 4px 16px rgba(99,102,241,0.12);
  --dp-shadow-active:  0 0 12px rgba(99,102,241,0.18);
  --dp-tts-color:      #6366f1;
  --dp-heart:          #ec4899;
}

/* === Theme: Kunst === */
body.theme-kunst {
  --dp-bg:             #1a1410;
  --dp-bg-card:        linear-gradient(140deg, #2a2018 0%, #3a2a1e 50%, #2e2218 100%);
  --dp-bg-card-active: linear-gradient(140deg, #4a3520 0%, #6b4a28 50%, #8b6530 100%);
  --dp-bg-overlay:     rgba(22,17,12,0.94);
  --dp-text:           #f5e6d0;
  --dp-text-dim:       rgba(245,230,208,0.80);
  --dp-text-muted:     rgba(245,230,208,0.50);
  --dp-accent:         #d4a54a;
  --dp-accent-glow:    rgba(212,165,74,0.25);
  --dp-border:         rgba(212,165,74,0.12);
  --dp-border-active:  #d4a54a;
  --dp-shadow-hover:   0 6px 24px rgba(0,0,0,0.45);
  --dp-shadow-active:  0 0 16px rgba(212,165,74,0.30);
  --dp-tts-color:      #e8b84a;
  --dp-heart:          #e06050;
}

/* =========================================================================
   Base Reset & Body
   ========================================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%; height: 100dvh;
  background: var(--dp-bg);
  font-family: var(--dp-font);
  color: var(--dp-text);
  overflow: hidden;
}

/* Subtle background glow (dark theme only) */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 30%, rgba(243,156,18,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 80%, rgba(233,69,96,0.04) 0%, transparent 50%);
}
body.theme-light::before,
body.theme-contrast::before,
body.theme-gray::before,
body.theme-modern::before { display: none; }
body.theme-colorful::before {
  display: block;
  background:
    radial-gradient(ellipse at 20% 25%, rgba(77,208,255,0.16) 0%, transparent 52%),
    radial-gradient(ellipse at 78% 78%, rgba(230,77,122,0.14) 0%, transparent 50%),
    radial-gradient(ellipse at 52% 8%, rgba(140,110,255,0.12) 0%, transparent 45%);
}
body.theme-kunst::before {
  display: block;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(212,165,74,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 75% 75%, rgba(224,96,80,0.10) 0%, transparent 48%);
}

/* =========================================================================
   Content Tile (.dp-tile) — Project tiles, theme tiles
   ========================================================================= */
.dp-tile {
  display: flex; flex-direction: column;
  align-items: var(--dp-text-align, center);
  justify-content: var(--dp-text-valign, center);
  border-radius: var(--dp-radius);
  text-decoration: none; color: var(--dp-text-color);
  position: relative; overflow: hidden;
  background: var(--dp-bg-card);
  border: 1px solid var(--dp-border);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  cursor: pointer; min-height: 0;
  font-size: var(--dp-text-size);
  font-weight: var(--dp-text-weight);
  width: 100%; height: 100%;
}
@media (hover: hover) { .dp-tile:hover { transform: scale(1.03); box-shadow: var(--dp-shadow-hover), 0 0 20px var(--dp-accent-glow); border-color: rgba(255,255,255,0.12); z-index: 2; } }
.dp-tile:active { transform: scale(0.97); }
.dp-tile.inactive { opacity: 0.35; filter: grayscale(0.6); }
.dp-tile.inactive::after {
  content: 'DEV'; position: absolute; top: 6px; right: 6px;
  background: #e94560; color: #fff; font-size: 10px; font-weight: 700;
  padding: 2px 5px; border-radius: 4px; z-index: 2;
}

/* =========================================================================
   Function Button (.dp-btn-func) — Settings, grid, dwell, filter
   ========================================================================= */
.dp-btn-func {
  display: flex; flex-direction: column;
  align-items: var(--dp-text-align, center);
  justify-content: var(--dp-text-valign, center);
  text-align: var(--dp-text-align, center);
  font-size: var(--dp-text-size);
  font-weight: var(--dp-text-weight);
  color: var(--dp-text-color);
  background: var(--dp-bg-card);
  border: 2px solid transparent;
  border-radius: var(--dp-radius-sm);
  position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  cursor: pointer; min-height: 0;
  font-family: inherit;
  width: 100%; height: 100%;
}
@media (hover: hover) { .dp-btn-func:hover { transform: scale(1.03); box-shadow: var(--dp-shadow-hover), 0 0 12px var(--dp-accent-glow); border-color: var(--dp-accent); z-index: 2; } }
.dp-btn-func:active { transform: scale(0.97); }
.dp-btn-func.active {
  border-color: var(--dp-border-active);
  background: var(--dp-bg-card-active);
  box-shadow: var(--dp-shadow-active);
}

/* =========================================================================
   Link Button (.dp-btn-link) — Navigation, back, close
   ========================================================================= */
.dp-btn-link {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--dp-bg-card-active);
  border: 2px solid var(--dp-accent);
  border-radius: var(--dp-radius-sm);
  color: var(--dp-text); font-family: inherit;
  font-size: clamp(12px, 1.5vw, 17px);
  cursor: pointer; text-decoration: none;
  transition: transform 0.15s;
  position: relative; overflow: hidden;
}
@media (hover: hover) { .dp-btn-link:hover { transform: scale(1.03); } }

/* =========================================================================
   TTS Button (.dp-btn-tts) — Read-aloud buttons
   ========================================================================= */
.dp-btn-tts {
  display: flex; align-items: center; justify-content: center;
  background: var(--dp-bg-card);
  border: 2px solid transparent;
  border-radius: var(--dp-radius-sm);
  color: var(--dp-tts-color); cursor: pointer;
  position: relative; overflow: hidden;
  font-size: clamp(16px, 2.2vw, 28px); font-family: inherit;
  transition: transform 0.15s, border-color 0.15s;
}
@media (hover: hover) { .dp-btn-tts:hover { transform: scale(1.05); border-color: var(--dp-accent); z-index: 2; } }
.dp-btn-tts.speaking { border-color: var(--dp-heart); color: var(--dp-heart); }

/* =========================================================================
   Label (.dp-label) — Non-interactive title/description areas
   ========================================================================= */
.dp-label {
  display: flex; align-items: center; justify-content: center;
  color: var(--dp-text); font-weight: 700;
  text-align: center; pointer-events: none;
}

/* =========================================================================
   OK/Cancel Buttons (.dp-btn-ok / .dp-btn-cancel) — Confirm dialogs
   ========================================================================= */
.dp-btn-ok {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--dp-bg-card);
  border: 3px solid var(--dp-ok);
  border-radius: var(--dp-radius);
  color: var(--dp-text); cursor: pointer;
  position: relative; overflow: hidden;
  font-family: inherit; font-size: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}
@media (hover: hover) { .dp-btn-ok:hover { transform: scale(1.03); box-shadow: 0 0 20px rgba(76,175,80,0.3); z-index: 2; } }

.dp-btn-cancel {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: var(--dp-bg-card);
  border: 3px solid var(--dp-cancel);
  border-radius: var(--dp-radius);
  color: var(--dp-text); cursor: pointer;
  position: relative; overflow: hidden;
  font-family: inherit; font-size: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}
@media (hover: hover) { .dp-btn-cancel:hover { transform: scale(1.03); box-shadow: 0 0 20px rgba(244,67,54,0.3); z-index: 2; } }

/* =========================================================================
   Shared UI Elements
   ========================================================================= */

/* Dwell dot (eye-tracking indicator) */
.dwell-dot {
  position: absolute; z-index: 10; top: 50%; left: 50%;
  transform: translate(-50%, -50%); border-radius: 50%;
  pointer-events: none; width: 0; height: 0;
}

/* Overlay pattern (for lang/settings/confirm overlays) */
.dp-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: var(--dp-bg-overlay);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.dp-overlay.open {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 10), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows, 6), minmax(0, 1fr));
  gap: var(--dp-gap); padding: var(--dp-gap);
}

/* Portrait lockout */
#rotate-prompt {
  display: none; position: fixed; inset: 0;
  background: var(--dp-bg); color: var(--dp-text);
  font-family: inherit; justify-content: center; align-items: center;
  text-align: center; z-index: 99999; flex-direction: column; gap: 16px;
}
#rotate-prompt .rotate-icon { font-size: 4em; }
#rotate-prompt .rotate-text { font-size: clamp(16px, 3vw, 24px); line-height: 1.5; opacity: 0.9; }
@media (orientation: portrait) and (max-width: 1024px) {
  #rotate-prompt { display: flex; }
  body > *:not(#rotate-prompt) { display: none !important; }
}

/* Auto-fit text sizing — add .dp-autofit to any text element */
.dp-autofit {
  overflow: hidden;
}

/* Tile content sub-elements */
.tile-content { position: relative; text-align: center; padding: 6px 6px 8px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; width: 100%; height: 100%; box-sizing: border-box; }
.tile-content .tile-name,
.tile-content .tile-desc { background: rgba(0,0,0,0.5); padding: 2px 10px; border-radius: 6px; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.tile-icon { font-size: var(--dp-icon-size); margin-bottom: 2px; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; width: 100%; }
.tile-icon img { display: block; max-width: 60%; max-height: 60%; object-fit: contain; height: clamp(40px, 8vh, 72px); filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3)); }
.theme-tile .tile-icon img { max-width: 96%; max-height: 96%; }
.tile-name { font-size: calc(100vh / var(--grid-rows, 6) * 0.16); font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,0.75), 0 1px 3px rgba(0,0,0,0.9); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.tile-desc { font-size: calc(100vh / var(--grid-rows, 6) * 0.10); opacity: 0.92; margin-top: 2px; text-shadow: 0 1px 5px rgba(0,0,0,0.75), 0 1px 2px rgba(0,0,0,0.9); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
/* Keep strong shadow on image-background tiles even in light mode */
body.theme-light .tile-name, body.theme-modern .tile-name { text-shadow: 0 2px 8px rgba(0,0,0,0.75), 0 1px 3px rgba(0,0,0,0.9); }
body.theme-light .tile-desc, body.theme-modern .tile-desc { text-shadow: 0 1px 5px rgba(0,0,0,0.75), 0 1px 2px rgba(0,0,0,0.9); }

/* =========================================================================
   Tile Overlay — gradient for text readability over images
   ========================================================================= */
.tile-overlay {
  background: linear-gradient(180deg,
    rgba(0,0,0,0.05) 0%,
    rgba(0,0,0,0.35) 50%,
    rgba(0,0,0,0.65) 100%);
}

/* =========================================================================
   Toolbar Active States & Color Buttons
   ========================================================================= */

/* Active toolbar button: colored background */
.dp-toolbar-btn.active {
  background: linear-gradient(135deg, var(--dp-accent), #c17d0e) !important;
  border-color: var(--dp-accent) !important;
  box-shadow: 0 0 12px var(--dp-accent-glow);
  color: #fff;
}
@supports (background: color-mix(in srgb, red, blue)) {
  .dp-toolbar-btn.active {
    background: linear-gradient(135deg, var(--dp-accent), color-mix(in srgb, var(--dp-accent) 80%, #000)) !important;
  }
}

/* Inactive mode button: dimmed */
.dp-toolbar-btn[data-group="mode"]:not(.active) {
  opacity: 0.45;
  filter: grayscale(0.4);
}

/* Round color buttons */
.dp-color-btn {
  border-radius: 50% !important;
  border: 3px solid rgba(255,255,255,0.15) !important;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  aspect-ratio: 1;
}
@media (hover: hover) {
  .dp-color-btn:hover {
    transform: scale(1.15);
    border-color: rgba(255,255,255,0.5);
  }
}
.dp-color-btn.active {
  border-color: #fff !important;
  box-shadow: 0 0 12px rgba(255,255,255,0.3);
  transform: scale(1.1);
}

/* =========================================================================
   PBN (Paint by Numbers) — Color swatch number labels + hint pulse
   ========================================================================= */

/* Number label on each color swatch (PBN only — only rendered when labels are passed) */
.dp-color {
  position: relative;
}
.dp-color .dp-color-num {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 2.5vw, 28px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.95), 0 0 8px rgba(0,0,0,0.6), 0 2px 6px rgba(0,0,0,0.4);
  pointer-events: none;
  line-height: 1;
  user-select: none;
}

/* Hint pulse: briefly highlights the correct color swatch */
@keyframes pbn-hint-pulse {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0   rgba(255,255,255,0.9); }
  40%  { transform: scale(1.22); box-shadow: 0 0 0 10px rgba(255,255,255,0.5); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0   rgba(255,255,255,0); }
}
.dp-color.pbn-hint {
  animation: pbn-hint-pulse 0.9s ease;
  z-index: 2;
}

/* =========================================================================
   Fade-in Animations
   ========================================================================= */

/* Tile entrance animation */
@keyframes dp-fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Page fade-in */
body {
  animation: dp-fadeIn 0.3s ease-out;
}
@keyframes dp-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* =========================================================================
   Settings Overlay (#settings-overlay) — Created by dp-hub-settings.js
   ========================================================================= */
#settings-overlay {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: var(--dp-bg, #0a0a1a);
}
#settings-overlay.open {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 10), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows, 6), minmax(0, 1fr));
  gap: 6px; padding: 6px;
}
.settings-title {
  display: flex; align-items: center; justify-content: center;
  font-size: calc(100vh / var(--grid-rows) * 0.15); font-weight: 700;
  color: var(--dp-text);
}
.settings-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: var(--dp-radius-sm); border: 2px solid transparent;
  background: var(--dp-bg-card); color: var(--dp-text); cursor: pointer;
  position: relative; overflow: hidden; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  font-family: inherit; font-size: inherit;
}
@media (hover: hover) { .settings-tile:hover { transform: scale(1.03); box-shadow: var(--dp-shadow-hover), 0 0 12px var(--dp-accent-glow); border-color: var(--dp-accent); z-index: 1; } }
.settings-tile.active {
  border-color: var(--dp-border-active); background: var(--dp-bg-card-active);
  box-shadow: var(--dp-shadow-active);
}
.settings-tile .tile-icon { font-size: calc(100vh / var(--grid-rows) * 0.28); margin-bottom: 2px; }
.settings-tile .tile-name { font-size: calc(100vh / var(--grid-rows) * 0.13); font-weight: 600; }
.settings-color-preview {
  width: calc(100vh / var(--grid-rows) * 0.22); height: calc(100vh / var(--grid-rows) * 0.22);
  border-radius: 50%; margin-bottom: 4px; border: 2px solid rgba(255,255,255,0.3);
}
.settings-category {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5vh;
  cursor: pointer; position: relative; overflow: hidden;
  background: var(--dp-bg-card, #2a2a3e); border: 2px solid transparent; border-radius: 12px;
  color: var(--dp-text, #e0e0e0); font-family: inherit; font-size: inherit;
  transition: transform 0.15s, border-color 0.15s;
}
@media (hover: hover) { .settings-category:hover { transform: scale(1.03); border-color: var(--dp-accent, #7b68ee); z-index: 2; } }
.settings-category.active {
  border-color: var(--dp-border-active); background: var(--dp-bg-card-active);
  box-shadow: var(--dp-shadow-active);
}
.settings-category .tile-icon { font-size: calc(100vh / var(--grid-rows) * 0.4); }
.settings-category .tile-name { font-size: calc(100vh / var(--grid-rows) * 0.15); font-weight: 600; }
/* Inline SVG icons (used by settings tiles) */
.tile-svg {
  width: 1em; height: 1em; display: inline-block; vertical-align: middle;
  stroke: currentColor; stroke-width: 2; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
}

/* =========================================================================
   Backwards-Compatibility Aliases
   ========================================================================= */
.tile       { /* alias for .dp-tile — apply same base styles */
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: var(--dp-radius); text-decoration: none; color: var(--dp-text);
  position: relative; overflow: hidden;
  background: var(--dp-bg-card);
  border: 1px solid var(--dp-border);
  transition: transform 0.2s ease, box-shadow 0.3s ease, border-color 0.15s;
  cursor: pointer; min-height: 0;
  width: 100%; height: 100%;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: dp-fadeInUp 0.4s ease-out both;
}
@media (hover: hover) { .tile:hover { transform: scale(1.03); box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.12); z-index: 100; } }
body.theme-light .tile:hover, body.theme-modern .tile:hover { border-color: var(--dp-border-active) !important; box-shadow: var(--dp-shadow-hover) !important; }
.tile:active { transform: scale(0.97); }

.setting-tile, .nav-btn {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: var(--dp-radius-sm); text-decoration: none; color: var(--dp-text);
  position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  cursor: pointer; min-height: 0;
  border: 2px solid transparent !important;
  outline: none !important;
  background: var(--dp-bg-card);
  font-family: inherit; font-size: inherit;
  width: 100%; height: 100%;
}
@media (hover: hover) { .setting-tile:hover, .nav-btn:hover { transform: scale(1.03); box-shadow: var(--dp-shadow-hover), 0 0 12px var(--dp-accent-glow); border-color: var(--dp-accent) !important; z-index: 100; } }
.setting-tile:active, .nav-btn:active { transform: scale(0.97); }
.setting-tile:focus, .nav-btn:focus { outline: none; }
.setting-tile.active {
  border-color: var(--dp-border-active);
  background: var(--dp-bg-card-active);
  box-shadow: var(--dp-shadow-active);
}

.lang-tile {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: var(--dp-radius-sm);
  border: 2px solid transparent;
  background: var(--dp-bg-card); color: var(--dp-text);
  cursor: pointer; position: relative; overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  font-family: inherit; font-size: inherit;
  width: 100%; height: 100%;
}
@media (hover: hover) { .lang-tile:hover { transform: scale(1.03); box-shadow: var(--dp-shadow-hover), 0 0 12px var(--dp-accent-glow); border-color: var(--dp-accent); z-index: 2; } }
.lang-tile.active {
  border-color: var(--dp-border-active);
  background: var(--dp-bg-card-active);
  box-shadow: var(--dp-shadow-active);
}
.lang-tile .tile-name {
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  font-family: "Segoe UI", system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Noto Sans JP", "Noto Sans KR", sans-serif;
}

.g-btn {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  border: 2px solid var(--dp-border);
  background: var(--dp-bg-card); color: var(--dp-text);
  border-radius: var(--dp-radius-sm);
  font-family: inherit; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-decoration: none; padding: 4px;
  width: 100%; height: 100%;
}
@media (hover: hover) { .g-btn:hover { transform: scale(1.03); box-shadow: var(--dp-shadow-hover); z-index: 2; } }
.g-btn:active { transform: scale(0.97); }
.g-btn.active {
  border-color: var(--dp-border-active);
  box-shadow: var(--dp-shadow-active);
}

.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--dp-bg-card-active);
  border: 2px solid var(--dp-accent);
  border-radius: var(--dp-radius-sm);
  color: var(--dp-text); font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: transform 0.15s;
  position: relative; overflow: hidden;
}
@media (hover: hover) { .nav-btn:hover { transform: scale(1.03); } }

/* =========================================================================
   TTS Tour Button & Highlight
   ========================================================================= */
.tile-tts {
  background: linear-gradient(145deg, #1a1a2e, #1a2040, #1a1a2e);
  border: 1px solid rgba(79,172,254,0.15);
}
@media (hover: hover) { .tile-tts:hover { border-color: rgba(79,172,254,0.3); box-shadow: 0 4px 16px rgba(79,172,254,0.1); } }
.tile-tts.tour-active {
  border-color: rgba(79,172,254,0.5);
  box-shadow: 0 0 16px rgba(79,172,254,0.2);
}

.tile-highlight {
  animation: tile-pulse 0.8s ease-in-out infinite alternate;
  border-color: rgba(79,172,254,0.6) !important;
  box-shadow: 0 0 20px rgba(79,172,254,0.3), 0 0 40px rgba(0,242,254,0.15) !important;
  z-index: 5;
}
@keyframes tile-pulse { from { transform: scale(1); } to { transform: scale(1.04); } }

/* ── TTS Highlight (unified for all modules) ── */
.dp-tts-highlight {
    outline: 3px solid rgba(79,172,254,0.6);
    outline-offset: 2px;
    animation: dp-tts-glow 0.8s infinite alternate;
}
.tile.dp-tts-highlight {
    animation: dp-tts-glow 0.8s infinite alternate, dp-tts-scale 0.8s infinite alternate;
}
@keyframes dp-tts-glow {
    from { box-shadow: 0 0 6px rgba(79,172,254,0.3); }
    to   { box-shadow: 0 0 18px rgba(79,172,254,0.6); }
}
@keyframes dp-tts-scale {
    from { transform: scale(1); }
    to   { transform: scale(1.04); }
}

/* =========================================================================
   Light / Modern theme — fix hardcoded white text in hub pages
   ========================================================================= */
body.theme-light .hub-title h1,
body.theme-modern .hub-title h1 {
  color: var(--dp-text) !important;
}
body.theme-light .lang-title,
body.theme-modern .lang-title {
  color: var(--dp-text) !important;
}
body.theme-light .lang-nav,
body.theme-modern .lang-nav {
  background: var(--dp-bg-card-active) !important;
  color: var(--dp-text) !important;
  border-color: var(--dp-accent) !important;
}
body.theme-light .settings-color-preview,
body.theme-modern .settings-color-preview {
  border-color: rgba(0,0,0,0.2) !important;
}
/* AssistUK logo: invert to dark blue in light/modern mode */
body.theme-light #logo-left img,
body.theme-modern #logo-left img {
  filter: invert(1) sepia(1) saturate(3) hue-rotate(190deg) brightness(0.35) !important;
  opacity: 1 !important;
}

/* ── TTS Lock State (tap required before Dwell works) ── */
.tts-locked { opacity: 0.5; pointer-events: none; }
.tts-locked .dwell-dot { display: none; }
.tts-tap-hint {
    font-size: clamp(9px, 1.4vw, 13px);
    color: var(--dp-accent, #4facfe);
    text-align: center;
    margin-top: 2px;
    line-height: 1.2;
}

/* =========================================================================
   Tile Entry Animations — staggered fade-in on page load
   ========================================================================= */
@keyframes dp-tile-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tile, .dp-tile, .setting-tile, .nav-btn, .lang-tile, .dp-btn-func, .dp-btn-link,
.hub-title, .hub-dp-logo, .settings-tile, .settings-category,
.pay-card, .page-header, .tts-btn {
  animation: dp-tile-enter 0.4s ease-out both;
}

/* Staggered delays via nth-child on body direct children */
body > *:nth-child(1)  { animation-delay: 0.02s; }
body > *:nth-child(2)  { animation-delay: 0.05s; }
body > *:nth-child(3)  { animation-delay: 0.08s; }
body > *:nth-child(4)  { animation-delay: 0.11s; }
body > *:nth-child(5)  { animation-delay: 0.14s; }
body > *:nth-child(6)  { animation-delay: 0.17s; }
body > *:nth-child(7)  { animation-delay: 0.20s; }
body > *:nth-child(8)  { animation-delay: 0.23s; }
body > *:nth-child(9)  { animation-delay: 0.26s; }
body > *:nth-child(10) { animation-delay: 0.29s; }
body > *:nth-child(11) { animation-delay: 0.30s; }
body > *:nth-child(12) { animation-delay: 0.31s; }
body > *:nth-child(13) { animation-delay: 0.32s; }
body > *:nth-child(14) { animation-delay: 0.33s; }
body > *:nth-child(15) { animation-delay: 0.34s; }
body > *:nth-child(16) { animation-delay: 0.35s; }
body > *:nth-child(17) { animation-delay: 0.36s; }
body > *:nth-child(18) { animation-delay: 0.37s; }
body > *:nth-child(19) { animation-delay: 0.38s; }
body > *:nth-child(20) { animation-delay: 0.39s; }

/* ===== Reduced motion (Epilepsy/Photosensitivity — global) ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .tile:hover, .g-btn:hover, .g-slot:hover {
    transform: none !important;
  }
}
