/* AI Project Universe V5.5 — shared editorial design, light/dark theme, language controls.
   Visual direction is adapted from the user-provided reference while preserving every app's layout. */
:root {
  --apu-ivory: #f0f0f0;
  --apu-cream: #e7e7e7;
  --apu-paper: #f7f7f7;
  --apu-charcoal: #181818;
  --apu-ink: #2a2a2a;
  --apu-muted: #666666;
  --apu-accent: #454545;
  --apu-accent-rgb: 0, 71, 255;
  --apu-accent-warm: #6d6d6d;
  --apu-line: rgba(24, 24, 24, 0.14);
  --apu-shadow: 0 24px 70px rgba(24, 24, 24, 0.12);
  --apu-font-display: Optima, Candara, 'Noto Sans', 'Source Sans Pro', source-sans-pro, system-ui, sans-serif;
  --apu-font-mono: 'DM Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  --apu-radius: 18px;
  --apu-control-height: 42px;
  color-scheme: light dark;
}

html[data-scroll-theme='computer-vision'] { --apu-accent: #767676; --apu-accent-rgb: 8,145,178; }
html[data-scroll-theme='incident-monitoring'] { --apu-accent: #4a4a4a; --apu-accent-rgb: 225,29,72; }
html[data-scroll-theme='it-helpdesk'] { --apu-accent: #606060; --apu-accent-rgb: 37,99,235; }
html[data-scroll-theme='kotlin-policy'] { --apu-accent: #555555; --apu-accent-rgb: 124,58,237; }
html[data-scroll-theme='malaysia-cost'] { --apu-accent: #606060; --apu-accent-rgb: 14,116,144; }
html[data-scroll-theme='network-subnet'] { --apu-accent: #747474; --apu-accent-rgb: 5,150,105; }
html[data-scroll-theme='sentiment-analysis'] { --apu-accent: #555555; --apu-accent-rgb: 124,58,237; }
html[data-scroll-theme='url-shortener'] { --apu-accent: #727272; --apu-accent-rgb: 234,88,12; }
html[data-scroll-theme='academic-evidence'] { --apu-accent: #4e4e4e; --apu-accent-rgb: 29,78,216; }
html[data-scroll-theme='ai-architect'] { --apu-accent: #767676; --apu-accent-rgb: 8,145,178; }
html[data-scroll-theme='student-performance'] { --apu-accent: #606060; --apu-accent-rgb: 37,99,235; }

html[data-apu-theme='light'] {
  --apu-page-bg: #f7f7f7;
  --apu-page-bg-2: #f0f0f0;
  --apu-surface: rgba(255,255,255,0.82);
  --apu-surface-solid: #fffdfa;
  --apu-surface-soft: rgba(240, 240, 240,0.86);
  --apu-text: #181818;
  --apu-text-soft: #2a2a2a;
  --apu-muted-text: #666666;
  --apu-border: rgba(24, 24, 24,0.14);
  --apu-nav-bg: rgba(247, 247, 247,0.86);
  --apu-grid-line: rgba(24, 24, 24,0.06);
  --apu-selection: rgba(var(--apu-accent-rgb),0.18);
}

html[data-apu-theme='dark'] {
  --apu-page-bg: #101010;
  --apu-page-bg-2: #151515;
  --apu-surface: rgba(21, 21, 21,0.82);
  --apu-surface-solid: #151515;
  --apu-surface-soft: rgba(27, 27, 27,0.84);
  --apu-text: #f0f0f0;
  --apu-text-soft: #e3e3e3;
  --apu-muted-text: #b4b4b4;
  --apu-border: rgba(231, 231, 231,0.14);
  --apu-nav-bg: rgba(16, 16, 16,0.86);
  --apu-grid-line: rgba(255,255,255,0.055);
  --apu-selection: rgba(var(--apu-accent-rgb),0.32);
  --apu-shadow: 0 24px 80px rgba(0,0,0,0.38);
}

html[data-apu-project-scroll] {
  min-height: 100%;
  background: var(--apu-page-bg);
  accent-color: var(--apu-accent);
  scroll-behavior: smooth;
}

html[data-apu-project-scroll] body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% 8%, rgba(var(--apu-accent-rgb),0.12), transparent 30rem),
    linear-gradient(var(--apu-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--apu-grid-line) 1px, transparent 1px),
    var(--apu-page-bg) !important;
  background-size: auto, 56px 56px, 56px 56px, auto;
  color: var(--apu-text);
  font-family: var(--apu-font-display) !important;
  font-style: italic;
  overflow-x: hidden;
  transition: background-color .28s ease, color .28s ease;
}

/* Safe equivalent of the supplied centered body concept: preserve full-height apps and scrolling. */
html[data-apu-project-scroll] body > #root {
  min-width: 0;
  min-height: 100dvh;
  width: 100%;
  position: relative;
  isolation: isolate;
}

html[data-apu-project-scroll] body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2147482000;
  opacity: .16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

html[data-apu-project-scroll] ::selection {
  background: var(--apu-selection);
  color: var(--apu-text);
}

html[data-apu-project-scroll] :where(button, input, textarea, select, option) {
  font: inherit;
}

html[data-apu-project-scroll] :where(h1,h2,h3,h4,h5,h6,strong,b) {
  letter-spacing: -0.018em;
}

html[data-apu-project-scroll] :where(code,pre,kbd,samp) {
  font-family: var(--apu-font-mono) !important;
  font-style: normal;
}

html[data-apu-project-scroll] :where(a,button,input,select,textarea,[role='button']):focus-visible {
  outline: 3px solid rgba(var(--apu-accent-rgb),.35) !important;
  outline-offset: 3px;
}

html[data-apu-project-scroll] * {
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--apu-accent-rgb),.72) transparent;
}

html[data-apu-project-scroll] *::-webkit-scrollbar { width: 11px; height: 11px; }
html[data-apu-project-scroll] *::-webkit-scrollbar-track { background: transparent; }
html[data-apu-project-scroll] *::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(var(--apu-accent-rgb),.78), rgba(var(--apu-accent-rgb),.36));
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}

/* Shared glass/editorial treatment for major navigation surfaces. */
html[data-apu-project-scroll] :where(header,nav,aside) {
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
}

html[data-apu-theme='light'][data-apu-project-scroll] :where(header,nav,aside) {
  border-color: var(--apu-border) !important;
}

html[data-apu-project-scroll] :where(button,[role='button'],a) {
  -webkit-tap-highlight-color: transparent;
}

html[data-apu-project-scroll] :where(button,[role='button']) {
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease, border-color .18s ease;
}

@media (hover:hover) and (pointer:fine) {
  html[data-apu-project-scroll] :where(button,[role='button']):not(:disabled):hover {
    transform: translateY(-1px);
  }
}

/* Common utility/application surfaces become genuine light and dark themes. */
html[data-apu-theme='light'][data-apu-project-scroll] :where(
  [class~='bg-slate-950'],[class~='bg-slate-900'],[class~='bg-slate-800'],
  [class~='bg-gray-950'],[class~='bg-gray-900'],[class~='bg-gray-800'],
  [class~='bg-zinc-950'],[class~='bg-zinc-900'],[class~='bg-neutral-950'],[class~='bg-neutral-900']
) {
  background-color: var(--apu-surface-solid) !important;
  color: var(--apu-text) !important;
}

html[data-apu-theme='light'][data-apu-project-scroll] :where(
  [class~='bg-slate-900/50'],[class~='bg-gray-900/50'],[class~='bg-gray-800/50'],[class~='bg-gray-800/30']
) { background-color: var(--apu-surface-soft) !important; }

html[data-apu-theme='light'][data-apu-project-scroll] :where(
  [class~='text-white'],[class~='text-slate-100'],[class~='text-slate-200'],
  [class~='text-gray-100'],[class~='text-gray-200'],[class~='text-zinc-100'],[class~='text-zinc-200']
) { color: var(--apu-text) !important; }

html[data-apu-theme='light'][data-apu-project-scroll] :where(
  [class~='text-slate-300'],[class~='text-slate-400'],[class~='text-slate-500'],[class~='text-slate-600'],
  [class~='text-gray-300'],[class~='text-gray-400'],[class~='text-gray-500'],[class~='text-gray-600'],
  [class~='text-zinc-300'],[class~='text-zinc-400'],[class~='text-zinc-500']
) { color: var(--apu-muted-text) !important; }

html[data-apu-theme='light'][data-apu-project-scroll] :where(
  [class~='border-slate-700'],[class~='border-slate-800'],[class~='border-gray-700'],[class~='border-gray-800'],
  [class~='border-zinc-700'],[class~='border-zinc-800'],[class~='border-white/10']
) { border-color: var(--apu-border) !important; }

html[data-apu-theme='dark'][data-apu-project-scroll] :where(
  [class~='bg-white'],[class~='bg-white/80'],[class~='bg-gray-50'],[class~='bg-gray-100'],
  [class~='bg-slate-50'],[class~='bg-slate-100'],[class~='bg-zinc-50'],[class~='bg-zinc-100']
) {
  background-color: var(--apu-surface-solid) !important;
  color: var(--apu-text) !important;
}

html[data-apu-theme='dark'][data-apu-project-scroll] :where(
  [class~='text-gray-900'],[class~='text-gray-800'],[class~='text-gray-700'],
  [class~='text-slate-900'],[class~='text-slate-800'],[class~='text-slate-700'],
  [class~='text-zinc-900'],[class~='text-zinc-800'],[class~='text-zinc-700']
) { color: var(--apu-text) !important; }

html[data-apu-theme='dark'][data-apu-project-scroll] :where(
  [class~='text-gray-600'],[class~='text-gray-500'],[class~='text-slate-600'],[class~='text-slate-500'],
  [class~='text-zinc-600'],[class~='text-zinc-500']
) { color: var(--apu-muted-text) !important; }

html[data-apu-theme='dark'][data-apu-project-scroll] :where(
  [class~='border-gray-100'],[class~='border-gray-200'],[class~='border-slate-100'],[class~='border-slate-200'],
  [class~='border-zinc-100'],[class~='border-zinc-200'],[class~='border-white/30']
) { border-color: var(--apu-border) !important; }

/* Variable-driven projects receive complete palettes rather than a superficial filter. */
html[data-scroll-theme='it-helpdesk'][data-apu-theme='light'] {
  --bg-primary: #f8fafc; --bg-secondary: #fffdfa; --text-primary: #282828;
  --text-secondary: #727272; --border: #e2e2e2; --shadow: 0 1px 3px rgba(23, 23, 23,.1);
}
html[data-scroll-theme='it-helpdesk'][data-apu-theme='dark'] {
  --bg-primary: #101010; --bg-secondary: #151515; --text-primary: #f0f0f0;
  --text-secondary: #b4b4b4; --border: rgba(231, 231, 231,.14); --shadow: 0 10px 30px rgba(0,0,0,.3);
}

html[data-scroll-theme='malaysia-cost'][data-apu-theme='light'] {
  --bg:#f3f3f3; --surface:#fffdfa; --surface-soft:#f7fafb; --ink:#252525;
  --muted:#747474; --line:#e2e2e2;
}
html[data-scroll-theme='malaysia-cost'][data-apu-theme='dark'] {
  --bg:#131313; --surface:#1b1b1b; --surface-soft:#222222; --ink:#f3f7f8;
  --muted:#b7b7b7; --line:rgba(226, 226, 226,.16); --shadow:0 18px 48px rgba(0,0,0,.34);
}

html[data-scroll-theme='network-subnet'][data-apu-theme='light'] {
  --bg:#f6f6f6; --panel:#fffdfa; --surface:#fffdfa; --surface-2:#f3f3f3;
  --ink:#1e1e1e; --muted:#727272; --line:#e4e4e4; color-scheme:light;
}
html[data-scroll-theme='network-subnet'][data-apu-theme='dark'] {
  --bg:#101010; --panel:#151515; --surface:#151515; --surface-2:#1f1f1f;
  --ink:#f6f6f6; --muted:#aeaeae; --line:rgba(228, 228, 228,.15); --navy:#0b0b0b; color-scheme:dark;
}

html[data-scroll-theme='student-performance'][data-apu-theme='light'] {
  --bg:#f2f2f2; --panel:#fffdfa; --panel-2:#efefef; --panel-3:#e5e5e5;
  --line:rgba(24, 24, 24,.14); --text:#181818; --muted:#666666; --shadow:0 22px 70px rgba(24, 24, 24,.12);
}
html[data-scroll-theme='student-performance'][data-apu-theme='dark'] {
  --bg:#101010; --panel:#191919; --panel-2:#1e1e1e; --panel-3:#242424;
  --line:rgba(161, 161, 161,.18); --text:#f6f6f6; --muted:#a3a3a3; --shadow:0 22px 70px rgba(0,0,0,.34);
}

html[data-scroll-theme='kotlin-policy'][data-apu-theme='light'] #root {
  background: linear-gradient(135deg,#f0f0f0 0%,#eeeeee 50%,#f7f7f7 100%) !important;
}
html[data-scroll-theme='kotlin-policy'][data-apu-theme='light'] .app-root {
  background:#fffdfa !important; color:#181818 !important;
}
html[data-scroll-theme='kotlin-policy'][data-apu-theme='dark'] #root {
  background:linear-gradient(135deg,#101010 0%,#181818 50%,#101010 100%) !important;
}
html[data-scroll-theme='kotlin-policy'][data-apu-theme='dark'] .app-root {
  background:#151515 !important; color:#f0f0f0 !important;
}

html[data-apu-theme='dark'][data-apu-project-scroll] :where(input,textarea,select) { color-scheme: dark; }
html[data-apu-theme='light'][data-apu-project-scroll] :where(input,textarea,select) { color-scheme: light; }

/* Floating theme + language dock. */
#apu-ui-dock-v55 {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 2147483000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px;
  border: 1px solid var(--apu-border);
  border-radius: 15px;
  background: var(--apu-nav-bg);
  color: var(--apu-text);
  box-shadow: var(--apu-shadow);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  font-family: var(--apu-font-display);
  font-style: italic;
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

#apu-ui-dock-v55::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(var(--apu-accent-rgb),.65), transparent 48%, rgba(var(--apu-accent-rgb),.24));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.apu-ui-button-v55,
.apu-ui-language-v55 {
  height: var(--apu-control-height);
  min-width: var(--apu-control-height);
  border: 1px solid var(--apu-border);
  border-radius: 11px;
  background: var(--apu-surface);
  color: var(--apu-text);
  box-shadow: none;
}

.apu-ui-button-v55 {
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  cursor: pointer;
}

.apu-ui-button-v55 svg { width: 18px; height: 18px; stroke: currentColor; }
.apu-ui-button-v55:hover { border-color: rgba(var(--apu-accent-rgb),.72); color: var(--apu-accent); }

.apu-ui-language-wrap-v55 {
  position: relative;
  display: flex;
  align-items: center;
}

.apu-ui-language-wrap-v55 svg {
  position: absolute;
  left: 11px;
  width: 16px;
  height: 16px;
  pointer-events: none;
  stroke: var(--apu-accent);
}

.apu-ui-language-v55 {
  appearance: none;
  -webkit-appearance: none;
  padding: 0 31px 0 34px;
  max-width: 148px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}

.apu-ui-language-wrap-v55::after {
  content: '⌄';
  position: absolute;
  right: 11px;
  top: 9px;
  color: var(--apu-muted-text);
  pointer-events: none;
}

#apu-ui-toast-v55 {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  top: calc(max(12px, env(safe-area-inset-top)) + 62px);
  z-index: 2147483000;
  max-width: min(320px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--apu-border);
  color: var(--apu-text);
  background: var(--apu-nav-bg);
  box-shadow: var(--apu-shadow);
  backdrop-filter: blur(18px);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  font-family: var(--apu-font-display);
  font-size: 12px;
}
#apu-ui-toast-v55[data-show='true'] { opacity: 1; transform: translateY(0); }

@media (max-width: 760px) {
  #apu-ui-dock-v55 {
    top: auto;
    bottom: max(14px, env(safe-area-inset-bottom));
    right: max(12px, env(safe-area-inset-right));
    max-width: calc(100vw - 24px);
    padding: 6px;
  }
  .apu-ui-language-v55 { max-width: 126px; }
  #apu-ui-toast-v55 {
    top: auto;
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 62px);
  }
}

@media (max-width: 390px) {
  .apu-ui-language-v55 { width: 55px; max-width: 55px; color: transparent; }
  .apu-ui-language-v55 option { color: initial; }
  .apu-ui-language-wrap-v55::before {
    content: attr(data-short-label);
    position: absolute;
    left: 32px;
    font-size: 11px;
    font-weight: 800;
    color: var(--apu-text);
    pointer-events: none;
  }
}

@media print {
  #apu-ui-dock-v55, #apu-ui-toast-v55 { display: none !important; }
  html[data-apu-project-scroll] body::before { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-apu-project-scroll] { scroll-behavior: auto; }
  html[data-apu-project-scroll] *,
  html[data-apu-project-scroll] *::before,
  html[data-apu-project-scroll] *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
