:root {
  --bg: #0f0a0d;
  --bg-grad-1: #16101a;
  --bg-grad-2: #0c0a10;
  --elev: rgba(255, 255, 255, 0.045);
  --elev-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --border-soft: rgba(255, 255, 255, 0.055);
  --text: #f6eef2;
  --text-dim: #b9a6b0;
  --text-dimmer: #8a7680;
  --accent: #f5a9c4;
  --accent-2: #ffd9e4;
  --accent-deep: #d98ca0;
  --accent-glow: rgba(245, 169, 196, 0.38);
  --danger: #ff6b81;
  --ok: #7fe3ab;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow-soft: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font-body: 'Poppins', system-ui, sans-serif;
  --font-script: 'Dancing Script', cursive;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* an element's own display:flex/grid rule otherwise beats the UA [hidden]
   default, so anything toggled via the hidden attribute needs this to
   actually disappear */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(1200px 800px at 15% -10%, rgba(245, 169, 196, 0.12), transparent 60%),
    radial-gradient(900px 700px at 110% 10%, rgba(217, 140, 160, 0.10), transparent 55%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2) 60%, var(--bg));
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }

::selection { background: var(--accent-glow); }

/* ---------- glass ---------- */
.glass {
  background: var(--elev);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--elev-2);
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, background 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #2a0e17;
  box-shadow: 0 6px 22px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 8px 28px var(--accent-glow); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); }
.btn-ghost-danger { background: transparent; border: 1px solid rgba(255, 107, 129, 0.35); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-lg { padding: 15px 30px; font-size: 1.05rem; }
.btn-round { width: 46px; height: 46px; padding: 0; border-radius: 50%; flex: 0 0 auto; }

/* ---------- screens ---------- */
.screen { min-height: 100vh; width: 100%; }
.screen-center { display: flex; align-items: center; justify-content: center; padding: 24px; }

.auth-card {
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius-lg);
  padding: 36px 28px 30px;
  text-align: center;
  animation: rise 0.5s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-mark { display: flex; justify-content: center; margin-bottom: 18px; }
.brand-icon {
  width: 96px; height: 96px; border-radius: 26px;
  box-shadow: 0 10px 34px var(--accent-glow), 0 0 0 1px var(--border);
}
.brand-mark.small .brand-icon { width: 72px; height: 72px; border-radius: 20px; }

.brand-word {
  font-family: var(--font-script);
  font-weight: 700;
  font-size: 3rem;
  margin: 0 0 4px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent) 55%, var(--accent-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 14px var(--accent-glow));
}

.identity-title { margin: 0 0 4px; font-weight: 700; font-size: 1.4rem; }

.auth-sub { color: var(--text-dim); margin: 0 0 26px; font-size: 0.92rem; }

.pin-form { display: flex; flex-direction: column; gap: 14px; }
.pin-input {
  width: 100%;
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.5rem;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.pin-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.form-error { color: var(--danger); font-size: 0.85rem; margin: 0; animation: shake 0.35s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.identity-list { display: flex; flex-direction: column; gap: 12px; }
.identity-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
  text-align: left;
}
.identity-option:active { transform: scale(0.98); }
.identity-option:hover { border-color: var(--accent); background: rgba(245, 169, 196, 0.08); }
.identity-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.05rem; color: #200910; flex: 0 0 auto;
}
.identity-option-name { font-weight: 600; }

/* ---------- app shell ---------- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
  position: sticky; top: 0; z-index: 20;
}
.app-header-brand { display: flex; align-items: center; gap: 10px; }
.header-icon { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 4px 14px var(--accent-glow); }
.header-word {
  font-family: var(--font-script);
  font-weight: 700;
  font-size: 1.7rem;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.whoami-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  background: var(--elev);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  transition: border-color 0.2s ease;
}
.whoami-chip:hover { border-color: var(--accent); }
.whoami-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #200910;
  background: var(--accent);
}

.app-main {
  flex: 1;
  padding: 6px 18px 110px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.panel-title { font-size: 1.4rem; font-weight: 700; margin: 10px 0 18px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 18px; }
.panel-title-row .panel-title { margin: 0; }

.tab-panel { display: none; animation: fadein 0.28s ease; }
.tab-panel.active { display: block; }
@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  gap: 4px;
  padding: 8px;
  border-radius: 999px;
  z-index: 30;
  width: calc(100% - 28px);
  max-width: 480px;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 4px;
  color: var(--text-dimmer);
  font-size: 0.66rem;
  font-weight: 600;
  position: relative;
  transition: color 0.2s ease, background 0.2s ease;
}
.nav-btn .nav-icon { font-size: 1.25rem; line-height: 1; }
.nav-btn.active { color: var(--text); background: rgba(245, 169, 196, 0.14); }
.nav-dot {
  position: absolute; top: 4px; right: 18%;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent-glow);
}

/* ---------- home ---------- */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.summary-card {
  border-radius: var(--radius-md);
  padding: 18px 16px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  text-align: left;
  color: var(--text);
  transition: transform 0.18s ease, border-color 0.2s ease;
  min-height: 108px;
}
.summary-card:active { transform: scale(0.97); }
.summary-card:hover { border-color: var(--accent); }
.summary-icon { font-size: 1.4rem; }
.summary-label { color: var(--text-dim); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.summary-value { font-size: 0.95rem; font-weight: 600; }
.summary-card-photo { padding: 10px; }
.summary-photo-thumb {
  width: 100%; height: 64px; border-radius: 10px;
  background-size: cover; background-position: center;
  background-color: rgba(255, 255, 255, 0.05);
}

/* ---------- chat ---------- */
.chat-messages {
  display: flex; flex-direction: column; gap: 10px;
  padding-bottom: 14px;
  min-height: 40vh;
}
.chat-bubble-row { display: flex; flex-direction: column; max-width: 78%; animation: fadein 0.2s ease; }
.chat-bubble-row.mine { align-self: flex-end; align-items: flex-end; }
.chat-bubble-row.theirs { align-self: flex-start; align-items: flex-start; }
.chat-sender { font-size: 0.72rem; color: var(--text-dimmer); margin: 0 4px 3px; font-weight: 600; }
.chat-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.93rem;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
}
.chat-bubble-row.theirs .chat-bubble {
  background: var(--elev-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.chat-bubble-row.mine .chat-bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #2a0e17;
  border-bottom-right-radius: 5px;
}
.chat-time { font-size: 0.65rem; color: var(--text-dimmer); margin: 3px 4px 0; }

.chat-composer {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 36px);
  max-width: 684px;
  display: flex;
  gap: 10px;
  padding: 8px 8px 8px 18px;
  border-radius: 999px;
  z-index: 25;
}
.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}
.chat-input::placeholder { color: var(--text-dimmer); }

/* ---------- goals ---------- */
.goals-list { display: flex; flex-direction: column; gap: 12px; }
.goal-card {
  border-radius: var(--radius-md);
  padding: 16px 18px;
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.goal-card:active { transform: scale(0.99); }
.goal-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.goal-title { font-weight: 700; font-size: 1.02rem; margin: 0 0 4px; }
.goal-desc { color: var(--text-dim); font-size: 0.88rem; margin: 4px 0 0; line-height: 1.45; white-space: pre-wrap; }
.goal-meta { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.goal-badge {
  font-size: 0.7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.goal-badge.status-in_progress { background: rgba(255, 197, 90, 0.16); color: #ffcb6b; }
.goal-badge.status-done { background: rgba(127, 227, 171, 0.16); color: var(--ok); }
.goal-owner {
  display: flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--text-dim); margin-left: auto;
}
.goal-owner-dot { width: 8px; height: 8px; border-radius: 50%; }
.goal-date { font-size: 0.76rem; color: var(--text-dimmer); }
.goal-edit-btn {
  background: transparent; border: none; color: var(--text-dimmer); font-size: 1.05rem; padding: 4px;
}

/* ---------- pictures ---------- */
.photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.photo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
  cursor: pointer;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.3s ease; }
.photo-tile:active img { transform: scale(1.05); }
.photo-tile-owner {
  position: absolute; bottom: 5px; left: 5px;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700; color: #200910;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4);
}
.photo-upload-label { display: inline-flex; }

/* ---------- empty states ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-dim); }
.empty-emoji { font-size: 2.6rem; margin-bottom: 10px; filter: drop-shadow(0 4px 14px var(--accent-glow)); }
.empty-state p { margin: 0; font-size: 0.92rem; }

/* ---------- call ---------- */
.call-idle {
  border-radius: var(--radius-lg);
  padding: 46px 24px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.call-idle-orb {
  width: 92px; height: 92px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent) 55%, var(--accent-deep));
  box-shadow: 0 0 0 10px rgba(245, 169, 196, 0.08), 0 0 60px var(--accent-glow);
  animation: pulse-orb 2.6s ease-in-out infinite;
}
@keyframes pulse-orb {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.call-idle-text { font-weight: 600; font-size: 1.05rem; margin: 0; }
.call-idle-note { color: var(--text-dimmer); font-size: 0.8rem; margin: 4px 0 0; }

.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 100px;
}
.video-grid.count-2 { grid-template-columns: 1fr 1fr; }
.video-grid.count-3 { grid-template-columns: 1fr 1fr; }
.video-tile {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #180f14;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--border);
}
.video-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-tile.mirrored video { transform: scaleX(-1); }
.video-tile-label {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.video-tile-status {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  color: var(--text-dim);
  font-size: 0.8rem;
  background: rgba(15, 10, 13, 0.55);
}
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.call-controls {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  padding: 12px 18px;
  border-radius: 999px;
  z-index: 25;
}
.call-ctrl-btn {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--elev-2);
  font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, background 0.2s ease;
}
.call-ctrl-btn:active { transform: scale(0.92); }
.call-ctrl-btn.muted { background: rgba(255, 107, 129, 0.22); }
.call-ctrl-hangup { background: linear-gradient(135deg, #ff6b81, #d63a58); }

/* ---------- ringing banner ---------- */
.ringing-banner {
  position: sticky; top: 66px; z-index: 22;
  margin: 0 18px 10px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(245, 169, 196, 0.22), rgba(217, 140, 160, 0.14));
  border: 1px solid var(--accent);
  animation: rise 0.3s ease;
}
.ringing-pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
  animation: ringpulse 1.4s ease-out infinite;
  flex: 0 0 auto;
}
@keyframes ringpulse {
  0% { box-shadow: 0 0 0 0 var(--accent-glow); }
  70% { box-shadow: 0 0 0 10px rgba(245, 169, 196, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 169, 196, 0); }
}
.ringing-text { flex: 1; font-size: 0.85rem; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(5, 3, 4, 0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein 0.2s ease;
}
.modal {
  width: 100%; max-width: 480px;
  border-radius: 26px 26px 0 0;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  animation: modalup 0.25s ease;
}
@keyframes modalup {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h3 { margin: 0 0 18px; font-size: 1.2rem; }
.field-label { display: block; font-size: 0.78rem; color: var(--text-dim); font-weight: 600; margin: 14px 0 6px; }
.field-optional { font-weight: 400; color: var(--text-dimmer); }
.field-input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  padding: 11px 13px;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s ease;
}
.field-input:focus { border-color: var(--accent); }
.field-textarea { resize: vertical; font-family: inherit; }
.field-row { display: flex; gap: 12px; }
.field-col { flex: 1; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 22px; }
.modal-actions-right { display: flex; gap: 10px; margin-left: auto; }
select.field-input { appearance: none; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 3, 4, 0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadein 0.2s ease;
}
.lightbox img { max-width: 100%; max-height: 80vh; border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.lightbox-meta { color: var(--text-dim); font-size: 0.85rem; margin-top: 14px; }
.lightbox-close {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: 16px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--elev-2); color: var(--text);
  font-size: 1.1rem;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: var(--elev-2); border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  padding: 10px 20px; border-radius: 999px;
  font-size: 0.85rem; z-index: 80;
  box-shadow: var(--shadow-soft);
  animation: toastin 0.25s ease;
}
@keyframes toastin {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast.toast-error { border-color: var(--danger); color: var(--danger); }

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 8px; }

/* ---------- desktop ---------- */
@media (min-width: 860px) {
  .app-header { padding: 22px 40px 10px; }
  .app-main { padding: 10px 40px 60px; max-width: 900px; }
  .bottom-nav {
    position: sticky;
    left: auto; transform: none; bottom: auto;
    width: fit-content;
    margin: 6px auto 24px;
  }
  .app-shell { display: flex; flex-direction: column; }
  .chat-composer { position: sticky; bottom: 20px; margin: 16px auto 0; }
  .call-controls { position: sticky; bottom: 20px; margin: 16px auto 0; }
  .video-grid { margin-bottom: 20px; }
  .video-grid.count-1 { max-width: 460px; margin-left: auto; margin-right: auto; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .photos-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 380px) {
  .brand-word { font-size: 2.4rem; }
  .summary-grid { gap: 10px; }
}
