/* ==========================================================================
   Zeina - Dark mode add-on
   Active when <html> has the class "dark" (set by the toggle in the navbar,
   or automatically from the visitor's system setting on first visit).
   ========================================================================== */

html.dark {
  color-scheme: dark;

  /* Text/link colour used for hovers, active tabs and links.
     The default primary blue is too dark to read on a dark background,
     so a lighter shade is used. If you changed the primary colour in the
     theme control panel, put a lighter version of it here (R, G, B). */
  --color-text: 96, 165, 250;

  /* Secondary (muted) text */
  --color-secondary: 156, 163, 175;

  /* Palette */
  --dm-page: #111318;     /* page background          */
  --dm-surface: #1a1d23;  /* cards, navbar, dropdowns */
  --dm-subtle: #20242b;   /* inputs, table rows, quotes */
  --dm-hover: #272b33;    /* hover backgrounds        */
  --dm-border: #2d323b;   /* borders                  */
  --dm-border-soft: #23272e;
  --dm-text: #e5e7eb;     /* main text                */
  --dm-text-muted: #9ca3af;
}

/* ---------- Base ---------- */
html.dark,
:where(html.dark) body,
:where(html.dark) .bg-gray-100,
:where(html.dark) .page-body {
  background-color: var(--dm-page);
  color: var(--dm-text);
}

:where(html.dark) *,
:where(html.dark) :after,
:where(html.dark) :before {
  border-color: var(--dm-border-soft);
}

:where(html.dark) .text-gray-800,
:where(html.dark) .text-gray-800\/95 { color: var(--dm-text); }
:where(html.dark) .text-gray-600 { color: var(--dm-text-muted); }

/* ---------- Surfaces ---------- */
:where(html.dark) .bg-white,
:where(html.dark) .navbar,
:where(html.dark) .card,
:where(html.dark) .card-sm,
:where(html.dark) .panel,
:where(html.dark) .dropdown,
:where(html.dark) .\!dropdown,
:where(html.dark) [data-zn-tab].active,
:where(html.dark) blockquote > div > blockquote {
  background-color: var(--dm-surface);
}

:where(html.dark) {
	.username-coloured {
		background: #aaa;
		border-radius: 5px;
		padding: 2px;
  	/*text-shadow:
    -1px -1px 0 #eee,   /* top left     */
     0   -1px 0 #eee,   /* top          */
     1px -1px 0 #eee,   /* top right    */
    -1px  0   0 #eee,   /* left         */
     1px  0   0 #eee,   /* right        */
    -1px  1px 0 #eee,   /* bottom left  */
     0    1px 0 #eee,   /* bottom       */
     1px  1px 0 #eee;   /* bottom right */*/
}
}

:where(html.dark) .bg-gray-50,
:where(html.dark) .bg-slate-50,
:where(html.dark) .file\:bg-gray-50::file-selector-button,
:where(html.dark) .inputbox,
:where(html.dark) select,
:where(html.dark) .content .codebox p,
:where(html.dark) blockquote,
:where(html.dark) blockquote > div > blockquote > div > blockquote {
  background-color: var(--dm-subtle);
}

@media (max-width: 767.98px) {
  :where(html.dark) .max-md\:bg-gray-50 { background-color: var(--dm-subtle); }
}
@media (min-width: 768px) {
  :where(html.dark) .md\:bg-gray-50 { background-color: var(--dm-subtle); }
  :where(html.dark) .md\:hover\:bg-transparent:hover { background-color: transparent; }
}

:where(html.dark) .hover\:bg-gray-50:hover,
:where(html.dark) .hover\:bg-gray-100:hover { background-color: var(--dm-hover); }

/* Panel / forum headers (only when "colourful panel" is OFF;
   a custom panel colour set in the control panel is kept) */
:where(html.dark) body:not(.card-primary) {
  --panel-bg: #22262e;
}

/* ---------- Borders ---------- */
:where(html.dark) .card,
:where(html.dark) .card-sm,
:where(html.dark) .panel,
:where(html.dark) .card-title,
:where(html.dark) .dropdown,
:where(html.dark) .\!dropdown,
:where(html.dark) .border-gray-200,
:where(html.dark) .md\:border-gray-200,
:where(html.dark) .max-md\:border-gray-200,
:where(html.dark) .divide-gray-200 > :not([hidden]) ~ :not([hidden]),
:where(html.dark) .before\:border-gray-200:before,
:where(html.dark) .after\:border-gray-200:after,
:where(html.dark) blockquote,
:where(html.dark) blockquote cite {
  border-color: var(--dm-border);
}

/* ---------- Forms ---------- */
:where(html.dark) [type=text], :where(html.dark) [type=email], :where(html.dark) [type=password],
:where(html.dark) [type=search], :where(html.dark) [type=number], :where(html.dark) [type=url],
:where(html.dark) [type=tel], :where(html.dark) [type=date], :where(html.dark) [type=datetime-local],
:where(html.dark) [type=month], :where(html.dark) [type=time], :where(html.dark) [type=week],
:where(html.dark) [multiple], :where(html.dark) textarea, :where(html.dark) select,
:where(html.dark) input:where(:not([type])) {
  background-color: var(--dm-subtle);
  border-color: #3a404b;
  color: var(--dm-text);
}
:where(html.dark) .register-input .inputbox { background-color: var(--dm-subtle); }

/* Zeina draws input outlines with a "ring" shadow, not a border */
:where(html.dark) .inputbox,
:where(html.dark) select { --tw-ring-color: var(--dm-border); }
:where(html.dark) .inputbox:focus,
:where(html.dark) select:focus { --tw-ring-color: rgba(var(--color-primary), 1); }

/* Dropdown shadows need to be stronger to show on dark */
:where(html.dark) .dropdown,
:where(html.dark) .\!dropdown { --tw-shadow: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.4); }

:where(html.dark) [type=checkbox],
:where(html.dark) [type=radio],
:where(html.dark) .checkbox-primary,
:where(html.dark) .radio-primary {
  background-color: var(--dm-subtle);
  border-color: #4b5563;
}
:where(html.dark) [type=checkbox]:checked,
:where(html.dark) [type=radio]:checked { background-color: currentColor; border-color: transparent; }
:where(html.dark) .checkbox-primary:checked,
:where(html.dark) .radio-primary:checked {
  background-color: rgba(var(--color-primary), 1);
  border-color: rgba(var(--color-primary), 1);
}

:where(html.dark) input::placeholder,
:where(html.dark) textarea::placeholder { color: #6b7280; }

/* ---------- Status colours ---------- */
:where(html.dark) .bg-red-50 { background-color: rgba(127, 29, 29, .25); }
:where(html.dark) .border-red-300 { border-color: rgba(248, 113, 113, .35); }
:where(html.dark) .text-red-700 { color: #fca5a5; }

:where(html.dark) .bg-yellow-100\/50 { background-color: rgba(113, 63, 18, .3); }
:where(html.dark) .border-yellow-800\/10 { border-color: rgba(253, 230, 138, .15); }
:where(html.dark) .text-yellow-700 { color: #fcd34d; }
:where(html.dark) .text-yellow-800 { color: #fde68a; }
:where(html.dark) .hover\:text-yellow-900:hover { color: #fef3c7; }

:where(html.dark) .bg-blue-100 { background-color: rgba(30, 64, 175, .3); }
:where(html.dark) .border-blue-200 { border-color: rgba(96, 165, 250, .3); }
:where(html.dark) .text-blue-600 { color: #60a5fa; }
:where(html.dark) .hover\:text-blue-800:hover { color: #93c5fd; }

:where(html.dark) .bg-green-100 { background-color: rgba(22, 101, 52, .3); }
:where(html.dark) .text-green-700,
:where(html.dark) .text-green-800 { color: #86efac; }

/* Online / "posted in" dots use a white ring - match the dark surface */
:where(html.dark) .author.online .author-img:after,
:where(html.dark) .author.online .author-img-sm:after,
:where(html.dark) div[class*=_mine]:not(.forum_custom_icon):before {
  border-color: var(--dm-surface);
}

/* Modal backdrop a bit darker */
:where(html.dark) .backdrop-show:before { background-color: rgba(0, 0, 0, .6); }

/* ---------- Logo ----------
   Turns a black-on-transparent logo white. If your logo is
   already coloured / light, delete this rule. */
:where(html.dark) .navbar img.logo { filter: invert(1); }

/* ---------- Code highlighting (GitHub Dark colours) ---------- */
:where(html.dark) .hljs { color: #c9d1d9; background: var(--dm-subtle); }
:where(html.dark) .hljs-doctag, :where(html.dark) .hljs-keyword, :where(html.dark) .hljs-meta .hljs-keyword,
:where(html.dark) .hljs-template-tag, :where(html.dark) .hljs-template-variable, :where(html.dark) .hljs-type,
:where(html.dark) .hljs-variable.language_ { color: #ff7b72; }
:where(html.dark) .hljs-title, :where(html.dark) .hljs-title.class_, :where(html.dark) .hljs-title.class_.inherited__,
:where(html.dark) .hljs-title.function_ { color: #d2a8ff; }
:where(html.dark) .hljs-attr, :where(html.dark) .hljs-attribute, :where(html.dark) .hljs-literal, :where(html.dark) .hljs-meta,
:where(html.dark) .hljs-number, :where(html.dark) .hljs-operator, :where(html.dark) .hljs-selector-attr,
:where(html.dark) .hljs-selector-class, :where(html.dark) .hljs-selector-id, :where(html.dark) .hljs-variable,
:where(html.dark) .hljs-section { color: #79c0ff; }
:where(html.dark) .hljs-meta .hljs-string, :where(html.dark) .hljs-regexp, :where(html.dark) .hljs-string { color: #a5d6ff; }
:where(html.dark) .hljs-built_in, :where(html.dark) .hljs-symbol { color: #ffa657; }
:where(html.dark) .hljs-code, :where(html.dark) .hljs-comment, :where(html.dark) .hljs-formula { color: #8b949e; }
:where(html.dark) .hljs-name, :where(html.dark) .hljs-quote, :where(html.dark) .hljs-selector-pseudo,
:where(html.dark) .hljs-selector-tag { color: #7ee787; }
:where(html.dark) .hljs-subst, :where(html.dark) .hljs-emphasis, :where(html.dark) .hljs-strong { color: #c9d1d9; }
:where(html.dark) .hljs-bullet { color: #f2cc60; }
:where(html.dark) .hljs-addition { color: #aff5b4; background-color: #033a16; }
:where(html.dark) .hljs-deletion { color: #ffdcd7; background-color: #67060c; }

/* ---------- Toggle button ---------- */
.theme-toggle .theme-icon-sun { display: none; }
:where(html.dark) .theme-toggle .theme-icon-sun { display: block; }
:where(html.dark) .theme-toggle .theme-icon-moon { display: none; }
