/* ===== DIPLOHUB THEME: dark = Midnight Focus (default), light = Academic Blue ===== */
:root, :root[data-theme="dark"] {
  /* ORIGINAL look (default) */
  --bg-1: #0a0a0f;
  --bg-2: #1a0f2e;
  --accent: #6366f1;
  --accent-2: #a855f7;
  --text: #f8fafc;
  --text-muted: #9ca3af;
  --accent-rgb: 99, 102, 241;
  --surface-rgb: 21, 21, 32;
  --deep-rgb: 15, 15, 26;
  --text-rgb: 255, 255, 255;
  --shadow-rgb: 0, 0, 0;
  --border-soft: rgba(156, 163, 175, 0.25);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg-1: #FFFFFF;
  --bg-2: #EFF6FF;
  --accent: #2563EB;
  --accent-2: #1D4ED8;
  --text: #1E293B;
  --text-muted: #475569;
  --accent-rgb: 37, 99, 235;
  --surface-rgb: 255, 255, 255;
  --deep-rgb: 239, 246, 255;
  --shadow-rgb: 30, 41, 59;
  --text-rgb: 30, 41, 59;
  --border-soft: rgba(30, 41, 59, 0.15);
  color-scheme: light;
}

body { color: var(--text); }

/* ---- Tailwind utility overrides (both themes use palette) ---- */
html[data-theme] .text-gray-100, html[data-theme] .text-gray-200 { color: var(--text) !important; }
html[data-theme] .text-gray-300, html[data-theme] .text-gray-400 { color: var(--text-muted) !important; }
html[data-theme] .text-gray-500, html[data-theme] .text-gray-600 { color: var(--text-muted) !important; }
html[data-theme] .text-white { color: var(--text) !important; }
html[data-theme] .bg-gray-900, html[data-theme] .bg-gray-900\/50, html[data-theme] .bg-gray-900\/60 { background-color: rgba(var(--deep-rgb), .6) !important; }
html[data-theme] .bg-gray-800, html[data-theme] .bg-gray-800\/80, html[data-theme] .bg-gray-800\/50 { background-color: rgba(var(--surface-rgb), .8) !important; }
html[data-theme] .bg-gray-700, html[data-theme] .bg-gray-700\/50 { background-color: rgba(var(--surface-rgb), .6) !important; }
html[data-theme] .border-gray-700, html[data-theme] .border-gray-700\/50, html[data-theme] .border-gray-600 { border-color: var(--border-soft) !important; }
html[data-theme] .bg-white\/5 { background-color: rgba(var(--accent-rgb), .06) !important; }
html[data-theme] .bg-white\/10 { background-color: rgba(var(--accent-rgb), .12) !important; }

/* keep white text on coloured/gradient buttons */
html[data-theme] [class*="bg-gradient"] .text-white, html[data-theme] [class*="bg-gradient"].text-white,
html[data-theme] [class*="bg-gradient"] .text-gray-100, html[data-theme] [class*="bg-gradient"].text-gray-100,
html[data-theme] .theme-keep-white, html[data-theme] .theme-keep-white * { color: #fff !important; }

/* accent gradients -> theme accent */
html[data-theme] .from-indigo-400, html[data-theme] .from-indigo-500, html[data-theme] .from-indigo-600,
html[data-theme] .from-purple-400, html[data-theme] .from-purple-500, html[data-theme] .from-purple-600 {
  --tw-gradient-from: var(--accent) var(--tw-gradient-from-position);
  --tw-gradient-to: rgb(139 92 246 / 0) var(--tw-gradient-to-position);
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
html[data-theme] .to-purple-500, html[data-theme] .to-purple-600, html[data-theme] .to-indigo-500, html[data-theme] .to-indigo-600, html[data-theme] .to-violet-500, html[data-theme] .to-violet-600 {
  --tw-gradient-to: var(--accent-2) var(--tw-gradient-to-position);
}

/* ---- Settings: switches ---- */
html[data-anim="off"] *, html[data-anim="off"] *::before, html[data-anim="off"] *::after { animation: none !important; transition: none !important; }
html[data-bg="static"] body { animation: none !important; }
html[data-bg="solid"] body { background: var(--bg-1) !important; animation: none !important; }

/* ---- Settings button + drawer ---- */
.dh-gear { display:inline-flex; align-items:center; justify-content:center; width:40px; height:40px; border-radius:12px; cursor:pointer; flex-shrink:0;
  background: rgba(var(--accent-rgb), .15); color: var(--accent-2); border:1px solid rgba(var(--accent-rgb), .35); font-size:18px; line-height:1; transition: background .2s; }
.dh-gear:hover { background: rgba(var(--accent-rgb), .28); }
.dh-gear.floating { position:fixed; top:12px; right:12px; z-index:9998; }
.dh-overlay { display:none; }
.dh-overlay.open { display:none; }
.dh-drawer { position:fixed; top:0; right:0; height:100%; width:min(380px, 86vw); z-index:10000; overflow-y:auto; padding:16px 16px 0;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2)); color: var(--text); border-left:1px solid rgba(var(--accent-rgb), .35);
  box-shadow: -10px 0 40px rgba(var(--shadow-rgb), .45); transform: translateX(105%); transition: transform .3s ease; font-family: system-ui, sans-serif; font-size:14px; text-align:left; }
.dh-drawer.open { transform: translateX(0); }
.dh-drawer * { box-sizing:border-box; }
.dh-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; font-size:18px; font-weight:700; }
.dh-x { background:none; border:0; color:var(--text); font-size:22px; cursor:pointer; }
.dh-h { margin:18px 0 8px; font-size:12px; letter-spacing:.08em; text-transform:uppercase; color:var(--text-muted); font-weight:700; }
.dh-themes { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.dh-t { padding:8px; border-radius:12px; cursor:pointer; background: rgba(var(--surface-rgb), .6); border:2px solid transparent; color:var(--text); text-align:left; font-size:12px; }
.dh-t.on { border-color: var(--accent); }
.dh-sw { display:flex; border-radius:6px; overflow:hidden; margin-bottom:6px; border:1px solid var(--border-soft); }
.dh-sw i { flex:1; height:18px; display:block; }
.dh-row { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px; }
.dh-row input[type=color] { width:44px; height:28px; border:0; padding:0; background:none; cursor:pointer; }
.dh-row input[type=range] { flex:1; accent-color: var(--accent); }
.dh-row select { background: rgba(var(--surface-rgb), .8); color: var(--text); border:1px solid var(--border-soft); border-radius:8px; padding:6px 8px; }
.dh-sw-t { position:relative; width:44px; height:24px; border-radius:99px; border:0; cursor:pointer; background: var(--border-soft); transition: background .2s; }
.dh-sw-t::after { content:""; position:absolute; top:3px; left:3px; width:18px; height:18px; border-radius:50%; background:#fff; transition: transform .2s; }
.dh-sw-t.on { background: var(--accent); } .dh-sw-t.on::after { transform: translateX(20px); }
.dh-reset { width:100%; margin-top:18px; padding:10px; border-radius:10px; cursor:pointer; font-weight:700; background: rgba(239,68,68,.15); color:#ef4444; border:1px solid rgba(239,68,68,.4); }
/* ---- Footer / handle ---- */
.dh-grip { display:none; width:44px; height:5px; border-radius:99px; background: var(--border-soft); margin:0 auto 10px; }
.dh-head { position:sticky; top:0; z-index:3; padding:4px 0 8px; background: linear-gradient(180deg, var(--bg-1) 70%, transparent); }
.dh-note { font-size:12px; color:var(--text-muted); margin:2px 0 4px; }
.dh-foot { position:sticky; bottom:0; z-index:3; margin:18px -16px 0; padding:12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); display:flex; gap:8px; background: linear-gradient(180deg, transparent, var(--bg-2) 35%); }
.dh-foot button { flex:1; min-height:44px; padding:10px; border-radius:10px; cursor:pointer; font-weight:700; border:1px solid var(--border-soft); background: rgba(var(--surface-rgb), .95); color: var(--text); }
.dh-foot .dh-apply { background: linear-gradient(90deg, var(--accent), var(--accent-2)); color:#fff; border:0; flex:1.4; }
.dh-foot .dh-reset2 { color:#ef4444; border-color: rgba(239,68,68,.4); flex:.8; }

/* ---- Phones: bottom sheet (site stays visible above) ---- */
@media (max-width: 640px) {
  .dh-gear { width:44px; height:44px; }
  .dh-drawer { top:auto; right:0; left:0; bottom:0; width:100%; height:50vh; height:50dvh; max-height:50dvh; padding:10px 14px 0; border-left:0; border-top:1px solid rgba(var(--accent-rgb), .45);
    border-radius:20px 20px 0 0; box-shadow:0 -10px 40px rgba(var(--shadow-rgb), .5); transform: translateY(105%); overscroll-behavior: contain; }
  .dh-drawer.open { transform: translateY(0); }
  .dh-grip { display:block; }
  .dh-foot { margin:14px -14px 0; padding-left:14px; padding-right:14px; }
  .dh-themes { grid-template-columns: repeat(3, 1fr); gap:8px; }
  .dh-t { padding:7px; font-size:11px; min-height:44px; }
  .dh-row { min-height:44px; margin-bottom:4px; }
  .dh-row input[type=color] { width:56px; height:36px; }
  .dh-row select, .dh-row input[type=range] { font-size:16px; min-height:36px; }
  .dh-x { min-width:44px; min-height:44px; }
  html.dh-open body { padding-bottom: 52dvh; }
}
@media (max-width: 640px) and (max-height: 500px) { .dh-drawer { height:70dvh; max-height:70dvh; } html.dh-open body { padding-bottom:72dvh; } }

/* ---- Hide scrollbars everywhere (scrolling still works) ---- */
html, body, * { scrollbar-width: none !important; -ms-overflow-style: none !important; }
*::-webkit-scrollbar, ::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; background: transparent !important; }
