:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  --bg: #070b16;
  --bg-2: #0a1020;
  --text: #f7f9ff;
  --muted: #8f9ab3;
  --soft: #65708a;
  --line: rgba(255,255,255,.10);
  --glass: rgba(11,18,34,.52);
  --glass-strong: rgba(10,16,30,.72);
  --blue: #96c9ff;
  --violet: #a896ff;
  --good: #77e6b3;
  --bad: #ff6f7b;
  --safe-top: max(22px, env(safe-area-inset-top));
  --safe-bottom: max(22px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html { width: 100%; min-height: 100%; background: var(--bg); }
body { width: 100%; min-height: 100%; margin: 0; color: var(--text); background: var(--bg); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
input { -webkit-appearance: none; appearance: none; }

.login-page,
.dashboard-page {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(70vw 55vw at 18% 7%, rgba(56,99,190,.20), transparent 68%),
    radial-gradient(62vw 52vw at 88% 92%, rgba(104,67,190,.18), transparent 70%),
    linear-gradient(145deg, #060a14 0%, #0a1020 52%, #060914 100%);
}

.ambient {
  position: fixed;
  z-index: 0;
  width: min(42vw, 520px);
  aspect-ratio: 1;
  border-radius: 999px;
  filter: blur(68px);
  opacity: .28;
  pointer-events: none;
  will-change: transform;
  animation: ambientDrift 15s ease-in-out infinite alternate;
}
.ambient-one { left: -12vw; top: -18vw; background: #477de4; }
.ambient-two { right: -14vw; bottom: -20vw; background: #7450df; animation-delay: -7s; }

.grain {
  position: fixed;
  z-index: 0;
  inset: 0;
  opacity: .025;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150' viewBox='0 0 150 150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

.login-stage {
  position: relative;
  z-index: 4;
  min-height: 100svh;
  display: grid;
  align-items: center;
  padding-top: calc(var(--safe-top) + 16px);
  padding-right: max(clamp(20px, 6vw, 84px), env(safe-area-inset-right));
  padding-bottom: calc(var(--safe-bottom) + 18px);
  padding-left: max(clamp(20px, 6vw, 84px), env(safe-area-inset-left));
}

.login-content {
  width: min(100%, 420px);
  margin-left: clamp(0px, 6vw, 108px);
  transition: opacity .48s ease, transform .48s cubic-bezier(.2,.75,.2,1), filter .48s ease;
}

.hero { margin-bottom: clamp(32px, 6vh, 62px); }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  color: #b8c1d5;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .17em;
  text-transform: uppercase;
}
.live-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 6px rgba(119,230,179,.08), 0 0 18px rgba(119,230,179,.38);
}
.hero h1 {
  margin: 0;
  max-width: 9em;
  font-size: clamp(46px, 7vw, 74px);
  line-height: .98;
  letter-spacing: -.065em;
  font-weight: 760;
  text-wrap: balance;
}

.login-form { width: 100%; }
.field { display: block; margin-top: 20px; }
.field:first-child { margin-top: 0; }
.field-label {
  display: block;
  margin: 0 0 9px 4px;
  color: #ced5e5;
  font-size: 13px;
  font-weight: 520;
  letter-spacing: .02em;
}
.input-shell {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 58px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.095);
  border-radius: 19px;
  background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.022)), rgba(7,13,25,.46);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  backdrop-filter: blur(16px) saturate(125%);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
  transition: border-color .22s ease, background .22s ease, box-shadow .22s ease, transform .22s ease;
}
.input-shell:focus-within {
  border-color: rgba(151,199,255,.40);
  background: linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.026)), rgba(7,13,25,.62);
  box-shadow: 0 0 0 4px rgba(121,169,255,.055), inset 0 1px 0 rgba(255,255,255,.05);
  transform: translateY(-1px);
}
.input-shell > svg {
  width: 20px;
  height: 20px;
  margin-left: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: #74829f;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke .22s ease;
}
.input-shell:focus-within > svg { stroke: var(--blue); }
.input-shell input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 16px;
  border: 0;
  outline: 0;
  color: #fff;
  background: transparent;
  font-size: 16px;
  caret-color: var(--blue);
}
.input-shell input::placeholder { color: #59647b; opacity: .72; }
.eye-toggle {
  width: 50px;
  height: 50px;
  margin-right: 4px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 15px;
  color: #74809a;
  background: transparent;
  cursor: pointer;
  opacity: .8;
  transition: color .2s ease, background .2s ease, opacity .2s ease;
}
.eye-toggle:hover { color: #c5cfe2; background: rgba(255,255,255,.04); opacity: 1; }
.eye-toggle svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.auth-status {
  min-height: 22px;
  margin: 12px 4px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .2s ease, transform .2s ease, color .2s ease;
}
.auth-status.visible { opacity: 1; transform: translateY(0); }
.auth-status.error { color: #ff9099; }
.auth-status.success { color: #8ee7bd; }

.sound-toggle {
  position: fixed;
  z-index: 12;
  top: calc(var(--safe-top) + 4px);
  right: max(18px, env(safe-area-inset-right));
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 15px;
  color: #a8b2c9;
  background: rgba(8,14,27,.46);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
}
.sound-toggle svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sound-toggle .sound-off { display: none; }
.sound-toggle[aria-pressed="false"] .sound-on { display: none; }
.sound-toggle[aria-pressed="false"] .sound-off { display: block; }

.shiba-agent {
  position: fixed;
  z-index: 3;
  left: 0;
  top: 0;
  width: clamp(126px, 14vw, 178px);
  aspect-ratio: 300 / 230;
  transform: translate3d(20px, 20px, 0);
  will-change: transform;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.shiba-agent:focus-visible .shiba-visual { filter: drop-shadow(0 0 14px rgba(150,196,255,.28)); }
.shiba-visual {
  width: 100%;
  height: 100%;
  transform-origin: 50% 78%;
  will-change: transform, filter;
  transition: filter .2s ease;
  user-select: none;
}
.shiba-visual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.shiba-agent.facing-left .shiba-visual { transform: scaleX(-1); }
.shiba-agent.pet .shiba-visual { animation: petBounce .56s cubic-bezier(.2,.8,.2,1); }
.shiba-agent.spin .shiba-visual { animation: shibaSpin .72s cubic-bezier(.2,.75,.2,1); }
.shiba-agent.angry .shiba-visual { animation: angryLunge .32s ease-in-out 3; filter: drop-shadow(0 8px 18px rgba(255,93,105,.18)); }
.shiba-agent.happy .shiba-visual { animation: happyBounce .55s ease-in-out infinite alternate; filter: drop-shadow(0 10px 22px rgba(127,220,189,.15)); }
.shiba-agent.lookaway .shiba-visual { animation: shyBreath 1.6s ease-in-out infinite alternate; }

.bark-bubble {
  position: absolute;
  left: 50%;
  top: 2px;
  min-width: 46px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 13px 13px 13px 4px;
  color: #fff;
  background: rgba(20,24,34,.82);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -10px) scale(.9);
  pointer-events: none;
}
.bark-bubble.show { animation: bubblePop .7s cubic-bezier(.2,.8,.2,1) forwards; }

.sparkles { position: absolute; inset: -12px; opacity: 0; pointer-events: none; }
.sparkles i { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #d9f9e8; box-shadow: 0 0 14px rgba(139,244,193,.8); }
.sparkles i:nth-child(1) { left: 12%; top: 32%; }
.sparkles i:nth-child(2) { right: 18%; top: 12%; }
.sparkles i:nth-child(3) { right: 7%; bottom: 22%; }
.shiba-agent.happy .sparkles { opacity: 1; }
.shiba-agent.happy .sparkles i { animation: sparkleFloat 1.1s ease-in-out infinite alternate; }
.shiba-agent.happy .sparkles i:nth-child(2) { animation-delay: -.35s; }
.shiba-agent.happy .sparkles i:nth-child(3) { animation-delay: -.7s; }

.paw-layer { position: fixed; z-index: 1; inset: 0; pointer-events: none; overflow: hidden; }
.paw-print {
  position: absolute;
  width: 20px;
  height: 20px;
  opacity: 0;
  background: url("../assets/shiba/paw.svg") center/contain no-repeat;
  filter: blur(.1px);
  transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(.78);
  animation: pawFade var(--life, 4.4s) ease-out forwards;
}

.field.error .input-shell {
  border-color: rgba(255,95,108,.68);
  box-shadow: 0 0 0 4px rgba(255,95,108,.055), inset 0 1px 0 rgba(255,255,255,.04);
  animation: fieldNudge .5s cubic-bezier(.36,.07,.19,.97);
}

.login-page.auth-success .login-content {
  opacity: 0;
  transform: translateY(-14px) scale(.985);
  filter: blur(6px);
  pointer-events: none;
}
.login-page.auth-success .ambient { animation: none; transition: transform 1.15s ease, opacity 1.15s ease; }
.login-page.auth-success .ambient-one { transform: translate(22vw, 18vh) scale(1.55); opacity: .36; }
.login-page.auth-success .ambient-two { transform: translate(-22vw, -18vh) scale(1.45); opacity: .34; }
.login-page.page-exit::after {
  content: "";
  position: fixed;
  z-index: 30;
  inset: 0;
  background: #070b16;
  opacity: 0;
  animation: pageFadeOut .52s ease forwards;
}

.transition-message {
  position: fixed;
  z-index: 15;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #eef7f3;
  opacity: 0;
  transform: translate(-50%, -44%) scale(.96);
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}
.transition-message.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.transition-message strong { font-size: 18px; letter-spacing: -.02em; }
.transition-check {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(123,229,180,.32);
  border-radius: 50%;
  background: rgba(75,169,125,.14);
}
.transition-check svg { width: 16px; fill: none; stroke: #8cf0bf; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Dashboard */
.dashboard-shell {
  position: relative;
  z-index: 2;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding-top: calc(var(--safe-top) + 20px);
  padding-right: max(clamp(18px, 5vw, 72px), env(safe-area-inset-right));
  padding-bottom: calc(var(--safe-bottom) + 20px);
  padding-left: max(clamp(18px, 5vw, 72px), env(safe-area-inset-left));
}
.dashboard-panel {
  width: min(100%, 760px);
  padding: clamp(26px, 5vw, 48px);
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.018)), rgba(8,14,27,.48);
  backdrop-filter: blur(18px) saturate(125%);
  -webkit-backdrop-filter: blur(18px) saturate(125%);
  box-shadow: 0 28px 70px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.035);
}
.dashboard-brand { display: flex; align-items: center; gap: 10px; color: #bcc7da; font-size: 12px; font-weight: 700; letter-spacing: .18em; }
.dashboard-hero { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 28px; margin-top: 38px; }
.dashboard-kicker { margin: 0 0 10px; color: #84e4b7; font-size: 13px; font-weight: 650; }
.dashboard-hero h1 { margin: 0; font-size: clamp(36px, 6vw, 60px); line-height: 1.02; letter-spacing: -.055em; }
.dashboard-copy { margin: 14px 0 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.dashboard-shiba { width: clamp(130px, 20vw, 210px); filter: drop-shadow(0 16px 22px rgba(0,0,0,.22)); animation: dashboardDog 1.8s ease-in-out infinite alternate; }
.dashboard-divider { height: 1px; margin: 32px 0 22px; background: linear-gradient(90deg, rgba(255,255,255,.11), rgba(255,255,255,.025)); }
.dashboard-actions { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.session-pill { display: inline-flex; align-items: center; gap: 9px; color: #aeb9cf; font-size: 13px; }
.session-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 14px rgba(119,230,179,.45); }
.logout-button {
  height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 14px;
  color: #d9e0ee;
  background: rgba(255,255,255,.045);
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.logout-button:hover { border-color: rgba(255,255,255,.18); background: rgba(255,255,255,.075); }
.logout-button:active { transform: scale(.98); }

@keyframes ambientDrift { to { transform: translate(10vw, 8vh) scale(1.08); } }
@keyframes petBounce { 0% { transform: translateY(0) scale(1); } 45% { transform: translateY(-9px) scale(1.035); } 100% { transform: translateY(0) scale(1); } }
@keyframes shibaSpin { to { transform: rotate(360deg); } }
@keyframes angryLunge { 0%,100% { transform: translateX(0) scale(1); } 50% { transform: translateX(7px) scale(1.035); } }
@keyframes happyBounce { from { transform: translateY(0) scale(1); } to { transform: translateY(-7px) scale(1.025); } }
@keyframes shyBreath { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes bubblePop { 0% { opacity: 0; transform: translate(-50%, -5px) scale(.82); } 22% { opacity: 1; transform: translate(-50%, -18px) scale(1); } 72% { opacity: 1; transform: translate(-50%, -20px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -29px) scale(.94); } }
@keyframes sparkleFloat { from { opacity: .35; transform: translateY(3px) scale(.75); } to { opacity: 1; transform: translateY(-7px) scale(1.15); } }
@keyframes pawFade { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--r, 0deg)) scale(.7); } 10% { opacity: .12; } 70% { opacity: .08; } 100% { opacity: 0; transform: translate(-50%, -60%) rotate(var(--r, 0deg)) scale(.9); } }
@keyframes fieldNudge { 10%, 90% { transform: translateX(-2px); } 30%, 70% { transform: translateX(3px); } 50% { transform: translateX(-3px); } }
@keyframes pageFadeOut { to { opacity: 1; } }
@keyframes dashboardDog { to { transform: translateY(-6px) rotate(1deg); } }

@media (max-width: 760px) {
  .login-stage { align-items: start; padding-top: calc(var(--safe-top) + 74px); }
  .login-content { margin: 0 auto; width: min(100%, 440px); }
  .hero { margin-bottom: clamp(30px, 6.5vh, 54px); }
  .hero h1 { font-size: clamp(44px, 13vw, 62px); }
  .shiba-agent { width: clamp(118px, 34vw, 158px); }
  .dashboard-hero { grid-template-columns: 1fr; }
  .dashboard-shiba { justify-self: end; margin-top: -20px; }
}

@media (max-width: 430px) {
  .login-stage { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); padding-top: calc(var(--safe-top) + 66px); }
  .hero { margin-bottom: 34px; }
  .eyebrow { margin-bottom: 13px; font-size: 11px; }
  .field { margin-top: 17px; }
  .input-shell { height: 56px; border-radius: 18px; }
  .sound-toggle { width: 40px; height: 40px; border-radius: 14px; }
  .dashboard-panel { padding: 26px 22px; border-radius: 26px; }
  .dashboard-actions { align-items: stretch; flex-direction: column; }
  .logout-button { width: 100%; }
}

@media (max-width: 340px) {
  .login-stage { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .hero h1 { font-size: 42px; }
  .input-shell { height: 54px; }
  .shiba-agent { width: 112px; }
}

@media (min-width: 1100px) {
  .login-content { width: min(100%, 440px); }
  .input-shell { height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  .ambient,
  .shiba-agent .shiba-visual,
  .sparkles i,
  .dashboard-shiba { animation: none !important; }
  .paw-print { display: none !important; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .12s !important; }
}
