/* ==========================================================================
   PixelMind · Dream Storybook — Desktop PC Web UI Design System
   Aesthetic: Luminous Lake v2 (Twilight Indigo, Warm Parchment, Dawn Gold)
   Breakpoints: 1440px (Primary Desktop), 1280px (Laptop), <=1024px (Compact)
   ========================================================================== */

:root {
  /* Palette */
  --sky-top: #040B2D;
  --deep-ink: #070C26;
  --rail-bg: rgba(7, 11, 34, 0.78);
  --surface-1: rgba(16, 22, 56, 0.66);
  --surface-2: rgba(22, 29, 70, 0.74);
  --surface-elevated: rgba(14, 19, 49, 0.88);
  --glass-bg: linear-gradient(158deg, rgba(22, 28, 68, 0.72), rgba(10, 14, 40, 0.88));

  /* Borders & Hairlines */
  --border-subtle: rgba(255, 224, 188, 0.11);
  --border-warm: rgba(255, 224, 188, 0.22);
  --border-strong: rgba(255, 227, 188, 0.42);

  /* Ink */
  --text-main: #F7F1E8;
  --text-body: #EAE4DA;
  --text-sub: #C8CBE4;
  --text-muted: #8E95BF;

  /* Accents */
  --gold-bright: #FFE3BC;
  --gold-warm: #F8BA85;
  --rose-dawn: #F0937E;
  --violet-mist: #9D8DF1;
  --danger-soft: #F3A69B;

  /* Typography — English Literary Editorial */
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;

  /* Layout */
  --rail-width: 268px;
  --topbar-height: 58px;
  --content-max: 1040px;
  --composer-max: 760px;

  /* Radii & Shadows */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --shadow-card: 0 24px 64px rgba(2, 5, 20, 0.56), inset 0 1px 0 rgba(255, 232, 200, 0.14);
  --shadow-soft: 0 12px 32px rgba(2, 5, 20, 0.36);

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

[hidden] {
  display: none !important;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--sky-top);
  color: var(--text-main);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, textarea, select, a {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible,
[role="tab"]:focus-visible,
[tabindex="0"]:focus-visible {
  outline: 2px solid #FFE2B8;
  outline-offset: 2px;
}

/* ==========================================================================
   Desktop Application Shell (Left Rail + Atmospheric Lake Stage)
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--deep-ink);
  position: relative;
}

/* ---------- Left Persistent Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  background: var(--rail-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border-subtle);
  z-index: 20;
  overflow-y: auto;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 224, 188, 0.08);
  margin-bottom: 14px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: radial-gradient(circle at 30% 28%, #FFE3BC 0%, #F0937E 48%, #282B6B 100%);
  box-shadow: 0 0 20px rgba(248, 186, 133, 0.28), inset 0 1px 2px rgba(255, 255, 255, 0.45);
  position: relative;
  flex-shrink: 0;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  border: 1.5px solid rgba(7, 12, 38, 0.45);
}

.brand-text {
  min-width: 0;
}

.brand-eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-warm);
  line-height: 1.2;
}

.brand-title {
  display: block;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-main);
  margin-top: 2px;
}

/* Primary Navigation */
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-sub);
  border: 1px solid transparent;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 227, 188, 0.06);
  color: var(--text-main);
}

.nav-item[aria-current="page"] {
  background: linear-gradient(135deg, rgba(248, 186, 133, 0.16), rgba(157, 141, 241, 0.1));
  border-color: rgba(255, 224, 188, 0.22);
  color: var(--gold-bright);
}

.nav-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 227, 188, 0.1);
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

/* Sidebar Drafts & Recent Lists */
.sidebar-section {
  margin-bottom: 18px;
}

.sidebar-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 8px;
}

.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar-action {
  font-size: 12px;
  color: var(--gold-warm);
  padding: 2px 7px;
  border-radius: 7px;
  transition: background 0.18s ease, color 0.18s ease;
}

.sidebar-action:hover {
  background: rgba(248, 186, 133, 0.14);
  color: var(--gold-bright);
}

.mini-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-item {
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 11px;
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.mini-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 224, 188, 0.1);
}

.mini-item.is-active {
  background: rgba(255, 227, 188, 0.08);
  border-color: rgba(255, 224, 188, 0.22);
}

.mini-item-top {
  display: flex;
  align-items: center;
  gap: 7px;
}

.draft-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-warm);
  box-shadow: 0 0 8px rgba(248, 186, 133, 0.75);
  flex-shrink: 0;
}

.story-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--violet-mist);
  opacity: 0.8;
  flex-shrink: 0;
}

.mini-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-item-meta {
  display: block;
  margin-top: 2px;
  padding-left: 13px;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 224, 188, 0.08);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ambient-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-sub);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ambient-toggle:hover {
  background: rgba(255, 227, 188, 0.07);
  border-color: var(--border-warm);
  color: var(--text-main);
}

.ambient-toggle img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.ambient-state {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

.ambient-toggle[aria-pressed="true"] .ambient-state {
  color: var(--gold-bright);
}

.local-privacy-note {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.privacy-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7FD1B9;
  opacity: 0.85;
  flex-shrink: 0;
}

/* ==========================================================================
   Main Atmospheric Stage
   ========================================================================== */
.main-stage {
  position: relative;
  min-height: 100vh;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
}

.stage-backdrop {
  position: fixed;
  top: 0;
  left: var(--rail-width);
  right: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: var(--sky-top);
}

.lake-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 44%;
  transform: scale(1.02);
  filter: brightness(0.68) saturate(1.06);
  transition: transform 0.9s var(--ease-out), filter 0.85s ease;
}

.main-stage[data-capture-state="speaking"] .lake-photo {
  object-position: center 68%;
  transform: scale(1.03);
  filter: brightness(0.98) saturate(1.12);
}

.main-stage[data-capture-state="paused"] .lake-photo {
  object-position: center 68%;
  transform: scale(1.02);
  filter: brightness(0.88) saturate(1.04);
}

.main-stage[data-view="story"] .lake-photo,
.main-stage[data-view="storybook"] .lake-photo,
.main-stage[data-view="map"] .lake-photo {
  transform: scale(1.05);
  filter: brightness(0.46) saturate(0.92) blur(4px);
}

.lake-aura {
  position: absolute;
  inset: -8%;
  background:
    radial-gradient(circle at 22% 24%, rgba(140, 122, 236, 0.22) 0%, transparent 46%),
    radial-gradient(circle at 78% 36%, rgba(246, 166, 134, 0.18) 0%, transparent 48%),
    radial-gradient(circle at 52% 82%, rgba(255, 206, 152, 0.12) 0%, transparent 44%);
  animation: auraBreathe 10s ease-in-out infinite alternate;
}

@keyframes auraBreathe {
  0% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.04) translateY(-8px); }
  100% { opacity: 0.68; transform: scale(1.01) translateY(4px); }
}

.lake-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(4, 11, 45, 0.52) 0%, rgba(4, 11, 45, 0.22) 38%, rgba(4, 9, 32, 0.72) 100%);
  transition: opacity 0.6s ease;
}

.main-stage[data-capture-state="speaking"] .lake-veil,
.main-stage[data-capture-state="paused"] .lake-veil {
  background:
    linear-gradient(180deg, rgba(4, 11, 45, 0.34) 0%, rgba(4, 11, 45, 0.08) 42%, rgba(4, 9, 32, 0.78) 100%);
}

/* ---------- Top Context Bar ---------- */
.stage-topbar {
  position: relative;
  z-index: 10;
  height: var(--topbar-height);
  padding: 0 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 224, 188, 0.06);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-sub);
}

.topbar-sep {
  opacity: 0.4;
}

.autosave-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: rgba(10, 15, 42, 0.56);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-sub);
}

.autosave-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-warm);
}

/* ---------- View Container ---------- */
.stage-body {
  position: relative;
  z-index: 10;
  flex: 1;
  width: 100%;
  max-width: calc(var(--content-max) + 72px);
  margin: 0 auto;
  padding: 28px 36px 56px;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   VIEW 1: RECORD DREAM (Capture & Draft Workspace)
   ========================================================================== */
.capture-hero {
  text-align: center;
  max-width: 740px;
  margin: 4px auto 24px;
  transition: opacity 0.4s ease, transform 0.5s var(--ease-out);
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-warm);
  margin-bottom: 10px;
}

.hero-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 2.5vw, 35px);
  font-weight: 500;
  line-height: 1.24;
  letter-spacing: -0.01em;
  text-wrap: balance;
  color: var(--text-main);
  text-shadow: 0 4px 24px rgba(4, 11, 45, 0.55);
}

.hero-subtitle {
  margin: 10px 0 0;
  font-size: 15px;
  color: var(--text-sub);
}

/* Flowing-Rim Unified Composer Card */
.composer-wrap {
  position: relative;
  width: 100%;
  max-width: var(--composer-max);
  margin: 0 auto 38px;
  border-radius: calc(var(--radius-lg) + 1.5px);
  padding: 1.5px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: opacity 0.4s ease, transform 0.5s var(--ease-out);
}

.composer-wrap::before {
  content: "";
  position: absolute;
  inset: -120%;
  background: conic-gradient(
    from 0deg,
    rgba(255, 227, 188, 0.08) 0deg,
    rgba(255, 227, 188, 0.56) 42deg,
    rgba(240, 147, 126, 0.45) 84deg,
    rgba(157, 141, 241, 0.34) 136deg,
    rgba(255, 227, 188, 0.08) 195deg,
    rgba(255, 227, 188, 0.08) 360deg
  );
  animation: rimSpin 14s linear infinite;
  z-index: 0;
}

@keyframes rimSpin {
  to { transform: rotate(360deg); }
}

.composer-card {
  position: relative;
  z-index: 1;
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 20px 24px 22px;
  display: flex;
  flex-direction: column;
  min-height: 332px; /* Locks footer CTA Y-position across Voice & Write tabs */
}

.composer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

/* Segmented Mode Switch */
.mode-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: rgba(5, 9, 30, 0.65);
  border: 1px solid var(--border-subtle);
}

.mode-btn {
  padding: 7px 18px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-sub);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.mode-btn[aria-selected="true"] {
  background: linear-gradient(135deg, rgba(255, 227, 188, 0.22), rgba(240, 147, 126, 0.18));
  color: var(--gold-bright);
  box-shadow: inset 0 1px 0 rgba(255, 244, 226, 0.24);
}

.composer-draft-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.text-link-btn {
  font-size: 12.5px;
  color: var(--text-sub);
  padding: 4px 9px;
  border-radius: 8px;
  transition: background 0.18s ease, color 0.18s ease;
}

.text-link-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--gold-bright);
}

/* Fixed-Height Composer Body (Zero Jump Between Voice & Write) */
.composer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 204px;
}

/* Voice Idle Pane */
.voice-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 0 6px;
}

.orb-button {
  position: relative;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform 0.28s var(--ease-out);
}

.orb-button::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(248, 186, 133, 0.34) 0%, rgba(240, 147, 126, 0.12) 48%, transparent 72%);
  animation: orbHalo 4.2s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes orbHalo {
  0% { transform: scale(0.94); opacity: 0.72; }
  100% { transform: scale(1.08); opacity: 1; }
}

.orb-button:hover {
  transform: scale(1.045);
}

.orb-button:active {
  transform: scale(0.97);
}

.orb-button img {
  position: relative;
  z-index: 1;
  width: 104px;
  height: 104px;
  object-fit: contain;
  filter: drop-shadow(0 12px 26px rgba(240, 147, 126, 0.32));
}

.voice-prompt {
  margin: 14px 0 4px;
  font-family: var(--serif);
  font-size: 19px;
  color: var(--text-main);
}

.voice-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-warm);
  background: rgba(255, 255, 255, 0.05);
  font-size: 11px;
  color: var(--gold-bright);
  vertical-align: 1px;
}

/* Write / Draft Pane */
.write-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dream-textarea {
  width: 100%;
  min-height: 158px;
  resize: vertical;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(5, 9, 30, 0.52);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 15.5px;
  line-height: 1.72;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dream-textarea::placeholder {
  color: rgba(176, 183, 218, 0.54);
}

.dream-textarea:focus {
  border-color: rgba(255, 227, 188, 0.36);
  background: rgba(5, 9, 30, 0.68);
}

.write-helpers {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.prompt-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.prompt-chip {
  font-size: 12px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  background: rgba(255, 227, 188, 0.06);
  border: 1px solid rgba(255, 227, 188, 0.14);
  color: var(--text-sub);
  transition: background 0.18s ease, color 0.18s ease;
}

.prompt-chip:hover {
  background: rgba(255, 227, 188, 0.14);
  color: var(--gold-bright);
}

.word-count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Post-Record Draft Pane */
.recorded-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audio-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(5, 9, 30, 0.62);
  border: 1px solid var(--border-warm);
}

.play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 227, 188, 0.12);
  flex-shrink: 0;
  transition: background 0.18s ease, transform 0.18s ease;
}

.play-btn:hover {
  background: rgba(255, 227, 188, 0.22);
  transform: scale(1.04);
}

.play-btn img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.audio-track {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.audio-track-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.audio-progress {
  height: 5px;
  border-radius: var(--radius-pill);
  background: rgba(255, 227, 188, 0.14);
  overflow: hidden;
}

.audio-progress-fill {
  width: 38%;
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--gold-warm), var(--rose-dawn));
}

.dream-textarea.compact {
  min-height: 114px;
}

/* Composer Footer (Pinned to identical vertical slot across modes) */
.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid rgba(255, 224, 188, 0.09);
}

.tone-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tone-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 2px;
}

.tone-pill {
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  color: var(--text-sub);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.18s ease;
}

.tone-pill:hover {
  border-color: var(--border-warm);
  color: var(--text-main);
}

.tone-pill[aria-pressed="true"] {
  background: rgba(255, 227, 188, 0.14);
  border-color: rgba(255, 227, 188, 0.34);
  color: var(--gold-bright);
}

.cta-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-secondary {
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.btn-secondary:hover {
  background: rgba(255, 227, 188, 0.09);
  border-color: var(--border-warm);
  color: var(--text-main);
}

.btn-primary {
  padding: 10px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  color: #161028;
  background: linear-gradient(135deg, #FFE6C4 0%, #F8BA85 52%, #F0937E 100%);
  box-shadow: 0 8px 24px rgba(240, 147, 126, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transition: transform 0.2s var(--ease-out), filter 0.2s ease, opacity 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* ---------- Full-Lake Immersive Recording Stage ---------- */
.recording-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: calc(100vh - var(--topbar-height) - 96px);
  padding-top: 56px;
  text-align: center;
}

.recording-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.rec-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  background: rgba(7, 12, 38, 0.62);
  border: 1px solid rgba(255, 227, 188, 0.24);
  font-size: 12.5px;
  color: var(--gold-bright);
  backdrop-filter: blur(12px);
}

.rec-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rose-dawn);
  box-shadow: 0 0 10px var(--rose-dawn);
  animation: recPulse 1.4s ease-in-out infinite;
}

@keyframes recPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.75); }
}

.rec-timer {
  font-family: var(--serif);
  font-size: 52px;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.04em;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 6px 28px rgba(4, 11, 45, 0.72);
}

.rec-wave {
  width: min(460px, 82vw);
  height: 54px;
  margin: 4px 0 12px;
}

.rec-controls {
  display: flex;
  align-items: center;
  gap: 24px;
}

.rec-stop-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: transform 0.22s var(--ease-out);
}

.rec-stop-btn:hover {
  transform: scale(1.05);
}

.rec-stop-btn img {
  width: 94px;
  height: 94px;
  object-fit: contain;
  filter: drop-shadow(0 12px 26px rgba(240, 147, 126, 0.42));
}

.rec-side-btn {
  min-width: 96px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: rgba(10, 15, 42, 0.72);
  border: 1px solid var(--border-warm);
  backdrop-filter: blur(14px);
  font-size: 13.5px;
  color: var(--text-main);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.rec-side-btn:hover {
  background: rgba(255, 227, 188, 0.14);
  border-color: var(--border-strong);
}

/* ---------- Style Examples Gallery (3-up Desktop Row) ---------- */
.examples-section {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  color: var(--text-main);
}

.section-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.example-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(12, 17, 44, 0.72);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  transition: transform 0.28s var(--ease-out), border-color 0.24s ease, box-shadow 0.28s ease;
}

.example-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-warm);
  box-shadow: 0 18px 42px rgba(2, 5, 20, 0.56);
}

.example-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #0B1133;
}

.example-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s var(--ease-out);
}

.example-card:hover .example-thumb img {
  transform: scale(1.03);
}

.example-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(7, 12, 38, 0.72);
  border: 1px solid rgba(255, 227, 188, 0.22);
  backdrop-filter: blur(8px);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
}

.example-body {
  padding: 14px 16px 16px;
}

.example-name {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-main);
}

.example-quote {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-sub);
  font-style: italic;
}

/* ==========================================================================
   VIEW 2: STORY EDITORIAL READING VIEW (2-Column Desktop Spread)
   ========================================================================== */
.story-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: rgba(14, 19, 49, 0.72);
  border: 1px solid var(--border-subtle);
  font-size: 13.5px;
  color: var(--text-sub);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.back-btn:hover {
  background: rgba(255, 227, 188, 0.1);
  border-color: var(--border-warm);
  color: var(--text-main);
}

.back-btn img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.story-spread {
  display: grid;
  grid-template-columns: minmax(320px, 44%) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

.story-art-col {
  position: sticky;
  top: 24px;
}

.art-frame {
  border-radius: 22px;
  overflow: hidden;
  background: rgba(12, 17, 44, 0.8);
  border: 1px solid var(--border-warm);
  box-shadow: var(--shadow-card);
}

.art-frame img.story-artwork {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.art-caption-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 224, 188, 0.08);
}

.art-placeholder {
  position: relative;
  aspect-ratio: 4 / 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  background: linear-gradient(180deg, rgba(16, 22, 56, 0.7), rgba(7, 12, 38, 0.92)), url('art/story-header-v2.jpg') center/cover no-repeat;
}

.art-placeholder img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  margin-bottom: 12px;
  opacity: 0.92;
}

.art-placeholder h3 {
  margin: 0 0 6px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-main);
}

.art-placeholder p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-sub);
  max-width: 280px;
}

/* Literary Reading Column */
.story-read-col {
  background: rgba(11, 16, 44, 0.68);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  padding: 34px 38px 32px;
  box-shadow: var(--shadow-soft);
}

.story-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--gold-warm);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.story-title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  line-height: 1.2;
  color: var(--text-main);
}

.story-epigraph {
  margin: 0 0 24px;
  padding-left: 14px;
  border-left: 2px solid rgba(248, 186, 133, 0.45);
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--gold-bright);
  opacity: 0.92;
}

.story-prose {
  max-width: 60ch;
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--text-body);
}

.story-prose p {
  margin: 0 0 18px;
}

.story-prose p:last-child {
  margin-bottom: 0;
}

.story-disclosures {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 224, 188, 0.1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.disclosure {
  border-radius: 14px;
  background: rgba(5, 9, 30, 0.46);
  border: 1px solid var(--border-subtle);
  padding: 12px 16px;
}

.disclosure summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-sub);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.disclosure summary::after {
  content: "+";
  font-size: 16px;
  color: var(--gold-warm);
}

.disclosure[open] summary::after {
  content: "−";
}

.disclosure-body {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-sub);
}

.motif-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.motif-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: rgba(255, 227, 188, 0.08);
  border: 1px solid rgba(255, 227, 188, 0.18);
  font-size: 12.5px;
  color: var(--gold-bright);
}

.story-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   VIEW 3: STORYBOOK ARCHIVE (Stories & Drafts Grid)
   ========================================================================== */
.view-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.view-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  color: var(--text-main);
}

.view-subtitle {
  margin: 6px 0 0;
  font-size: 14.5px;
  color: var(--text-sub);
}

.archive-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.filter-pills {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: rgba(8, 13, 38, 0.72);
  border: 1px solid var(--border-subtle);
}

.filter-pill {
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-sub);
  transition: all 0.18s ease;
}

.filter-pill[aria-pressed="true"] {
  background: rgba(255, 227, 188, 0.16);
  color: var(--gold-bright);
}

.search-input {
  width: 280px;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  background: rgba(8, 13, 38, 0.72);
  border: 1px solid var(--border-subtle);
  font-size: 13.5px;
  color: var(--text-main);
}

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

.archive-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.entry-card {
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(13, 18, 48, 0.76);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  transition: transform 0.24s var(--ease-out), border-color 0.2s ease;
}

.entry-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-warm);
}

.entry-card.is-draft {
  border-style: dashed;
  border-color: rgba(248, 186, 133, 0.34);
  background: rgba(18, 22, 54, 0.68);
}

.entry-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(32, 40, 92, 0.8), rgba(10, 14, 40, 0.94));
}

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

.entry-cover-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  background: radial-gradient(circle at 75% 24%, rgba(248, 186, 133, 0.22), transparent 55%),
              linear-gradient(160deg, rgba(24, 30, 74, 0.88), rgba(8, 12, 36, 0.96));
}

.entry-status-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  background: rgba(7, 12, 38, 0.78);
  border: 1px solid rgba(255, 227, 188, 0.24);
  color: var(--gold-bright);
}

.entry-body {
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.entry-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.entry-title {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--text-main);
}

.entry-excerpt {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.58;
  color: var(--text-sub);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.entry-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 224, 188, 0.08);
}

/* ==========================================================================
   VIEW 4: DREAM MAP (Recurring Symbols)
   ========================================================================== */
.map-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 18px 20px;
  border-radius: 16px;
  background: rgba(12, 17, 46, 0.72);
  border: 1px solid var(--border-subtle);
}

.stat-value {
  font-family: var(--serif);
  font-size: 28px;
  color: var(--gold-bright);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-sub);
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.map-column {
  padding: 22px;
  border-radius: 18px;
  background: rgba(12, 17, 46, 0.76);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

.map-col-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.star-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 12px var(--gold-warm);
}

.map-col-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 500;
  color: var(--text-main);
}

.map-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.map-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  background: rgba(255, 227, 188, 0.07);
  border: 1px solid rgba(255, 227, 188, 0.16);
  font-size: 13.5px;
  color: var(--text-main);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.map-pill:hover,
.map-pill[aria-pressed="true"] {
  background: rgba(255, 227, 188, 0.18);
  border-color: var(--border-strong);
  color: var(--gold-bright);
}

.map-pill-count {
  font-size: 11.5px;
  color: var(--gold-warm);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   MODAL LIGHTBOX (Style Example Preview)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(3, 6, 22, 0.78);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 28px;
}

.modal-card {
  width: min(860px, 94vw);
  border-radius: 24px;
  overflow: hidden;
  background: var(--surface-elevated);
  border: 1px solid var(--border-warm);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.65);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}

.modal-art img {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
  display: block;
}

.modal-content {
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  font-size: 18px;
  display: grid;
  place-items: center;
}

.modal-close:hover {
  background: rgba(255, 227, 188, 0.14);
  color: var(--text-main);
}

.modal-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 500;
}

.modal-story {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-body);
  margin: 0 0 18px;
}

/* ==========================================================================
   DESIGN REVIEW BAR (Optional, hidden when ?clean=1)
   ========================================================================== */
.design-bar {
  position: fixed;
  right: 18px;
  bottom: 16px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: rgba(5, 9, 30, 0.88);
  border: 1px solid var(--border-warm);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  font-size: 11.5px;
}

.design-bar-label {
  color: var(--gold-warm);
  font-weight: 600;
  padding: 0 6px 0 4px;
}

.design-bar button {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  color: var(--text-sub);
  font-size: 11.5px;
}

.design-bar button:hover,
.design-bar button.is-on {
  background: rgba(255, 227, 188, 0.18);
  color: var(--gold-bright);
}

body.clean-mode .design-bar,
body.clean-mode #btn-toggle-art-state {
  display: none !important;
}

/* ==========================================================================
   Responsive Breakpoints (1280px Laptop & <=1024px Compact)
   ========================================================================== */
@media (max-width: 1320px) {
  :root {
    --rail-width: 248px;
  }
  .stage-topbar {
    padding: 0 28px;
  }
  .stage-body {
    padding: 24px 28px 48px;
  }
  .story-spread {
    gap: 28px;
  }
  .story-read-col {
    padding: 28px 30px;
  }
}

@media (max-width: 1060px) {
  .examples-grid,
  .archive-grid,
  .map-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .story-spread {
    grid-template-columns: 1fr;
  }
  .story-art-col {
    position: static;
  }
  .modal-card {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .lake-aura,
  .composer-wrap::before,
  .orb-button::before,
  .rec-pulse {
    animation: none !important;
  }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}
