@import url("/frontend/css/base.css");
@import url("/frontend/css/themes.css?v=20260617-me-settings-v2");
@import url("/frontend/css/layout.css");
@import url("/frontend/css/sidebar.css");
@import url("/frontend/css/chat.css?v=20260802-journey-continuity-v1");
@import url("/frontend/css/auth.css");
@import url("/frontend/css/journey-map.css?v=20260617-me-settings-v2");
@import url("/frontend/css/lifemap.css?v=20260801-ios-pwa-safearea-v1");

button,
[role="button"],
a {
  -webkit-tap-highlight-color: transparent;
}

button,
[role="button"] {
  touch-action: manipulation;
}

/* ===== App Boot Screen ===== */
.app-boot-screen {
  position: fixed;
  inset: 0;
  z-index: 20000;
  min-height: 100dvh;
  padding: max(32px, env(safe-area-inset-top)) 28px max(36px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #202427;
  background:
    radial-gradient(circle at 50% 38%, rgba(168, 132, 92, 0.12), transparent 36%),
    #f7f7f8;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.app-boot-mark {
  width: 132px;
  height: 126px;
  display: grid;
  place-items: center;
}

.app-boot-logo {
  width: 132px;
  height: 98px;
  overflow: visible;
  color: #202427;
  filter: drop-shadow(0 18px 34px rgba(32, 36, 39, 0.06));
  transform-origin: center;
}

.app-boot-logo-draw {
  opacity: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 28;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 1.2;
  stroke-dashoffset: 0.99;
  animation-name: appBootLogoDrawStroke;
  animation-duration: var(--app-boot-logo-draw-duration, 520ms);
  animation-delay: var(--app-boot-logo-draw-delay, 0ms);
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.34, 0, 0.14, 1);
}

.app-boot-logo-left-ear {
  --app-boot-logo-draw-delay: 110ms;
  --app-boot-logo-draw-duration: 380ms;
  d: path("M 196.29 672.6 C 92.65 402.12 343.16 173.58 440.62 226.49 C 547.24 284.37 406.31 505.76 271.79 627.3");
  animation-name: appBootLogoDrawStroke, appBootLogoLeftEarWiggle;
  animation-duration: var(--app-boot-logo-draw-duration), 233ms;
  animation-delay: var(--app-boot-logo-draw-delay), 2640ms;
  animation-fill-mode: both, both;
  animation-timing-function: cubic-bezier(0.34, 0, 0.14, 1), cubic-bezier(0.22, 1, 0.36, 1);
}

.app-boot-logo-right-ear {
  --app-boot-logo-draw-delay: 490ms;
  --app-boot-logo-draw-duration: 380ms;
  d: path("M 282 618 C 282 618 422.74 437.89 652 393 C 867 350.91 790.1 486.97 696 553 C 632 597.91 538 650.91 398 699");
  animation-name: appBootLogoDrawStroke, appBootLogoRightEarWiggle;
  animation-duration: var(--app-boot-logo-draw-duration), 233ms;
  animation-delay: var(--app-boot-logo-draw-delay), 2640ms;
  animation-fill-mode: both, both;
  animation-timing-function: cubic-bezier(0.34, 0, 0.14, 1), cubic-bezier(0.22, 1, 0.36, 1);
}

.app-boot-logo-base {
  --app-boot-logo-draw-delay: 870ms;
  --app-boot-logo-draw-duration: 130ms;
}

.app-boot-logo-tail-piece {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  animation-name: appBootLogoTailPieceIn;
  animation-duration: 160ms;
  animation-delay: var(--app-boot-logo-tail-piece-delay, 0ms);
  animation-fill-mode: both;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

.app-boot-logo-tail-piece-01 { --app-boot-logo-tail-piece-delay: 1460ms; }
.app-boot-logo-tail-piece-02 { --app-boot-logo-tail-piece-delay: 1520ms; }
.app-boot-logo-tail-piece-03 { --app-boot-logo-tail-piece-delay: 1580ms; }
.app-boot-logo-tail-piece-04 { --app-boot-logo-tail-piece-delay: 1640ms; }
.app-boot-logo-tail-piece-05 { --app-boot-logo-tail-piece-delay: 1700ms; }
.app-boot-logo-tail-piece-06 { --app-boot-logo-tail-piece-delay: 1760ms; }
.app-boot-logo-tail-piece-07 { --app-boot-logo-tail-piece-delay: 1820ms; }
.app-boot-logo-tail-piece-08 { --app-boot-logo-tail-piece-delay: 1880ms; }
.app-boot-logo-tail-piece-09 { --app-boot-logo-tail-piece-delay: 1940ms; }
.app-boot-logo-tail-piece-10 { --app-boot-logo-tail-piece-delay: 2000ms; }

body.app-boot-failed .app-boot-logo-draw,
body.app-boot-failed .app-boot-logo-tail-piece {
  animation: none !important;
  opacity: 1;
}

body.app-boot-failed .app-boot-logo-draw {
  stroke-dashoffset: 0;
}

body.app-boot-failed .app-boot-logo-tail-piece {
  transform: scale(1);
}

.app-boot-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.app-boot-status {
  min-height: 22px;
  font-size: 14px;
  line-height: 1.5;
  color: #667085;
  text-align: center;
}

.app-boot-spinner {
  width: 22px;
  height: 22px;
  margin-top: 6px;
  border: 2px solid rgba(32, 36, 39, 0.12);
  border-top-color: #202427;
  border-radius: 50%;
  animation: appBootSpin 0.8s linear infinite;
}

.app-boot-actions[hidden] {
  display: none;
}

.app-boot-retry {
  min-width: 96px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid rgba(32, 36, 39, 0.18);
  border-radius: 999px;
  background: #202427;
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

body.app-booting .app-shell {
  opacity: 0;
  pointer-events: none;
}

body.app-boot-failed .app-boot-spinner {
  display: none;
}

body:not(.app-booting) .app-boot-screen {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ===== App Network State ===== */
.app-network-state {
  position: fixed;
  inset: 0;
  z-index: 22000;
  min-height: 100dvh;
  padding: max(30px, env(safe-area-inset-top)) 22px max(34px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #202427;
  background: #f7f7f8;
  backdrop-filter: blur(18px) saturate(1.04);
  -webkit-backdrop-filter: blur(18px) saturate(1.04);
}

.app-network-card {
  width: min(100%, 360px);
  padding: 24px 22px 22px;
  border: 1px solid rgba(32, 36, 39, 0.1);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 52px rgba(32, 36, 39, 0.1);
  text-align: center;
}

.app-network-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.app-network-message {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: #667085;
}

.app-network-actions {
  margin-top: 20px;
  display: grid;
  gap: 10px;
}

.app-network-retry,
.app-network-dismiss {
  min-height: 44px;
  width: 100%;
  border-radius: 999px;
  padding: 0 18px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}

.app-network-retry {
  border: 1px solid #202427;
  background: #202427;
  color: #ffffff;
}

.app-network-retry:disabled {
  cursor: progress;
  opacity: 0.66;
}

.app-network-dismiss {
  border: 1px solid rgba(32, 36, 39, 0.16);
  background: transparent;
  color: #202427;
}

.app-network-dismiss[hidden],
.app-network-state.hidden {
  display: none;
}

body.app-network-blocked .app-shell {
  pointer-events: none;
}

@keyframes appBootSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes appBootLogoDrawStroke {
  0% {
    opacity: 0;
    stroke-dashoffset: 0.99;
  }
  0.01% {
    opacity: 1;
    stroke-dashoffset: 0.99;
    animation-timing-function: cubic-bezier(0.34, 0, 0.14, 1);
  }
  84% {
    opacity: 1;
    stroke-dashoffset: 0;
    animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  }
  100% {
    opacity: 1;
    stroke-dashoffset: 0;
  }
}

@keyframes appBootLogoLeftEarWiggle {
  0%, 100% {
    d: path("M 196.29 672.6 C 92.65 402.12 343.16 173.58 440.62 226.49 C 547.24 284.37 406.31 505.76 271.79 627.3");
  }
  24% {
    d: path("M 196.29 672.6 C 95.5 405 357 184 454 238 C 560 295 412 510 271.79 627.3");
  }
  50% {
    d: path("M 196.29 672.6 C 90.5 400 335 170 432 220 C 539 279 402 504 271.79 627.3");
  }
  74% {
    d: path("M 196.29 672.6 C 94 404 350 180 448 234 C 553 291 410 508 271.79 627.3");
  }
}

@keyframes appBootLogoRightEarWiggle {
  0%, 100% {
    d: path("M 282 618 C 282 618 422.74 437.89 652 393 C 867 350.91 790.1 486.97 696 553 C 632 597.91 538 650.91 398 699");
  }
  24% {
    d: path("M 282 618 C 282 618 435 448 665 404 C 881 362 800 495 704 560 C 638 602 542 653 398 699");
  }
  50% {
    d: path("M 282 618 C 282 618 416 432 644 387 C 858 344 782 482 690 548 C 626 596 534 649 398 699");
  }
  74% {
    d: path("M 282 618 C 282 618 429 443 658 399 C 874 357 794 491 700 557 C 635 600 540 652 398 699");
  }
}

@keyframes appBootLogoTailPieceIn {
  0% {
    opacity: 0;
    transform: scale(0.58) rotate(-2deg);
  }
  70% {
    opacity: 1;
    transform: scale(1.08) rotate(0.8deg);
    animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-boot-screen {
    transition: none;
  }

  .app-boot-logo,
  .app-boot-logo-draw,
  .app-boot-logo-tail-piece,
  .app-boot-spinner {
    animation: none;
  }

  .app-boot-logo-draw,
  .app-boot-logo-tail-piece {
    opacity: 1;
  }

  .app-boot-logo-draw {
    stroke-dashoffset: 0;
  }

  .app-boot-logo-tail-piece {
    transform: scale(1);
  }

  .app-network-state {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* ===== PWA install guidance ===== */
.pwa-install-card {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(18px);
  width: min(420px, calc(100% - 28px));
  max-width: 420px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px 12px;
  padding: 16px;
  border: 1px solid rgba(17, 17, 17, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.pwa-install-card.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.pwa-install-card-close {
  position: absolute;
  top: 7px;
  right: 9px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #777;
  font-size: 22px;
  line-height: 1;
}

.pwa-install-card-icon {
  grid-row: 1;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border-radius: 13px;
  background: #090a0c;
}

.pwa-install-card-icon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.pwa-install-card-copy {
  min-width: 0;
  padding-right: 22px;
}

.pwa-install-card-copy strong,
.pwa-install-card-copy span {
  display: block;
}

.pwa-install-card-copy strong {
  color: #111;
  font-size: 15px;
  line-height: 1.35;
}

.pwa-install-card-copy span {
  margin-top: 4px;
  color: #666;
  font-size: 12px;
  line-height: 1.45;
}

.pwa-install-card-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pwa-btn {
  font-size: 13px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  border: none;
}

.pwa-btn-secondary {
  background: transparent;
  color: #666;
}

.pwa-btn-primary {
  background: #111;
  color: #fff;
}

.pwa-install-help-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  padding: 16px 14px max(14px, env(safe-area-inset-bottom, 0px));
  background: rgba(0, 0, 0, 0.42);
  z-index: 10020;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pwa-install-help-overlay.show {
  opacity: 1;
}

.pwa-install-help-sheet {
  position: relative;
  width: min(440px, 100%);
  box-sizing: border-box;
  padding: 26px 22px 20px;
  border-radius: 24px;
  background: #fff;
  color: #111;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  transform: translateY(18px);
  transition: transform 0.22s ease;
}

.pwa-install-help-overlay.show .pwa-install-help-sheet {
  transform: translateY(0);
}

.pwa-install-help-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f2f2f2;
  color: #555;
  font-size: 23px;
}

.pwa-install-help-eyebrow {
  margin-bottom: 7px;
  color: #777;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pwa-install-help-sheet h2 {
  margin: 0;
  padding-right: 34px;
  font-size: 21px;
  line-height: 1.35;
}

.pwa-install-help-sheet p {
  margin: 10px 0 0;
  color: #666;
  font-size: 13px;
  line-height: 1.6;
}

.pwa-install-help-sheet ol {
  margin: 18px 0;
  padding: 0;
  list-style: none;
  counter-reset: pwa-step;
}

.pwa-install-help-sheet li {
  position: relative;
  min-height: 32px;
  margin: 0 0 12px;
  padding: 6px 0 0 42px;
  color: #222;
  font-size: 14px;
  line-height: 1.55;
  counter-increment: pwa-step;
}

.pwa-install-help-sheet li::before {
  content: counter(pwa-step);
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.pwa-install-help-install,
.pwa-install-help-done {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
}

.pwa-install-help-install {
  margin-bottom: 8px;
  background: #111;
  color: #fff;
}

.pwa-install-help-done {
  background: #f1f1f1;
  color: #222;
}

.pwa-install-success-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 16px;
  background: #111;
  color: #fff;
  font-size: 27px;
  font-weight: 700;
}

@media (min-width: 700px) {
  .pwa-install-help-overlay {
    align-items: center;
  }
}
