:root {
  --ink: #101d42;
  --green: #182b61;
  --mint: #e5ecff;
  --paper: #f4f6fb;
  --white: #fff;
  --muted: #667085;
  --line: #dbe1ed;
  --orange: #248cff;
  --shadow: 0 18px 50px #10225316;
}

body {
  background:
    radial-gradient(circle at 8% 8%, #dfeaff 0, transparent 26rem),
    radial-gradient(circle at 92% 42%, #e8e4ff 0, transparent 30rem),
    var(--paper);
  background-attachment: fixed;
}

body::before, body::after {
  content: '';
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(75px);
  opacity: .22;
  pointer-events: none;
  animation: ambient-drift 12s ease-in-out infinite;
}
body::before { top: 7%; left: -12rem; background: #6aa8ff; }
body::after { right: -13rem; bottom: 3%; background: #9a75ff; animation-delay: -6s; }

.topbar {
  border-bottom-color: #dce3f0;
  background: #ffffffeb;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: -.02em;
}

.brand > span {
  position: relative;
  overflow: hidden;
  border-radius: 11px;
  background: linear-gradient(145deg, #1768e5, #643de0);
  box-shadow: 0 7px 18px #315bd542;
}

.brand > span::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  right: -9px;
  top: -9px;
  border: 1px solid #ffffff70;
  transform: rotate(45deg);
}

.brand small { color: #77829a; }
.primary { background: linear-gradient(135deg, #1768e5, #5141cf); border-color: transparent; box-shadow: 0 6px 16px #315bd528; }
.primary:hover { box-shadow: 0 8px 22px #315bd53d; }

.hero {
  background:
    linear-gradient(118deg, #0d1b41 0%, #132c68 58%, #3146a4 100%);
  box-shadow: 0 24px 55px #152b6429;
}

.hero > div { position: relative; z-index: 2; }
.hero::selection { background: #72bdff; }

.hero::before {
  content: '< / >';
  position: absolute;
  right: 11%;
  bottom: 12%;
  color: #ffffff08;
  font: 800 clamp(70px, 11vw, 150px)/1 ui-monospace, monospace;
  letter-spacing: -.18em;
  white-space: nowrap;
  transform: rotate(-7deg);
}

.hero::after { border-radius: 28%; transform: rotate(18deg); }
.hero > div::after {
  content: '';
  position: absolute;
  z-index: -1;
  top: -140px;
  left: -220px;
  width: 150px;
  height: 520px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  transform: rotate(18deg);
  opacity: .1;
  animation: hero-glow 8s ease-in-out infinite;
}
.hero .eyebrow { color: #69b7ff; }
.scan-button {
  border-color: #ffffff24;
  background: linear-gradient(145deg, #61c5ff, #8ea7ff);
  box-shadow: 0 16px 40px #050d2b50;
}
.scan-button:hover { transform: translateY(-4px) rotate(2deg); }

.stats, .card, .detail-card, .auth-card, .settings-card, .timeline article, .user-row {
  border-color: #dfe5f0;
  box-shadow: 0 8px 30px #1a326a0b;
}
.card, .detail-card, .settings-card, .user-row { background: linear-gradient(145deg, #fff, #fbfcff); }
.card { position: relative; overflow: hidden; }
.card::before {
  content: ''; position: absolute; top: 0; right: 0; left: 0; height: 3px;
  background: linear-gradient(90deg, #2577ee, #7758e9); transform: scaleX(0); transform-origin: left; transition: transform .28s ease;
}
.card:hover::before { transform: scaleX(1); }
.event-icon { transition: transform .22s ease, background .22s ease; }
.timeline article:hover .event-icon { transform: rotate(-7deg) scale(1.08); background: #dce7ff; }

.event-icon, .meta div { background: #e8eeff; }
.code { color: #2856bf; background: #edf2ff; }
.status { color: #214cb2; background: #e4edff; }
.status.out { color: #94512e; background: #fff0df; }
.eyebrow { color: #276fe5; }
.avatar { background: linear-gradient(145deg, #1768e5, #643de0); }
.auth-tabs, nav button.active { background: #eef2fa; }
.account-button { color: #172752; background: #eef2fa; }
.account-button:hover { background: #e3eafe; transform: translateY(-1px); }
.account-menu { border-color: #dce3f0; }
input:focus, select:focus, textarea:focus { border-color: #4a83e8; box-shadow: 0 0 0 3px #247dff22; }

@media (max-width: 820px) {
  body { background: linear-gradient(180deg, #f7f9fd, #f2f5fb); }
  body::before, body::after { width: 17rem; height: 17rem; filter: blur(55px); opacity: .16; }
  .hero::before { right: 4%; bottom: 18%; font-size: 66px; }
  .hero { box-shadow: 0 14px 32px #152b6426; }
  #mainNav:not([hidden]) {
    display: flex !important;
    position: fixed !important;
    z-index: 100;
    top: auto !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(66px + env(safe-area-inset-bottom)) !important;
    margin: 0 !important;
    padding: 3px 3px env(safe-area-inset-bottom) !important;
    gap: 1px;
    background: #ffffffed;
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 25px #152b6414;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
  #mainNav button {
    display: block;
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: 59px;
    margin: 0;
    padding: 6px 2px;
    font-size: 11px;
    line-height: 1.15;
  }
  #mainNav button[hidden] { display: none !important; }
  #mainNav button.active { color: #1c5fd1; background: #eaf0ff; transform: translateY(-2px); }
  #mainNav button::after { bottom: 5px; }
}

/* Some phones report a desktop-like CSS width. Touch capability is a more reliable fallback. */
.touch-device body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
.touch-device #mainNav:not([hidden]) {
  display: flex !important;
  position: fixed !important;
  z-index: 100 !important;
  inset: auto 0 0 0 !important;
  width: 100% !important;
  max-width: none !important;
  height: calc(66px + env(safe-area-inset-bottom)) !important;
  margin: 0 !important;
  padding: 3px 3px env(safe-area-inset-bottom) !important;
  gap: 1px !important;
  background: #ffffffed !important;
  border-top: 1px solid var(--line) !important;
  box-shadow: 0 -8px 25px #152b6414 !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.touch-device #mainNav button {
  display: block !important;
  flex: 1 1 0 !important;
  width: auto !important;
  min-width: 0 !important;
  height: 59px !important;
  margin: 0 !important;
  padding: 6px 2px !important;
  overflow: hidden;
  white-space: normal;
  font-size: 11px !important;
  line-height: 1.15;
}
.touch-device #mainNav button[hidden] { display: none !important; }
