/* ============================================================
   Virtues — Style Sheet
   Serene, contemplative card experience
   Palette: Deep Navy / Royal Blue / Virtue Purple / Magenta
   ============================================================ */

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

/* === DESIGN TOKENS === */
:root {
  /* Typography */
  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body: 'DM Sans', 'Helvetica Neue', sans-serif;

  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);

  /* Spacing (4px base) */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Unified palette — Virtues Project + Virtues Matter */
  --color-bg:            #f5f0eb;
  --color-surface:       #faf7f3;
  --color-surface-2:     #ffffff;
  --color-surface-offset:#eee8e0;
  --color-divider:       #ddd5c8;
  --color-border:        #d1c8b8;

  --color-text:          #1a2a40;
  --color-text-muted:    #5a6478;
  --color-text-faint:    #9ba3b2;
  --color-text-inverse:  #faf7f3;

  --color-primary:       #2a3f6b;
  --color-primary-hover: #1f3058;
  --color-primary-active:#162244;
  --color-primary-light: #e8edf5;

  --color-accent:        #7b3f8d;
  --color-accent-hover:  #663475;
  --color-accent-light:  #f0eaf5;

  --color-warm:          #ef9f53;
  --color-warm-hover:    #d88a3e;
  --color-warm-light:    #fdf3e6;
  --color-gold:          #c4975a;

  --color-magenta:       #b31e8c;
  --color-magenta-hover: #941775;
  --color-magenta-light: #f5e5f1;

  --color-heart:         #b31e8c;
  --color-heart-hover:   #941775;

  --color-error:         #b8433a;

  /* Aliases used by chatbot styles */
  --color-navy:          #1a2a40;
  --color-purple:        #7b3f8d;
  --color-golden:        #c4975a;
  --color-surface-alt:   #eee8e0;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.25rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast:  150ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-base:  250ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow:  400ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(44,36,22,0.06);
  --shadow-md: 0 4px 16px rgba(44,36,22,0.08);
  --shadow-lg: 0 12px 40px rgba(44,36,22,0.12);
  --shadow-xl: 0 20px 60px rgba(44,36,22,0.16);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1280px;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.15; font-family: var(--font-display); font-optical-sizing: auto; }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }
button { cursor: pointer; background: none; border: none; }

::selection {
  background: rgba(42,63,107,0.2);
  color: var(--color-text);
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

a, button, [role="button"], input, textarea, select {
  transition: color var(--transition-fast),
              background var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0;
}

/* ============================================================
   PASSWORD GATE
   ============================================================ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #1a2a40 0%, #2a3f6b 30%, #7b3f8d 65%, #b31e8c 100%);
  overflow: hidden;
}

.gate::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(255,255,255,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(239,159,83,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(179,30,140,0.06) 0%, transparent 40%);
  pointer-events: none;
}

.gate::after {
  content: '';
  position: absolute;
  inset: -50%;
  background:
    radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.15) 0%, transparent 100%),
    radial-gradient(2px 2px at 40% 70%, rgba(255,255,255,0.1) 0%, transparent 100%),
    radial-gradient(2px 2px at 60% 40%, rgba(255,255,255,0.12) 0%, transparent 100%),
    radial-gradient(2px 2px at 80% 60%, rgba(255,255,255,0.08) 0%, transparent 100%);
  background-size: 200px 200px;
  animation: starDrift 60s linear infinite;
  pointer-events: none;
}

@keyframes starDrift {
  from { transform: translateY(0); }
  to   { transform: translateY(50%); }
}

.gate-inner {
  position: relative;
  text-align: center;
  padding: var(--space-8);
  max-width: 520px;
  width: 100%;
  /* Children have staggered fadeSlideUp animations */
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.gate-logo {
  color: rgba(255,255,255,0.85);
  margin-bottom: var(--space-6);
  display: flex;
  justify-content: center;
}

.gate-logo-img {
  width: min(280px, 70vw);
  height: auto;
  filter: drop-shadow(0 4px 24px rgba(0,0,0,0.25));
}

/* Gate partner logos & attribution */
.gate-partners {
  margin-top: var(--space-8);
}

.gate-partners-label {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.06em;
  margin-bottom: var(--space-4);
  font-weight: 400;
}

.gate-partners-label a {
  color: rgba(255,255,255,0.82);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(255,255,255,0.35);
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

.gate-partners-label a:hover,
.gate-partners-label a:focus-visible {
  color: #fff;
  text-decoration-color: rgba(255,255,255,0.7);
}

.gate-partner-logos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
}

.gate-partner-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: rgba(255,255,255,0.75);
  font-size: var(--text-xs);
  font-weight: 400;
  transition: all var(--transition-fast);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
}

.gate-partner-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.gate-partner-link img {
  border-radius: var(--radius-lg);
  flex-shrink: 0;
  background: rgba(255,255,255,0.9);
  padding: 2px;
}

.gate-partner-link .partner-vp-logo {
  border-radius: var(--radius-full);
  padding: 0;
  background: none;
}

.gate-partner-divider {
  width: 1px;
  height: 28px;
  background: rgba(255,255,255,0.2);
}

.gate-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 1.5rem + 4vw, 6rem);
  font-weight: 500;
  color: #fff;
  letter-spacing: 0.06em;
  margin-bottom: clamp(0.5rem, 1vw, 1rem);
}

.gate-tagline {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 0.75rem + 2vw, 2.5rem);
  font-style: italic;
  color: rgba(255,255,255,0.8);
  font-weight: 400;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-6);
}

.gate-tagline-sub {
  display: block;
  font-size: clamp(0.9rem, 0.6rem + 1.6vw, 2rem);
  font-style: italic;
  color: rgba(255,255,255,0.74);
  letter-spacing: 0.03em;
  margin-top: 0;
}

.gate-subtitle {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.55);
  font-weight: 300;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-8);
}

.gate-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.gate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 200px;
  padding: 16px 48px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  margin: 0 auto;
  transition: all 0.2s ease;
}

.gate-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.gate-btn:active {
  transform: translateY(0);
}

.gate-btn:focus {
  outline: none;
}

.gate-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.gate-error {
  font-size: var(--text-xs);
  color: #ffb8b3;
  animation: fadeIn 0.3s ease;
}

.gate.gate-exit {
  animation: gateExit 0.6s ease-in forwards;
}

@keyframes gateExit {
  to { opacity: 0; transform: scale(1.05); pointer-events: none; }
}

/* Small phone — tighter padding so content has more room */
@media (max-width: 420px) {
  .gate-inner { padding: var(--space-5) var(--space-4); }
}

/* Tablet portrait+ — widen container */
@media (min-width: 768px) {
  .gate-inner { max-width: 620px; }
}

/* Desktop — widen container, lock sub-tagline to one line, scale button */
@media (min-width: 1024px) {
  .gate-inner      { max-width: 720px; }
  .gate-title      { font-size: clamp(3.5rem, 2rem + 4vw, 6.5rem); }
  .gate-tagline    { font-size: clamp(1.4rem, 0.9rem + 2.2vw, 3rem); }
  .gate-tagline-sub { font-size: clamp(1.1rem, 0.7rem + 1.8vw, 2.4rem); white-space: nowrap; }
  .gate-btn        { min-width: 260px; padding: 18px 64px; font-size: 1.125rem; }
  .gate-partners   { margin-top: var(--space-12); }
}

/* Wide desktop */
@media (min-width: 1280px) {
  .gate-inner { max-width: 800px; }
}

/* Phone landscape / short screens — compress vertical rhythm */
@media (max-height: 500px) and (orientation: landscape) {
  .gate-inner   { padding: var(--space-4) var(--space-6); }
  .gate-title   { font-size: clamp(1.75rem, 3vw, 2.5rem); margin-bottom: var(--space-1); }
  .gate-tagline { font-size: clamp(0.875rem, 1.5vw, 1.25rem); margin-bottom: var(--space-3); }
  .gate-tagline-sub { font-size: clamp(0.75rem, 1.2vw, 1rem); }
  .gate-partners { margin-top: var(--space-3); }
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245,240,235,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-divider);
}

.header-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.logo-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
  /* Allow logo-btn to yield space; logo-text inside will truncate */
  flex: 0 1 auto;
  min-width: 0;
}

.header-logo-img {
  border-radius: var(--radius-full);
  object-fit: contain;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  letter-spacing: 0.04em;
  /* Truncate rather than push siblings */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
  /* min-width: 0 allows shrinking; overflow: hidden stops buttons spilling
     into header-actions when the nav gets squeezed */
  min-width: 0;
  overflow: hidden;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.nav-btn.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.icon-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

/* Search Bar */
.search-bar {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: 0 var(--space-6) var(--space-3);
  animation: slideDown 0.25s ease-out;
}

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

.search-bar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
}

.search-bar-inner:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(42,63,107,0.12);
}

.search-icon {
  flex-shrink: 0;
  color: var(--color-text-faint);
}

.search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: var(--text-sm);
}

.search-input::placeholder {
  color: var(--color-text-faint);
}

.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
}

.search-clear:hover {
  background: var(--color-surface-offset);
}

/* Filter Pills */
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: var(--space-3);
}

.filter-pill {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.filter-pill:hover {
  color: var(--color-text);
  border-color: var(--color-primary);
}

.filter-pill.active {
  color: var(--color-text-inverse);
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(123, 63, 141, 0.25);
}

/* ============================================================
   VIEWS
   ============================================================ */
.app {
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
}

.view {
  min-height: calc(100dvh - 160px);
  animation: viewFadeIn 0.35s ease-out;
}

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

.section {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.section-title {
  font-size: var(--text-xl);
  font-weight: 500;
  color: var(--color-text);
}

.section-count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ============================================================
   HERO — Daily Virtue
   ============================================================ */
.hero {
  position: relative;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: var(--space-12) var(--space-6);
}

@media (min-width: 900px) {
  .hero {
    padding: var(--space-8) var(--space-8);
  }
  .hero > .hero-content,
  .hero > .hero-guide-panel {
    position: relative;
    z-index: 1;
  }
  .hero {
    flex-direction: row;
    gap: var(--space-8);
    align-items: stretch;
    justify-content: center;
  }
  .hero-content {
    text-align: center;
    max-width: 400px;
    flex-shrink: 0;
  }
  .hero-guide-panel {
    width: 320px;
    max-height: 440px;
    flex-shrink: 0;
    align-self: center;
  }
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(170deg, #e8edf5 0%, #f5f0eb 35%, #f0eaf5 65%, #fdf3e6 100%);
  z-index: 0;
}

.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 30% 30%, rgba(42,63,107,0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 70%, rgba(123,63,141,0.04) 0%, transparent 50%);
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 600px;
}

.hero-label {
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin-bottom: var(--space-1);
}

.hero-date {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-4);
  font-weight: 400;
}

.hero-title {
  font-size: var(--text-2xl);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  text-transform: capitalize;
}

.hero-card-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}

/* Quick Shuffle — ring flash (positioned relative to hero-card-wrap) */
.shuffle-ring-flash {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  border-radius: calc(var(--radius-xl) + 4px);
  border: 3px solid var(--color-warm);
  box-shadow: 0 0 16px rgba(239, 159, 83, 0.4), inset 0 0 16px rgba(239, 159, 83, 0.15);
}

@keyframes shuffleRingFlash {
  0%   { opacity: 0; transform: scale(0.96); }
  30%  { opacity: 1; transform: scale(1.0); }
  100% { opacity: 0; transform: scale(1.04); }
}

/* Quick Shuffle — wobble on each card switch */
@keyframes shuffleWobbleLeft {
  0%   { transform: translateX(0) rotate(0deg); }
  50%  { transform: translateX(-5px) rotate(-1.5deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

@keyframes shuffleWobbleRight {
  0%   { transform: translateX(0) rotate(0deg); }
  50%  { transform: translateX(5px) rotate(1.5deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

/* Quick Shuffle — lock-in bounce on final card */
@keyframes shuffleLockBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.08); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.hero-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-6);
}

.hero-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* ============================================================
   FLIP CARDS
   ============================================================ */
.flip-card {
  perspective: 1000px;
  cursor: pointer;
  position: relative;
}

.hero-flip-card {
  width: 300px;
  height: 387px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.flip-card-back {
  transform: rotateY(180deg);
}

.flip-card-front img,
.flip-card-back img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  color: transparent; /* hides alt text */
}

.flip-card-front img {
  background: var(--color-navy);
}

.flip-card-back img {
  background: var(--color-bg);
}

/* ============================================================
   CARD GRID
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-8);
}

.card-item {
  position: relative;
  animation: fadeInUp 0.4s ease-out both;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

@media (hover: hover) {
  .card-item:hover {
    transform: translateY(-6px);
  }
  .card-item:hover .flip-card-front,
  .card-item:hover .flip-card-back {
    box-shadow: var(--shadow-xl);
  }
}

.card-item .flip-card {
  width: 100%;
  aspect-ratio: 200/258;
}

.card-item .flip-card-front img,
.card-item .flip-card-back img {
  display: block;
}

.card-label {
  text-align: center;
  padding-top: var(--space-3);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text);
  text-transform: capitalize;
}

.card-interaction-hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  margin-bottom: var(--space-4);
}

.card-heart {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 10;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-faint);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.card-heart:hover {
  background: #fff;
  transform: scale(1.1);
}

.card-heart.favorited {
  color: var(--color-heart);
}

.card-heart.favorited svg {
  fill: var(--color-heart);
}

.card-heart svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

/* Flip button — sits inside .flip-card, outside .flip-card-inner so it doesn't rotate */
.card-flip-btn {
  position: absolute;
  bottom: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 8px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  pointer-events: auto;
}

.card-flip-btn:hover {
  background: #fff;
  box-shadow: var(--shadow-md);
  transform: translateX(-50%) scale(1.06);
}

.card-flip-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

/* Grid cards: icon-only, no label text */
.card-grid .card-flip-btn {
  padding: 5px;
  gap: 0;
  bottom: var(--space-2);
}
.card-grid .card-flip-btn span { display: none; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-surface-offset);
}

.btn-link {
  background: none;
  color: var(--color-primary);
  padding: var(--space-2) 0;
}

.btn-link:hover {
  color: var(--color-primary-hover);
}

/* ============================================================
   DETAIL VIEW
   ============================================================ */
.detail {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-6);
}

.detail-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.detail-back:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-12);
  align-items: start;
}

.detail-card-area {
  position: sticky;
  top: 6rem;
}

.detail-cards {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
}

.detail-card-single {
  text-align: center;
}

.detail-card-img-wrap {
  position: relative;
  display: inline-block;
  width: 280px;
  height: 361px;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.detail-card-single img {
  width: 280px;
  height: 361px;
  object-fit: contain;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  color: transparent;
}

#detail-front-img {
  background: var(--color-navy);
}

#detail-back-img {
  background: var(--color-bg);
}

.detail-card-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.detail-title {
  font-size: var(--text-2xl);
  font-weight: 500;
  text-transform: capitalize;
  flex: 1;
}

.heart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  color: var(--color-text-faint);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.heart-btn:hover {
  background: var(--color-surface-offset);
  transform: scale(1.1);
}

.heart-btn.favorited {
  color: var(--color-heart);
}

.heart-btn.favorited svg {
  fill: var(--color-heart);
}

.heart-btn svg {
  fill: none;
}

.detail-category {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  margin-bottom: var(--space-8);
}

.detail-section {
  margin-bottom: var(--space-8);
}

.detail-section-title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.detail-distinction {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
}

/* Journal */
.journal-textarea {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.6;
  resize: vertical;
  min-height: 120px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.journal-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(42,63,107,0.12);
}

.journal-textarea::placeholder {
  color: var(--color-text-faint);
}

.journal-saved {
  font-size: var(--text-xs);
  color: var(--color-primary);
  margin-top: var(--space-2);
  animation: fadeIn 0.3s ease;
}

/* Share */
.share-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.share-note {
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
}

.share-note:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(42,63,107,0.12);
}

.share-note::placeholder {
  color: var(--color-text-faint);
}

.btn-share {
  align-self: flex-start;
}

/* ============================================================
   EMPTY STATES & NO RESULTS
   ============================================================ */
.empty-state {
  text-align: center;
  padding: var(--space-16) var(--space-6);
  color: var(--color-text-muted);
}

.empty-state svg {
  margin: 0 auto var(--space-4);
}

.empty-state p {
  max-width: 36ch;
  margin: 0 auto;
}

.no-results {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  font-family: var(--font-display);
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  text-align: center;
  padding: var(--space-8) var(--space-6);
  border-top: 1px solid var(--color-divider);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer-attribution {
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.6;
}

.footer-attribution a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.footer-attribution a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

.footer > a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.footer > a:hover {
  color: var(--color-primary);
}

.footer-feedback-btn {
  background: none;
  border: none;
  color: var(--color-accent);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.footer-feedback-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* ============================================================
   FEEDBACK MODAL
   ============================================================ */

.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 42, 64, 0.55);
  backdrop-filter: blur(4px);
  z-index: 3050;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1.5rem, 6vh, 3rem) var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.feedback-overlay[hidden] { display: none; }

.feedback-modal {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  box-shadow: 0 20px 64px rgba(26, 42, 64, 0.28);
  max-width: 480px;
  width: 100%;
  padding: var(--space-8) var(--space-8) var(--space-6);
  animation: welcomeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.feedback-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  color: var(--color-text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-full);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.feedback-close:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.feedback-headline {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  line-height: 1.2;
}

.feedback-body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.feedback-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.feedback-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.feedback-textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  resize: vertical;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  line-height: 1.55;
}

.feedback-textarea::placeholder {
  color: var(--color-text-faint);
}

.feedback-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.feedback-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  min-height: 48px;
}

.feedback-input::placeholder { color: var(--color-text-faint); }

.feedback-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.feedback-optional {
  font-weight: 400;
  color: var(--color-text-muted);
}

.feedback-followup {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
}

.feedback-check-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.5;
}

.feedback-checkbox {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.feedback-contact {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--color-primary-light);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
  animation: feedbackReveal 0.2s ease;
}

.feedback-contact[hidden] { display: none; }

@keyframes feedbackReveal {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.feedback-field-error {
  font-size: var(--text-xs);
  color: #c0392b;
  line-height: 1.5;
  margin-top: var(--space-1);
}

.feedback-field-error[hidden] { display: none; }

.feedback-input.feedback-input--invalid {
  border-color: #c0392b;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.feedback-submit-error {
  font-size: var(--text-xs);
  color: #c0392b;
  line-height: 1.5;
  margin-top: var(--space-2);
  text-align: center;
}

.feedback-submit-error[hidden] { display: none; }

.feedback-contact-error {
  font-size: var(--text-xs);
  color: #c0392b;
  line-height: 1.5;
  padding: var(--space-2) 0 0;
}

.feedback-contact-error[hidden] { display: none; }

.feedback-submit {
  width: 100%;
  justify-content: center;
  margin-top: var(--space-2);
  min-height: 52px;
  font-size: var(--text-base);
}

/* Thank-you state */
.feedback-thanks-icon {
  color: var(--color-accent);
  margin-bottom: var(--space-4);
}

.feedback-thanks-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.feedback-thanks-body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.feedback-done-btn {
  width: 100%;
  justify-content: center;
  min-height: 48px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* 1100px: logo text fully hidden — nav + actions have clear room */
@media (max-width: 1100px) {
  .logo-text {
    display: none;
  }
}

/* 900px: intermediate compression before full mobile treatment */
@media (max-width: 900px) {
  .header-inner {
    gap: var(--space-2);
  }

  .nav {
    gap: 0;
  }

  .nav-btn {
    padding: var(--space-2) var(--space-2);
    font-size: var(--text-xs);
  }

  .header-actions {
    gap: var(--space-1);
  }
}

@media (max-width: 768px) {
  .header-inner {
    padding: var(--space-3) var(--space-3);
    gap: var(--space-2);
  }

  .logo-btn {
    gap: var(--space-1);
  }

  .nav {
    gap: 0;
  }

  .nav-btn {
    padding: 2px 6px;
    font-size: 10.5px;
  }

  .nav-btn svg {
    display: none;
  }

  .header-actions {
    gap: var(--space-1);
  }

  .header-actions .icon-btn {
    width: 32px;
    height: 32px;
  }

  .header-actions .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  /* On mobile, hide search and avatar to make room for TTS toggle */
  #search-toggle,
  #avatar-settings-btn {
    display: none;
  }

  .hero {
    min-height: auto;
    padding: var(--space-8) var(--space-4);
  }

  .hero-flip-card {
    width: 232px;
    height: 300px;
  }

  .hero-guide-panel {
    width: 100%;
    max-width: 360px;
    max-height: 380px;
  }

  .section {
    padding: var(--space-6) var(--space-4);
  }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-5);
  }

  .detail-layout {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .detail-card-area {
    position: static;
  }

  .detail-cards {
    flex-direction: column;
    align-items: center;
  }

  .detail-card-single img {
    width: 256px;
    height: 330px;
  }

  .detail-card-img-wrap {
    width: 256px;
    height: 330px;
  }

  .detail {
    padding: var(--space-4);
  }

  .search-bar {
    padding: 0 var(--space-4) var(--space-3);
  }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .hero-flip-card {
    width: 209px;
    height: 270px;
  }

  .hero-guide-panel {
    width: 100%;
    max-height: 360px;
  }

  .detail-card-single img {
    width: 209px;
    height: 270px;
  }

  .detail-card-img-wrap {
    width: 209px;
    height: 270px;
  }
}

/* ===== DETAIL VIEW: Full-screen cards on mobile portrait ===== */
@media (max-width: 600px) and (orientation: portrait) {
  /* Make detail section fill the viewport with scroll snapping */
  #view-detail {
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    height: calc(100dvh - 56px); /* subtract header */
  }

  .detail {
    padding: 0;
  }

  .detail-back {
    position: fixed;
    top: calc(56px + 12px);
    left: 12px;
    z-index: 100;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(6px);
    border-radius: 20px;
    padding: 6px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  }

  .detail-layout {
    display: block;
  }

  .detail-card-area {
    position: static;
  }

  .detail-cards {
    display: block;
    gap: 0;
  }

  /* Each card = one full screen snap section */
  .detail-card-single {
    scroll-snap-align: start;
    height: calc(100dvh - 56px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    background: var(--surface-cream);
  }

  .detail-card-single:first-child {
    background: #f0eaf5; /* soft lavender for front */
  }

  .detail-card-single:last-child {
    background: var(--surface-cream);
  }

  /* Card image fills the screen height */
  .detail-card-img-wrap {
    width: auto;
    height: calc(100dvh - 56px - 80px); /* leave room for label */
    max-height: 75dvh;
    aspect-ratio: 800 / 1032;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .detail-card-single img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    border-radius: var(--radius-xl);
  }

  .detail-card-label {
    margin-top: var(--space-3);
    font-size: var(--text-sm);
  }

  /* Scroll indicator hint between cards */
  .detail-card-single:first-child::after {
    content: '↓ Scroll for back';
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    opacity: 0.7;
    animation: bounceHint 2s ease-in-out infinite;
  }

  .detail-card-single:first-child {
    position: relative;
  }

  @keyframes bounceHint {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(4px); }
  }

  /* Info section scrolls normally after the two card screens */
  .detail-info {
    scroll-snap-align: start;
    padding: var(--space-6) var(--space-4) var(--space-12);
  }
}

/* Mobile landscape or zoomed out: front and back side by side */
@media (max-width: 900px) and (orientation: landscape) {
  .detail-cards {
    flex-direction: row;
    justify-content: center;
    gap: var(--space-4);
  }

  .detail-card-img-wrap {
    width: 180px;
    height: 232px;
  }

  .detail-card-single img {
    width: 180px;
    height: 232px;
  }

  .hero-title {
    font-size: var(--text-xl);
  }

  .filter-pills {
    gap: var(--space-1);
  }

  .filter-pill {
    padding: var(--space-1) var(--space-2);
  }
}

/* Staggered card entrance animations */
.card-item:nth-child(1)  { animation-delay: 0.03s; }
.card-item:nth-child(2)  { animation-delay: 0.06s; }
.card-item:nth-child(3)  { animation-delay: 0.09s; }
.card-item:nth-child(4)  { animation-delay: 0.12s; }
.card-item:nth-child(5)  { animation-delay: 0.15s; }
.card-item:nth-child(6)  { animation-delay: 0.18s; }
.card-item:nth-child(7)  { animation-delay: 0.21s; }
.card-item:nth-child(8)  { animation-delay: 0.24s; }
.card-item:nth-child(9)  { animation-delay: 0.27s; }
.card-item:nth-child(10) { animation-delay: 0.30s; }
.card-item:nth-child(11) { animation-delay: 0.33s; }
.card-item:nth-child(12) { animation-delay: 0.36s; }

/* ============================================================
   GALLERY FILTERS (visible without search)
   ============================================================ */
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.gallery-filters[hidden] {
  display: none;
}

.gallery-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.btn-sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
}

/* ============================================================
   ENTRANCE ANIMATIONS
   ============================================================ */
@keyframes heroFloat {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.hero-content {
  animation: heroFloat 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.hero-label {
  animation: fadeSlideUp 0.6s ease-out 0.1s both;
}

.hero-date {
  animation: fadeSlideUp 0.6s ease-out 0.15s both;
}

.hero-title {
  animation: fadeSlideUp 0.6s ease-out 0.2s both;
}

.hero-card-wrap {
  animation: heroFloat 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.hero-actions {
  animation: fadeSlideUp 0.6s ease-out 0.5s both;
}

.section-header {
  animation: fadeSlideUp 0.5s ease-out both;
}

/* Gate staggered entrance */
.gate-logo {
  animation: fadeSlideUp 0.7s ease-out 0.1s both;
}

.gate-title {
  animation: fadeSlideUp 0.7s ease-out 0.2s both;
}

.gate-tagline {
  animation: fadeSlideUp 0.7s ease-out 0.3s both;
}

.gate-subtitle {
  animation: fadeSlideUp 0.7s ease-out 0.4s both;
}

.gate-form {
  animation: fadeSlideUp 0.7s ease-out 0.5s both;
}

.gate-partners {
  animation: fadeSlideUp 0.7s ease-out 0.6s both;
}

/* ============================================================
   BACK TO TOP BUTTON
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 90;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (hover: hover) {
  .back-to-top:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
  }
}

/* ============================================================
   JOURNEY VIEW
   ============================================================ */
.journey-section {
  text-align: center;
  max-width: var(--content-narrow);
  padding-top: var(--space-12);
}

.journey-title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

.journey-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  margin-bottom: var(--space-10);
  max-width: none;
}

.journey-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.journey-stat {
  padding: var(--space-6) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
}

.journey-stat-number {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.journey-stat-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.journey-progress {
  width: 100%;
  height: 8px;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.journey-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent), var(--color-magenta));
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 0;
}

.journey-encouragement {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--color-accent);
  margin-bottom: var(--space-10);
  max-width: none;
}

.journey-recent {
  text-align: left;
}

.journey-recent-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-4);
}

.journey-recent-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.journey-recent-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.journey-recent-item:hover {
  background: var(--color-surface-offset);
  border-color: var(--color-primary);
}

.journey-recent-item-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  flex: 1;
  text-transform: capitalize;
}

.journey-recent-item-meta {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ============================================================
   SHARE BUTTONS
   ============================================================ */
.share-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ============================================================
   JOURNAL META (timestamp)
   ============================================================ */
.journal-meta {
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
}

.journal-timestamp {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-style: italic;
}

/* ============================================================
   FOCUS / KEYBOARD STATES
   ============================================================ */
.card-item:focus-within {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
  border-radius: var(--radius-xl);
}

/* ============================================================
   VIRTUES GUIDE — CHAT COMPONENTS
   ============================================================ */

/* === HERO GUIDE PROMPT (Home page avatar + bubble) === */
/* Hero Guide Chat Panel */
.hero-guide-panel {
  position: relative;
  z-index: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(26, 42, 64, 0.1);
  animation: guideSlideIn 0.6s ease-out 0.3s both;
  margin-top: var(--space-6);
}

@media (min-width: 900px) {
  .hero-guide-panel {
    margin-top: 0;
  }
}

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

.hero-guide-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: linear-gradient(135deg, var(--color-navy), var(--color-primary));
  color: #fff;
}

.hero-guide-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.hero-guide-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
}

.hero-guide-sub {
  font-size: var(--text-xs);
  opacity: 0.85;
  line-height: 1.4;
}

.hero-guide-messages {
  flex: 1;
  min-height: 120px;
  max-height: 240px;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.hero-guide-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

.hero-guide-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  resize: none;
  min-height: 36px;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}

.hero-guide-input:focus { border-color: var(--color-purple); }

.hero-guide-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--color-purple), var(--color-magenta));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.hero-guide-send:hover { transform: scale(1.05); }

/* === GUIDE TAB (Full chat view) === */
.guide-section {
  max-width: 640px;
  margin: 0 auto;
}

.guide-header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.guide-avatar-large {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-golden);
  box-shadow: 0 4px 20px rgba(123, 63, 141, 0.3);
  margin-bottom: var(--space-4);
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.guide-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.guide-chat-container {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 400px;
  max-height: calc(100vh - 340px);
}

.guide-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.guide-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.guide-chat-input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
}

.guide-chat-input:focus {
  border-color: var(--color-purple);
}

.guide-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--color-purple), var(--color-magenta));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.guide-send-btn:hover { transform: scale(1.05); }
.guide-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* === CHAT MESSAGE BUBBLES (shared across all chat instances) === */
.chat-msg {
  display: flex;
  gap: var(--space-3);
  animation: msgFadeIn 0.3s ease-out;
}

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

.chat-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-msg-bubble {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.chat-msg.assistant .chat-msg-bubble {
  background: linear-gradient(135deg, rgba(123, 63, 141, 0.08), rgba(179, 30, 140, 0.05));
  border: 1px solid rgba(123, 63, 141, 0.12);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
  color: var(--color-text);
}

.chat-msg.user {
  flex-direction: row-reverse;
}

.chat-msg.user .chat-msg-bubble {
  background: linear-gradient(135deg, var(--color-navy), var(--color-primary));
  color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}

.chat-msg-bubble strong {
  color: var(--color-purple);
}

.chat-msg.user .chat-msg-bubble strong {
  color: var(--color-golden);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: var(--space-2) 0;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-purple);
  opacity: 0.4;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* === FLOATING CHAT BUBBLE (All Cards page) === */
.chat-fab {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 900;
}

.chat-fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--color-purple), var(--color-magenta));
  box-shadow: 0 4px 20px rgba(123, 63, 141, 0.4);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-fab-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(123, 63, 141, 0.5);
}

.chat-fab-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chat-fab-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-height: 480px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 32px rgba(26, 42, 64, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fabPanelIn 0.25s ease-out;
}

.chat-fab-panel[hidden] {
  display: none;
}

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

.chat-fab-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: linear-gradient(135deg, var(--color-navy), var(--color-primary));
  color: #fff;
}

.chat-fab-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
}

.chat-fab-header-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
}

.chat-fab-header-sub {
  font-size: var(--text-xs);
  opacity: 0.8;
}

.chat-fab-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  padding: var(--space-1);
}

.chat-fab-close:hover { opacity: 1; }

.chat-fab-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 180px;
  max-height: 300px;
}

.chat-fab-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

.chat-fab-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  resize: none;
  min-height: 36px;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}

.chat-fab-input:focus { border-color: var(--color-purple); }

.chat-fab-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--color-purple), var(--color-magenta));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.chat-fab-send:hover { transform: scale(1.05); }

/* === DETAIL PAGE GUIDE CHAT (embedded) === */
.detail-guide-chat {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.detail-guide-messages {
  min-height: 100px;
  max-height: 280px;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.detail-guide-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.detail-guide-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  resize: none;
  min-height: 36px;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}

.detail-guide-input:focus { border-color: var(--color-purple); }

.detail-guide-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--color-purple), var(--color-magenta));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* === MOBILE RESPONSIVE === */
@media (max-width: 600px) {
  .chat-fab-panel {
    width: calc(100vw - 2rem);
    right: -0.5rem;
  }

  .hero-guide-panel {
    margin-top: var(--space-4);
  }

  .hero-guide-messages {
    min-height: 120px;
    max-height: 220px;
  }

  .guide-chat-container {
    max-height: calc(100vh - 300px);
  }
}

/* ===== Cold Start Notice ===== */
.chat-cold-start {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  margin: var(--space-2) auto;
  max-width: 320px;
  background: var(--color-warm-light);
  border: 1px solid var(--color-warm);
  border-radius: var(--radius-full, 999px);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  animation: coldStartFadeIn 0.4s ease-out;
}

.chat-cold-start svg {
  flex-shrink: 0;
  color: var(--color-warm);
  animation: coldStartPulse 1.5s ease-in-out infinite;
}

.chat-cold-start-done {
  animation: coldStartFadeOut 0.5s ease-out forwards;
}

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

@keyframes coldStartFadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-6px); }
}

@keyframes coldStartPulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; }
}

/* ============================================================
   AVATAR PICKER MODAL
   ============================================================ */
.avatar-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 42, 64, 0.6);
  backdrop-filter: blur(4px);
  z-index: 3400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: avatarModalFadeIn 0.25s ease-out;
}

.avatar-modal-overlay[hidden] {
  display: none;
}

@keyframes avatarModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.avatar-modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: 0 16px 64px rgba(26, 42, 64, 0.3);
  max-width: 480px;
  width: 100%;
  padding: var(--space-6);
  animation: avatarModalSlideIn 0.3s ease-out;
}

@keyframes avatarModalSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.avatar-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.avatar-modal-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
}

.avatar-modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: var(--space-1);
  transition: color 0.15s;
}

.avatar-modal-close:hover {
  color: var(--color-text);
}

.avatar-modal-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.avatar-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.avatar-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface-alt);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.avatar-option:hover {
  border-color: var(--color-purple);
  box-shadow: 0 4px 16px rgba(123, 63, 141, 0.15);
  transform: translateY(-2px);
}

.avatar-option.selected {
  border-color: var(--color-purple);
  background: linear-gradient(135deg, rgba(123, 63, 141, 0.08), rgba(179, 30, 140, 0.05));
  box-shadow: 0 4px 16px rgba(123, 63, 141, 0.2);
}

.avatar-option img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-golden);
  box-shadow: 0 2px 12px rgba(123, 63, 141, 0.2);
}

.avatar-option-name {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

/* Generic .guide-avatar class for swappable avatars */
.guide-avatar {
  border-radius: 50%;
  object-fit: cover;
}

/* ============================================================
   SCROLL-REVEAL ANIMATIONS
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered reveals for grid children */
.reveal-stagger > .card-item {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.reveal-stagger.revealed > .card-item {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-8);
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-navy);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  pointer-events: auto;
}

.toast.toast-exit {
  animation: toastOut 0.3s ease-in forwards;
}

.toast-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ============================================================
   SKELETON LOADING
   ============================================================ */
.skeleton-shimmer {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, var(--color-surface) 0%, var(--color-surface-offset) 100%);
}

.skeleton-shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.4) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.card-img-loading {
  background: linear-gradient(145deg, var(--color-surface) 0%, var(--color-surface-offset) 100%);
}

/* ============================================================
   SURPRISE ME SHUFFLE ANIMATION
   ============================================================ */
/* Old cardShuffle removed — replaced by Quick Shuffle in hero-card-wrap section */

/* ============================================================
   JOURNEY PROGRESS RINGS
   ============================================================ */
.journey-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.journey-ring {
  position: relative;
  width: 88px;
  height: 88px;
}

.journey-ring svg {
  width: 88px;
  height: 88px;
  transform: rotate(-90deg);
}

.journey-ring-bg {
  fill: none;
  stroke: var(--color-surface-offset);
  stroke-width: 6;
}

.journey-ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.journey-ring-fill.ring-explored {
  stroke: var(--color-primary);
}

.journey-ring-fill.ring-favorited {
  stroke: var(--color-magenta);
}

.journey-ring-fill.ring-journaled {
  stroke: var(--color-accent);
}

.journey-ring-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-primary);
}

/* ==================== VOICE INPUT & TTS ==================== */

/* Mic button — sits between textarea and send button */
.voice-mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast), transform 0.15s ease;
}

.voice-mic-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

/* Recording state — pulsing red */
.voice-mic-btn.recording {
  color: #e53e3e;
  background: rgba(229, 62, 62, 0.12);
  animation: micPulse 1.2s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.3); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(229, 62, 62, 0); }
}

.voice-mic-btn.processing {
  color: #ef9f53;
  background: rgba(239, 159, 83, 0.12);
  animation: micProcess 0.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes micProcess {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* TTS control bar below chat input */
.tts-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 0 2px;
}

.tts-bar-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1.5px solid var(--surface-sand);
  border-radius: 20px;
  padding: 4px 12px 4px 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
  line-height: 1;
}

.tts-bar-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.tts-bar-toggle.tts-active {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(123, 63, 141, 0.06);
}

.tts-bar-label {
  pointer-events: none;
}

.tts-bar-speed {
  position: relative;
}

.tts-speed-btn {
  background: none;
  border: 1.5px solid var(--color-primary);
  color: var(--color-primary);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.tts-speed-btn:hover {
  background: var(--color-primary);
  color: #fff;
}

.tts-speed-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid var(--surface-sand);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  padding: 4px;
  z-index: 1000;
  min-width: 70px;
}

.tts-speed-option {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}

.tts-speed-option:hover {
  background: var(--surface-cream);
  color: var(--text-primary);
}

.tts-speed-option.active {
  color: var(--color-primary);
  font-weight: 700;
  background: rgba(123, 63, 141, 0.08);
}

/* Fix input area layouts to accommodate mic button */
.hero-guide-input-area,
.guide-input-area,
.detail-guide-input-area,
.chat-fab-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-1);
}


/* Speaking indicator on message bubble */
.chat-msg.speaking .chat-msg-bubble {
  position: relative;
}

.chat-msg.speaking .chat-msg-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 16px;
  width: 24px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--color-purple), var(--color-gold));
  animation: speakingBar 1.5s ease-in-out infinite;
}

@keyframes speakingBar {
  0%, 100% { opacity: 0.4; transform: scaleX(0.6); }
  50% { opacity: 1; transform: scaleX(1); }
}


/* Ensure hidden attribute works on SVG elements */
.voice-mic-btn svg[hidden] {
  display: none !important;
}


/* ============================================================
   DECK SELECTION SCREEN
   ============================================================ */

.deck-select {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--color-navy) 0%, #1e1440 40%, var(--color-primary) 100%);
  overflow-y: auto;
  padding: var(--space-8) var(--space-4);
}

.deck-select[hidden] { display: none; }

.deck-select-inner {
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-10);
}

.deck-select-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.deck-select-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  opacity: 0.95;
  filter: drop-shadow(0 0 24px rgba(239,159,83,0.35));
}

.deck-select-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.5rem + 2.5vw, 3.5rem);
  font-weight: 600;
  color: var(--color-surface);
  letter-spacing: 0.01em;
  line-height: 1.1;
}

.deck-select-subtitle {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: rgba(250,247,243,0.65);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 400;
}

.deck-select-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  width: 100%;
}

@media (max-width: 600px) {
  .deck-select-cards {
    grid-template-columns: 1fr;
  }
}

.deck-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-8) var(--space-6) var(--space-6);
  background: rgba(250,247,243,0.06);
  border: 1.5px solid rgba(250,247,243,0.12);
  border-radius: var(--radius-2xl);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1),
              background 0.25s ease,
              border-color 0.25s ease,
              box-shadow 0.25s ease;
  outline: none;
  text-align: center;
}

.deck-option:hover,
.deck-option:focus-visible {
  transform: translateY(-6px);
  background: rgba(250,247,243,0.1);
  border-color: rgba(239,159,83,0.5);
  box-shadow: 0 16px 48px rgba(0,0,0,0.4), 0 0 0 1px rgba(239,159,83,0.3);
}

.deck-option-badge {
  position: absolute;
  top: -12px;
  right: var(--space-5);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.deck-badge-reflection {
  background: var(--color-primary);
  color: var(--color-surface);
}

.deck-badge-resilience {
  background: linear-gradient(90deg, var(--color-accent), var(--color-magenta));
  color: var(--color-surface);
}

.deck-option-img-wrap {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(42,63,107,0.5);
  border: 2px solid rgba(250,247,243,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.25s ease;
}

.deck-option-img-wrap--resilience {
  background: linear-gradient(135deg, rgba(123,63,141,0.4), rgba(179,30,140,0.3));
}

.deck-option:hover .deck-option-img-wrap,
.deck-option:focus-visible .deck-option-img-wrap {
  border-color: rgba(239,159,83,0.5);
}

.deck-option-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  opacity: 0.9;
}

.deck-option-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

.deck-option-name {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 1rem + 0.75vw, 1.625rem);
  font-weight: 600;
  color: var(--color-surface);
  line-height: 1.2;
}

.deck-option-desc {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: rgba(250,247,243,0.65);
  font-weight: 400;
}

.deck-option-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.deck-tag {
  padding: 2px var(--space-3);
  background: rgba(250,247,243,0.1);
  border: 1px solid rgba(250,247,243,0.18);
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: rgba(250,247,243,0.7);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.deck-option-btn {
  padding: var(--space-3) var(--space-8);
  background: rgba(250,247,243,0.1);
  border: 1.5px solid rgba(250,247,243,0.25);
  border-radius: var(--radius-full);
  color: var(--color-surface);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  pointer-events: none; /* parent div handles clicks */
}

.deck-option:hover .deck-option-btn,
.deck-option:focus-visible .deck-option-btn {
  background: var(--color-warm);
  border-color: var(--color-warm);
  color: var(--color-navy);
  transform: scale(1.04);
}

.deck-option-btn--resilience:hover {
  background: var(--color-magenta);
  border-color: var(--color-magenta);
}

/* Enter animation for deck-select */
@keyframes deckSelectFadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

.deck-select:not([hidden]) .deck-select-inner {
  animation: deckSelectFadeIn 0.4s cubic-bezier(0.16,1,0.3,1) both;
}

/* Exit animation class */
.deck-select-exit {
  animation: deckSelectFadeOut 0.35s ease forwards !important;
}

@keyframes deckSelectFadeOut {
  to { opacity: 0; transform: scale(1.02); }
}


/* ============================================================
   DECK SWITCHER PILL (in header)
   ============================================================ */

.deck-switcher-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 4px var(--space-3) 4px var(--space-2);
  background: var(--color-primary-light);
  border: 1.5px solid var(--color-divider);
  border-radius: var(--radius-full);
  color: var(--color-primary);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.deck-switcher-pill:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Resilience deck accent on pill */
.deck-switcher-pill[data-deck="resilience"] {
  background: var(--color-magenta-light);
  border-color: var(--color-magenta);
  color: var(--color-magenta);
}

.deck-switcher-pill[data-deck="resilience"]:hover {
  background: var(--color-magenta);
  color: white;
}


/* ============================================================
   DECK SCOPE TOGGLE (Journey & Favorites)
   ============================================================ */

.deck-scope-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
  margin-bottom: var(--space-6);
}

.deck-scope-btn {
  padding: var(--space-1) var(--space-5);
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.deck-scope-btn.active {
  background: var(--color-surface-2);
  color: var(--color-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.deck-scope-btn:not(.active):hover {
  color: var(--color-text);
}

/* ============================================================
   WELCOME MODAL
   ============================================================ */
.welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 42, 64, 0.55);
  backdrop-filter: blur(4px);
  z-index: 3000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(1.5rem, 8vh, 4rem) var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: welcomeFadeIn 0.3s ease-out;
}

.welcome-overlay[hidden] { display: none; }

.welcome-overlay.welcome-exit {
  animation: welcomeFadeOut 0.3s ease-in forwards;
}

.welcome-overlay.welcome-exit .welcome-modal {
  animation: welcomeSlideOut 0.3s ease-in forwards;
}

@keyframes welcomeFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes welcomeSlideOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(12px) scale(0.97); }
}

@keyframes welcomeFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.welcome-modal {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  box-shadow: 0 20px 64px rgba(26, 42, 64, 0.28);
  max-width: 480px;
  width: 100%;
  padding: var(--space-8) var(--space-8) var(--space-6);
  animation: welcomeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes welcomeSlideIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  color: var(--color-text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-full);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.welcome-close:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.welcome-logo {
  margin-bottom: var(--space-5);
}

.welcome-logo img {
  width: 40px;
  height: 40px;
}

.welcome-headline {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  line-height: 1.2;
}

.welcome-body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
  max-width: 100%;
}

.welcome-uses {
  margin: var(--space-5) 0 0;
  background: var(--color-surface-offset);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
}

.welcome-uses-title {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.welcome-uses-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.welcome-use-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.welcome-use-label {
  font-weight: 600;
  color: var(--color-text);
  flex-shrink: 0;
}

.welcome-use-label::after {
  content: ' —';
  font-weight: 400;
  color: var(--color-text-muted);
}

.welcome-use-desc {
  color: var(--color-text-muted);
}

.welcome-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.welcome-cta-primary,
.welcome-cta-secondary {
  width: 100%;
  justify-content: center;
}

/* ============================================================
   HOW TO USE DRAWER
   ============================================================ */
.howto-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 42, 64, 0.45);
  backdrop-filter: blur(3px);
  z-index: 3100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: welcomeFadeIn 0.25s ease-out;
}

.howto-overlay[hidden] { display: none; }

.howto-overlay.howto-exit {
  animation: welcomeFadeOut 0.3s ease-in forwards;
}

.howto-overlay.howto-exit .howto-panel {
  animation: howtoSlideDown 0.3s ease-in forwards;
}

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

.howto-panel {
  background: var(--color-surface);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: 0 -8px 48px rgba(26, 42, 64, 0.2);
  width: 100%;
  max-width: 600px;
  max-height: 85dvh;
  display: flex;
  flex-direction: column;
  animation: howtoSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.howto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}

.howto-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}

.howto-close {
  color: var(--color-text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-full);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.howto-close:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.howto-body {
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.howto-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.howto-section-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-primary);
}

.howto-section p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 100%;
}

.howto-tips {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.howto-tips li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: 100%;
}

.howto-tips li::before {
  content: '';
  display: block;
  flex-shrink: 0;
  margin-top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-gold);
}

.howto-footer {
  padding: var(--space-4) var(--space-6) var(--space-6);
  border-top: 1px solid var(--color-divider);
  flex-shrink: 0;
}

.howto-footer .btn {
  width: 100%;
  justify-content: center;
}

/* Desktop: howto panel as centered modal instead of bottom sheet */
@media (min-width: 640px) {
  .howto-overlay {
    align-items: center;
  }

  .howto-panel {
    border-radius: var(--radius-2xl);
    max-height: 80dvh;
    animation: welcomeSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }
}

/* ============================================================
   THEME & TEXT-SIZE OVERRIDES
   ============================================================ */

/* dark mode removed — light only for workshop */

:root.text-larger {
  --text-xs:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-sm:   clamp(1rem,     0.9rem  + 0.5vw,  1.125rem);
  --text-base: clamp(1.125rem, 1rem    + 0.5vw,  1.25rem);
  --text-lg:   clamp(1.25rem,  1.1rem  + 0.75vw, 1.625rem);
}

/* ============================================================
   PERSONALIZATION PAGE
   ============================================================ */

.prefs-page {
  position: fixed;
  inset: 0;
  z-index: 3200;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.prefs-page[hidden] { display: none; }

/* ── Page header ──────────────────────────────────────────── */

.prefs-page-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
  min-height: 64px;
}

.prefs-page-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.prefs-page-back:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}

.prefs-page-title-wrap { flex: 1; min-width: 0; }

.prefs-page-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.15;
}

.prefs-page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Scrollable content ───────────────────────────────────── */

.prefs-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-6) var(--space-5) var(--space-20);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  scrollbar-width: none;
}

.prefs-content::-webkit-scrollbar { display: none; }

/* ── Tab bar ──────────────────────────────────────────────── */

.prefs-tab-bar {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-divider);
}

.prefs-tab-bar-inner {
  display: flex;
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 2px;
}

.prefs-tab-btn {
  flex: 1;
  padding: 10px var(--space-3);
  border-radius: calc(var(--radius-lg) - 3px);
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  min-height: 42px;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.prefs-tab-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}

.prefs-tab-panel {
  display: none;
}

.prefs-page[data-tab="experience"] #prefs-panel-experience,
.prefs-page[data-tab="preferences"] #prefs-panel-preferences {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

@media (min-width: 680px) {
  .prefs-tab-bar {
    padding-left: 0;
    padding-right: 0;
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
    border-bottom: none;
  }
}

@media (min-width: 680px) {
  .prefs-content {
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
  }
}

/* ── Section card ─────────────────────────────────────────── */

.prefs-section {
  background: var(--color-surface);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--color-divider);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex-shrink: 0;
  transition: box-shadow var(--transition-base), opacity var(--transition-base);
}

.prefs-section-head {
  padding: var(--space-5) var(--space-5) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.prefs-section-head-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.prefs-section-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

.prefs-section-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.55;
  padding-top: 2px;
}

.prefs-section-body {
  padding: var(--space-2) var(--space-5) var(--space-5);
}

/* Mode badge (shows which preset controls a section) */
.prefs-mode-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-body);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-full);
  padding: 2px 9px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity var(--transition-base);
}

.prefs-mode-badge[hidden] { display: none; }

/* ── Experience section — the organizing heart ────────────── */

.prefs-section--experience {
  border-top: 3px solid var(--color-primary);
  border-color: var(--color-primary);
}

.prefs-section--experience .prefs-section-head {
  padding-bottom: var(--space-3);
}

.prefs-section--experience .prefs-section-title {
  font-size: clamp(1.2rem, 1.1rem + 0.4vw, 1.5rem);
}

.exp-options {
  display: flex;
  flex-direction: row;
  gap: var(--space-2);
}

.exp-option {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-2);
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-2);
  text-align: center;
  min-height: 96px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast),
              box-shadow var(--transition-fast), transform var(--transition-fast);
}

.exp-option:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(42,63,107,0.10);
}

.exp-option:active { transform: translateY(0); }

.exp-option[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 2px rgba(42, 63, 107, 0.18);
}

.exp-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-lg);
  background: var(--color-surface-offset);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
  transition: background var(--transition-base), color var(--transition-base), transform var(--transition-base);
}

.exp-option[aria-pressed="true"] .exp-icon {
  background: var(--color-primary);
  color: #fff;
  transform: scale(1.05);
}

.exp-option-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.exp-option-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
  transition: color var(--transition-fast);
}

.exp-option[aria-pressed="true"] .exp-option-name {
  color: var(--color-primary);
}

.exp-option-desc {
  display: none;
}

.exp-radio {
  display: none;
}

.exp-option[aria-pressed="true"] .exp-radio {
  border-color: var(--color-primary);
  background: var(--color-primary);
}

.exp-radio::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #fff;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity var(--transition-fast), transform var(--transition-base);
}

.exp-option[aria-pressed="true"] .exp-radio::after {
  opacity: 1;
  transform: scale(1);
}

/* ── Experience description (always-visible, updates on selection) ── */

.exp-description {
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary-light);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.6;
  color: var(--color-text);
  transition: opacity 0.15s ease;
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
}

.exp-description--changing { opacity: 0; }

.exp-description-mode {
  font-weight: 600;
  color: var(--color-primary);
  font-style: normal;
}

.exp-description-sep {
  color: var(--color-text-muted);
}

.exp-description-text {
  color: var(--color-text-muted);
}

.exp-helper {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.55;
  text-align: center;
  letter-spacing: 0.01em;
}

/* Mode-switch fade — brief pulse on sections when mode changes */
.prefs-section--updating {
  animation: prefsSectionPulse 0.35s ease;
}
@keyframes prefsSectionPulse {
  0%   { opacity: 1; }
  35%  { opacity: 0.55; }
  100% { opacity: 1; }
}

/* ── Control groups (label + chips) ──────────────────────── */

.prefs-control-group {
  padding: var(--space-4) 0 var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}

.prefs-control-group:last-child,
.prefs-control-group + .prefs-section-locked-note {
  border-bottom: none;
}

.prefs-control-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  letter-spacing: 0.01em;
}

/* Chips */
.prefs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.prefs-chip {
  padding: 9px 16px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  min-height: 44px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--transition-fast), background var(--transition-fast),
              color var(--transition-fast), transform var(--transition-fast);
}

.prefs-chip:hover:not([disabled]):not(.active) {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-light);
  transform: translateY(-1px);
}

.prefs-chip.active {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(42,63,107,0.25);
}

.prefs-chip[disabled] {
  opacity: 0.28;
  cursor: not-allowed;
  pointer-events: none;
}

/* Focus styles */
.prefs-chip:focus-visible,
.exp-option:focus-visible,
.prefs-toggle:focus-visible,
.prefs-option-row:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Hint callout */
.prefs-hint:not([hidden]) {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--color-primary-light);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text);
  line-height: 1.5;
  animation: fadeInUp 0.2s ease;
}

.prefs-conflict {
  font-size: var(--text-xs);
  color: var(--color-error);
  background: rgba(184, 67, 58, 0.07);
  border-left: 3px solid var(--color-error);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  line-height: 1.5;
}

/* ── Toggle rows ──────────────────────────────────────────── */

.prefs-rows {
  display: flex;
  flex-direction: column;
}

.prefs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-divider);
  min-height: 56px;
  transition: opacity var(--transition-base);
}

.prefs-row:last-child { border-bottom: none; }

.prefs-row-label {
  font-size: var(--text-base);
  color: var(--color-text);
  font-weight: 400;
  flex: 1;
  text-align: left;
  line-height: 1.4;
}

.prefs-row-value {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.prefs-row-chevron {
  color: var(--color-text-faint);
  flex-shrink: 0;
}

.prefs-row-btn {
  cursor: pointer;
  border-radius: var(--radius-lg);
  padding: var(--space-1) 0;
  transition: background var(--transition-fast);
  width: 100%;
}

.prefs-row-btn:hover {
  background: var(--color-surface-offset);
}

/* Toggle switch */
.prefs-toggle {
  position: relative;
  width: 50px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-base);
}

.prefs-toggle[aria-checked="true"] {
  background: var(--color-primary);
}

.prefs-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform var(--transition-base);
}

.prefs-toggle[aria-checked="true"] .prefs-toggle-thumb {
  transform: translateX(22px);
}

.prefs-toggle[data-locked] {
  opacity: 0.5;
  cursor: default;
}

/* ── Option list (radio rows) ─────────────────────────────── */

.prefs-option-list {
  display: flex;
  flex-direction: column;
}

.prefs-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-divider);
  text-align: left;
  width: 100%;
  min-height: 52px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.prefs-option-row:last-child { border-bottom: none; }

.prefs-option-row:hover { background: var(--color-surface-offset); }

.prefs-option-row-label {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  font-weight: 400;
  padding-left: var(--space-1);
  transition: color var(--transition-fast);
}

.prefs-option-row.active .prefs-option-row-label {
  color: var(--color-primary);
  font-weight: 500;
}

.prefs-option-check {
  color: var(--color-primary);
  opacity: 0;
  flex-shrink: 0;
  transition: opacity var(--transition-fast), transform var(--transition-base);
  transform: scale(0.7);
  padding-right: var(--space-1);
}

.prefs-option-row.active .prefs-option-check {
  opacity: 1;
  transform: scale(1);
}

/* ── Preset-locked sections ───────────────────────────────── */

.prefs-section-locked-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-3);
  margin-top: var(--space-3);
  line-height: 1.55;
}

.prefs-section-locked-note::before {
  content: '';
  display: block;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-top: 1px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='11' width='18' height='11' rx='2' ry='2'/%3E%3Cpath d='M7 11V7a5 5 0 0110 0v4'/%3E%3C/svg%3E");
  background-size: 14px 14px;
  background-repeat: no-repeat;
}

/* Locked: keep active chip fully visible; fade others */
.prefs-section--locked .prefs-chips {
  pointer-events: none;
}

.prefs-section--locked .prefs-chip {
  transition: opacity var(--transition-base);
}

.prefs-section--locked .prefs-chip:not(.active) {
  opacity: 0.25;
}

.prefs-section--locked .prefs-chip.active {
  opacity: 1;
}

.prefs-section--locked .prefs-toggle {
  pointer-events: none;
  opacity: 0.45;
}

/* ── Mobile ───────────────────────────────────────────────── */

@media (max-width: 480px) {
  .prefs-content {
    padding: var(--space-4) var(--space-4) var(--space-20);
    gap: var(--space-3);
  }

  .prefs-section-head { padding: var(--space-4) var(--space-4) var(--space-2); }
  .prefs-section-body { padding: var(--space-1) var(--space-4) var(--space-4); }

  .exp-option { min-height: 80px; padding: var(--space-3) var(--space-1); }
  .exp-icon { width: 38px; height: 38px; }
  .exp-option-name { font-size: var(--text-sm); }
}

/* ============================================================
   WELCOME EXPERIENCE PICKER (first-run overlay)
   ============================================================ */

.welcome-picker[hidden] { display: none; }

.welcome-picker {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  animation: fadeIn 0.3s ease;
}

.welcome-picker--exit {
  animation: fadeOut 0.35s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; transform: scale(0.97); }
}

.welcome-picker-inner {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.welcome-picker-logo { margin-bottom: var(--space-1); }

.welcome-picker-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.25;
  margin: 0;
}

.welcome-picker-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.welcome-picker-modes {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.welcome-mode-btn {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 2px solid var(--color-divider);
  border-radius: var(--radius-xl);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.welcome-mode-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  transform: translateY(-1px);
}

.welcome-mode-btn:active { transform: translateY(0); }

.welcome-mode-icon {
  flex-shrink: 0;
  flex-basis: 48px;
  width: 48px;
  min-width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.welcome-mode-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.welcome-mode-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}

.welcome-mode-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

