/* Piqaloo dark theme. Loaded after Tailwind and the component stylesheets, so
   these overrides win for the common utility classes used across the site.
   Light mode is unchanged. */
html.dark {
  color-scheme: dark;
  --pg-bg: #0b1120;
  --pg-panel: #111827;
  --pg-panel-soft: #162033;
  --pg-panel-alt: #1f2937;
  --pg-border: #334155;
  --pg-text: #e5e7eb;
  --pg-text-strong: #f8fafc;
  --pg-muted: #a8b5c6;
}

html.dark body,
html.dark main {
  background: var(--pg-bg) !important;
  color: var(--pg-text) !important;
}

/* Surfaces built from Tailwind utilities */
html.dark .bg-white,
html.dark .bg-gray-50,
html.dark .bg-gray-100,
html.dark .bg-slate-50,
html.dark .bg-slate-100,
html.dark .bg-zinc-50 {
  background-color: var(--pg-panel) !important;
}
html.dark [class*="bg-white/"] {
  background-color: rgba(17, 24, 39, .94) !important;
}
html.dark .bg-gradient-to-br {
  background-image: linear-gradient(135deg, #1e1b4b 0%, #312e63 55%, #4c1d95 100%) !important;
}
html.dark .bg-violet-50,
html.dark .bg-indigo-50,
html.dark .bg-blue-50,
html.dark .bg-sky-50 {
  background-color: #1c2540 !important;
}
html.dark .bg-amber-50,
html.dark .bg-yellow-50 {
  background-color: #3a2f16 !important;
}
html.dark .bg-rose-50,
html.dark .bg-red-50 {
  background-color: #3a1f2a !important;
}
html.dark .bg-emerald-50,
html.dark .bg-green-50 {
  background-color: #14332b !important;
}
html.dark .bg-blue-100,
html.dark .bg-indigo-100,
html.dark .bg-sky-100 {
  background-color: #1e3a5f !important;
}
html.dark .bg-violet-100,
html.dark .bg-fuchsia-100 {
  background-color: #2e2455 !important;
}
html.dark .bg-rose-100,
html.dark .bg-red-100 {
  background-color: #4a2130 !important;
}
html.dark .bg-amber-100,
html.dark .bg-yellow-100 {
  background-color: #4a3b16 !important;
}
html.dark .bg-emerald-100,
html.dark .bg-green-100 {
  background-color: #174334 !important;
}
html.dark .bg-gray-200,
html.dark .bg-gray-300,
html.dark .bg-slate-200 {
  background-color: #273449 !important;
}

/* Text */
html.dark .text-gray-900,
html.dark .text-gray-800,
html.dark .text-gray-700,
html.dark .text-black,
html.dark .text-slate-900,
html.dark .text-slate-800,
html.dark .text-slate-700 {
  color: var(--pg-text-strong) !important;
}
html.dark .text-gray-600,
html.dark .text-gray-500,
html.dark .text-slate-600,
html.dark .text-slate-500 {
  color: var(--pg-muted) !important;
}
html.dark .text-gray-400,
html.dark .text-slate-400 {
  color: #94a3b8 !important;
}
html.dark .text-violet-700,
html.dark .text-violet-600,
html.dark .text-purple-700,
html.dark .text-indigo-600,
html.dark .text-indigo-700 {
  color: #c4b5fd !important;
}
html.dark .text-blue-600,
html.dark .text-blue-700,
html.dark .text-sky-600 {
  color: #93c5fd !important;
}
html.dark .text-emerald-700,
html.dark .text-green-700,
html.dark .text-teal-700 {
  color: #6ee7b7 !important;
}
html.dark .text-amber-700,
html.dark .text-yellow-700 {
  color: #fcd34d !important;
}
html.dark .text-rose-700,
html.dark .text-rose-800,
html.dark .text-red-600,
html.dark .text-red-700,
html.dark .text-red-800 {
  color: #fda4af !important;
}
html.dark .text-blue-800,
html.dark .text-blue-900,
html.dark .text-sky-700,
html.dark .text-sky-800 {
  color: #93c5fd !important;
}
html.dark .text-violet-800,
html.dark .text-violet-900,
html.dark .text-purple-800,
html.dark .text-indigo-800 {
  color: #c4b5fd !important;
}
html.dark .text-amber-800,
html.dark .text-amber-900,
html.dark .text-yellow-800 {
  color: #fcd34d !important;
}
html.dark .text-emerald-800,
html.dark .text-green-800 {
  color: #6ee7b7 !important;
}

/* Borders */
html.dark .border-gray-100,
html.dark .border-gray-200,
html.dark .border-gray-300,
html.dark .border-slate-200,
html.dark .border-violet-100,
html.dark .border-violet-200,
html.dark .border-blue-200,
html.dark .border-amber-200,
html.dark .border-rose-200,
html.dark .border-emerald-200 {
  border-color: var(--pg-border) !important;
}

/* Form controls */
html.dark input:not([type="color"]):not([type="checkbox"]):not([type="radio"]),
html.dark select,
html.dark textarea {
  background-color: #0f172a !important;
  color: var(--pg-text) !important;
  border-color: #475569 !important;
}
html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #94a3b8 !important;
}
html.dark input[type="checkbox"],
html.dark input[type="radio"] {
  accent-color: #8b5cf6;
}

/* Generator-specific inline-styled elements */
html.dark .pro-tag { color: #c4b5fd !important; }
html.dark #btnToggleGrid:not(.is-active),
html.dark #btnToggleSymbols:not(.is-active) { color: #c4b5fd !important; }
html.dark #canvasCard .fs-toolbar,
html.dark #chartEditBar {
  background: rgba(17, 24, 39, .96) !important;
  border-color: #334155 !important;
}
html.dark .site-nav a.is-active {
  background: linear-gradient(135deg, #7c3aed, #2563eb) !important;
  color: #ffffff !important;
  box-shadow: 0 3px 8px rgba(124, 58, 237, .25);
}
html.dark .login-link {
  background: #1f2937 !important;
  color: #ddd6fe !important;
  border-color: #475569 !important;
}

/* Buttons that use neutral styling */
html.dark .btn-ghost,
html.dark .btn-secondary {
  background-color: var(--pg-panel-alt) !important;
  color: var(--pg-text) !important;
  border-color: #475569 !important;
}

/* Header and navigation */
html.dark .site-header {
  background: rgba(11, 17, 32, .95) !important;
  border-bottom-color: #1f2937 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
html.dark .site-brand__name,
html.dark .site-nav a.is-active {
  color: var(--pg-text-strong) !important;
}
html.dark .site-nav {
  background: var(--pg-panel-soft);
  border-color: #243049;
}
html.dark .site-nav a {
  color: #cbd5e1;
}
html.dark .site-nav a:hover {
  background: #25314b;
  color: #ddd6fe;
}
html.dark .site-action {
  color: #cbd5e1;
}
html.dark .site-action:hover {
  background: #2b2450;
  color: #ddd6fe;
}
html.dark .site-action.is-active {
  background: #312e63 !important;
  color: #ddd6fe !important;
  border-color: #6d28d9 !important;
  box-shadow: none;
}
html.dark .account-menu__panel,
html.dark .mobile-menu {
  background: #111827 !important;
  color: var(--pg-text) !important;
  border-color: #334155 !important;
}
html.dark .account-menu__panel a,
html.dark .mobile-menu__nav a,
html.dark .mobile-menu__account a {
  color: var(--pg-text) !important;
}
html.dark .account-menu__panel a:hover,
html.dark .account-menu__panel a.is-active,
html.dark .mobile-menu__nav a:hover,
html.dark .mobile-menu__nav a.is-active,
html.dark .mobile-menu__account a:hover,
html.dark .mobile-menu__account a.site-action.is-active {
  background: #312e63 !important;
  color: #ddd6fe !important;
}
html.dark .account-menu[open] > summary {
  background: #312e63 !important;
  color: #ddd6fe !important;
}
html.dark .mobile-toggle span {
  background: var(--pg-text);
}

/* Blog and About heroes/cards */
html.dark .blog-hero,
html.dark .about-hero {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e63 55%, #4c1d95 100%) !important;
}
html.dark .blog-eyebrow,
html.dark .about-eyebrow {
  background: #312e63;
  color: #ddd6fe;
}
html.dark .blog-hero h1,
html.dark .blog-hero h2,
html.dark .about-hero h1,
html.dark .about-hero h2,
html.dark .page-surface h1 {
  color: var(--pg-text-strong) !important;
}
html.dark .blog-hero p,
html.dark .about-hero p,
html.dark .blog-meta {
  color: #cbd5e1 !important;
}
html.dark .page-surface {
  background: linear-gradient(180deg, #0b1120 0%, #111827 420px) !important;
}
html.dark .filter-card {
  background: var(--pg-panel) !important;
  color: var(--pg-text) !important;
  border-color: var(--pg-border) !important;
  box-shadow: none;
}
html.dark .blog-prose p,
html.dark .blog-prose li,
html.dark .blog-prose td,
html.dark .about-card p,
html.dark .about-value p {
  color: #cbd5e1 !important;
}
html.dark .blog-prose h1,
html.dark .blog-prose h2,
html.dark .blog-prose h3,
html.dark .blog-prose h4,
html.dark .blog-prose strong,
html.dark .about-card h2,
html.dark .about-card h3,
html.dark .about-value h3,
html.dark .blog-related h2 {
  color: var(--pg-text-strong) !important;
}
html.dark .blog-prose a,
html.dark .about-card a {
  color: #c4b5fd !important;
}
html.dark .blog-prose blockquote,
html.dark .blog-toc,
html.dark .about-card,
html.dark .blog-related a,
html.dark .about-value {
  background: var(--pg-panel) !important;
  color: var(--pg-text) !important;
  border-color: var(--pg-border) !important;
}
html.dark .blog-toc a {
  color: #cbd5e1 !important;
}
html.dark .blog-prose code,
html.dark code {
  background: #1f2937;
  color: #e5e7eb;
}

/* Plans page */
html.dark .plans-free {
  background: var(--pg-panel) !important;
  border-color: var(--pg-border) !important;
  box-shadow: none;
  color: var(--pg-text) !important;
}
html.dark .plans-free h2,
html.dark .plans-free p,
html.dark .plans-free ul,
html.dark .plans-free li {
  color: #cbd5e1 !important;
}
html.dark .plans-free li[style*="9ca3af"] {
  color: #94a3b8 !important;
}
html.dark .plans-free a {
  color: #c4b5fd !important;
}

/* Auth pages */
html.dark .auth-shell {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e63 100%) !important;
}
html.dark .auth-card {
  background: var(--pg-panel) !important;
  border-color: var(--pg-border) !important;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  color: var(--pg-text) !important;
}
html.dark .auth-badge {
  background: #312e63 !important;
  color: #ddd6fe !important;
}
html.dark .auth-title {
  color: var(--pg-text-strong) !important;
}
html.dark .auth-subtitle,
html.dark .auth-captcha-note,
html.dark .auth-field > span,
html.dark .auth-field > span.auth-hint,
html.dark .auth-foot,
html.dark .auth-foot p {
  color: #cbd5e1 !important;
}
html.dark .auth-foot a {
  color: #c4b5fd !important;
}
html.dark .auth-input {
  background: #0f172a !important;
  color: var(--pg-text) !important;
  border-color: #475569 !important;
}
html.dark .auth-alert--success {
  background: #14332b !important;
  color: #a7f3d0 !important;
}
html.dark .auth-alert--error {
  background: #4a2130 !important;
  color: #fecdd3 !important;
}

/* Admin area */
html.dark .admin-main > p { color: #cbd5e1 !important; }
html.dark .admin-topbar { border-color: #334155 !important; }
html.dark .admin-alert {
  background: #4a2130 !important;
  border-color: #7f1d1d !important;
  color: #fecdd3 !important;
}
html.dark .admin-card,
html.dark .admin-stat {
  background: var(--pg-panel) !important;
  border-color: var(--pg-border) !important;
  box-shadow: none;
}
html.dark .admin-card h2,
html.dark .admin-stat strong { color: var(--pg-text-strong) !important; }
html.dark .admin-stat span { color: #94a3b8 !important; }
html.dark .admin-table th {
  background: #162033 !important;
  color: #cbd5e1 !important;
  border-color: #334155 !important;
}
html.dark .admin-table td {
  color: var(--pg-text) !important;
  border-color: #1f2937 !important;
}
html.dark .admin-table tbody tr:hover td { background: #162033 !important; }
html.dark .admin-actions input[type="text"],
html.dark .admin-actions input[type="search"],
html.dark .admin-search input {
  background: #0f172a !important;
  color: var(--pg-text) !important;
  border-color: #475569 !important;
}
html.dark .admin-btn--red-soft { background: #4a2130 !important; color: #fecdd3 !important; border-color: #7f1d1d !important; }
html.dark .admin-btn--amber-soft { background: #4a3b16 !important; color: #fcd34d !important; border-color: #78350f !important; }
html.dark .admin-btn--sky-soft { background: #1e3a5f !important; color: #93c5fd !important; border-color: #1e40af !important; }
html.dark .admin-badge { background: #1f2937 !important; color: #cbd5e1 !important; }
html.dark .admin-badge--red { background: #4a2130 !important; color: #fecdd3 !important; }
html.dark .admin-badge--green { background: #174334 !important; color: #6ee7b7 !important; }
html.dark .admin-badge--violet { background: #312e63 !important; color: #ddd6fe !important; }
html.dark .admin-badge--amber { background: #4a3b16 !important; color: #fcd34d !important; }
html.dark .admin-badge--sky { background: #1e3a5f !important; color: #93c5fd !important; }
html.dark .admin-list > div { border-color: #1f2937 !important; }
html.dark .admin-list a { color: #c4b5fd !important; }
html.dark .admin-content-title { color: #f8fafc !important; }
html.dark .admin-content-body { color: #cbd5e1 !important; }
html.dark .admin-content-muted { color: #94a3b8 !important; }
html.dark .admin-content-link { color: #c4b5fd !important; }
html.dark .admin-flag { color: #fda4af !important; }
html.dark .admin-alert--amber { background: #4a3b16 !important; border-color: #78350f !important; color: #fcd34d !important; }
html.dark .admin-alert--indigo { background: #1c2540 !important; border-color: #4338ca !important; color: #c7d2fe !important; }
html.dark .admin-alert--pink { background: #4a2130 !important; border-color: #9d174d !important; color: #fbcfe8 !important; }
html.dark .admin-filter,
html.dark .admin-pager a {
  background: #1f2937 !important;
  color: #cbd5e1 !important;
  border-color: #475569 !important;
}
html.dark .admin-filter:hover,
html.dark .admin-pager a:hover { background: #273449 !important; }
html.dark .admin-filter.is-active {
  background: #7c3aed !important;
  color: #ffffff !important;
  border-color: #7c3aed !important;
}
html.dark .admin-note-card {
  background: var(--pg-panel-soft) !important;
  border-color: var(--pg-border) !important;
}
html.dark .admin-note-meta { color: #94a3b8 !important; }
html.dark .admin-note-body { color: var(--pg-text) !important; }
html.dark .admin-main .admin-card p { color: #cbd5e1 !important; }

.admin-sidebar__bottom .theme-toggle {
  width: 100%;
  padding: 10px 12px !important;
  justify-content: flex-start;
  color: #cbd5e1 !important;
}

/* Cookie panel */
html.dark .cookie-overlay {
  background: rgba(0, 0, 0, .72);
}
html.dark .cookie-box {
  background: #111827 !important;
  color: var(--pg-text) !important;
  border-color: #334155 !important;
}
html.dark .cookie-title {
  color: var(--pg-text-strong) !important;
}
html.dark .cookie-text,
html.dark .cookie-box label {
  color: #cbd5e1 !important;
}
html.dark .btn-reject {
  background: #1f2937 !important;
  color: var(--pg-text) !important;
  border-color: #475569 !important;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0 !important;
  border-radius: 10px;
  cursor: pointer;
}
html.dark .theme-icon-moon { display: none !important; }
html:not(.dark) .theme-icon-sun { display: none !important; }

/* Chart grid / symbol toggles: off = muted outline, on = bright filled chip */
html.dark .toggle-chip {
  background: #1f2937;
  border-color: #475569;
  color: #cbd5e1;
}
html.dark .toggle-chip:hover {
  background: #312e63;
  color: #ddd6fe;
}
html.dark .toggle-chip.is-active {
  background: #8b5cf6 !important;
  border-color: #c4b5fd !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.4), 0 1px 3px rgba(0, 0, 0, 0.35);
}
html.dark .toggle-chip.is-active:hover {
  background: #7c3aed !important;
  color: #ffffff !important;
}

/* Edit-chart tool chips: muted outline when off, bright purple when on */
html.dark .chart-tool {
  background: #1f2937;
  border-color: #475569;
  color: #cbd5e1;
}
html.dark .chart-tool:hover {
  background: #312e63;
  color: #ddd6fe;
}
html.dark .chart-tool.is-active {
  background: #8b5cf6 !important;
  border-color: #c4b5fd !important;
  color: #ffffff !important;
}
html.dark .chart-tool.is-active:hover {
  background: #7c3aed !important;
  color: #ffffff !important;
}

/* Followed row in the written instructions (outside full screen): readable
   amber-on-dark instead of pale yellow on pale yellow. */
html.dark .row-instruction-active {
  background: #4a3b16 !important;
  color: #fde68a !important;
  box-shadow: inset 3px 0 #fbbf24 !important;
}
html.dark .row-instruction-active .follow-run.active {
  background: #fbbf24 !important;
  color: #1f1300 !important;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45) !important;
}

/* Written-instruction row hover (the pale Tailwind amber-on-light hover was
   unreadable against the dark panel). */
html.dark .row-instruction-row:not(.row-instruction-active):hover {
  background: #4a3b16 !important;
}
html.dark .row-instruction-row:not(.row-instruction-active):hover .follow-run.active {
  background: #fbbf24 !important;
  color: #1f1300 !important;
}

/* Colour-breakdown letter badges: readable in the dark panel */
html.dark .colour-symbol-btn {
  background: #1f2937 !important;
  border-color: #475569 !important;
  color: #ddd6fe !important;
}
html.dark .colour-symbol-btn:hover {
  background: #312e63 !important;
  color: #ffffff !important;
}
