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

html, body {
  height: 100%;
  font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--text-primary);
  /* Match app chrome so any edge letterboxing is not harsh black (Guideline 4 / iPad). */
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  user-select: none;
}

/* iOS WKWebView: body user-select:none + weak inheritance can still block editable controls */
input,
textarea,
select,
[contenteditable="true"] {
  user-select: text !important;
  -webkit-user-select: text !important;
  -webkit-touch-callout: default;
  touch-action: auto;
}

/* ── Device frame: full width by default (iPad / tablet / WKWebView). Phone-only cap. ──
   Do not rely on --frame-max-w alone: if unset, old 430px fallback caused pillarboxing on iPad. */
#device-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg-primary);
  overflow: hidden;
}
@media (max-width: 599px) {
  #device-frame {
    max-width: 430px;
  }
}

/* ═══════════════════════════════════════════
   PAGE SYSTEM
   ═══════════════════════════════════════════ */
.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-normal) var(--ease-smooth),
              transform var(--dur-normal) var(--ease-smooth);
  transform: translateX(30px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.page.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  z-index: 1;
}
.page.page-exit {
  opacity: 0;
  transform: translateX(-30px);
}
.page-content {
  flex: 1;
  padding-bottom: calc(var(--tab-height) + 20px);
}

/* ═══════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════ */
.text-display-xl { font-size: 34px; font-weight: 700; line-height: 1.2; }
.text-display-l  { font-size: 28px; font-weight: 700; line-height: 1.25; }
.text-title      { font-size: 22px; font-weight: 600; line-height: 1.3; }
.text-headline   { font-size: 17px; font-weight: 600; line-height: 1.4; }
.text-body       { font-size: 17px; font-weight: 400; line-height: 1.5; }
.text-sub        { font-size: 15px; font-weight: 400; line-height: 1.5; color: var(--text-secondary); }
.text-caption    { font-size: 13px; font-weight: 400; line-height: 1.4; color: var(--text-secondary); }
.text-caption-s  { font-size: 11px; font-weight: 400; line-height: 1.4; color: var(--text-secondary); }

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-s);
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: transform var(--dur-fast) var(--ease-spring),
              opacity var(--dur-fast),
              box-shadow var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.35; pointer-events: none; cursor: not-allowed; }

.btn-primary {
  width: 100%;
  height: var(--btn-height-l);
  background: var(--grad-iris);
  color: #fff;
  font-size: 17px;
  border-radius: var(--r-l);
  box-shadow: var(--shadow-glow);
}
.btn-primary:active { box-shadow: 0 2px 10px rgba(124,77,255,0.3); }

.btn-secondary {
  width: 100%;
  height: var(--btn-height-m);
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--r-l);
}

.btn-text {
  background: none;
  border: none;
  color: var(--iris);
  font-size: 15px;
  font-weight: 600;
  padding: var(--sp-s) var(--sp-l);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-circle);
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-nav-icon {
  background: transparent;
  min-width: 44px;
  min-height: 44px;
}
.chat-nav-icon svg { color: var(--text-primary); }
.chat-nav-back svg { width: 20px; height: 20px; }
.chat-nav-menu svg { width: 18px; height: 18px; }
.chat-avatar {
  width: 32px;
  height: 32px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   TAG CHIPS
   ═══════════════════════════════════════════ */
.tag-chip {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(28,28,46,0.75);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-l);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  text-align: left;
  line-height: 1.25;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-spring),
    border-color var(--dur-fast),
    color var(--dur-fast),
    transform var(--dur-fast) var(--ease-spring),
    box-shadow var(--dur-fast);
  white-space: normal;
  box-sizing: border-box;
}
.tag-chip .tag-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--iris-light);
  opacity: 0.95;
}
.tag-chip .tag-icon svg {
  display: block;
}
.tag-chip .tag-label {
  flex: 1;
  min-width: 0;
}
.tag-chip:active { transform: scale(0.98); }
.tag-chip.selected {
  background: var(--grad-iris);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.tag-chip.selected .tag-icon {
  color: rgba(255,255,255,0.95);
}
.tag-chip:focus-visible {
  outline: 2px solid var(--iris-light);
  outline-offset: 2px;
}

.tag-filter {
  padding: 8px 16px;
  background: rgba(255,255,255,0.06);
  border: none;
  border-radius: var(--r-pill);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-fast);
}
.tag-filter.active {
  background: var(--iris);
  color: #fff;
}

/* ═══════════════════════════════════════════
   AVATAR
   ═══════════════════════════════════════════ */
.avatar {
  border-radius: var(--r-circle);
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-gradient {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  border-radius: var(--r-circle);
  overflow: hidden;
}

/* ═══════════════════════════════════════════
   NAVBAR
   ═══════════════════════════════════════════ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  min-height: calc(var(--nav-height) + var(--sc-safe-top));
  height: auto;
  padding: var(--sc-safe-top) var(--sp-l) 0;
  background: rgba(13,13,20,0.88);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.navbar-title {
  flex: 1;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}
.navbar-left, .navbar-right {
  width: 44px;
  display: flex;
  align-items: center;
}
.navbar-right { justify-content: flex-end; }

/* ═══════════════════════════════════════════
   TAB BAR
   ═══════════════════════════════════════════ */
.tab-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  box-sizing: border-box;
  height: var(--tab-height);
  display: flex;
  align-items: flex-end;
  padding: 4px 0 0;
  padding-bottom: var(--sc-safe-bottom);
  background: rgba(13,13,20,0.85);
  backdrop-filter: blur(40px) saturate(1.8);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  border-top: 1px solid rgba(255,255,255,0.06);
  z-index: 120;
}
.tab-bar::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 5%;
  right: 5%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124,77,255,0.18), transparent);
  pointer-events: none;
}
.tab-bar.hidden { display: none; }

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--text-disabled);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  min-height: 40px;
  padding: 4px 0 2px;
  transition: color var(--dur-normal) var(--ease-smooth),
              transform var(--dur-fast) var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.tab-item:active { transform: scale(0.92); }

.tab-item.active {
  color: var(--text-primary);
}

.tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  line-height: 1;
  transition: transform var(--dur-normal) var(--ease-spring),
              filter var(--dur-normal);
}
.tab-icon svg {
  width: 22px;
  height: 22px;
}
.tab-item.active .tab-icon {
  transform: translateY(-1px) scale(1.1);
  filter: drop-shadow(0 0 6px rgba(124,77,255,0.5));
}
.tab-item.active .tab-icon svg {
  stroke: var(--iris-light);
}

.tab-label {
  font-size: 10px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity var(--dur-normal), color var(--dur-normal);
}
.tab-item.active .tab-label {
  opacity: 1;
  color: var(--iris-light);
}

.tab-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--iris);
  opacity: 0;
  box-shadow: 0 0 8px rgba(124,77,255,0.6);
  transition: opacity var(--dur-normal) var(--ease-smooth),
              transform var(--dur-normal) var(--ease-spring);
  transform: scale(0);
}
.tab-item.active .tab-dot {
  opacity: 1;
  transform: scale(1);
}

/* ═══════════════════════════════════════════
   SPLASH PAGE
   ═══════════════════════════════════════════ */
#page-splash {
  background: var(--grad-night);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.splash-orbs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.splash-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: orbFloat 6s ease-in-out infinite alternate;
}
.splash-orb-1 { width: 200px; height: 200px; background: rgba(124,77,255,0.3); top: 15%; left: -20%; animation-delay: 0s; }
.splash-orb-2 { width: 160px; height: 160px; background: rgba(255,77,141,0.25); top: 55%; right: -15%; animation-delay: 2s; }
.splash-orb-3 { width: 140px; height: 140px; background: rgba(0,229,204,0.2); bottom: 10%; left: 20%; animation-delay: 4s; }

@keyframes orbFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -20px) scale(1.15); }
}

.splash-logo {
  width: 80px; height: 80px;
  background: var(--grad-iris);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: var(--shadow-glow);
  animation: splashIn 0.6s var(--ease-spring) both;
  z-index: 1;
}
.splash-title {
  margin-top: var(--sp-xl);
  font-size: 28px;
  font-weight: 700;
  animation: fadeUp 0.5s 0.3s both;
  z-index: 1;
}
.splash-subtitle {
  margin-top: var(--sp-s);
  font-size: 15px;
  color: var(--text-secondary);
  animation: fadeUp 0.5s 0.5s both;
  z-index: 1;
}
.splash-loader {
  position: absolute;
  bottom: 80px;
  width: 60px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
  animation: fadeUp 0.5s 0.7s both;
}
.splash-loader-bar {
  height: 100%;
  width: 0%;
  background: var(--grad-iris);
  border-radius: 2px;
  animation: loaderFill 1.5s 0.5s ease-in-out forwards;
}

@keyframes splashIn { 0% { opacity: 0; transform: scale(0.8); } 100% { opacity: 1; transform: scale(1); } }
@keyframes fadeUp { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } }
@keyframes loaderFill { 0% { width: 0; } 100% { width: 100%; } }

/* ═══════════════════════════════════════════
   INTEREST TAGS PAGE
   ═══════════════════════════════════════════ */
#page-tags {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  background: var(--bg-primary);
}
.tags-page-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(var(--sp-2xl), var(--sc-safe-top)) var(--sp-xl) var(--sp-l);
}
.tags-intro {
  text-align: center;
  margin-bottom: var(--sp-xl);
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
}
.tags-intro-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--iris-light);
  margin-bottom: var(--sp-s);
  opacity: 0.9;
}
.tags-intro-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: var(--sp-s);
}
.tags-intro-sub {
  font-size: 15px;
  line-height: 1.45;
  margin: 0;
}
.tags-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin-bottom: var(--sp-m);
}
#page-tags .tag-chip {
  width: 100%;
  min-height: 48px;
  align-items: center;
}
.tags-page-footer {
  flex-shrink: 0;
  padding: var(--sp-m) var(--sp-xl) max(var(--sp-xl), calc(var(--sc-safe-bottom) + var(--sp-s)));
  background: linear-gradient(180deg, transparent 0%, rgba(13,13,20,0.65) 35%, var(--bg-primary) 100%);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.tags-counter {
  text-align: center;
  margin: 0 0 var(--sp-m);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   TRANSITION PAGE
   ═══════════════════════════════════════════ */
#page-transition {
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.transition-text {
  font-size: 17px;
  color: var(--text-secondary);
  animation: pulse 1.5s ease-in-out infinite;
}
.transition-dots {
  display: flex;
  gap: 8px;
  margin-top: var(--sp-xl);
}
.transition-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--iris);
  animation: dotBounce 0.6s ease-in-out infinite alternate;
}
.transition-dot:nth-child(2) { animation-delay: 0.2s; }
.transition-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes dotBounce { 0% { transform: translateY(0); opacity: 0.4; } 100% { transform: translateY(-8px); opacity: 1; } }

/* ═══════════════════════════════════════════
   EXPLORE PAGE
   ═══════════════════════════════════════════ */
#page-explore { background: var(--bg-primary); }

.explore-header {
  position: sticky;
  top: 0;
  z-index: 10;
  /* Clear status bar / Dynamic Island (viewport-fit=cover) */
  padding: calc(var(--sc-safe-top) + var(--sp-m)) var(--sp-l) 0;
  background: rgba(13,13,20,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.explore-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-s);
}
.explore-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.explore-logo-icon {
  color: var(--iris-light);
}
.explore-selected-tags {
  display: flex;
  align-items: center;
  gap: var(--sp-s);
  overflow-x: auto;
  padding-bottom: var(--sp-s);
  scrollbar-width: none;
}
.explore-selected-tags::-webkit-scrollbar { display: none; }
.selected-feed-copy {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.selected-feed-pill {
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(124,77,255,0.16);
  border: 1px solid rgba(124,77,255,0.28);
  color: var(--iris-light);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.explore-filters {
  display: flex;
  gap: var(--sp-s);
  overflow-x: auto;
  padding-bottom: var(--sp-m);
  scrollbar-width: none;
}
.explore-filters::-webkit-scrollbar { display: none; }

.explore-feed {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: var(--sp-m);
  overflow-y: auto;
  /* Extra space so last card row clears the tab bar (Guideline 4 / iPad). */
  padding: var(--sp-m) var(--sp-l) calc(var(--tab-height) + 56px);
  scrollbar-width: none;
}
.explore-feed::-webkit-scrollbar { display: none; }

.explore-card {
  position: relative;
  min-height: 220px;
  border-radius: var(--r-xl);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring),
              box-shadow var(--dur-normal);
  border: 1px solid var(--border-card);
  background: rgba(28,28,46,0.92);
  display: flex;
  flex-direction: column;
}
.explore-card:active {
  transform: scale(0.97);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.explore-card-ad { min-height: 180px; }

.card-media {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  overflow: hidden;
}
.card-media-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  z-index: 0;
  pointer-events: none;
}
.card-media::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to top, rgba(13,13,20,0.18), rgba(13,13,20,0));
}
.card-media-ad {
  background: linear-gradient(135deg, rgba(124,77,255,0.22), rgba(255,77,141,0.16));
}
.card-emoji {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 20px rgba(0,0,0,0.35));
}
.card-content {
  position: relative;
  margin-top: 118px;
  padding: var(--sp-m);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 102px;
}
.card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.card-tag {
  padding: 4px 8px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1;
}
.card-name { font-size: 18px; font-weight: 700; line-height: 1.2; }
.card-tagline {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  font-size: 11px;
  color: rgba(255,255,255,0.42);
}
.card-stats svg { opacity: 0.7; }
.card-sponsored {
  position: absolute;
  top: var(--sp-m);
  right: var(--sp-m);
  padding: 4px 10px;
  background: rgba(0,0,0,0.5);
  border-radius: var(--r-xs);
  font-size: 11px;
  color: rgba(255,255,255,0.7);
}

.explore-tooltip {
  position: fixed;
  bottom: calc(var(--tab-height) + 120px);
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--r-m);
  font-size: 14px;
  color: var(--text-primary);
  z-index: 20;
  animation: tooltipBounce 2s ease-in-out infinite;
  white-space: nowrap;
}
@keyframes tooltipBounce {
  0%,100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* ═══════════════════════════════════════════
   CHARACTER DETAIL PAGE
   ═══════════════════════════════════════════ */
#page-detail {
  background: var(--bg-primary);
  z-index: 60;
  transform: scale(0.95);
  padding-bottom: calc(var(--tab-height) + 16px);
}
#page-detail.active { transform: scale(1); }

.detail-hero {
  position: relative;
  width: 100%;
  height: 55vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 160px;
  background: var(--grad-night);
  overflow: hidden;
}
.detail-hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, var(--bg-primary) 0%, transparent 100%);
}
.detail-close {
  position: absolute;
  top: calc(var(--sc-safe-top) + var(--sp-l));
  left: var(--sp-l);
  z-index: 5;
}
.detail-body {
  position: relative;
  margin-top: -40px;
  padding: 0 var(--sp-xl) calc(var(--tab-height) + 28px);
  z-index: 2;
}
.detail-name { font-size: 28px; font-weight: 700; margin-bottom: var(--sp-xs); }
.detail-creator {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-l);
}
.detail-tags {
  display: flex;
  gap: var(--sp-s);
  margin-bottom: var(--sp-l);
}
.detail-tag {
  padding: 4px 12px;
  background: rgba(124,77,255,0.15);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--iris-light);
}
.detail-tagline {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-xl);
}
.detail-greeting {
  position: relative;
  padding: var(--sp-l) var(--sp-l) var(--sp-l) var(--sp-xl);
  margin-bottom: var(--sp-l);
  font-style: italic;
  color: rgba(255,255,255,0.7);
  font-size: 15px;
  line-height: 1.6;
}
.detail-greeting::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 2px;
  background: var(--grad-iris);
}
.detail-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2xl);
}
.detail-cta {
  padding-bottom: var(--sp-3xl);
}

/* ═══════════════════════════════════════════
   CHAT PAGE
   ═══════════════════════════════════════════ */
#page-chat {
  background: var(--bg-primary);
  z-index: 70;
  /* No whole-page scroll: avoids a stray bottom gap on iOS WKWebView (flex + overflow-y: auto). */
  overflow: hidden;
  min-height: 0;
  padding-bottom: var(--tab-height);
}
/* While chatting, stack above most pages so the composer isn’t under .tab-bar in hit-testing order */
#page-chat.active {
  z-index: 110;
}
.chat-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: calc(var(--sc-safe-top) + var(--sp-s)) var(--sp-l) var(--sp-s);
  background: rgba(13,13,20,0.88);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.chat-nav-info { flex: 1; }
.chat-nav-name { font-size: 16px; font-weight: 600; }
.chat-nav-status { font-size: 12px; color: var(--mint); display: flex; align-items: center; gap: 4px; }
.chat-nav-status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--mint);
}

.energy-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-s);
  padding: var(--sp-s);
  font-size: 13px;
  font-weight: 600;
  color: var(--iris-light);
  background: rgba(124,77,255,0.08);
  border-bottom: 1px solid var(--divider);
}
.energy-icon-svg {
  display: flex;
  align-items: center;
}
.energy-bar.warning { color: var(--amber); background: rgba(255,140,66,0.08); }
.energy-bar.depleted { color: var(--crimson); background: rgba(255,77,77,0.08); }
.energy-progress {
  width: 60px; height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.energy-progress-fill {
  height: 100%;
  background: var(--iris);
  border-radius: 2px;
  transition: width 0.3s, background 0.3s;
}
.energy-progress-fill.is-full { width: 100%; }
.energy-bar.warning .energy-progress-fill { background: var(--amber); }
.energy-bar.depleted .energy-progress-fill { background: var(--crimson); }

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--sp-l) var(--sp-l) var(--sp-m);
  display: flex;
  flex-direction: column;
  gap: var(--sp-m);
  scrollbar-width: none;
}
.chat-messages::-webkit-scrollbar { display: none; }

.msg-row {
  display: flex;
  gap: var(--sp-s);
  max-width: 85%;
  animation: msgIn 0.3s var(--ease-spring);
}
.msg-row.ai { align-self: flex-start; }
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-row .avatar-gradient { width: var(--avatar-xs); height: var(--avatar-xs); font-size: 10px; flex-shrink: 0; margin-top: 4px; }

.msg-bubble {
  padding: var(--sp-m) var(--sp-l);
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.5;
  word-break: break-word;
}
.msg-row.ai .msg-bubble {
  background: var(--bg-card);
  color: rgba(255,255,255,0.9);
  border-bottom-left-radius: var(--r-xs);
}
.msg-row.user .msg-bubble {
  background: var(--grad-iris);
  color: #fff;
  border-bottom-right-radius: var(--r-xs);
}
.msg-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  padding: 0 var(--sp-s);
}
.msg-row.user .msg-time { text-align: right; }
.msg-not-charged {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

@keyframes msgIn { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } }

.typing-indicator {
  display: flex;
  gap: var(--sp-s);
  align-items: flex-end;
  max-width: 85%;
}
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: 18px;
  border-bottom-left-radius: var(--r-xs);
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-secondary);
  animation: typingBounce 0.6s ease-in-out infinite alternate;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0% { opacity: 0.3; transform: translateY(0); }
  100% { opacity: 1; transform: translateY(-4px); }
}

.chat-input-area {
  flex-shrink: 0;
  padding: var(--sp-s) var(--sp-l);
  border-top: 1px solid var(--divider);
  background: var(--bg-primary);
  position: relative;
  z-index: 2;
}
.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-s);
}
.chat-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--divider);
  border-radius: 14px;
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.4;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 100px;
  -webkit-appearance: none;
  appearance: none;
}
.chat-input::placeholder { color: var(--text-disabled); }
.chat-input:focus {
  border-color: rgba(124, 77, 255, 0.45);
  box-shadow: 0 0 0 2px rgba(124, 77, 255, 0.12);
}
.chat-input:disabled { opacity: 0.45; }

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: var(--r-circle);
  background: var(--grad-iris);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-spring),
              opacity var(--dur-fast),
              box-shadow var(--dur-fast);
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(124,77,255,0.3);
}
.chat-send:active { transform: scale(0.88); box-shadow: 0 1px 6px rgba(124,77,255,0.2); }
.chat-send:disabled { opacity: 0.25; box-shadow: none; }

.regenerate-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  background: rgba(124,77,255,0.1);
  border: 1px solid rgba(124,77,255,0.15);
  border-radius: var(--r-pill);
  color: var(--iris-light);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  margin-top: 6px;
  min-height: 32px;
  transition: background var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
}
.regenerate-btn:active {
  background: rgba(124,77,255,0.2);
  transform: scale(0.95);
}

/* ═══════════════════════════════════════════
   HALF-SHEET PAYWALL
   ═══════════════════════════════════════════ */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-normal);
}
.sheet-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.half-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: min(560px, calc(100vw - var(--sc-safe-left) - var(--sc-safe-right) - 16px));
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--r-3xl) var(--r-3xl) 0 0;
  padding: var(--sp-m) var(--sp-xl) var(--sp-3xl);
  z-index: 201;
  pointer-events: none;
  transition: transform var(--dur-slow) var(--ease-spring);
}
.half-sheet.visible {
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
@media (max-width: 599px) {
  .half-sheet {
    max-width: min(430px, calc(100vw - var(--sc-safe-left) - var(--sc-safe-right) - 16px));
  }
}

.sheet-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  margin: 0 auto var(--sp-xl);
}
.sheet-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--sp-xl);
}
.sheet-options { display: flex; flex-direction: column; gap: var(--sp-m); }
.half-sheet-compact { padding-bottom: 40px; }
.sheet-annual {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: var(--sp-m);
  padding: var(--sp-s) 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: underline;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.subscribe-meta {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.8;
}
.btn-with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-danger-subtle {
  color: var(--crimson);
  border-color: rgba(255,77,77,0.3);
}
.confirm-desc {
  text-align: center;
  margin-bottom: 24px;
}
.btn-confirm-danger {
  background: var(--crimson);
  box-shadow: none;
}
.sheet-legal {
  margin-top: var(--sp-xl);
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}
.sheet-links {
  text-align: center;
  margin-top: var(--sp-s);
  font-size: 11px;
}
.sheet-legal a { color: var(--text-secondary); text-decoration: underline; }
.sheet-links a { color: var(--text-secondary); text-decoration: underline; }

/* ═══════════════════════════════════════════
   CHATS LIST PAGE
   ═══════════════════════════════════════════ */
.chats-list { padding: var(--sp-l); }

.chat-list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-m) var(--sp-s);
  margin: 0 calc(-1 * var(--sp-s));
  border-bottom: 1px solid var(--divider);
  border-radius: var(--r-m);
  cursor: pointer;
  transition: background var(--dur-fast), transform var(--dur-fast) var(--ease-spring);
}
.chat-list-item:active {
  background: rgba(255,255,255,0.04);
  transform: scale(0.99);
}
.chat-list-info { flex: 1; min-width: 0; }
.chat-list-name { font-size: 16px; font-weight: 600; }
.chat-list-last {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-list-time {
  font-size: 12px;
  color: var(--text-disabled);
  flex-shrink: 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3xl) var(--sp-xl);
  text-align: center;
}
.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin: 0 auto var(--sp-xl);
  border-radius: var(--r-2xl);
  background: rgba(124,77,255,0.08);
  color: var(--iris-light);
  opacity: 0.8;
}
.empty-title { font-size: 18px; font-weight: 600; margin-bottom: var(--sp-s); }
.empty-desc { font-size: 15px; color: var(--text-secondary); margin-bottom: var(--sp-xl); }

/* ═══════════════════════════════════════════
   CREATOR PAGE
   ═══════════════════════════════════════════ */
.creator-form { padding: var(--sp-xl); }

.form-group { margin-bottom: var(--sp-xl); }
.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-s);
  display: flex;
  justify-content: space-between;
}
.form-label .char-count { font-weight: 400; color: var(--text-disabled); }
.form-label .char-count.over { color: var(--crimson); }
.form-input, .form-textarea {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--divider);
  border-radius: var(--r-m);
  color: var(--text-primary);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--dur-fast);
}
.form-input:focus, .form-textarea:focus { border-color: rgba(124,77,255,0.4); }
.form-textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-disabled); }

.avatar-upload {
  width: 100px;
  height: 100px;
  border-radius: var(--r-circle);
  border: 2px dashed rgba(124,77,255,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0 auto;
  font-size: 24px;
  color: var(--iris);
  transition: border-color var(--dur-fast), transform var(--dur-fast);
  background: var(--bg-card);
}
.avatar-upload:hover { border-color: var(--iris); }
.avatar-upload:active { transform: scale(0.95); }

.visibility-toggle {
  display: flex;
  gap: var(--sp-m);
}
.vis-option {
  flex: 1;
  padding: var(--sp-m);
  border-radius: var(--r-m);
  border: 1px solid var(--divider);
  background: var(--bg-card);
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--dur-fast);
}
.vis-option.active {
  border-color: var(--iris);
  color: var(--text-primary);
  background: rgba(124,77,255,0.1);
}

.advanced-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-s);
  padding: var(--sp-m) 0;
  color: var(--iris-light);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}
.advanced-fields { display: none; }
.advanced-fields.visible { display: block; }

/* ═══════════════════════════════════════════
   PROFILE PAGE
   ═══════════════════════════════════════════ */
.profile-header {
  display: flex;
  align-items: center;
  gap: var(--sp-l);
  padding: calc(var(--sc-safe-top) + var(--sp-xl)) var(--sp-xl) var(--sp-xl);
}
.profile-avatar {
  width: var(--avatar-l);
  height: var(--avatar-l);
  font-size: 24px;
  box-shadow: 0 0 0 2px rgba(124,77,255,0.2), 0 4px 16px rgba(0,0,0,0.3);
}
.profile-avatar-default { background: var(--grad-iris); }
.profile-header-info { min-width: 0; flex: 1; }
.profile-name { font-size: 20px; font-weight: 700; }
.profile-handle {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-section {
  padding: 0 var(--sp-xl);
  margin-bottom: var(--sp-xl);
}
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--sp-m);
}

.recent-chats-row {
  display: flex;
  gap: var(--sp-l);
  overflow-x: auto;
  padding-bottom: var(--sp-s);
  scrollbar-width: none;
}
.recent-chats-row::-webkit-scrollbar { display: none; }
.recent-chats-empty-copy { padding: 8px 0; }
.recent-chat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
  cursor: pointer;
}
.recent-chat-item .avatar-gradient {
  width: var(--avatar-m);
  height: var(--avatar-m);
  font-size: 20px;
  border: 2px solid rgba(124,77,255,0.3);
}
.recent-chat-item span { font-size: 12px; color: var(--text-secondary); }

.subscription-card {
  padding: var(--sp-xl);
  background: rgba(28,28,46,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--r-l);
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-upgrade {
  height: 44px;
  font-size: 15px;
  gap: 6px;
}
.btn-upgrade svg {
  flex-shrink: 0;
}
.btn-restore {
  display: block;
  width: 100%;
  margin-top: var(--sp-m);
  padding: var(--sp-s) 0;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: underline;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.btn-restore:active { opacity: 0.6; }
.sheet-restore { margin-top: var(--sp-s); }
.profile-version {
  font-weight: 400;
  color: var(--text-disabled);
  text-decoration: none;
}
.sub-energy {
  display: flex;
  align-items: center;
  gap: var(--sp-s);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: var(--sp-m);
}
.sub-energy .energy-icon {
  color: var(--iris-light);
  display: flex;
  align-items: center;
}
.pro-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: var(--grad-pro);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.settings-list {
  padding: 0 var(--sp-xl);
  margin-top: var(--sp-xl);
}
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: var(--sp-l) 0;
  border: none;
  border-bottom: 1px solid var(--divider);
  background: none;
  font-family: inherit;
  font-size: 16px;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: opacity var(--dur-fast), background var(--dur-fast);
}
.settings-item:active {
  opacity: 0.7;
  background: rgba(255,255,255,0.02);
}
.settings-item .arrow {
  color: var(--text-disabled);
  font-size: 14px;
  display: flex;
  align-items: center;
}
.settings-item.danger { color: var(--crimson); }

/* ═══════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(var(--tab-height) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: 12px 20px;
  background: var(--bg-card);
  border: var(--glass-border);
  border-radius: var(--r-m);
  font-size: 14px;
  color: var(--text-primary);
  z-index: 300;
  opacity: 0;
  transition: all var(--dur-normal) var(--ease-spring);
  white-space: nowrap;
  max-width: calc(100% - 32px);
}
.toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.toast.success { border-left: 3px solid var(--mint); }
.toast.error { border-left: 3px solid var(--crimson); }

/* ═══════════════════════════════════════════
   CONFETTI (create success)
   ═══════════════════════════════════════════ */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
}
.confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFall 1s ease-in forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ═══════════════════════════════════════════
   SCROLLBAR GLOBAL HIDE
   ═══════════════════════════════════════════ */
.page::-webkit-scrollbar { display: none; }
.page { scrollbar-width: none; }

/* ═══════════════════════════════════════════
   MOOD AURA
   ═══════════════════════════════════════════ */
.mood-aura {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  opacity: 0; transition: opacity 1.5s ease, background 2s ease;
}
.mood-aura.active { opacity: 1; }
.mood-aura[data-mood="happy"]       { background: radial-gradient(ellipse at 50% 70%, rgba(255,221,87,0.28) 0%, rgba(255,200,50,0.10) 40%, transparent 75%); }
.mood-aura[data-mood="calm"]        { background: radial-gradient(ellipse at 50% 70%, rgba(0,229,204,0.25) 0%, rgba(0,229,204,0.08) 40%, transparent 75%); }
.mood-aura[data-mood="sad"]         { background: radial-gradient(ellipse at 50% 70%, rgba(77,136,255,0.28) 0%, rgba(77,136,255,0.10) 40%, transparent 75%); }
.mood-aura[data-mood="mysterious"]  { background: radial-gradient(ellipse at 50% 70%, rgba(124,77,255,0.30) 0%, rgba(124,77,255,0.12) 40%, transparent 75%); }
.mood-aura[data-mood="excited"]     { background: radial-gradient(ellipse at 50% 70%, rgba(255,140,66,0.30) 0%, rgba(255,140,66,0.12) 40%, transparent 75%); }
.mood-aura[data-mood="thoughtful"]  { background: radial-gradient(ellipse at 50% 70%, rgba(155,140,255,0.26) 0%, rgba(120,100,200,0.10) 40%, transparent 75%); }
.mood-aura[data-mood="curious"]     { background: radial-gradient(ellipse at 50% 70%, rgba(77,187,255,0.28) 0%, rgba(77,150,255,0.10) 40%, transparent 75%); }
.mood-aura[data-mood="supportive"]  { background: radial-gradient(ellipse at 50% 70%, rgba(38,198,218,0.26) 0%, rgba(0,131,143,0.10) 40%, transparent 75%); }
.mood-aura[data-mood="hopeful"]     { background: radial-gradient(ellipse at 50% 70%, rgba(165,214,167,0.28) 0%, rgba(67,160,71,0.10) 40%, transparent 75%); }
.mood-aura[data-mood="melancholic"] { background: radial-gradient(ellipse at 50% 70%, rgba(100,100,180,0.28) 0%, rgba(100,100,180,0.10) 40%, transparent 75%); }

/* ═══════════════════════════════════════════
   PURE MODE — explore gate dialog + settings toggle
   ═══════════════════════════════════════════ */
.pure-mode-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-xl);
  background: rgba(0, 0, 0, 0.72);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-normal), visibility var(--dur-normal);
}
.pure-mode-modal-overlay.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.pure-mode-modal {
  width: 100%;
  max-width: 320px;
  padding: var(--sp-xl);
  border-radius: var(--r-xl);
  background: var(--bg-card);
  border: 1px solid var(--divider);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.pure-mode-modal-title {
  margin: 0 0 var(--sp-m);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.pure-mode-modal-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
}
.pure-mode-modal-actions {
  display: flex;
  gap: var(--sp-s);
  margin-top: var(--sp-xl);
}
.pure-mode-modal-btn {
  flex: 1;
  min-height: 44px;
  font-size: 14px;
  font-weight: 600;
}

.settings-page-body {
  padding: var(--sp-s) 0 var(--sp-xl);
}
.settings-list-padded {
  padding: 0 var(--sp-xl);
}
.settings-row-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-m);
  padding: var(--sp-l) 0;
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.settings-row-toggle-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}
.settings-row-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.settings-row-sub {
  font-size: 13px;
  line-height: 1.35;
}
.settings-toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.settings-toggle-ui {
  flex-shrink: 0;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: #3a3a45;
  position: relative;
  transition: background 0.2s;
}
.settings-toggle-ui::after {
  content: '';
  position: absolute;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.settings-toggle-input:checked + .settings-toggle-ui {
  background: var(--iris);
}
.settings-toggle-input:checked + .settings-toggle-ui::after {
  transform: translateX(20px);
}
.settings-toggle-input:focus-visible + .settings-toggle-ui {
  outline: 2px solid var(--iris-light);
  outline-offset: 3px;
}

/* ═══════════════════════════════════════════
   VIBE CHECK CARD
   ═══════════════════════════════════════════ */
.vibe-card-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.75);
  z-index: 9998; display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.vibe-card-overlay.visible { opacity: 1; pointer-events: auto; }

.vibe-card {
  width: 300px; padding: 32px 24px; border-radius: 24px;
  text-align: center; position: relative; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.vibe-card::before {
  content: ''; position: absolute; inset: 0; opacity: 0.15;
  background: radial-gradient(circle at 30% 20%, white, transparent 60%);
}
.vibe-card-emoji { font-size: 56px; margin-bottom: 12px; position: relative; }
.vibe-card-title {
  font-size: 22px; font-weight: 700; color: #fff; margin-bottom: 4px; position: relative;
}
.vibe-card-sub {
  font-size: 13px; color: rgba(255,255,255,0.7); margin-bottom: 20px; position: relative;
}
.vibe-card-meter {
  display: flex; gap: 6px; justify-content: center; margin-bottom: 20px; position: relative;
}
.vibe-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255,255,255,0.2); transition: background 0.3s;
}
.vibe-dot.lit { background: #fff; box-shadow: 0 0 8px rgba(255,255,255,0.6); }
.vibe-card-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
  color: rgba(255,255,255,0.5); margin-bottom: 16px; position: relative;
}
.vibe-card-dismiss {
  background: rgba(255,255,255,0.15); border: none; color: #fff;
  padding: 10px 28px; border-radius: 99px; font-size: 14px; font-weight: 600;
  cursor: pointer; position: relative; backdrop-filter: blur(8px);
}

/* ═══════════════════════════════════════════
   CHAT STREAK
   ═══════════════════════════════════════════ */
.streak-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,140,66,0.15); color: #FF8C42;
  padding: 2px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 700; margin-left: 8px;
  animation: streakPulse 2s ease-in-out infinite;
}
.streak-badge .streak-flame {
  display: inline-block; animation: flicker 0.4s ease-in-out infinite alternate;
}
@keyframes flicker {
  from { transform: scale(1) rotate(-3deg); }
  to   { transform: scale(1.15) rotate(3deg); }
}
@keyframes streakPulse {
  0%,100% { box-shadow: 0 0 0 rgba(255,140,66,0); }
  50%     { box-shadow: 0 0 12px rgba(255,140,66,0.3); }
}

/* ═══════════════════════════════════════════
   PAYWALL PLANS
   ═══════════════════════════════════════════ */
.paywall-plans {
  display: flex; gap: 12px; padding: 0 16px;
}
.paywall-plan {
  flex: 1; padding: 20px 14px; border-radius: 16px;
  background: rgba(28,28,46,0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.08);
  text-align: center; cursor: pointer; position: relative;
  transition: border-color 0.2s, box-shadow 0.2s, transform var(--dur-fast) var(--ease-spring);
}
.paywall-plan:active { transform: scale(0.97); }
.paywall-plan.selected {
  border-color: var(--iris);
  box-shadow: 0 0 0 1px var(--iris), 0 4px 24px rgba(124,77,255,0.25);
  background: rgba(124,77,255,0.08);
}
.plan-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--iris-light);
  margin-bottom: 8px;
}
.plan-badge.best-value {
  color: var(--mint);
}
.plan-name {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 4px;
}
.plan-price {
  font-size: 22px; font-weight: 800; color: var(--text-primary);
}
.plan-price span {
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
}
.plan-detail {
  font-size: 11px; color: var(--text-secondary); margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════════
   iPadOS / Stage Manager / multitasking (v1.5.0)
   ─────────────────────────────────────────────────────────────────
   Native shell injects `.is-ipad` on <html> and sets --sc-vw / safe-area.
   `index.html` adds `.sc-wide` before CSS when viewport ≥600px (avoids FOUC).
   iPad Air 11″ (M3) portrait ≈ 820×1180pt; split-view windows can be narrower.
   Explore uses auto-fill columns; sheets respect safe-area insets.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Compact tablet & split view (≥600px): fluid grid, no phone stripe ── */
@media (min-width: 600px) {
  .explore-header {
    padding: calc(var(--sc-safe-top) + var(--sp-m)) var(--sp-xl) 0;
  }
  .explore-feed {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-l);
    padding: var(--sp-m) var(--sp-xl) calc(var(--tab-height) + 88px);
  }
  .explore-card {
    min-height: 240px;
  }
  .card-media {
    height: 142px;
  }
  .card-content {
    margin-top: 132px;
    min-height: 108px;
  }
  .half-sheet {
    max-width: min(560px, calc(100vw - var(--sc-safe-left) - var(--sc-safe-right) - 16px));
  }
  .tags-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    max-width: 52rem;
    margin-left: auto;
    margin-right: auto;
  }
}

/* ── Base font bump ── */
html.is-ipad body {
  font-size: 18px;
}
@media (min-width: 768px) {
  body {
    font-size: 18px;
  }
}

/* ──────────── Explore page ──────────── */
@media (min-width: 768px) {
  .explore-header {
    padding: calc(var(--sc-safe-top) + var(--sp-l)) var(--sp-2xl) 0;
  }
  .explore-logo {
    font-size: 22px;
  }
  .explore-selected-tags {
    padding-bottom: var(--sp-m);
  }
  .tag-filter {
    padding: 10px 20px;
    font-size: 15px;
  }
  .explore-feed {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--sp-l) var(--sp-l);
    padding: var(--sp-l) var(--sp-2xl) calc(var(--tab-height) + 120px);
  }
  .explore-card {
    min-height: 260px;
  }
  .card-media {
    height: 155px;
  }
  .card-content {
    margin-top: 142px;
    padding: var(--sp-l);
    gap: 8px;
    min-height: 118px;
  }
  .card-name {
    font-size: 20px;
  }
  .card-tagline {
    font-size: 14px;
    -webkit-line-clamp: 3;
  }
  .card-tag {
    font-size: 12px;
    padding: 5px 10px;
  }
  .card-stats {
    font-size: 12px;
  }
  .explore-tooltip {
    font-size: 15px;
    padding: 14px 24px;
    border-radius: var(--r-l);
  }
}

/* ──────────── Tags page ──────────── */
@media (min-width: 768px) {
  /* Center intro + grid inside the flex:1 region only. Never use min-height:100% here — it sizes
     against #page-tags (full viewport) and pushes .tags-page-footer (Continue) below the clip. */
  .tags-page-scroll {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    box-sizing: border-box;
    padding: max(var(--sp-xl), var(--sc-safe-top)) var(--sp-2xl) var(--sp-l);
  }
  .tags-intro {
    max-width: 36rem;
    margin-bottom: var(--sp-2xl);
  }
  .tags-intro-title {
    font-size: 32px;
  }
  .tags-intro-sub {
    font-size: 17px;
  }
  .tags-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px 16px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
  }
  #page-tags .tag-chip {
    min-height: 56px;
    padding: 14px 18px;
    font-size: 15px;
    gap: 12px;
  }
  .tags-page-footer {
    padding: var(--sp-l) var(--sp-2xl) max(var(--sp-2xl), calc(var(--sc-safe-bottom) + var(--sp-m)));
  }
  .tags-page-footer .btn-primary {
    max-width: 400px;
    margin: 0 auto;
  }
  .tags-counter {
    font-size: 14px;
  }
}

/* ──────────── Detail page ──────────── */
@media (min-width: 1024px) {
  .explore-feed {
    grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  }
  .tags-grid {
    max-width: 56rem;
  }
}

@media (min-width: 768px) {
  .detail-hero {
    height: 48vh;
  }
  .detail-body {
    padding: 0 var(--sp-2xl) calc(var(--tab-height) + 36px);
    max-width: min(900px, calc(100% - 32px));
    margin-left: auto;
    margin-right: auto;
  }
  .detail-name {
    font-size: 34px;
  }
  .detail-creator {
    font-size: 15px;
  }
  .detail-tag {
    font-size: 13px;
    padding: 5px 14px;
  }
  .detail-tagline {
    font-size: 18px;
    line-height: 1.6;
  }
  .detail-greeting {
    font-size: 17px;
    padding: var(--sp-xl) var(--sp-xl) var(--sp-xl) var(--sp-2xl);
    line-height: 1.7;
  }
  .detail-stats {
    font-size: 14px;
  }
  .detail-cta .btn-primary {
    max-width: min(480px, 92vw);
    margin: 0 auto;
  }
}

@media (orientation: landscape) and (min-width: 768px) {
  .detail-hero {
    height: clamp(220px, 48vh, 520px);
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .detail-hero {
    height: min(42vh, 300px);
  }
}

/* ──────────── Chat page ──────────── */
@media (min-width: 768px) {
  .chat-nav {
    padding: calc(var(--sc-safe-top) + var(--sp-m)) var(--sp-2xl) var(--sp-m);
  }
  .chat-nav-name {
    font-size: 18px;
  }
  .chat-nav-status {
    font-size: 13px;
  }
  .chat-avatar {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
  .energy-bar {
    font-size: 14px;
    padding: var(--sp-m) var(--sp-2xl);
    gap: var(--sp-m);
  }
  .energy-progress {
    width: 80px;
  }
  .chat-messages {
    padding: var(--sp-xl) var(--sp-2xl) var(--sp-l);
    gap: var(--sp-l);
    max-width: min(880px, calc(100% - 24px));
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
  }
  .msg-row {
    max-width: min(760px, 92%);
  }
  .msg-row .avatar-gradient {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  .msg-bubble {
    padding: var(--sp-l) var(--sp-xl);
    font-size: 17px;
    line-height: 1.55;
    border-radius: 20px;
  }
  .msg-row.ai .msg-bubble {
    border-bottom-left-radius: 6px;
  }
  .msg-row.user .msg-bubble {
    border-bottom-right-radius: 6px;
  }
  .msg-time {
    font-size: 12px;
  }
  .typing-dots {
    padding: 16px 20px;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
  }
  .typing-dot {
    width: 8px;
    height: 8px;
  }
  .chat-input-area {
    padding: var(--sp-m) var(--sp-2xl);
    max-width: min(880px, calc(100% - 24px));
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
  }
  .chat-input {
    min-height: 48px;
    padding: 12px 20px;
    font-size: 17px;
    border-radius: 16px;
    max-height: 140px;
  }
  .chat-send {
    width: 48px;
    height: 48px;
  }
  .regenerate-btn {
    font-size: 13px;
    padding: 10px 16px;
    min-height: 36px;
  }
}

/* ──────────── Chats list page ──────────── */
@media (min-width: 768px) {
  #page-chats {
    align-items: stretch;
  }
  #page-chats .navbar {
    width: 100%;
  }
  #page-chats .page-content {
    width: 100%;
    max-width: min(960px, calc(100% - var(--sp-2xl) * 2));
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--sp-2xl);
    padding-right: var(--sp-2xl);
  }
  .chat-list-item {
    padding: var(--sp-l) var(--sp-m);
    gap: var(--sp-l);
  }
  .chat-list-item .avatar-gradient {
    width: 48px;
    height: 48px;
  }
  .chat-list-name {
    font-size: 17px;
  }
  .chat-list-last {
    font-size: 15px;
  }
  .chat-list-time {
    font-size: 13px;
  }
  /* Use width for preview; JS sends longer text on wide viewports. */
  .chat-list-last {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    line-height: 1.4;
    word-break: break-word;
  }
}

/* ──────────── Profile page ──────────── */
@media (min-width: 768px) {
  #page-profile {
    align-items: stretch;
  }
  #page-profile .navbar {
    width: 100%;
  }
  #page-profile .page-content {
    width: 100%;
    max-width: min(960px, calc(100% - var(--sp-2xl) * 2));
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--sp-2xl);
    padding-right: var(--sp-2xl);
  }
  .profile-header {
    padding: calc(var(--sc-safe-top) + var(--sp-2xl)) var(--sp-2xl) var(--sp-2xl);
  }
  .profile-avatar {
    width: 76px;
    height: 76px;
    font-size: 30px;
  }
  .profile-name {
    font-size: 24px;
  }
  .profile-handle {
    font-size: 16px;
  }
  .profile-section {
    padding: 0 var(--sp-2xl);
    margin-bottom: var(--sp-2xl);
  }
  .section-title {
    font-size: 14px;
    letter-spacing: 0.6px;
  }
  .recent-chats-row {
    gap: var(--sp-xl);
  }
  .recent-chat-item .avatar-gradient {
    width: 68px;
    height: 68px;
    font-size: 24px;
  }
  .recent-chat-item span {
    font-size: 13px;
  }
  .subscription-card {
    padding: var(--sp-2xl);
    border-radius: var(--r-xl);
  }
  .sub-energy {
    font-size: 18px;
  }
  .btn-upgrade {
    height: 48px;
    font-size: 16px;
  }
  .btn-restore {
    font-size: 14px;
  }
  .settings-list {
    padding: 0 var(--sp-2xl);
  }
  .settings-item {
    font-size: 17px;
    min-height: 52px;
    padding: var(--sp-xl) 0;
  }
}

/* ──────────── Creator page ──────────── */
@media (min-width: 768px) {
  .creator-form {
    padding: var(--sp-2xl);
    max-width: min(960px, calc(100% - var(--sp-2xl) * 2));
    margin: 0 auto;
  }
  .form-label {
    font-size: 15px;
  }
  .form-input, .form-textarea {
    font-size: 17px;
    padding: 16px 18px;
    border-radius: var(--r-l);
  }
  .form-textarea {
    min-height: 100px;
  }
  .avatar-upload {
    width: 120px;
    height: 120px;
    font-size: 28px;
  }
  .visibility-toggle {
    gap: var(--sp-l);
  }
  .vis-option {
    padding: var(--sp-l);
    font-size: 15px;
  }
}

/* ──────────── Tab bar ──────────── */
@media (min-width: 768px) {
  .tab-bar {
    padding: 6px 0 0;
    /* Optional: center the tabs for wider screens */
    justify-content: center;
    gap: 0;
  }
  .tab-item {
    flex: 0 1 120px;
    font-size: 11px;
    min-height: 48px;
    padding: 6px 0 4px;
  }
  .tab-icon svg {
    width: 25px;
    height: 25px;
  }
  .tab-label {
    font-size: 12px;
  }
}

/* ──────────── Navbar ──────────── */
@media (min-width: 768px) {
  .navbar {
    min-height: calc(var(--nav-height) + var(--sc-safe-top) + 6px);
    padding: var(--sc-safe-top) var(--sp-2xl) 0;
  }
  .navbar-title {
    font-size: 19px;
  }
}

/* ──────────── Splash page ──────────── */
@media (min-width: 768px) {
  .splash-orb-1 { width: 280px; height: 280px; }
  .splash-orb-2 { width: 220px; height: 220px; }
  .splash-orb-3 { width: 180px; height: 180px; }
  .splash-logo {
    width: 100px;
    height: 100px;
    border-radius: 26px;
  }
  .splash-logo svg {
    width: 48px;
    height: 48px;
  }
  .splash-title {
    font-size: 36px;
    margin-top: var(--sp-2xl);
  }
  .splash-subtitle {
    font-size: 18px;
  }
  .splash-loader {
    width: 80px;
  }
}

/* ──────────── Paywall / Sheets ──────────── */
@media (min-width: 768px) {
  .half-sheet {
    max-width: min(560px, calc(100vw - var(--sc-safe-left) - var(--sc-safe-right) - 16px));
    padding: var(--sp-xl) var(--sp-2xl) var(--sp-3xl);
    border-radius: var(--r-3xl) var(--r-3xl) 0 0;
  }
  .sheet-title {
    font-size: 22px;
  }
  .sheet-handle {
    margin-bottom: var(--sp-2xl);
  }
  .paywall-plans {
    gap: 16px;
    padding: 0;
  }
  .paywall-plan {
    padding: 24px 18px;
    border-radius: 20px;
  }
  .plan-badge {
    font-size: 11px;
  }
  .plan-name {
    font-size: 17px;
  }
  .plan-price {
    font-size: 26px;
  }
  .plan-price span {
    font-size: 14px;
  }
  .plan-detail {
    font-size: 12px;
    margin-top: 6px;
  }
  .sheet-legal {
    font-size: 12px;
  }
  .btn-subscribe,
  .half-sheet .btn-primary {
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
  }
  /* Action sheet / menu sheet */
  .half-sheet-compact {
    padding-bottom: 48px;
  }
  .sheet-options {
    gap: var(--sp-l);
  }
  .btn-secondary {
    height: 52px;
    font-size: 16px;
  }
}

/* ──────────── Vibe check card ──────────── */
@media (min-width: 768px) {
  .vibe-card {
    width: 380px;
    padding: 40px 32px;
    border-radius: 28px;
  }
  .vibe-card-emoji {
    font-size: 68px;
    margin-bottom: 16px;
  }
  .vibe-card-title {
    font-size: 26px;
  }
  .vibe-card-sub {
    font-size: 14px;
  }
  .vibe-card-dismiss {
    padding: 12px 32px;
    font-size: 15px;
  }
}

/* ──────────── Empty states ──────────── */
@media (min-width: 768px) {
  .empty-state {
    padding: var(--sp-3xl) var(--sp-2xl);
  }
  .empty-icon {
    width: 100px;
    height: 100px;
    border-radius: var(--r-3xl);
  }
  .empty-icon svg {
    width: 40px;
    height: 40px;
  }
  .empty-title {
    font-size: 22px;
  }
  .empty-desc {
    font-size: 17px;
    max-width: 360px;
  }
  .empty-state .btn-primary {
    max-width: 300px;
  }
}

/* ──────────── Confirm dialog ──────────── */
@media (min-width: 768px) {
  .confirm-desc {
    font-size: 16px;
    margin-bottom: 28px;
  }
}

/* ──────────── Toast ──────────── */
@media (min-width: 768px) {
  .toast {
    font-size: 15px;
    padding: 14px 24px;
    border-radius: var(--r-l);
  }
}
