* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  color-scheme: dark;
  --bg: #171036;
  --bg-top: #3a1d60;
  --panel: rgba(34, 24, 74, 0.76);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f7fbff;
  --text-soft: #d0d7ea;
  --text-muted: #9da7c4;
  --mint: #80ffe0;
  --sky: #70ceff;
  --gold: #ffd46d;
  --danger: #ff7b7b;
  --app-surface: linear-gradient(180deg, rgba(44, 24, 87, 0.9) 0%, rgba(16, 18, 48, 0.98) 100%);
  --app-border: rgba(255, 255, 255, 0.06);
  --topbar-bg: rgba(41, 22, 76, 0.78);
  --tabbar-bg: rgba(28, 20, 58, 0.88);
  --card-surface: rgba(255, 255, 255, 0.065);
  --card-surface-strong: rgba(255, 255, 255, 0.085);
  --shadow-soft: rgba(6, 8, 24, 0.3);
  --shadow-strong: rgba(7, 8, 24, 0.48);
  --grid-line: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2ff;
  --bg-top: #fff6ef;
  --panel: rgba(255, 255, 255, 0.78);
  --line: rgba(34, 51, 96, 0.1);
  --text: #18254a;
  --text-soft: #586988;
  --text-muted: #8a96b0;
  --mint: #18b999;
  --sky: #4f86ff;
  --gold: #d4922a;
  --danger: #e55e6d;
  --app-surface: linear-gradient(180deg, rgba(255, 255, 255, 0.88) 0%, rgba(246, 247, 255, 0.98) 100%);
  --app-border: rgba(34, 48, 88, 0.08);
  --topbar-bg: rgba(255, 255, 255, 0.78);
  --tabbar-bg: rgba(255, 255, 255, 0.88);
  --card-surface: rgba(255, 255, 255, 0.68);
  --card-surface-strong: rgba(255, 255, 255, 0.78);
  --shadow-soft: rgba(88, 103, 150, 0.14);
  --shadow-strong: rgba(88, 103, 150, 0.24);
  --grid-line: rgba(14, 36, 68, 0.035);
}

:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 80px;
  --glass: rgba(255, 255, 255, 0.03);
  --glass-stroke: rgba(255, 255, 255, 0.08);
  --glass-shine: rgba(255, 255, 255, 0.12);
  --magic-gradient: linear-gradient(135deg, #80ffe0 0%, #70ceff 50%, #ea80fc 100%);
}

html,
body,
#root {
  height: 100%;
  width: 100%;
  background: #0a0a0d;
  background-attachment: fixed;
  color: var(--text);
  font-family: "Satoshi", "Inter", "SF Pro Display", sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 220ms ease, color 220ms ease;
}

body {
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 112px 112px;
  mask-image: linear-gradient(180deg, rgba(255, 255, 255, 0.5), transparent 92%);
  opacity: 0.24;
}

/* --- Layout --- */
.app-container {
  display: flex;
  height: 100dvh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
}

/* --- App Store download banner (web only) --- */
:root {
  --appstore-banner-h: 64px;
}

.appstore-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--appstore-banner-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px 0 44px;
  color: #fff;
  background: linear-gradient(135deg, rgba(44, 24, 87, 0.98) 0%, rgba(86, 41, 196, 0.96) 52%, rgba(160, 80, 255, 0.94) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 24px rgba(12, 8, 32, 0.45);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: border-box;
}

.appstore-banner__close {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(255, 255, 255, 0.1);
  transition: background 150ms ease, color 150ms ease;
}

.appstore-banner__close:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.appstore-banner__icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.appstore-banner__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.appstore-banner__title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appstore-banner__subtitle {
  font-size: 0.8rem;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appstore-banner__cta {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: 12px;
  color: #fff;
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.appstore-banner__cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
}

.appstore-banner__cta:active {
  transform: translateY(0);
}

.appstore-banner__apple {
  flex-shrink: 0;
}

.appstore-banner__cta-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.05;
  text-align: left;
}

.appstore-banner__cta-top {
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.85);
}

.appstore-banner__cta-bottom {
  font-size: 1rem;
  font-weight: 600;
}

/* Push the app down so the fixed banner doesn't cover it. */
html[data-appstore-banner="1"] .app-container {
  height: calc(100dvh - var(--appstore-banner-h) - env(safe-area-inset-top, 0px));
  min-height: calc(100dvh - var(--appstore-banner-h) - env(safe-area-inset-top, 0px));
  margin-top: calc(var(--appstore-banner-h) + env(safe-area-inset-top, 0px));
}

@media (max-width: 640px) {
  :root {
    --appstore-banner-h: 60px;
  }

  .appstore-banner {
    gap: 10px;
    padding-left: 38px;
    padding-right: 12px;
  }

  .appstore-banner__subtitle {
    display: none;
  }

  .appstore-banner__icon {
    width: 38px;
    height: 38px;
  }

  .appstore-banner__cta {
    padding: 8px 12px;
  }
}

.main-content {
  flex: 1;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

button,
input,
textarea {
  border: none;
  background: none;
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

textarea {
  resize: none;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

::selection {
  background: rgba(122, 244, 207, 0.26);
}

::-webkit-scrollbar {
  display: none;
}

/* --- Premium Animations --- */
@keyframes orb-float {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.8; }
  50% { transform: translateY(-20px) scale(1.1); opacity: 1; }
}

@keyframes text-shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.magic-text {
  background: var(--magic-gradient);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: text-shimmer 3s linear infinite;
}

.glass-panel {
  background: var(--panel);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-stroke);
  border-radius: 20px;
  box-shadow: 0 8px 32px var(--shadow-strong);
}

.rhythmic-pulse {
  transition: transform 100ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform: scale(calc(1 + var(--pulse-intensity, 0) * 0.05));
}


/* --- Mobile Responsiveness --- */
@media (max-width: 980px), (hover: none) and (pointer: coarse) {
  .sidebar {
    display: none !important;
  }
  
  .app-container {
    flex-direction: column;
    height: 100dvh;
    min-height: 100dvh;
  }
  
  .main-content {
    width: 100%;
    max-width: 100vw;
  }
}

html[data-platform="ios"] .sidebar {
  display: none !important;
}

html[data-platform="ios"] .app-container {
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
}

html[data-platform="ios"] .main-content {
  width: 100%;
  max-width: 100vw;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
