@import url('https://fonts.googleapis.com/css2?family=Bodoni+Moda:ital,wght@0,400;0,700;1,400&family=Montserrat:wght@400;500;600;700;900&display=swap');

:root {
  --crimson: #F5003A;
  --crimson-deep: #CC0030;
  --ink: #241F20;
  --card: #2F2729;
  --card-alt: #382E30;
  --body-text: #E5DED2;
  --muted: rgba(229, 222, 210, 0.6);
  --muted-faint: rgba(229, 222, 210, 0.4);
  --pink: #F5A3C7;
  --border: rgba(229, 222, 210, 0.1);
}

* { box-sizing: border-box; }
button, a { color: inherit; font-family: inherit; }

/* Native-app feel: no double-tap zoom delay, no blue tap flash. */
button, a, .chip, .tile, .star, .toggle { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

html {
  /* Stop mobile Safari inflating text in landscape. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: #1A1A1C;
  font-family: 'Montserrat', system-ui, sans-serif;
  color: var(--body-text);
  -webkit-font-smoothing: antialiased;
  /* Kill the rubber-band overscroll that reveals the page behind the app. */
  overscroll-behavior-y: none;
}

#app {
  max-width: 28rem;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--ink);
  position: relative;
  overflow-x: hidden;
  /* Standalone (Add to Home Screen) draws under the status bar because
     index.html sets viewport-fit=cover. Without this the back buttons on
     screens with no header sit beneath the clock and can't be tapped. */
  padding-top: env(safe-area-inset-top);
}

.screen {
  min-height: calc(100vh - env(safe-area-inset-top));
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

.brand-strip {
  padding: 16px 0 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.brand-strip .wordmark { font-family: 'Bodoni Moda', serif; font-size: 15px; letter-spacing: 0.08em; }
.brand-strip .sub { font-family: 'Bodoni Moda', serif; font-style: italic; font-size: 11px; color: var(--pink); }

h1, h2, h3 { font-family: 'Montserrat', sans-serif; font-weight: 900; letter-spacing: -0.02em; margin: 0; }
.label-sm { font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.px { padding-left: 18px; padding-right: 18px; }

.btn {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 14px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--crimson), var(--crimson-deep));
  color: white;
  box-shadow: 0 10px 24px rgba(245, 0, 58, 0.35);
}
.btn-primary:active { transform: scale(0.98); }
.btn-secondary { background: var(--card); color: var(--body-text); border: 1px solid var(--border); }
.btn-block { width: 100%; }

input, textarea, select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--body-text);
  padding: 12px 14px;
  font-family: inherit;
  /* Must stay >= 16px: iOS Safari auto-zooms the page on focus for anything
     smaller, which breaks the native-app feel. */
  font-size: 16px;
  width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--muted-faint); }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--card);
  color: var(--body-text);
  cursor: pointer;
}
.chip.selected { background: var(--crimson); border-color: var(--crimson); color: white; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.tabbar {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 28rem;
  background: rgba(47, 39, 41, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  /* Clear the iPhone home indicator (index.html sets viewport-fit=cover). */
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index: 50;
}
.tab-item {
  background: none; border: none; color: var(--muted); display: flex; flex-direction: column;
  align-items: center; gap: 2px; font-size: 10px; font-family: 'Montserrat'; font-weight: 500; padding: 6px 8px;
}
.tab-item.active { color: var(--crimson); }
.tab-item.raised {
  background: var(--crimson); color: white; border-radius: 16px; padding: 12px 18px; margin-top: -20px;
  box-shadow: 0 8px 20px rgba(245, 0, 58, 0.4); font-weight: 700;
}

.stars { display: inline-flex; gap: 4px; cursor: pointer; }
.star { font-size: 22px; color: var(--muted-faint); }
.star.filled { color: var(--crimson); }

.progress-bar { height: 4px; background: var(--card-alt); border-radius: 4px; overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--crimson); transition: width 0.3s ease; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.tile {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  height: 124px;
  background: var(--card);
  border: 1px solid var(--border);
}
.tile img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 25%; }
.tile .tile-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 8px 6px 6px;
  background: linear-gradient(0deg, rgba(0,0,0,0.85), transparent);
  color: white; font-weight: 900; text-transform: uppercase; font-size: 10.5px; text-align: center;
}

.session-row { display: flex; gap: 10px; align-items: flex-start; }
.swatch { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.dot { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; }

a, .link { color: var(--pink); text-decoration: none; font-weight: 600; }

.hidden { display: none !important; }

.blob {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.35; pointer-events: none;
}

.err { color: var(--crimson); font-size: 12px; margin-top: 8px; }

.otp-boxes { display: flex; gap: 8px; justify-content: center; margin: 20px 0; }
.otp-box {
  width: 42px; height: 52px; border-radius: 10px; background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700;
}
.otp-box.filled { border-color: var(--crimson); }

.chat-dots { letter-spacing: 2px; animation: pulse 1.4s ease-in-out infinite; color: var(--muted); font-size: 10px; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
#chat-scroll { scroll-behavior: smooth; }

.back-btn {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: none; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 17px; cursor: pointer;
}
.back-btn:active { background: rgba(0,0,0,0.55); }

/* Confirmation sheet (delete session, etc.) */
.sheet-wrap { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); animation: sheet-fade 0.2s ease-out both; }
.sheet {
  position: relative;
  width: 100%; max-width: 28rem;
  background: var(--card);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  animation: sheet-up 0.26s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes sheet-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop { animation-duration: 0.01s; }
}

/* Add-to-Home-Screen nudge. Sits above the tab bar; on iOS the caret points
   down at Safari's share button, which lives in the browser chrome below. */
#a2hs {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 200;
  width: calc(100% - 28px);
  max-width: 26rem;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 30px 13px 14px;
  border-radius: 16px;
  background: rgba(56, 46, 48, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(229, 222, 210, 0.16);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  animation: a2hs-in 0.4s cubic-bezier(0.16, 1.1, 0.3, 1) both,
             a2hs-bob 2.4s ease-in-out 0.6s infinite;
}
#a2hs.leaving { animation: a2hs-out 0.2s ease-in both; }

@keyframes a2hs-in {
  from { opacity: 0; transform: translate(-50%, 24px) scale(0.94); }
  to   { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
@keyframes a2hs-bob {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, -7px); }
}
@keyframes a2hs-out {
  to { opacity: 0; transform: translate(-50%, 12px) scale(0.96); }
}
@media (prefers-reduced-motion: reduce) {
  #a2hs { animation: a2hs-in 0.01s both; }
}

.a2hs-icon { width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0; }
.a2hs-copy { flex: 1; min-width: 0; }
.a2hs-title { font-size: 13px; font-weight: 800; line-height: 1.25; }
.a2hs-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.a2hs-sub strong { color: var(--body-text); font-weight: 700; }
.a2hs-x {
  position: absolute; top: 5px; right: 7px;
  background: none; border: none; color: var(--muted-faint);
  font-size: 21px; line-height: 1; padding: 4px 7px; cursor: pointer;
}
.a2hs-x:active { color: var(--body-text); }
.a2hs-cta {
  flex-shrink: 0; border: none; border-radius: 10px; cursor: pointer;
  background: var(--crimson); color: #fff; font-family: inherit;
  font-weight: 700; font-size: 12.5px; padding: 9px 14px;
}
.a2hs-caret {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(56, 46, 48, 0.97);
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.3));
}

.toggle { width: 40px; height: 22px; border-radius: 12px; background: var(--muted-faint); position: relative; flex-shrink: 0; transition: background 0.2s; cursor: pointer; border: none; padding: 0; }
.toggle.on { background: var(--crimson); }
.toggle-knob { width: 18px; height: 18px; border-radius: 50%; background: #fff; position: absolute; top: 2px; left: 2px; transition: left 0.2s; }
.toggle.on .toggle-knob { left: 20px; }
