:root {
  --blue: #007AFF;
  --gray-bubble: #E5E5EA;
  --gray-text: #8E8E93;
  --hairline: #C6C6C8;
  --bg: #ffffff;
  --header-bg: rgba(247, 247, 247, 0.92);
  --composer-bg: rgba(247, 247, 247, 0.92);
  --text: #000000;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blue: #0A84FF;
    --gray-bubble: #2C2C2E;
    --gray-text: #8E8E93;
    --hairline: #38383A;
    --bg: #000000;
    --header-bg: rgba(28, 28, 30, 0.92);
    --composer-bg: rgba(28, 28, 30, 0.92);
    --text: #FFFFFF;
  }
}

* { box-sizing: border-box; }

html {
  height: 100%;
  overflow: hidden;
}
body {
  /* position:fixed inset:0 is the bulletproof iOS PWA pin: iOS can't
   * shift the layout viewport up to put a focused input above the
   * keyboard, because the body itself isn't in normal flow and has
   * nowhere to scroll. The earlier `overflow: hidden` alone wasn't
   * enough — iOS would still translate the entire layout viewport up,
   * dragging the sticky header off the screen. JS sizes #app to
   * visualViewport.height so the composer naturally sits above the
   * keyboard without needing iOS to scroll anything. */
  position: fixed;
  inset: 0;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 700px;
  margin: 0 auto;
  background: var(--bg);
}

/* ---------- Header ---------- */

#header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 50px 1fr 50px;
  align-items: center;
  height: calc(64px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--hairline);
}
#header .back {
  font-size: 28px;
  color: var(--blue);
  text-align: center;
  cursor: pointer;
  user-select: none;
  background: transparent;
  border: none;
  padding: 0;
  font-family: inherit;
  line-height: 1;
}
#header .back:active { opacity: 0.5; }
#header .name-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
#header .header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gray-bubble);
}
#header .name {
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}
#header .info {
  font-size: 14px;
  color: var(--blue);
  background: transparent;
  text-align: center;
  border: 1.5px solid var(--blue);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  line-height: 19px;
  justify-self: center;
  font-family: Georgia, serif;
  font-style: italic;
  user-select: none;
  padding: 0;
  cursor: pointer;
}
#header .info:active { opacity: 0.5; }

/* ---------- Messages ---------- */

#messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

/* Each rendered chat message lives in a .message-line wrapper so the swipe
 * gesture can shift bubble + revealed timestamp in unison. The msg-time
 * sits 60px past the right edge by default (clipped by #messages overflow-x)
 * and slides into view when --swipe-x is set. */
.message-line {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  transition: transform 0.2s ease;
  flex: 0 0 auto;
}
.message-line.user { justify-content: flex-end; }
.message-line.claire { justify-content: flex-start; }
.msg-time {
  position: absolute;
  right: -76px;
  top: 50%;
  transform: translateY(-50%);
  width: 64px;
  font-size: 10px;
  color: var(--gray-text);
  white-space: nowrap;
  pointer-events: none;
  text-align: left;
}
#messages.swiping > * {
  transform: translateX(var(--swipe-x, 0));
  transition: none;
}

.separator {
  text-align: center;
  font-size: 11px;
  color: var(--gray-text);
  margin: 16px 0 6px;
  font-weight: 500;
}
.separator .day { font-weight: 600; }

.bubble {
  max-width: 75%;
  padding: 8px 13px;
  border-radius: 18px;
  margin-top: 2px;
  font-size: 16px;
  line-height: 1.32;
  word-wrap: break-word;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.bubble.first-in-group { margin-top: 8px; }

.bubble.user {
  background: var(--blue);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}
.bubble.user.not-last-in-group {
  border-bottom-right-radius: 18px;
}

.bubble.claire {
  background: var(--gray-bubble);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}
.bubble.claire.not-last-in-group {
  border-bottom-left-radius: 18px;
}

/* Photo bubble (Claire-sent photos, §7a). When a Claire bubble has an
 * attached photo, the <img> sits at the top of the bubble (rounded to
 * match) and the optional caption text sits below in the same bubble.
 * If there's no caption (.photo-only), strip the bubble padding so the
 * image fills edge-to-edge inside the bubble shape. */
.bubble.with-photo {
  padding: 4px 4px 4px 4px;
  max-width: 75%;
  overflow: hidden;
}
.bubble.with-photo.photo-only {
  padding: 0;
}
.bubble-photo {
  display: block;
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: 14px;
  cursor: zoom-in;
  background: var(--gray-bubble);
}
.bubble.with-photo.photo-only .bubble-photo {
  border-radius: 16px;
}
.bubble-caption {
  padding: 6px 9px 4px;
  font-size: 16px;
  line-height: 1.32;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Photo lightbox: full-screen black overlay with the photo centered,
 * tap anywhere to dismiss. */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
          env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.photo-lightbox.hidden { display: none; }
.photo-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-out;
}

/* Typing indicator: three-dot bubble shown ~2s before Claire's reply lands.
 * Same shape and color as a Claire bubble so it visually previews the
 * incoming message. Lives in a .message-line so swipe gestures play nicely. */
.bubble.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  min-height: 28px;
}
.typing-bubble .typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gray-text);
  opacity: 0.45;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-bubble .typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-bubble .typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.45; }
  30%          { transform: translateY(-3px); opacity: 0.9; }
}

/* ---------- Composer ---------- */

#composer-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--composer-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--hairline);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.composer-wrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

#composer {
  flex: 1;
  min-height: 36px;
  max-height: 140px;
  padding: 8px 12px;
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.3;
  resize: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#composer:focus {
  border-color: var(--blue);
}

#send {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.15s, transform 0.1s;
}
#send:disabled {
  opacity: 0.3;
  cursor: default;
}
#send:active:not(:disabled) {
  transform: scale(0.9);
}

/* ---------- Auth modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--bg);
  padding: 22px 20px 18px;
  border-radius: 14px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.modal-card h2 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  text-align: center;
}
.modal-card input {
  padding: 11px 12px;
  border: 1px solid var(--hairline);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.modal-card input:focus {
  border-color: var(--blue);
}
.modal-card button {
  padding: 11px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}
.modal-card button:active { transform: scale(0.98); }

/* ---------- Upcoming-dates panel (left-sliding) ---------- */
/* Borrows the info-panel chrome but slides in from the left so the
 * iMessage back-arrow affordance reads correctly. Lists rows pulled
 * from /scheduled-dates/upcoming. */
.upcoming-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.25s ease;
  max-width: 700px;
  margin: 0 auto;
}
.upcoming-panel.hidden {
  transform: translateX(-100%);
  pointer-events: none;
}
.upcoming-row {
  background: var(--gray-bubble);
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.upcoming-row .upcoming-scenario {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
.upcoming-row .upcoming-when {
  font-size: 14px;
  color: var(--blue);
}
.upcoming-row .upcoming-where {
  font-size: 13px;
  color: var(--gray-text);
}
.upcoming-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--gray-text);
  font-size: 15px;
  line-height: 1.5;
}

/* iPhone-Calendar-style month grid + day view inside the upcoming-panel. */
.upcoming-month-view, .upcoming-day-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.upcoming-day-view.hidden { display: none; }
.upcoming-month-view.hidden { display: none; }

.cal-month-header, .cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
  gap: 12px;
}
.cal-month-label, .cal-day-label {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.cal-nav-btn {
  background: transparent;
  border: none;
  color: var(--blue);
  font-size: 28px;
  line-height: 1;
  padding: 4px 12px;
  cursor: pointer;
}
.cal-nav-btn:active { opacity: 0.5; }
.cal-nav {
  width: 44px;  /* spacer so the day-label centers */
}

.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 8px 8px 4px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  padding: 4px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.cal-day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 0 4px;
  font-size: 18px;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  min-height: 52px;
}
.cal-day-cell.dim {
  color: rgba(0,0,0,0.25);  /* days outside the current month */
  cursor: default;
  pointer-events: none;     /* inert: don't open another month's day */
}
.cal-day-cell.today .cal-day-number {
  background: var(--blue);
  color: white;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.cal-day-cell.selected:not(.today) .cal-day-number {
  background: rgba(0, 122, 255, 0.15);
  color: var(--blue);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.cal-day-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  margin-top: 4px;
}
.cal-event-dot.completed { background: var(--gray-text); }

/* Day view: scrollable hourly timeline. */
.cal-day-timeline {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 24px;
  position: relative;
}
.cal-hour-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  min-height: 56px;
  border-top: 1px solid rgba(0,0,0,0.06);
  position: relative;
}
.cal-hour-row:first-child { border-top: none; }
.cal-hour-label {
  font-size: 12px;
  color: var(--gray-text);
  padding-top: 2px;
}
.cal-hour-slot {
  position: relative;
  border-left: 1px solid rgba(0,0,0,0.06);
  padding-left: 8px;
}
.cal-day-event {
  background: rgba(0, 122, 255, 0.12);
  border-left: 3px solid var(--blue);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 4px 6px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-day-event.past {
  background: rgba(0,0,0,0.06);
  border-left-color: var(--gray-text);
  opacity: 0.85;
}
.cal-day-event .cal-event-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.cal-day-event .cal-event-time {
  font-size: 12px;
  color: var(--gray-text);
}
.cal-day-event .cal-event-status {
  font-size: 11px;
  color: var(--gray-text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.upcoming-start-btn {
  margin-top: 8px;
  align-self: stretch;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.upcoming-start-btn:disabled {
  background: var(--gray-bubble);
  color: var(--gray-text);
  cursor: not-allowed;
}
.upcoming-start-btn.ready {
  background: var(--blue);
  color: white;
}
.cal-day-empty {
  text-align: center;
  color: var(--gray-text);
  padding: 32px 16px;
  font-size: 14px;
}

/* ---------- Info panel (chat info-pane aesthetic) ---------- */

.info-panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateX(0);
  transition: transform 0.25s ease;
  max-width: 700px;
  margin: 0 auto;
}
.info-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.info-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 60px 1fr 60px;
  align-items: center;
  height: calc(44px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--hairline);
}
.info-nav {
  background: transparent;
  border: none;
  color: var(--blue);
  font-family: inherit;
  font-size: 17px;
  cursor: pointer;
  padding: 0 14px;
  text-align: left;
}
.info-nav-close {
  text-align: right;
  font-weight: 600;
}
.info-nav#info-back { font-size: 28px; line-height: 1; }
.info-nav:active { opacity: 0.5; }
.info-nav[hidden],
.info-nav.is-hidden { visibility: hidden; }
.info-title {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}

.info-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.info-tier.hidden { display: none; }

.info-tier h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-text);
  margin: 22px 4px 6px;
}

.info-avatar-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.info-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gray-bubble);
}
.info-tier-name {
  color: var(--gray-text);
  font-size: 15px;
  margin-left: 8px;
}

.info-card {
  background: var(--gray-bubble);
  padding: 12px 14px;
  border-radius: 12px;
}
.info-primary {
  font-size: 17px;
  color: var(--text);
  line-height: 1.3;
}
.info-secondary {
  font-size: 14px;
  color: var(--gray-text);
  margin-top: 4px;
}
.info-of {
  color: var(--gray-text);
  font-size: 15px;
}

.info-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 22px;
  background: var(--gray-bubble);
  border: none;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--blue);
  font-family: inherit;
  font-size: 17px;
  text-align: left;
  cursor: pointer;
}
.info-more:active { opacity: 0.6; }
.info-chevron {
  color: var(--gray-text);
  font-size: 20px;
  line-height: 1;
}

#info-milestones-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.milestone-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--gray-bubble);
  border-radius: 12px;
  gap: 12px;
}
.milestone-label {
  font-size: 15px;
  color: var(--text);
}
.milestone-date {
  font-size: 13px;
  color: var(--gray-text);
  white-space: nowrap;
}
.info-empty {
  padding: 12px 14px;
  font-size: 14px;
  color: var(--gray-text);
  text-align: center;
}

/* ---------- DEV MODE indicator ---------- */
/* Tiny orange chip pinned over the header, visible only when the
 * relationship is at TESTING_LEVEL (100+). Driven by `body.dev-mode`,
 * which app.js toggles after polling /state. Out-of-app toggle: Andrew
 * tells Claude "developer mode" and Claude calls /admin/testing-mode. */
.dev-badge {
  display: none;
  position: absolute;
  top: calc(env(safe-area-inset-top) + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #ff9500;
  color: white;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 2px 10px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 11;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}
body.dev-mode .dev-badge { display: block; }

/* ---------- Date Mode (full-screen overlay, VN layout) ---------- */

.date-mode {
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: hidden;
  color: white;
  opacity: 1;
}
.date-mode.hidden { display: none; }
/* crossfade in/out of Date Mode (texting ↔ Date Mode), 800ms */
.date-mode.fading {
  transition: opacity 800ms ease;
}

/* Background: Replicate FLUX-generated photographic location per scenario.
 * JS sets background-image on this element from session.scenario.background_url.
 * Falls back to a warm gradient when no URL is set (asset not yet generated).
 * Two-layer crossfade: the .date-bg-incoming layer rides above this one and
 * fades from 0→1 during dissolves; on completion JS copies the new image
 * onto this base and resets the incoming layer. */
.date-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, #2a2422 0%, #3a2f2a 35%, #44342c 70%, #1c1612 100%);
  background-size: cover;
  background-position: center;
}
.date-bg-incoming {
  z-index: 1;
  background: transparent;
  opacity: 0;
  pointer-events: none;
}

/* H-scene CG: full-screen overlay above the bg, below the panel.
 * Hidden by default (no src) and revealed when session.current_mode is
 * 'h_scene' or 'h_scene_after'. Same two-layer model as the bg:
 * .date-cg-incoming fades up over the base for the cg variant dissolve
 * (500ms) and the slow during→after dissolve (1200ms). */
.date-cg {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
}
.date-cg.visible { opacity: 1; }
.date-cg:not([src]),
.date-cg[src=""]   { display: none; }
.date-cg-incoming {
  z-index: 3;
  opacity: 0;
}

/* v2 sprite layer: transparent-PNG Claire over the bg. Element fills
 * the container; object-fit:contain scales the image to fit while
 * preserving the natural aspect ratio. object-position bottom-center
 * keeps her feet on the floor.
 *
 * Previous rule used `height: 100%; width: auto; max-width: 100%`,
 * which stretched the image vertically whenever the sprite's
 * natural width-at-full-viewport-height exceeded the viewport width. */
.date-sprite {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Lift slightly above the bottom: object-position controls where
   * the contain-fit image sits inside the element box. 100% = flush
   * with bottom (feet behind panel); 75% = bottom of image is 25%
   * of the leftover vertical slack above the element bottom. Lift
   * amount scales with each sprite's natural aspect ratio. */
  object-position: 50% 60%;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.date-sprite.visible { opacity: 1; }
.date-sprite:not([src]),
.date-sprite[src=""] { display: none; }
/* Incoming sprite layer: stacks above the base at the same position,
   starts invisible. JS crossfade animates opacity 0->1 then promotes
   the src down to the base and resets this layer. */
.date-sprite-incoming {
  z-index: 3;
  opacity: 0;
}

/* Vignette layer: comes up alongside cg_during in the slow_iris_to_h_scene
 * transition. Soft radial darkening at the corners to frame the intimate
 * moment. Hidden by default; toggled by JS during h_scene transitions. */
.date-vignette {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 30%,
    rgba(0, 0, 0, 0.35) 70%,
    rgba(0, 0, 0, 0.75) 100%
  );
}
.date-vignette.visible { opacity: 1; }

/* Blackout layer: full-screen black, hidden by default. JS animates its
 * opacity for the slow_iris_to_h_scene fade-to-black phase (600ms),
 * the iris-out fade-up phase (1500ms), and the fade_to_black exit on
 * H-Scene → Date and mode-close paths (1000ms). Sits above everything
 * including the panel and log overlay so it cleanly covers visual state
 * changes happening underneath. */
.date-blackout {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

/* Sprite deferred to v2; scene area is background-only in v1. */

/* Top controls (log + end). Float top-right over the scene.
 * z-index sits above panel (5) so it stays tappable. */
.date-top {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 6;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 0;
  display: flex;
  gap: 6px;
}
.date-top-btn,
.date-end {
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 6px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.date-top-btn:active,
.date-end:active { opacity: 0.7; }

/* Kinetic "preparing" overlay: black fullscreen with a slow pulse +
 * three dots. Shown while the kinetic scene LLM call is running in
 * the background (~30-60s). z-index above everything except blackout. */
.kinetic-preparing {
  position: absolute;
  inset: 0;
  z-index: 18;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.kinetic-preparing.hidden {
  display: none;
}
.kinetic-preparing-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(233, 184, 224, 0.6);
  animation: kinetic-preparing-pulse 1.8s ease-in-out infinite;
}
.kinetic-preparing-text {
  color: rgba(255, 255, 255, 0.5);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  letter-spacing: 0.4em;
  animation: kinetic-preparing-pulse 1.8s ease-in-out infinite;
}
@keyframes kinetic-preparing-pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50%      { opacity: 0.9; transform: scale(1.15); }
}

/* Kinetic STOP control: hidden in normal Date Mode; visible only when
 * a kinetic scene is in progress. Different color so it reads as the
 * "abort" affordance, not a regular nav button. */
.date-stop {
  /* Compact square stop icon, not a big red text button (Andrew 2026-05-31). */
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 10px;
}
.date-stop svg {
  width: 15px;
  height: 15px;
  display: block;
}
.date-stop.hidden { display: none; }

/* Kinetic mode marker on body: lets us hide the End button while
 * kinetic is in progress (End is part of the post-aftercare Date Mode
 * flow; during kinetic the STOP control is the only exit). */
body.kinetic-active #date-end { display: none; }
/* No user input during a kinetic h-scene (it is pure tap-to-advance): hide the
 * whole composer so there is no send button or "say something" box. 2026-05-31. */
body.kinetic-active .date-composer-wrap { display: none; }
/* Pre-rendered h-scene: the clip IS the whole surface. Hide the text panel,
 * vignette, and sprite layers, and lift the video above the panel. 2026-05-31. */
body.prerender-active .date-panel,
body.prerender-active .date-vignette,
body.prerender-active #date-sprite,
body.prerender-active #date-sprite-incoming { display: none !important; }
body.prerender-active #hscene-video { z-index: 50 !important; }

/* Fade-in / fade-out transitions at scene start + end. Driven by JS
 * adding a class on #date-mode for ~1.5s while the opacity goes
 * 0 → 1 (in) or 1 → 0 (out). */
#date-mode.kinetic-fading-in {
  animation: kinetic-fade-in 1500ms ease forwards;
}
#date-mode.kinetic-fading-out {
  animation: kinetic-fade-out 900ms ease forwards;
}
@keyframes kinetic-fade-in {
  0%   { opacity: 0; }
  20%  { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes kinetic-fade-out {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Mute toggle: same shape as the other date-top buttons, just an icon
 * instead of a label. .muted swaps the icon to a struck-through note. */
.date-mute {
  min-width: 38px;
  padding: 6px 10px;
}
.date-mute .date-mute-icon {
  font-size: 16px;
  line-height: 1;
  font-family: -apple-system, "SF Pro Text", "Segoe UI Symbol", system-ui, sans-serif;
}
.date-mute.muted .date-mute-icon {
  opacity: 0.55;
}

/* Log overlay: full-screen scrollable transcript of the current date
 * session. Read-only; no compose, no send. Tap "back" returns to live. */
.date-log {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(8, 8, 14, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  color: white;
}
.date-log.hidden { display: none; }
.date-log-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.35);
}
.date-log-back {
  background: transparent;
  color: #e9b8e0;
  border: none;
  font: inherit;
  font-size: 15px;
  padding: 4px 0;
  cursor: pointer;
}
.date-log-back:active { opacity: 0.6; }
.date-log-title {
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.7);
}
.date-log-spacer { width: 80px; }
.date-log-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.55;
}
.date-log-line {
  margin: 0 0 14px 0;
}
.date-log-line.user {
  color: rgba(255, 255, 255, 0.55);
  font-style: italic;
  font-size: 14px;
  border-left: 2px solid rgba(255, 255, 255, 0.2);
  padding-left: 10px;
}
.date-log-line.claire-dialogue {
  color: #ffffff;
}
.date-log-line.claire-action {
  color: rgba(255, 255, 255, 0.78);
  font-style: italic;
}
.date-log-name {
  display: block;
  color: #e9b8e0;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  margin-bottom: 2px;
}
.date-log-empty {
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
  text-align: center;
  padding-top: 40px;
}

/* VN-style text panel: bottom-anchored, translucent dark, light text.
 * z-index sits above the vignette layer (4) so dialogue stays readable
 * through the radial darkening during h_scene framing. */
.date-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  background: rgba(12, 12, 22, 0.78);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 22px 22px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 28vh;
}

/* Name pill: floats over the top-left edge of the panel, slightly overlapping. */
.date-name-pill {
  position: absolute;
  top: -14px;
  left: 22px;
  background: rgba(40, 36, 60, 0.95);
  color: #e9b8e0;                /* soft pink-lavender, TLoL-ish */
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 4px 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.date-name-pill.user { color: #b5d4ff; }
.date-name-pill.hidden { display: none; }

.date-line {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.55;
  color: #ffffff;
  min-height: 52px;
  max-height: 16vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.date-line.action {
  font-style: italic;
  color: rgba(255, 255, 255, 0.82);
}
.date-line.empty {
  font-style: italic;
  color: rgba(255, 255, 255, 0.4);
}

.date-composer-wrap {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-top: auto;
  /* No transition: keep this in sync with the iOS keyboard animation,
   * which doesn't expose timing. A separate CSS transition would
   * desync visibly. */
}
/* When the keyboard is up, the composer bar is translated UP into the
 * area above the keyboard and OUT of the dialogue panel's background.
 * It needs its own bar styling (bg + blur + offset to overflow the
 * panel's side padding) so it doesn't read as a floating pill over
 * the sprite/bg. */
.date-composer-wrap.keyboard-up {
  background: rgba(12, 12, 22, 0.92);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
  padding: 8px 22px calc(8px + env(safe-area-inset-bottom));
  margin: 0 -22px 0;  /* cancel panel side-padding to make bar full-width */
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
#date-composer {
  flex: 1;
  min-height: 36px;
  max-height: 120px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.3;
  resize: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#date-composer:focus { border-color: rgba(10, 132, 255, 0.8); }
#date-composer::placeholder { color: rgba(255, 255, 255, 0.4); }
#date-composer:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.08);
}
.date-send {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--blue);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.date-send:disabled { opacity: 0.3; cursor: default; }
.date-send:active:not(:disabled) { transform: scale(0.9); }

/* ---------- Outbound message status ---------- */

.status {
  align-self: flex-end;
  margin-top: 2px;
  margin-right: 4px;
  font-size: 11px;
  color: var(--gray-text);
  letter-spacing: 0.01em;
  min-height: 14px;
}
.status.failed { color: #FF3B30; }
.status.failed::before { content: "! "; font-weight: 700; }

/* ---------- Notification banner ---------- */

.notif-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--header-bg);
  border-bottom: 0.5px solid var(--hairline);
  font-size: 13px;
}
.notif-banner.hidden { display: none; }
.notif-banner span { flex: 1; color: var(--text); }
.notif-banner button {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
}
.notif-banner button#notif-dismiss {
  background: transparent;
  color: var(--gray-text);
  font-size: 20px;
  padding: 4px 8px;
  font-weight: 400;
  line-height: 1;
}

/* ===== Phase 4: H-Scene video playback ===== */
.hscene-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; z-index: 3;
}
.hscene-subs {
  position: absolute; left: 0; right: 0; bottom: 14%;
  text-align: center; padding: 0 8%; z-index: 7; pointer-events: none;
}
.hscene-subs span {
  display: inline; background: rgba(0,0,0,0.55); color: #fff;
  padding: 0.25em 0.5em; border-radius: 6px; font-size: 16px; line-height: 1.5;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.hscene-gate {
  position: absolute; inset: 0; z-index: 8; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; background: rgba(0,0,0,0.42); padding: 8%;
}
.hscene-gate-q {
  color: #fff; font-style: italic; font-size: 20px; text-align: center;
  text-shadow: 0 1px 6px #000;
}
.hscene-gate-form { display: flex; gap: 8px; width: 100%; max-width: 320px; }
.hscene-gate-form input {
  flex: 1; padding: 10px 14px; border-radius: 18px; font: inherit;
  border: 1px solid rgba(255,255,255,0.4); background: rgba(255,255,255,0.12);
  color: #fff;
}
.hscene-gate-form button {
  padding: 10px 16px; border-radius: 18px; border: 0; background: #fff;
  color: #000; font: inherit;
}
/* hide the kinetic text panel while video plays; keep STOP tappable on top */
.date-panel.hscene-video-mode { visibility: hidden; }
.kinetic-active #kinetic-stop { z-index: 20; }
/* Video-only pivot REVERTED (2026-05-31): H-scenes are kinetic text again.
   The #hscene-video / #hscene-subs elements carry a `hidden` class in markup
   but nothing in CSS backed it, so the opaque black .hscene-video (inset:0,
   z-index:3) painted over the background AND swallowed taps on the scene area
   (its tap handler no-ops when video isn't active), leaving a black screen
   that wouldn't advance. Hide them so the kinetic beats play over the bg. */
.hscene-video.hidden,
.hscene-subs.hidden { display: none; }
/* iOS Safari only synthesizes a `click` from a tap on a non-interactive
   element (plain div / img) when that element has cursor:pointer. The H-scene
   tap-to-advance targets are bare divs/imgs, so without this iOS swallows the
   tap and the scene never advances (the click handler is correct; the click
   event just never fires). Scope to kinetic playback. (2026-05-31) */
body.kinetic-active .date-mode,
body.kinetic-active .date-bg,
body.kinetic-active .date-sprite,
body.kinetic-active .date-panel { cursor: pointer; }
