:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --text: #222222;
  --muted: #666666;
  --link: #0066cc;
  --accent: #0066cc;
}

html.dark-mode {
  --bg: #0f1720;
  --surface: #0b1220;
  --text: #e6eef6;
  --muted: #98a0ac;
  --link: #5fb3ff;
  --accent: #5fb3ff;
}

/* Basic page backgrounds & text */
body {
  background: var(--bg) !important;
  color: var(--text) !important;
}

/* Ensure wrapper and sections use the surface color */
#wrapper, #shadow, section.theme, aside.theme {
  background: var(--surface) !important;
}

a { color: var(--link); }

/* Header / footer tweaks */
header.theme, footer.theme, #headerWrap {
  background: transparent;
}

/* Navigation bar follows theme variables */
nav.theme {
  background: var(--surface) !important;
  padding: 10px 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

nav.theme ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 28px;
}

nav.theme ul li { display: inline-block; }

nav.theme a {
  color: var(--muted) !important;
  text-decoration: none;
  font-weight: 600;
  padding: 8px 6px;
  display: inline-block;
}

nav.theme a.current {
  color: var(--text) !important;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 6px;
}

.mobile-nav-shell {
  display: none;
}

.mobile-nav-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mobile-page-nav {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 12px;
  padding: 12px 44px 12px 14px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% - 3px), calc(100% - 14px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.mobile-page-nav:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(95,179,255,0.08);
}

html.dark-mode .mobile-page-nav {
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 18px 36px rgba(0,0,0,0.35);
}

/* Nav shadows tuned for light vs dark modes */
html.dark-mode nav.theme {
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
}
html:not(.dark-mode) nav.theme {
  box-shadow: 0 10px 30px rgba(0,0,0,0.08) !important;
}

/* Theme toggle button */
#theme-toggle {
  background: transparent;
  border: 1px solid rgba(0,0,0,0.08);
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
}

html.dark-mode #theme-toggle {
  border-color: rgba(255,255,255,0.12);
}

@media (max-width: 720px) {
  #nav-toggle {
    display: none !important;
  }

  #theme-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 20;
  }

  .mobile-nav-shell {
    display: block;
    margin: 14px 0 8px;
    padding-right: 56px;
  }

  nav.theme {
    box-shadow: none !important;
    padding: 0 !important;
    background: transparent !important;
  }

  nav.theme ul {
    display: none !important;
  }

  .home-showcase {
    padding: 22px 18px;
    border-radius: 24px;
  }

  .home-showcase__card {
    padding: 20px;
  }
}

/* Make sure pre-existing theme styles can be overridden */
/* Add more rules here later to refine dark theme */

/* Home page featured app showcase */
.home-showcase {
  position: relative;
  margin: 6px 0 24px;
  padding: 28px;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(0, 102, 204, 0.14), transparent 34%),
    radial-gradient(circle at bottom left, rgba(0, 102, 204, 0.08), transparent 28%),
    linear-gradient(145deg, rgba(255,255,255,0.96), rgba(244,248,252,0.96));
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 22px 48px rgba(15, 23, 32, 0.08);
}

.home-showcase__intro {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin-bottom: 20px;
}

.home-showcase__meta {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.home-showcase__hint {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.home-showcase__controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.home-showcase__arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 999px;
  background: rgba(255,255,255,0.9);
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(15, 23, 32, 0.08);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.home-showcase__arrow:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(15, 23, 32, 0.12);
}

.home-showcase__arrow:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.home-showcase__eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.home-showcase h2 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.05;
}

.home-showcase__intro p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
}

.home-showcase__grid {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 4px 14px;
  gap: 18px;
  position: relative;
  z-index: 1;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,102,204,0.35) transparent;
}

.home-showcase__grid.is-paused {
  cursor: grab;
}

.home-showcase__grid::-webkit-scrollbar {
  height: 10px;
}

.home-showcase__grid::-webkit-scrollbar-track {
  background: transparent;
}

.home-showcase__grid::-webkit-scrollbar-thumb {
  background: rgba(0,102,204,0.28);
  border-radius: 999px;
}

.home-showcase__card {
  position: relative;
  flex: 0 0 320px;
  width: 320px;
  min-height: 100%;
  padding: 22px;
  border-radius: 24px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 18px 40px rgba(15, 23, 32, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateY(20px);
  opacity: 0;
  animation: showcase-rise 0.7s ease forwards;
  transition: transform 180ms ease, box-shadow 180ms ease;
  scroll-snap-align: start;
}

.home-showcase__card:nth-child(2) {
  animation-delay: 0.12s;
}

.home-showcase__card:nth-child(3) {
  animation-delay: 0.24s;
}

.home-showcase__card:nth-child(4) {
  animation-delay: 0.36s;
}

.home-showcase__card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 50px rgba(15, 23, 32, 0.14);
}

.home-showcase__glow {
  position: absolute;
  inset: auto -40px -50px auto;
  width: 140px;
  height: 140px;
  border-radius: 999px;
  opacity: 0.55;
  filter: blur(14px);
  animation: showcase-float 7s ease-in-out infinite;
}

.home-showcase__card--photomark .home-showcase__glow {
  background: radial-gradient(circle, rgba(227, 0, 140, 0.42), rgba(96, 21, 170, 0));
}

.home-showcase__card--copyit .home-showcase__glow {
  background: radial-gradient(circle, rgba(220, 38, 38, 0.34), rgba(127, 29, 29, 0));
}

.home-showcase__card--copyit-access .home-showcase__glow {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.34), rgba(161, 98, 7, 0));
}

.home-showcase__card--veriscope .home-showcase__glow {
  background: radial-gradient(circle, rgba(37, 99, 235, 0.34), rgba(21, 94, 117, 0));
}

.home-showcase__icon {
  display: block;
  width: 88px;
  height: 88px;
  margin-bottom: 18px;
  border-radius: 22px;
}

.home-showcase__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.home-showcase__status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 6px rgba(0,102,204,0.12);
}

.home-showcase__card h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 24px;
  line-height: 1.15;
}

.home-showcase__card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.home-showcase__actions {
  margin-top: 18px;
}

.home-showcase__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff !important;
  font-weight: 700;
  text-decoration: none !important;
  box-shadow: 0 14px 28px rgba(0,102,204,0.24);
}

.home-showcase__button:hover {
  transform: translateY(-1px);
}

html.dark-mode .home-showcase {
  background:
    radial-gradient(circle at top right, rgba(95, 179, 255, 0.18), transparent 30%),
    radial-gradient(circle at bottom left, rgba(59, 130, 246, 0.16), transparent 28%),
    linear-gradient(145deg, rgba(11,18,32,0.98), rgba(19,30,49,0.98));
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 26px 56px rgba(0,0,0,0.38);
}

html.dark-mode .home-showcase__card {
  background: rgba(15, 23, 32, 0.72);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 22px 44px rgba(0,0,0,0.34);
}

html.dark-mode .home-showcase__arrow {
  background: rgba(15, 23, 32, 0.92);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 16px 30px rgba(0,0,0,0.26);
}

html.dark-mode .home-showcase__grid {
  scrollbar-color: rgba(95,179,255,0.45) transparent;
}

html.dark-mode .home-showcase__grid::-webkit-scrollbar-thumb {
  background: rgba(95,179,255,0.38);
}

html.dark-mode .home-showcase__button {
  color: #0b1220 !important;
}

@keyframes showcase-rise {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes showcase-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(-10px, -14px, 0) scale(1.04);
  }
}

@media (max-width: 900px) {
  .home-showcase__card {
    flex-basis: min(320px, calc(100vw - 92px));
    width: min(320px, calc(100vw - 92px));
  }
}

@media (max-width: 720px) {
  .home-showcase__meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .home-showcase__controls {
    display: none;
  }

  .home-showcase__hint {
    font-size: 13px;
  }
}

/* App grid overrides so app tiles follow theme colors */
.app-grid .app-item {
  background: var(--surface) !important;
  color: var(--muted) !important;
  border-radius: 18px;
  padding: 28px 20px !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.app-grid .app-item img {
  background: transparent !important;
  box-shadow: none !important;
}

/* Remove shadows for inline app icons (index page) so they match the app grid */
.theme #content a > img,
.theme #content img {
  box-shadow: none !important;
  filter: none !important;
}

.app-grid .app-item span {
  display: block;
  margin-top: 12px;
  color: var(--muted) !important;
}

/* Shadows tuned for light vs dark modes */
html.dark-mode .app-grid .app-item {
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
}
html:not(.dark-mode) .app-grid .app-item {
  box-shadow: none !important;
}

/* Terms page blocks (.div1) should follow theme colors */
.theme .div1 {
  background: var(--surface) !important;
  color: var(--muted) !important;
  border-color: rgba(0,0,0,0.12) !important;
}

.theme .div1 h1 {
  color: var(--text) !important;
  margin-top: 0 !important;
}

/* Adjust borders for dark mode */
html.dark-mode .theme .div1 {
  border-color: rgba(255,255,255,0.12) !important;
}

/* Ensure lists and links inside terms blocks follow theme */
.theme .div1 ul { color: var(--muted) !important; }
.theme .div1 a { color: var(--link) !important; }

/* Contact page: form inputs, textarea and buttons follow theme */
.theme label {
  color: var(--text) !important;
  font-weight: 600;
  display: block;
  margin-bottom: 6px;
}

.theme .form-input-field {
  width: 100% !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid rgba(0,0,0,0.12) !important;
  border-radius: 10px !important;
  padding: 12px 14px !important;
  box-sizing: border-box !important;
  box-shadow: none !important;
}

.theme textarea.form-input-field { resize: vertical; }

.theme .form-input-field::placeholder { color: var(--muted) !important; }

html.dark-mode .theme .form-input-field {
  border-color: rgba(255,255,255,0.08) !important;
}

.theme .form-input-field:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px rgba(95,179,255,0.08) !important;
}

.theme .form-input-button {
  background: var(--accent) !important;
  color: #ffffff !important;
  border: none !important;
  padding: 8px 14px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  font-weight: 600 !important;
}

html.dark-mode .theme .form-input-button {
  color: #0b1220 !important;
}

.theme .message-text, .theme .form-footer { color: var(--muted) !important; }
