
/* ==============================
   Base & Reset
============================== */
*, *::before, *::after { box-sizing: border-box; }

/* Keyboard focus: a clear ring for keyboard users, not shown on mouse/touch.
   Purely additive — controls with their own focus glow keep it; everything else
   (buttons, links, close ×, gallery thumbnails, toggles) gets a visible ring. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid rgba(var(--mood-glow), 0.9);
  outline-offset: 2px;
}

/* Respect the OS "reduce motion" setting — honours it by default, on top of the
   in-app toggle. Neutralises CSS animations/transitions for motion-sensitive users.
   (The atmosphere canvas is JS-driven; have atmosphere.js check matchMedia too.) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

:root {
  --mood-glow:    94, 159, 214; /* r,g,b — drifts with time-of-day, set by atmosphere.js */
  --primary:      #4FB6E8;
  --accent:       #3D8FC4;
  --bg-body:      #0B1420;
  --bg-section:   #0A1119;
  --bg-chat:      #111E2C;
  --bg-bot:       #16243A;
  --bg-user:      #0D1822;
  --text:         #DCE8F2;
  --text-muted:   #7E97AC;
  --glow-soft:    rgba(79, 182, 232, 0.15);
  --glow-mid:     rgba(79, 182, 232, 0.30);

  /* single danger colour for every destructive action (muted red that sits with
     the cool palette). --danger = fill/text/border, --danger-hover = brighter hover. */
  --danger:        #e2565a;
  --danger-hover:  #f06b6b;

  /* readability overrides (set by applyCustomization) */
  --message-font-size: 1rem;
  --chat-max-width:    1400px;
  --border-radius:     20px;
  /* cap a bubble's text to a readable measure (~70ch) on wide screens while staying
     responsive; mobile breakpoints override with their own percentage widths. */
  --bubble-max-width:  min(72%, 42rem);

  /* landing page palette (dark desaturated teal/sage) */
  --landing-bg:          #0B1420;
  --landing-surface:     #111E2C;
  --landing-accent:      #4FB6E8;
  --landing-text:        #DCE8F2;
  --landing-text-muted:  #8CAFC8;
}

body {
  font-family: 'Inter', sans-serif;
  margin: 0;
  padding: 0;
  position: relative;
  background-color: var(--bg-body);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  line-height: 1.65;
}

/* Hide UI until Firebase resolves auth — prevents the raw chat shell
   flashing before we know if the user is signed in or not. */
body:not(.auth-ready) header,
body:not(.auth-ready) .slogan,
body:not(.auth-ready) main,
body:not(.auth-ready) #auth-section { opacity: 0; }

/* Hide chrome behind the landing overlay — the overlay is opaque but
   header/slogan/main are in normal flow above any fixed-position stacking. */
body:has(#auth-section.landing-mode) header,
body:has(#auth-section.landing-mode) .slogan,
body:has(#auth-section.landing-mode) main { visibility: hidden; }

body.auth-ready header,
body.auth-ready .slogan,
body.auth-ready main,
body.auth-ready #auth-section { transition: opacity 0.2s ease; }

/* ==============================
   Ambient Atmosphere
   A living backdrop that drifts through morning / afternoon / evening /
   night based on local time — painted by assets/js/atmosphere.js.
============================== */
#atmosphere-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  display: block;
}

/* ==============================
   Header & Slogan
============================== */
header {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  font-size: 2.6rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(61, 143, 196, 0.4);
  user-select: none;
}

.slogan {
  font-family: 'Exo 2', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 2rem;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.slogan em {
  font-style: normal;
  color: var(--accent);
}

/* ==============================
   Landing Page
============================== */
#auth-section.landing-mode {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 3.5rem 1.5rem 3rem;
  border: none;
  border-radius: 0;
  box-shadow: none;
  /* Frosted-glass landing layer — same living sky as the chat shows through
     here too, so the world feels continuous from first glance to first message.
     NOTE: background-image can't end in a plain color (only background shorthand
     can) — the color lives in background-color so the gradient list stays valid. */
  background-image:
    radial-gradient(ellipse 65% 55% at 24% 18%, rgba(var(--mood-glow), 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 86%, rgba(var(--mood-glow), 0.08) 0%, transparent 58%),
    repeating-linear-gradient(135deg, rgba(220, 232, 242, 0.02) 0px, rgba(220, 232, 242, 0.02) 1px, transparent 1px, transparent 34px);
  background-color: rgb(9, 16, 26);
  background-repeat: no-repeat, no-repeat, repeat;
  opacity: 1;
  transition: opacity 0.28s ease;
}

#auth-section.landing-mode.landing-fade-out {
  opacity: 0;
  pointer-events: none;
}

#auth-section.landing-mode #auth-box {
  max-width: 620px;
  width: 100%;
  margin: auto;
}

.landing-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.3rem;
}

.landing-eyebrow {
  font-family: 'Exo 2', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--landing-accent);
  margin: 0;
}

.landing-headline {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  font-size: clamp(1.9rem, 4.4vw, 2.7rem);
  line-height: 1.32;
  color: var(--landing-text);
  max-width: 17ch;
  margin: 0;
}

.landing-copy {
  font-family: 'Inter', sans-serif;
  font-size: 1.04rem;
  line-height: 1.8;
  color: var(--landing-text-muted);
  max-width: 46ch;
  margin: 0;
}

.landing-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 0.5rem;
}

.landing-btn {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  font-size: 0.98rem;
  padding: 0.85rem 1.9rem;
  border-radius: 999px;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.landing-btn:active { transform: scale(0.97); }

.landing-btn-primary {
  background: var(--landing-accent);
  color: #0A1119;
  box-shadow: 0 4px 26px rgba(79, 182, 232, 0.28);
}
.landing-btn-primary:hover {
  box-shadow: 0 6px 32px rgba(79, 182, 232, 0.42);
}

.landing-btn-ghost {
  background: transparent;
  color: var(--landing-text);
  border-color: rgba(220, 232, 242, 0.28);
}
.landing-btn-ghost:hover {
  border-color: var(--landing-accent);
  color: var(--landing-accent);
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.4rem 2.2rem;
  margin: 1.6rem 0 1.8rem;
  width: 100%;
  text-align: left;
}

.landing-feature {
  border-top: 1px solid rgba(79, 182, 232, 0.3);
  padding-top: 0.85rem;
  text-align: left;
}

.landing-feature-title {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--landing-accent);
  margin: 0 0 0.3rem;
  letter-spacing: 0.01em;
}

.landing-feature-copy {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  color: var(--landing-text-muted);
  line-height: 1.5;
  margin: 0;
}

@media (max-width: 560px) {
  .landing-features {
    grid-template-columns: auto 1fr;   /* ONE shared label|copy pair; features stack as rows */
    gap: 0;
    border-top: 1px solid rgba(79, 182, 232, 0.3);
    margin: 1.4rem 0 1.6rem;
  }
  .landing-feature {
    grid-column: 1 / -1;               /* span both shared columns... */
    display: grid;
    grid-template-columns: subgrid;    /* ...so every label uses the SAME width and the
                                          copy lines up across all rows (was: each row
                                          sized its own label, pushing copy to different edges) */
    border-top: none;
    border-bottom: 1px solid rgba(79, 182, 232, 0.12);
    padding: 0.75rem 0;
    gap: 0 0.75rem;
    align-items: baseline;
  }
  .landing-feature:last-child {
    border-bottom: none;
  }
  .landing-feature-title {
    white-space: nowrap;
    font-size: 0.82rem;
    margin: 0;
  }
  .landing-feature-copy {
    font-size: 0.8rem;
    line-height: 1.45;
  }
}

.ella-modal-legal,
.landing-legal {
  margin: 1.1rem 0 0;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  color: var(--landing-text-muted);
  text-align: center;
  line-height: 1.5;
}

.ella-modal-legal a,
.landing-legal a {
  color: var(--landing-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ella-modal-legal a:hover,
.landing-legal a:hover {
  color: var(--landing-accent);
}

/* ==============================
   Main Container
============================== */
main {
  width: 100%;
  max-width: var(--chat-max-width, 1400px);
  /* Single shared frosted-glass layer: the living atmosphere shows through
     here, blurred once. Everything nested rides on this blur rather than
     applying its own — one backdrop-filter is far cheaper than several. */
  background:
    radial-gradient(ellipse at 30% -15%, rgba(var(--mood-glow), 0.07), transparent 60%),
    rgba(10, 18, 28, 0.42);
  border-radius: var(--border-radius, 20px);
  border: 1px solid rgba(79, 182, 232, 0.1);
  box-shadow: 0 8px 40px rgba(0,0,0,0.6), 0 0 0 1px rgba(79, 182, 232, 0.05);
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ==============================
   Section Styling
============================== */
section {
  background: var(--bg-section);
  border-radius: 16px;
  padding: 1.8rem;
  border: 1px solid rgba(79, 182, 232, 0.08);
  box-shadow: inset 0 0 20px var(--glow-soft);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

section:hover {
  border-color: rgba(79, 182, 232, 0.2);
  box-shadow: inset 0 0 24px var(--glow-soft), 0 4px 20px rgba(0,0,0,0.4);
}

/* The chat section sits directly on main's frosted-glass layer — give it
   no opaque background of its own so the blurred sky shows through. */
main > section {
  background: transparent;
}

section h2 {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  margin: 0 0 1.2rem 0;
  color: var(--accent);
  letter-spacing: 0.04em;
}

/* ==============================
   Chat Container
============================== */
.chat-ella-container {
  display: block;
}

/* ==============================
   Chat Area
============================== */
#chatbot {
  /* Lighter glass panel riding on main's shared blur — no own backdrop-filter. */
  background:
    radial-gradient(ellipse at 50% -10%, rgba(var(--mood-glow), 0.07), transparent 55%),
    rgba(17, 30, 44, 0.4);
  border-radius: 14px;
  height: 520px;
  overflow-y: auto;
  padding: 1.4rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-family: 'Inter', sans-serif;
  font-size: var(--message-font-size, 1rem);
  line-height: 1.65;
  color: var(--text);
  border: 1px solid rgba(var(--mood-glow), 0.14);
  box-shadow: 0 0 26px rgba(var(--mood-glow), 0.07);
  transition: border-color 2.5s ease, box-shadow 2.5s ease;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) #0A1119;
}

#chatbot::-webkit-scrollbar { width: 6px; }
#chatbot::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}
#chatbot::-webkit-scrollbar-track { background: #0A1119; }

/* ==============================
   Messages
============================== */
.message {
  position: relative;
  max-width: var(--bubble-max-width, 72%);
  padding: 0.75rem 1.1rem;
  border-radius: 18px;
  word-break: break-word;
  animation: fadeSlide 0.25s ease;
  font-size: var(--message-font-size, 1rem);
  line-height: 1.6;
}

/* Soft mood-colored glow halo behind each bubble — replaces the old flat
   accent border. Drifts in color with --mood-glow and breathes gently
   so it feels alive without competing with the text. */
.message::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  box-shadow: 0 0 16px 1px rgba(var(--mood-glow), 0.4);
  opacity: 0.28;
  animation: glowBreathe 6.5s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

.user-message::after { animation-duration: 7.5s; }

@keyframes glowBreathe {
  0%, 100% { opacity: 0.18; }
  50%      { opacity: 0.42; }
}

.bot-message {
  align-self: flex-start;
  /* Ella's bubble carries a faint wash of the living mood-glow + a thin accent edge
     on the left, so it reads as "hers" at a glance vs. the neutral user bubble.
     The edge is an inset shadow (respects the rounded corners, no layout shift). */
  background:
    linear-gradient(180deg, rgba(var(--mood-glow), 0.10), rgba(var(--mood-glow), 0.04)),
    rgba(22, 36, 58, 0.7);
  color: var(--text);
  border-radius: 4px 18px 18px 18px;
  box-shadow: inset 3px 0 0 rgba(var(--mood-glow), 0.55), 0 2px 12px rgba(0,0,0,0.3);
}

.user-message {
  align-self: flex-end;
  background: rgba(13, 24, 34, 0.72);
  color: var(--text);
  border-radius: 18px 4px 18px 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  text-align: left;
}

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

/* ==============================
   Typing Indicator
============================== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.1rem;
  background: rgba(22, 36, 58, 0.7);
  border-radius: 4px 18px 18px 18px;
  align-self: flex-start;
}

.typing-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  color: var(--text-muted);
  font-style: italic;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dots > div {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  animation: typingBlink 1.3s infinite ease-in-out;
}

.typing-dots > div:nth-child(2) { animation-delay: 0.18s; }
.typing-dots > div:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBlink {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40%           { opacity: 1;    transform: scale(1.1); }
}

/* ==============================
   Markdown inside bot bubbles
============================== */
.bot-message p { margin: 0 0 0.45em 0; }
.bot-message p:last-child { margin-bottom: 0; }
.bot-message ul, .bot-message ol { margin: 0.3em 0; padding-left: 1.4em; }
.bot-message li { margin: 0.15em 0; }
.bot-message strong { color: var(--primary); font-weight: 700; }
.bot-message em { opacity: 0.85; }
.bot-message code {
  background: rgba(79, 182, 232, 0.12);
  padding: 0.12em 0.38em;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.87em;
}
.bot-message pre {
  background: rgba(7, 13, 22, 0.9);
  border: 1px solid rgba(79, 182, 232, 0.15);
  padding: 0.75em 1em;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0.5em 0;
}
.bot-message pre code { background: none; padding: 0; font-size: 0.9em; }
.bot-message blockquote {
  border-left: 2px solid var(--primary);
  margin: 0.4em 0 0.4em 0.2em;
  padding-left: 0.75em;
  color: var(--text-muted);
}
.bot-message img {
  max-width: 100%;
  border-radius: 12px;
  margin-top: 0.6rem;
  display: block;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.retry-btn {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.3rem 0.85rem;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  color: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.retry-btn:hover { background: rgba(255,255,255,0.2); }

/* ==============================
   Conversation Starters
============================== */
.starters-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  padding: 1.2rem 0.5rem 0.5rem;
  animation: fadeSlide 0.3s ease;
}

.starter-chip {
  background: rgba(79, 182, 232, 0.06);
  border: 1px solid rgba(79, 182, 232, 0.22);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}

.starter-chip:hover {
  background: rgba(79, 182, 232, 0.13);
  border-color: var(--primary);
  color: var(--text);
}

/* One-time ambient glimpse of Ella's world for a brand-new signup. Scene-setting,
   not a chat bubble — soft, centred, unobtrusive; clears on the first message. */
.chat-empty-scene {
  margin: auto;
  max-width: 34rem;
  padding: 1.4rem 1.6rem;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 1.02rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--text-muted);
  text-shadow: 0 0 24px rgba(var(--mood-glow), 0.18);
  animation: fadeSlide 1.1s ease;
}

/* ==============================
   Input Area
============================== */

/* ── Photo attachment preview ── */
#attach-preview {
  display: none;
  align-items: flex-end;
  gap: 0;
  padding: 0.4rem 1rem 0;
  position: relative;
  width: fit-content;
  align-self: flex-end;
  margin-right: auto;
  margin-left: auto;
}
#attach-preview-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(79, 182, 232, 0.3);
}
#attach-preview-clear {
  position: absolute;
  top: 2px;
  right: -8px;
  background: rgba(20, 30, 44, 0.9);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}

/* ── User image bubble ── */
.user-image-message {
  max-width: 60%;
}
.user-image-message img {
  max-width: 240px;
  max-height: 300px;
  border-radius: 14px 4px 14px 14px;
  display: block;
  width: 100%;
  object-fit: cover;
}

/* ── Photo attach button ── */
#photo-attach-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(79, 182, 232, 0.25);
  background: rgba(79, 182, 232, 0.04);
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}
#photo-attach-btn:hover {
  background: rgba(79, 182, 232, 0.12);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(79, 182, 232, 0.2);
}
#photo-attach-btn svg { width: 18px; height: 18px; }

#input-area {
  margin-top: 1.2rem;
  display: flex;
  gap: 0.7rem;
  align-items: center;
  background:
    linear-gradient(180deg, rgba(var(--mood-glow), 0.07), transparent),
    rgba(15, 26, 38, 0.38);
  border: 1px solid rgba(var(--mood-glow), 0.22);
  border-radius: 999px;
  padding: 0.4rem 0.4rem 0.4rem 0.2rem;
  transition: border-color 2.5s ease, box-shadow 0.25s;
}

#input-area:focus-within {
  border-color: rgba(var(--mood-glow), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--mood-glow), 0.1), 0 4px 20px rgba(0,0,0,0.3);
}

#user-input {
  flex: 1;
  min-width: 0;
  border: none;
  padding: 0.7rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  outline: none;
  color: var(--text);
  background: transparent;
  /* textarea-specific: keep it looking and behaving like the single-line
     input it replaced (swapped to defeat password-manager autofill) */
  resize: none;
  overflow-y: auto;
  line-height: 1.4;
  max-height: 6.5rem;
  align-self: center;
}

#user-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

#send-btn {
  flex-shrink: 0;
  background: var(--primary);
  color: #000;
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  padding: 0.72rem 1.6rem;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(79, 182, 232, 0.25);
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.1s ease;
  white-space: nowrap;
}

#send-btn:hover,
#send-btn:focus {
  background: var(--accent);
  box-shadow: 0 4px 18px rgba(61, 143, 196, 0.4);
  outline: none;
}

#send-btn:active { transform: scale(0.97); }

#send-btn:disabled {
  background: #16243A;
  color: #5E7A90;
  cursor: not-allowed;
  box-shadow: none;
}

/* ==============================
   Auth Section
============================== */
#auth-section {
  background:
    linear-gradient(180deg, rgba(var(--mood-glow), 0.05), transparent),
    var(--bg-section);
  border-radius: 16px;
  padding: 1.8rem;
  border: 1px solid rgba(var(--mood-glow), 0.1);
  box-shadow: inset 0 0 20px var(--glow-soft);
  transition: border-color 2.5s ease;
  margin-bottom: 1.5rem;
  max-width: 480px;
  width: 100%;
}

#auth-box {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
  align-items: start;
}

#signed-out, #signed-in { display: block; }

#auth-section input[type="email"],
#auth-section input[type="password"] {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(79, 182, 232, 0.25);
  padding: 0.8rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  outline: none;
  color: var(--text);
  background: rgba(10, 17, 25, 0.9);
  margin-bottom: 0.75rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#auth-section input[type="email"]:focus,
#auth-section input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(79, 182, 232, 0.2);
}

#auth-section .button-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

#auth-section button {
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1.2rem;
  font-family: 'Exo 2', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#auth-section button:active { transform: scale(0.97); }

#signed-in {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

#user-info {
  display: inline-block;
  background: rgba(79, 182, 232, 0.08);
  color: var(--text-muted);
  border: 1px solid rgba(79, 182, 232, 0.2);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
}

#logout {
  background: rgba(79, 182, 232, 0.06);
  color: var(--text-muted);
  border: 1px solid rgba(79, 182, 232, 0.2) !important;
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
}
#logout:hover { background: rgba(79, 182, 232, 0.12); color: var(--text); }

/* ==============================
   Settings FAB
============================== */
#settings-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(79, 182, 232, 0.08);
  color: var(--primary);
  border: 1px solid rgba(79, 182, 232, 0.25) !important;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-family: 'Exo 2', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
}
#settings-btn:hover {
  background: rgba(79, 182, 232, 0.15);
  box-shadow: 0 0 12px rgba(79, 182, 232, 0.2);
}
#settings-btn svg { flex-shrink: 0; }

/* Gallery button — warm golden identity, distinct from the blue settings pill */
#gallery-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, rgba(240, 180, 90, 0.16), rgba(232, 120, 79, 0.10));
  color: #f0c27a;
  border: 1px solid rgba(240, 180, 90, 0.4) !important;
  border-radius: 999px;
  padding: 0.5rem 1rem;
  font-family: 'Exo 2', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: box-shadow 0.25s, background 0.25s, transform 0.15s;
}
#gallery-btn:hover {
  background: linear-gradient(135deg, rgba(240, 180, 90, 0.28), rgba(232, 120, 79, 0.18));
  box-shadow: 0 0 14px rgba(240, 180, 90, 0.35);
  transform: translateY(-1px);
}
#gallery-btn svg { flex-shrink: 0; }

/* ==============================
   Google Sign-In Button & Divider
============================== */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.6rem 0;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(79, 182, 232, 0.15);
}

#google-signin-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  background: #fff;
  color: #3c4043;
  border: 1.5px solid #dadce0 !important;
  border-radius: 12px !important;
  padding: 0.78rem 1.2rem !important;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}
#google-signin-btn:hover {
  background: #f8f8f8;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
#google-signin-btn:active { transform: scale(0.98); }

/* ==============================
   Google Confirm & Link Modals
============================== */
#google-confirm-modal,
#google-link-modal,
#delete-message-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 24, 0.5);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeSlide 0.2s ease;
}

.google-modal-box {
  background:
    radial-gradient(ellipse at 30% 0%, rgba(var(--mood-glow), 0.1) 0%, transparent 60%),
    rgba(17, 30, 44, 0.62);
  border-radius: 20px;
  padding: 2rem 2rem 1.8rem;
  max-width: 400px;
  width: 90%;
  position: relative;
  box-shadow: 0 12px 50px rgba(79, 182, 232, 0.18);
  border: 1px solid rgba(79, 182, 232, 0.2);
  text-align: center;
}

.google-modal-box .g-logo { margin-bottom: 1rem; }

.google-modal-box h3 {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.55rem;
  font-size: 1.2rem;
}

.google-modal-box p {
  font-family: 'Inter', sans-serif;
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0 0 1.4rem;
  line-height: 1.5;
}

.google-modal-box .modal-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
}

.google-modal-box .modal-actions button {
  flex: 1;
  padding: 0.72rem 1rem;
  border-radius: 10px;
  font-family: 'Exo 2', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background 0.2s, box-shadow 0.2s;
}

.modal-cancel {
  background: rgba(79, 182, 232, 0.07);
  color: var(--text-muted);
  border: 1px solid rgba(79, 182, 232, 0.2) !important;
}
.modal-cancel:hover { background: rgba(79, 182, 232, 0.13); color: var(--text); }

.modal-confirm {
  background: var(--primary);
  color: #000;
  box-shadow: 0 2px 10px rgba(79, 182, 232, 0.3);
}
.modal-confirm:hover { background: var(--accent); box-shadow: 0 4px 14px rgba(61, 143, 196, 0.4); }

.modal-confirm.modal-danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 2px 10px rgba(226, 86, 86, 0.35);
}
.modal-confirm.modal-danger:hover { background: var(--danger-hover); box-shadow: 0 4px 14px rgba(226, 86, 86, 0.45); }

/* ==============================
   Photo gallery
============================== */
#gallery-modal {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#gallery-content {
  position: relative;
  background: rgba(10, 17, 25, 0.98);
  border: 1px solid rgba(79, 182, 232, 0.18);
  border-radius: 16px;
  width: min(94vw, 720px);
  max-height: 86vh;
  overflow-y: auto;
  padding: 1.2rem;
}

#gallery-content h2 { margin: 0 0 0.9rem; font-size: 1.15rem; }

#gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.gallery-tile {
  position: relative;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  background: rgba(255, 255, 255, 0.04);
}

.gallery-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-tile-date {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  font-size: 0.68rem;
  padding: 0.5rem 0.4rem 0.25rem;
  color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
}

#gallery-load-more {
  display: block;
  margin: 1rem auto 0;
  padding: 0.5rem 1.4rem;
  border-radius: 999px;
}

#gallery-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
}

#photo-viewer {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 950;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 1rem;
}

#photo-viewer img {
  max-width: 94vw;
  max-height: 70vh;
  border-radius: 12px;
  object-fit: contain;
}

#photo-viewer-caption {
  color: var(--text);
  font-size: 0.95rem;
  text-align: center;
  max-width: 90vw;
}

#photo-viewer-actions { display: flex; gap: 0.8rem; }

#photo-viewer-actions button {
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
}

#photo-viewer-close {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  font-size: 1.8rem;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

@media (max-width: 600px) {
  #gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ==============================
   Photos from Ella's phone
============================== */
.photo-message {
  padding: 0.4rem;
  max-width: min(72%, 340px);
}

.photo-message img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
}

.photo-caption {
  padding: 0.45rem 0.4rem 0.15rem;
  font-size: 0.92rem;
  color: var(--text);
}

/* ==============================
   Message context menu
============================== */
/* On touch devices the OS long-press gesture (text selection / callout)
   races our long-press menu and cancels it. Selection stays enabled for
   mouse users; touch users copy via the menu's Copy button. */
@media (pointer: coarse) {
  .message {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

#msg-ctx-menu {
  position: absolute;
  z-index: 500;
  background: rgba(10, 17, 25, 0.97);
  border: 1px solid rgba(79, 182, 232, 0.18);
  border-radius: 12px;
  padding: 0.5rem 0.4rem;
  min-width: 140px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ctx-ts {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.2rem 0.6rem 0.35rem;
  border-bottom: 1px solid rgba(79, 182, 232, 0.1);
  margin-bottom: 0.15rem;
}

.ctx-btn {
  background: none;
  border: none;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.ctx-btn:hover { background: rgba(79, 182, 232, 0.1); }
.ctx-btn-danger { color: var(--danger); }
.ctx-btn-danger:hover { background: rgba(226, 86, 86, 0.1); }

/* ==============================
   Reply strip
============================== */
#reply-strip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem;
  background: rgba(79, 182, 232, 0.07);
  border-top: 1px solid rgba(79, 182, 232, 0.15);
  border-bottom: none;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

#reply-strip-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reply-strip-cancel {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.3rem;
  flex-shrink: 0;
  transition: color 0.15s;
}
#reply-strip-cancel:hover { color: var(--text); }

/* ==============================
   Jump-to-latest button
============================== */
#jump-to-latest {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(10, 17, 25, 0.92);
  border: 1px solid rgba(79, 182, 232, 0.3);
  color: var(--primary);
  font-size: 1.1rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}
#jump-to-latest:hover { transform: translateX(-50%) translateY(-2px); }

/* ==============================
   Per-message delete button
============================== */
.message-delete-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(79, 182, 232, 0.25);
  background: rgba(17, 30, 44, 0.92);
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease;
  z-index: 2;
}

.message:hover .message-delete-btn {
  opacity: 1;
  transform: scale(1);
}

.message-delete-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

#google-link-modal input[type="password"] {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(79, 182, 232, 0.3);
  padding: 0.75rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: rgba(10, 17, 25, 0.9);
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#google-link-modal input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 8px rgba(79, 182, 232, 0.2);
}

#google-link-error {
  color: var(--danger);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  margin: -0.6rem 0 0.9rem;
  min-height: 1.1em;
}

/* ==============================
   Ella Modals (sign in / create account / verify)
============================== */
.ella-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 24, 0.5);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeSlide 0.2s ease;
  padding: 1rem;
}

.ella-modal-box {
  /* Translucent glass card riding on .ella-modal's shared blur — the living
     sky shows through both layers, softened. */
  background:
    radial-gradient(ellipse at 30% 0%, rgba(var(--mood-glow), 0.1) 0%, transparent 60%),
    rgba(17, 30, 44, 0.62);
  border-radius: 20px;
  padding: 2.3rem 2rem 2.1rem;
  max-width: 420px;
  width: 100%;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(79, 182, 232, 0.22);
  text-align: center;
}

.ella-modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: var(--landing-text-muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  transition: color 0.15s ease;
}
.ella-modal-close:hover { color: var(--landing-text); }

.ella-modal-eyebrow {
  font-family: 'Exo 2', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--landing-accent);
  margin: 0 0 0.6rem;
}

.ella-modal-title {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  color: var(--landing-text);
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
}

.ella-modal-sub {
  font-family: 'Inter', sans-serif;
  color: var(--landing-text-muted);
  font-size: 0.94rem;
  line-height: 1.65;
  margin: 0.4rem 0 1.4rem;
}

.ella-modal-box form {
  text-align: left;
  margin-top: 1.2rem;
}

.ella-modal-box input[type="email"],
.ella-modal-box input[type="password"] {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(79, 182, 232, 0.28);
  padding: 0.8rem 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  outline: none;
  color: var(--landing-text);
  background: rgba(8, 16, 15, 0.65);
  margin-bottom: 0.8rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ella-modal-box input[type="email"]:focus,
.ella-modal-box input[type="password"]:focus {
  border-color: var(--landing-accent);
  box-shadow: 0 0 10px rgba(79, 182, 232, 0.22);
}

.ella-modal-submit {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.8rem 1.2rem;
  font-family: 'Exo 2', sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--landing-accent);
  color: #0A1119;
  box-shadow: 0 4px 22px rgba(79, 182, 232, 0.28);
  transition: transform 0.08s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.ella-modal-submit:hover { box-shadow: 0 6px 28px rgba(79, 182, 232, 0.42); }
.ella-modal-submit:active { transform: scale(0.98); }

.ella-modal-link {
  display: block;
  background: none;
  border: none;
  color: var(--landing-text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  margin: 0.7rem auto 0;
  padding: 0.3rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
.ella-modal-link:hover { color: var(--landing-text); }

.ella-modal-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.4rem 0 1.1rem;
  color: var(--landing-text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
}
.ella-modal-divider::before,
.ella-modal-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(79, 182, 232, 0.18);
}

.ella-google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(220, 232, 242, 0.18);
  padding: 0.78rem 1rem;
  background: rgba(220, 232, 242, 0.06);
  color: var(--landing-text);
  font-family: 'Exo 2', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.08s ease;
}
.ella-google-btn:hover {
  background: rgba(220, 232, 242, 0.1);
  border-color: rgba(79, 182, 232, 0.4);
}
.ella-google-btn:active { transform: scale(0.98); }

.ella-modal-actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  margin-top: 0.4rem;
}

/* Shared modal helpers (replace one-off inline styles so every modal is consistent) */
.ella-modal-title.danger { color: var(--danger); }
.ella-modal-warning {
  margin: 0.8rem 0 1.2rem;
  font-size: 0.95rem;
  opacity: 0.85;
}
.ella-field-label {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.ella-field-full { width: 100%; box-sizing: border-box; }

.ella-modal-btn {
  flex: 1;
  border-radius: 10px;
  padding: 0.72rem 1rem;
  font-family: 'Exo 2', sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ella-modal-btn-ghost {
  background: rgba(220, 232, 242, 0.05);
  color: var(--landing-text-muted);
  border-color: rgba(220, 232, 242, 0.18);
}
.ella-modal-btn-ghost:hover { background: rgba(220, 232, 242, 0.1); color: var(--landing-text); }

.ella-modal-btn-primary {
  background: var(--landing-accent);
  color: #0A1119;
  box-shadow: 0 2px 14px rgba(79, 182, 232, 0.3);
}
.ella-modal-btn-primary:hover { box-shadow: 0 4px 20px rgba(79, 182, 232, 0.45); }

/* ==============================
   Settings Modal
============================== */
#settings-modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 24, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

#settings-content {
  background:
    radial-gradient(ellipse at 30% 0%, rgba(var(--mood-glow), 0.1) 0%, transparent 60%),
    rgba(17, 30, 44, 0.62);
  border-radius: 20px;
  padding: 2.5rem;
  max-width: 680px;
  width: 90%;
  max-height: 82vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 12px 60px rgba(79, 182, 232, 0.2);
  border: 1px solid rgba(79, 182, 232, 0.2);
}

#settings-content h2 {
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 1.5rem 0;
}

#settings-content h3 {
  font-family: 'Exo 2', sans-serif;
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

.settings-section-header {
  font-family: 'Exo 2', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(79, 182, 232, 0.1);
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  line-height: 1;
  transition: color 0.2s ease;
}
.close-btn:hover { color: var(--text); }

.layout-controls { display: flex; flex-direction: column; gap: 1.2rem; }
.layout-control { display: flex; justify-content: space-between; align-items: center; }
.layout-control label { color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.95rem; }

.layout-control select {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(79, 182, 232, 0.3);
  background: rgba(10, 17, 25, 0.9);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
}
.layout-control select:focus { outline: none; border-color: var(--primary); }

.layout-control input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.settings-hint {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.45);
  margin: 0.2rem 0 0;
  min-height: 1em;
}

/* Settings Actions */
.settings-actions {
  display: flex; gap: 1rem; margin-top: 2rem;
  padding-top: 1.5rem; border-top: 1px solid rgba(79, 182, 232, 0.12);
}
.settings-actions button {
  flex: 1; padding: 0.85rem 1.5rem; border-radius: 12px;
  font-family: 'Exo 2', sans-serif; font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: background 0.25s, box-shadow 0.25s;
}
#save-settings  { background: var(--primary); color: #000; border: none; }
#save-settings:hover { background: var(--accent); box-shadow: 0 4px 14px rgba(61, 143, 196, 0.35); }
#reset-settings { background: rgba(79, 182, 232, 0.07); color: var(--primary); border: 1px solid rgba(79, 182, 232, 0.25); }
#reset-settings:hover { background: rgba(79, 182, 232, 0.13); }

.settings-danger-zone {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(224, 92, 92, 0.2);
}
.settings-danger-btn {
  margin-top: 0.6rem;
  padding: 0.65rem 1.2rem;
  border-radius: 10px;
  border: 1px solid rgba(224, 92, 92, 0.45);
  background: rgba(224, 92, 92, 0.08);
  color: var(--danger);
  font-family: 'Exo 2', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.settings-danger-btn:hover { background: rgba(224, 92, 92, 0.18); }

/* ==============================
   Responsive — Tablet
============================== */
@media (max-width: 1024px) {
  main { max-width: 96%; }
}

/* ==============================
   Responsive — Mobile
============================== */
@media (max-width: 768px) {
  body { padding: 0.5rem 0.25rem; }
  main { padding: 1.2rem 0.75rem; }
  header { font-size: 2rem; }

  section h2 { display: none; }

  #chatbot { height: 420px; }
  .message { max-width: 85%; }
}

/* ==============================
   Full-screen chat on mobile (when signed in)
============================== */
@media (max-width: 768px) {
  body.is-signed-in {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    align-items: stretch;
  }

  body.is-signed-in header,
  body.is-signed-in .slogan {
    display: none;
  }

  /* Compact signed-in bar */
  body.is-signed-in #auth-section {
    flex-shrink: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    padding: 0.45rem 0.75rem;
    margin: 0;
    max-width: 100%;
    box-shadow: none;
  }

  body.is-signed-in #user-info { font-size: 0.78rem; padding: 0.25rem 0.7rem; }
  body.is-signed-in #logout { font-size: 0.78rem; padding: 0.28rem 0.65rem; }
  body.is-signed-in .settings-label { display: none; }

  /* Settings + gallery stay in the top bar as small icon circles */
  body.is-signed-in #settings-btn,
  body.is-signed-in #gallery-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
  }
  body.is-signed-in #settings-btn svg,
  body.is-signed-in #gallery-btn svg { width: 16px; height: 16px; }

  /* Main fills remaining viewport */
  body.is-signed-in main {
    flex: 1;
    overflow: hidden;
    max-width: 100%;
    border-radius: 0;
    padding: 0;
    margin: 0;
    gap: 0;
    min-height: 0;
  }

  body.is-signed-in main section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0;
    padding: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    min-height: 0;
  }

  body.is-signed-in .chat-ella-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    align-items: stretch;
    gap: 0;
  }

  body.is-signed-in #chatbot {
    flex: 1;
    height: auto;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
    min-height: 0;
  }

  body.is-signed-in #input-area {
    flex-shrink: 0;
    border-radius: 0;
    margin-top: 0;
    padding: 0.6rem 0.75rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom));
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-top: 1px solid rgba(var(--mood-glow), 0.18);
    background:
      linear-gradient(180deg, rgba(var(--mood-glow), 0.06), transparent),
      rgba(10, 18, 28, 0.55);
  }

  body.is-signed-in #input-area:focus-within {
    box-shadow: none;
    border-color: rgba(79, 182, 232, 0.3);
  }
}

/* ==============================
   PWA Install Banner
============================== */
#pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: rgba(10, 17, 25, 0.97);
  border-top: 1px solid rgba(79, 182, 232, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1rem 1.2rem calc(1rem + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 0.9rem;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

#pwa-install-banner.visible {
  transform: translateY(0);
}

#pwa-install-banner img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}

.pwa-banner-text {
  flex: 1;
  min-width: 0;
}

.pwa-banner-text strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
}

.pwa-banner-text span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

#pwa-install-btn {
  flex-shrink: 0;
  background: #E8A028;
  color: #0A1119;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#pwa-install-btn:hover { background: #d4911f; }

/* ==============================
   Push Notification Prompt
============================== */
.push-prompt {
  position: fixed;
  bottom: 72px;   /* sits above the pwa-install-banner if both showing */
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  width: min(360px, calc(100vw - 32px));
  background: rgba(10, 17, 25, 0.97);
  border: 1px solid rgba(79, 182, 232, 0.22);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  padding: 18px 20px 16px;
  transition: opacity 0.3s, transform 0.3s;
}
.push-prompt.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
}
.push-prompt-text {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 14px;
  text-align: center;
}
.push-prompt-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.push-btn-yes {
  background: var(--primary, #4fb6e8);
  color: #0a1119;
  border: none;
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.push-btn-yes:hover { background: #7bcbf0; }
.push-btn-no {
  background: transparent;
  color: var(--text-muted, #7a99b0);
  border: 1px solid rgba(79, 182, 232, 0.2);
  border-radius: 20px;
  padding: 8px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.push-btn-no:hover { border-color: var(--primary); color: var(--text); }

#pwa-dismiss-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

#pwa-dismiss-btn:hover { color: var(--text); }

@media (max-width: 480px) {
  #chatbot { height: 380px; }
  .message { max-width: 92%; }

  #input-area {
    flex-wrap: nowrap;
    gap: 0.4rem;
  }
  #user-input {
    min-height: 44px;
    font-size: 1rem;
    padding: 0.6rem 0.8rem;
  }
  #send-btn { padding: 0.65rem 1.1rem; font-size: 0.9rem; }
}

/* ── History loading indicators ────────────────────────────────────────── */
.history-loading,
.older-loading {
  text-align: center;
  font-size: 0.8rem;
  color: rgba(180, 200, 220, 0.55);
  padding: 0.6rem 1rem;
  letter-spacing: 0.02em;
  animation: pulse-opacity 1.4s ease-in-out infinite;
}

@keyframes pulse-opacity {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1;   }
}

.history-error {
  margin: auto;
  max-width: 30rem;
  padding: 1.4rem 1.2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}
.history-error p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-muted);
}
.history-retry-btn {
  background: rgba(79, 182, 232, 0.10);
  border: 1px solid var(--primary);
  border-radius: 999px;
  padding: 0.5rem 1.4rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s;
}
.history-retry-btn:hover { background: rgba(79, 182, 232, 0.2); }
