:root {
  color-scheme: dark;
  --bg: #141114;
  --surface: #211b20;
  --text: #f4edef;
  --muted: #bfb0b8;
  --accent: #edb2c6;
  --line: #51434c;
  --radius: 20px;
}
* { box-sizing: border-box; }
html { scrollbar-color: var(--accent) #342b32; scrollbar-width: thin; }
body { margin: 0; height: 100vh; height: 100dvh; min-height: 620px; display: grid; grid-template-rows: auto minmax(0,1fr); background: var(--bg); color: var(--text); font-family: 'DM Sans', Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button, select { font: inherit; }
button { cursor: pointer; }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.skip { position: absolute; top: -100px; left: 20px; padding: 15px; background: var(--surface); z-index: 200; }
.skip:focus { top: 12px; }
main { width: 100%; max-width: 1560px; margin: 0 auto; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; padding: 0 clamp(20px,4vw,64px) 28px; }
.intro { display: flex; align-items: center; justify-content: center; gap: 20px; padding: 16px 0; }
.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; }
.experience-actions { display: grid; grid-template-columns: minmax(0,1fr) 144px minmax(0,1fr); align-items: center; gap: 14px; width: min(100%, 1120px); margin-inline: auto; }
.ad-slot { display: grid; place-items: center; min-width: 0; height: 100px; padding: 12px; border: 2px dashed #a47b8d; border-radius: 14px; background: #251c25; color: #e9cbd5; text-align: center; }
.ad-slot:first-child { grid-column: 1; }
.ad-slot:last-child { grid-column: 3; }
.ad-slot span { max-width: 160px; font: 600 12px/1.35 'DM Sans', Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase; text-shadow: 0 2px 8px #000; }
#closeFilters, .photo-reveal { border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 12px; min-height: 44px; padding: 11px 16px; }
#closeFilters:hover, .photo-reveal:hover { background: #342b32; }
.workspace { min-height: 0; position: relative; }
.preferences-tab { position: fixed; z-index: 121; top: 50%; left: 0; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; gap: 6px; width: 126px; height: 56px; padding: 8px; border: 1px solid var(--line); border-left: 0; border-radius: 0 14px 14px 0; background: #251e24; color: var(--text); box-shadow: 5px 8px 24px #0007; transition: left 300ms cubic-bezier(.2,.8,.2,1), background 180ms ease; }
.preferences-tab svg { flex: none; transition: transform 220ms ease; }
.preferences-tab-label { font-size: 13px; font-weight: 600; }
.preferences-tab:hover, .preferences-tab[aria-expanded=true] { background: #342b32; }
.filters-open .preferences-tab { left: min(340px, calc(100vw - 48px)); }
.filters-open .preferences-tab svg { transform: rotate(180deg); }
.filter-backdrop { position: fixed; inset: 0; z-index: 119; width: 100%; height: 100%; padding: 0; border: 0; background: #100b10b8; cursor: default; }
.filter-backdrop[hidden] { display: none; }
.filter-drawer { position: fixed; top: 0; left: 0; width: min(340px, calc(100vw - 48px)); height: 100vh; height: 100dvh; z-index: 120; visibility: hidden; transform: translateX(-100%); transition: transform 300ms cubic-bezier(.2,.8,.2,1), visibility 300ms; }
.filters-open .filter-drawer { visibility: visible; transform: translateX(0); }
#filterPanel { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); background: #251e24; border: 1px solid var(--line); border-left: 0; border-radius: 0; box-shadow: 12px 8px 48px #0008; scrollbar-width: thin; scrollbar-color: var(--accent) #342b32; }
#filterPanel::-webkit-scrollbar, .mood-picker .pov-options::-webkit-scrollbar, #storyContent::-webkit-scrollbar, .reading .story::-webkit-scrollbar { width: 8px; }
#filterPanel::-webkit-scrollbar-track, .mood-picker .pov-options::-webkit-scrollbar-track, #storyContent::-webkit-scrollbar-track, .reading .story::-webkit-scrollbar-track { background: #342b32; }
#filterPanel::-webkit-scrollbar-thumb, .mood-picker .pov-options::-webkit-scrollbar-thumb, #storyContent::-webkit-scrollbar-thumb, .reading .story::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 8px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-heading h2 { font: 400 28px Georgia,serif; margin: 0; }
#closeFilters { width: 44px; padding: 10px; display: grid; place-items: center; }
.filters { display: grid; gap: 24px; margin-top: 28px; }
.filter-action { position: sticky; bottom: calc(-1 * max(24px, env(safe-area-inset-bottom))); z-index: 6; display: grid; gap: 10px; margin: 0 -24px calc(-1 * max(24px, env(safe-area-inset-bottom))); padding: 16px 24px max(24px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #251e24; box-shadow: 0 -12px 24px #0004; }
.filter-action p { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
.filter-action button { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 48px; padding: 10px 16px; border: 1px solid #f2c3d3; border-radius: 12px; background: #edb2c6; color: #26131f; font-weight: 700; }
.filter-action button:hover:not(:disabled) { background: #f6c8d8; }
.filter-action button:disabled { opacity: .55; cursor: wait; }
.filter-field { display: grid; gap: 10px; }
.filter-label { font-size: 13px; font-weight: 500; color: var(--text); }
.filter-select { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid #765763; border-radius: 12px; background: #322633; color: var(--text); cursor: pointer; }
.filter-select:hover, .filter-select:focus-visible { border-color: var(--accent); }
.filter-select:disabled { opacity: .55; cursor: wait; }
.filter-select option { background: #251e24; color: var(--text); }
.photo-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid #765763; border-radius: 12px; background: #221b24; }
.photo-mode-switch button:last-child { grid-column: 1 / -1; }
.photo-mode-switch button { min-height: 48px; padding: 8px 6px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; line-height: 1.25; }
.photo-mode-switch button[aria-pressed="true"] { background: #44303e; color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.photo-mode-switch button:hover:not(:disabled) { color: var(--text); background: #493140; }
.photo-mode-switch button:disabled { opacity: .45; cursor: not-allowed; }
.intensity-field { gap: 6px; padding: 16px; border: 1px solid #765763; border-radius: 14px; background: linear-gradient(135deg, #3a2935, #221b24 78%); }
.intensity-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.intensity-heading output { color: var(--accent); font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 600; }
.intensity-field input[type="range"] { appearance: none; -webkit-appearance: none; width: 100%; height: 44px; margin: 0; background: transparent; cursor: pointer; accent-color: var(--accent); }
.intensity-field input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 8px; background: linear-gradient(90deg, #edb2c6, #b64c77); }
.intensity-field input[type="range"]::-moz-range-track { height: 8px; border-radius: 8px; background: linear-gradient(90deg, #edb2c6, #b64c77); }
.intensity-field input[type="range"]::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px; border: 3px solid #f8e4ea; border-radius: 50%; background: #a8416b; box-shadow: 0 2px 12px #0009, 0 0 0 4px #edb2c633; }
.intensity-field input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 3px solid #f8e4ea; border-radius: 50%; background: #a8416b; box-shadow: 0 2px 12px #0009, 0 0 0 4px #edb2c633; }
.intensity-field input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.intensity-field input[type="range"]:disabled { opacity: .55; cursor: wait; }
.intensity-ends { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; color: var(--muted); }
.custom-setting input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid #765763; border-radius: 12px; background: #322633; color: var(--text); font: inherit; }
.custom-setting input::placeholder { color: var(--muted); }
.custom-setting input:hover, .custom-setting input:focus-visible { border-color: var(--accent); }
.custom-setting input:focus-visible, .surprise-setting:focus-visible, .pov-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.custom-setting input:disabled { opacity: .55; cursor: wait; }
.surprise-setting { display: flex; align-items: center; justify-content: space-between; min-height: 44px; width: 100%; padding: 9px 14px; border: 1px solid #765763; border-radius: 12px; background: #322633; color: var(--text); font: inherit; font-size: 13px; text-align: left; transition: border-color 180ms ease, background 180ms ease; }
.surprise-setting svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.surprise-setting:hover, .surprise-setting[aria-pressed="true"] { border-color: var(--accent); background: #44303e; }
.surprise-setting:disabled { opacity: .55; cursor: wait; }
.pov-picker { position: relative; }
.pov-trigger { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 70px; padding: 12px 15px 12px 18px; border: 1px solid #765763; border-radius: 14px; background: linear-gradient(135deg, #3a2935, #221b24 78%); box-shadow: inset 0 1px #ffffff16, 0 10px 24px #0003; color: var(--text); text-align: left; transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease; }
.pov-trigger::before { content: ""; align-self: stretch; width: 3px; flex: none; border-radius: 3px; background: var(--accent); }
.pov-trigger:hover, .pov-trigger[aria-expanded="true"] { border-color: var(--accent); background: linear-gradient(135deg, #44303e, #29202a 78%); }
.pov-trigger:disabled { opacity: .55; cursor: wait; }
.pov-trigger[aria-expanded="true"] { box-shadow: 0 0 0 3px #edb2c622, 0 10px 24px #0004; }
.pov-trigger-copy { display: grid; flex: 1; gap: 2px; min-width: 0; }
.pov-trigger-kicker { color: var(--accent); font-size: 9px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; }
.pov-trigger-value { font-size: 14px; font-weight: 600; line-height: 1.3; }
.pov-trigger-value span { color: var(--muted); font-weight: 400; }
.pov-trigger svg { width: 20px; height: 20px; flex: none; color: var(--accent); transition: transform 200ms cubic-bezier(.2,.8,.2,1); }
.pov-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.pov-options { position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 5; display: grid; gap: 5px; padding: 6px; border: 1px solid #765763; border-radius: 15px; background: #241b24; box-shadow: 0 20px 42px #0009, inset 0 1px #ffffff12; opacity: 0; transform: translateY(-8px) scale(.98); transform-origin: top center; pointer-events: none; transition: opacity 200ms ease, transform 240ms cubic-bezier(.2,.8,.2,1); }
.pov-options[hidden] { display: none; }
.pov-options.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.mood-picker .pov-options { position: static; max-height: min(360px, 48dvh); margin-top: 8px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--accent) #342b32; }
.pov-option { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 10px 12px; border-radius: 10px; color: var(--text); cursor: pointer; outline: none; transition: background 150ms ease, transform 150ms ease; }
.pov-option:hover, .pov-option:focus-visible { background: #493140; transform: translateX(2px); }
.pov-option[aria-selected="true"] { background: #382a36; }
.pov-option:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.pov-option-number { color: var(--accent); font: 400 24px Georgia, serif; }
.pov-option-copy { display: grid; gap: 2px; flex: 1; }
.pov-option-copy strong { font-size: 13px; font-weight: 600; }
.pov-option-copy small { color: var(--muted); font-size: 11px; }
.pov-option-check { color: var(--accent); font-size: 16px; opacity: 0; transform: scale(.6); transition: opacity 150ms ease, transform 150ms ease; }
.pov-option[aria-selected="true"] .pov-option-check { opacity: 1; transform: scale(1); }
.filter-help { font-size: 12px; line-height: 1.65; color: var(--muted); margin: 12px 0 0; }
.filters .filter-help { margin: 0; }
.reading { position: relative; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0; width: min(100%,1280px); height: 100%; min-height: 0; min-width: 0; margin-inline: auto; border: 0; }
figure { margin: 0; width: 100%; height: 100%; min-width: 0; min-height: 0; position: relative; overflow: hidden; border-radius: var(--radius) 0 0 var(--radius); background: transparent; }
figure img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; transform-origin: center; transition: transform 260ms cubic-bezier(.2,.8,.2,1); }
@media (hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference) { .reading:not(.is-pending) figure:hover img { transform: scale(1.025); } }
.is-pending figure img { filter: brightness(.68) saturate(.8); }
.story { position: relative; background: var(--surface); border: 0; border-radius: 0 var(--radius) var(--radius) 0; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto auto; padding: clamp(24px,3vw,44px); gap: 16px; }
.meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 10px; letter-spacing: .6px; }
.badge { display: inline-flex; align-items: center; gap: 7px; color: var(--accent); font-size: 11px; letter-spacing: 0; }
#storyContent { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--accent) #342b32; padding: 4px 12px 10px 4px; scroll-padding: 8px; }
#storyContent:focus-visible, #storyTitle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chapter { font-size: 10px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); margin: 8px 0 18px; }
.story h2 { font: 400 clamp(30px,3vw,44px)/1.12 Georgia,serif; letter-spacing: -.9px; margin: 0 0 28px; text-wrap: balance; }
.story-credit { margin: -18px 0 24px; color: var(--accent); font-size: 12px; font-weight: 600; letter-spacing: .08em; }
#storyBody p { font: 18px/1.85 Georgia,serif; color: #e2d7dd; margin: 0 0 24px; }
#storyBody p:last-child { margin-bottom: 0; }
.story #storyBody .story-retry { color: var(--text); font: 400 clamp(21px,2.3vw,27px)/1.4 Georgia,serif; }
.story-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; }
#listenStory { min-height: 44px; border: 1px solid var(--accent); border-radius: 12px; background: transparent; color: var(--text); padding: 10px 16px; font-size: 13px; }
#listenStory:hover:not(:disabled) { background: #342b32; }
#listenStory:disabled { opacity: .6; cursor: wait; }
.playback-speed { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.playback-speed[hidden] { display: none; }
.playback-speed select { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #322633; color: var(--text); cursor: pointer; }
.playback-speed select:hover, .playback-speed select:focus-visible { border-color: var(--accent); }
.playback-speed select option { background: #251e24; color: var(--text); }
#voiceStatus { flex-basis: 100%; }
#nextStory { position: relative; grid-column: 2; display: grid; place-items: center; width: 144px; height: 126px; padding: 0; border: 0; background: transparent; color: #351725; text-align: center; isolation: isolate; -webkit-tap-highlight-color: transparent; }
#nextStory[hidden] { display: none; }
.story-button-heart { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 8px 0 #6b2b49) drop-shadow(0 16px 17px #0009); transition: transform 280ms cubic-bezier(.2,.8,.2,1), filter 280ms ease; }
.heart-halo { fill: #f6b9cf; opacity: .18; stroke: #ffcfe0; stroke-width: 5; }
.heart-body { fill: url(#storyHeartFill); stroke: #ffe3e8; stroke-width: 2; }
.heart-sheen { opacity: .75; }
.heart-glint, .heart-glint-dot { fill: #ffe7ec; }
.story-button-label { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; text-shadow: 0 1px 0 #fff6; }
.story-button-kicker { font: 700 10px/1.2 'DM Sans', Arial, sans-serif; letter-spacing: .13em; padding-left: .13em; }
.story-button-title { font: italic 600 21px/1.04 'Palatino Linotype', 'Book Antiqua', Palatino, Georgia, serif; letter-spacing: -.045em; white-space: pre-line; }
#nextStory:hover .story-button-heart, #nextStory:focus-visible .story-button-heart { transform: translateY(-4px) scale(1.04); filter: drop-shadow(0 11px 0 #6b2b49) drop-shadow(0 22px 24px #000b); }
#nextStory:active .story-button-heart { transform: translateY(2px) scale(.98); filter: drop-shadow(0 4px 0 #6b2b49) drop-shadow(0 8px 10px #0008); }
#nextStory[aria-disabled=true] { cursor: wait; }
.story-heart-art { transform-box: fill-box; transform-origin: center; animation: story-heart-pulse 1.25s ease-in-out infinite; }
@keyframes story-heart-pulse { 0%, 100% { transform: scale(.94); } 50% { transform: scale(1.08); } }
.status { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 0; }
#storyStatus:empty { display: none; }
#storyStatus { max-height: 64px; overflow: auto; }
.photo-reveal { display: none; }
.photo-reveal svg { width: 20px; height: 20px; flex: none; }
@media(max-width:1000px) { .story { padding: 24px; } }
/* Let portrait screens scroll as one vertical page. */
@media(max-width:700px) {
  body { height: auto; min-height: 100vh; min-height: 100dvh; display: block; }
  main { display: flex; flex-direction: column; gap: 14px; padding: 0 max(16px,env(safe-area-inset-right)) max(88px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left)); }
  .intro { display: block; padding: 8px 0 0; }
  .experience-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
  #nextStory { order: -1; align-self: center; width: 132px; height: 114px; }
  .ad-slot { width: 100%; height: 56px; padding: 6px; border-radius: 10px; }
  .ad-slot span { max-width: none; font-size: 10px; letter-spacing: .07em; }
  .photo-reveal { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; margin: 0; font-size: 14px; }
  .workspace { min-height: 0; }
  .reading { display: flex; flex-direction: column; height: auto; min-height: 0; border-radius: var(--radius); overflow: visible; }
  .reading figure { display: none; position: relative; height: auto; aspect-ratio: 4 / 5; border-radius: var(--radius) var(--radius) 0 0; background: #211b20; }
  .reading.is-revealing figure { display: block; }
  .reading figure img { opacity: 1; }
  .reading .story { display: flex; flex-direction: column; gap: 0; overflow: visible; min-height: 300px; padding: 24px 20px 28px; border-radius: var(--radius); background: var(--surface); }
  .reading.is-revealing .story { border-radius: 0 0 var(--radius) var(--radius); }
  #storyContent { flex: none; overflow: visible; padding: 4px 0 10px; overflow-wrap: anywhere; }
  .story h2 { font-size: clamp(30px, 9vw, 38px); }
  #storyBody p { font-size: 17px; line-height: 1.75; }
  .story-footer { flex: none; display: grid; gap: 12px; margin-top: 20px; padding: 24px 0 8px; border-top: 1px solid var(--line); }
  #listenStory { width: 100%; min-height: 52px; font-size: 14px; }
  .playback-speed { justify-content: space-between; }
  #voiceStatus { flex-basis: auto; }
  #storyStatus { max-height: none; overflow: visible; margin-top: 12px; }
  .preferences-tab { top: auto; bottom: max(16px,env(safe-area-inset-bottom)); left: auto; right: max(16px,env(safe-area-inset-right)); transform: none; display: flex; gap: 8px; width: auto; height: 48px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 999px; background: #30222d; font-size: 14px; font-weight: 600; }
  .preferences-tab-label { display: inline; }
  .filters-open .preferences-tab { display: none; }
  .filter-drawer { width: min(420px,100vw); }
  #filterPanel { padding: max(24px,env(safe-area-inset-top)) 20px max(32px,env(safe-area-inset-bottom)); }
  .filter-action { margin-inline: -20px; margin-bottom: calc(-1 * max(32px, env(safe-area-inset-bottom))); padding-inline: 20px; padding-bottom: max(32px, env(safe-area-inset-bottom)); bottom: calc(-1 * max(32px, env(safe-area-inset-bottom))); }
}
@media(prefers-reduced-motion:reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
