/* Shared palettes for public pages and the Studio preview. */
.theme-forest { --theme-bg:#102c25; --theme-panel:#173a30; --theme-panel-2:#214b3e; --theme-text:#f0f7ef; --theme-muted:#b4cbbf; --theme-line:#ffffff29; --surface:#102c25; --surface-text:#f0f7ef; }
.theme-rose { --theme-bg:#f5e5e7; --theme-panel:#fff7f7; --theme-panel-2:#ead2d7; --theme-text:#3c202c; --theme-muted:#765360; --theme-line:#3c202c30; --surface:#f5e5e7; --surface-text:#3c202c; }
.theme-sand { --theme-bg:#ece1cf; --theme-panel:#faf4e8; --theme-panel-2:#dfceb3; --theme-text:#382b20; --theme-muted:#6e5a44; --theme-line:#382b2033; --surface:#ece1cf; --surface-text:#382b20; }
.preview-device.theme-ink { --theme-panel:#151517; --theme-text:#fff; }
.preview-device.theme-paper { --theme-panel:#faf8f2; --theme-text:#171719; }
.preview-device.theme-cobalt { --theme-panel:#12308d; --theme-text:#fff; }
.theme-swatch-forest { background:#173a30; }
.theme-swatch-rose { background:#ead2d7; }
.theme-swatch-sand { background:#dfceb3; }
:is(.theme-rose,.theme-sand) :is(.space-intro-kicker .eyebrow,.space-story-number,.space-explore-link span,.space-story-link svg,.space-next > .eyebrow,.space-next-link > span,.preview-copy p) { color:var(--theme-text); }
.theme-card:focus-within,.layout-card:focus-within { outline:3px solid #3154b8; outline-offset:3px; }
.theme-card small,.layout-card small { color:#64635f; }
.background-controls { display:grid; gap:16px; }
.background-controls label { display:grid; gap:8px; font-size:.88rem; }
.background-controls select { width:100%; min-height:44px; padding:10px 12px; border:1px solid #ccc9c1; border-radius:8px; color:#171719; background:#faf9f6; font:inherit; }
.background-controls .color-control { display:flex; flex-wrap:wrap; }
.background-image-preview { width:100%; max-height:180px; margin-bottom:12px; object-fit:cover; border-radius:10px; }
.background-actions { display:flex; flex-wrap:wrap; gap:10px; }
.background-controls [hidden] { display:none; }

/* The page backdrop is independent of its theme; solid text panels preserve contrast. */
:is(.profile-page,.preview-device)[data-background="color"],
:is(.profile-page,.preview-device)[data-background="pattern"] { background-color:var(--custom-bg); }
[data-background="pattern"] { --pattern-ink:#0000001c; }
:is(.profile-page,.preview-device)[data-background="pattern"][data-pattern="dots"] { background-image:radial-gradient(var(--pattern-ink) 1.5px,transparent 1.5px); background-size:20px 20px; }
:is(.profile-page,.preview-device)[data-background="pattern"][data-pattern="lines"] { background-image:linear-gradient(var(--pattern-ink) 1px,transparent 1px); background-size:24px 24px; }
:is(.profile-page,.preview-device)[data-background="pattern"][data-pattern="grid"] { background-image:linear-gradient(var(--pattern-ink) 1px,transparent 1px),linear-gradient(90deg,var(--pattern-ink) 1px,transparent 1px); background-size:28px 28px; }
:is(.profile-page,.preview-device)[data-background="pattern"][data-pattern="diagonal"] { background-image:repeating-linear-gradient(135deg,transparent 0 14px,var(--pattern-ink) 14px 16px); }
:is(.profile-page,.preview-device)[data-background="image"] { background-image:var(--custom-image,none); background-position:center top; background-size:cover; background-repeat:no-repeat; }
:is(.profile-page,.preview-device)[data-background="image"][data-background-fit="tile"] { background-size:240px auto; background-repeat:repeat; }
.profile-page[data-background]:not([data-background="theme"]) .space-header { background:transparent; }
.profile-page[data-background]:not([data-background="theme"]) :is(.space-intro,.space-work,.space-next,.space-signature,.space-page-footer) { background:var(--theme-panel); border-radius:18px; padding:clamp(22px,4vw,48px); margin-top:24px; }
.profile-page[data-background]:not([data-background="theme"]) .space-page-footer { margin-bottom:24px; }
.profile-page[data-background]:not([data-background="theme"]) .timeline-page-main { background:transparent; }
.profile-page[data-background]:not([data-background="theme"]) .timeline-footer { background:var(--theme-panel); }
.preview-device[data-background]:not([data-background="theme"]) :is(.preview-copy,.preview-block,.preview-nav) { background:var(--theme-panel); color:var(--theme-text); }
.preview-device[data-background]:not([data-background="theme"]) .preview-copy { margin:12px; border-radius:8px; }

/* Journal: one reading column. Gallery: visual cards. Split: intro beside stories. */
.layout-journal .space-page-main { max-width:860px; }
.layout-journal .space-intro h1 { font-family:Georgia,'Times New Roman',serif; font-weight:400; letter-spacing:-.04em; }
.layout-journal .space-intro-details { grid-template-columns:1fr; gap:24px; }
.layout-journal .space-intro-actions { justify-content:flex-start; }
.layout-journal .space-story:nth-child(n) { display:block; }
.layout-journal .space-story-number { display:block; margin-bottom:16px; }
.layout-journal .space-story-content { display:block; }
.layout-journal .space-story-visual { margin-bottom:28px; }
.layout-journal .space-story-detail > p { max-width:none; margin-top:24px; }
.layout-gallery .space-stories { grid-template-columns:repeat(3,minmax(0,1fr)); gap:20px; }
.layout-gallery .space-stories .space-story:nth-child(n) { display:flex; flex-direction:column; align-items:stretch; padding:24px; gap:18px; border:1px solid var(--theme-line); border-radius:16px; background:var(--theme-panel); }
.layout-gallery .space-story-number { order:0; }
.layout-gallery .space-story-visual { order:1; }
.layout-gallery .space-story-content { display:block; order:2; }
.layout-gallery .space-stories .space-story:nth-child(n) h3 { font-size:clamp(1.6rem,2.2vw,2.4rem); }
.layout-gallery .space-story-visual img { aspect-ratio:4/3; object-fit:cover; }
.layout-gallery .space-story-detail > p { margin-top:18px; font-size:.92rem; }
.layout-gallery .space-story-quote.no-media .space-story-content { padding-left:0; border:0; }
.layout-split .space-story:nth-child(n) { display:block; }
.layout-split .space-story-number { display:block; margin-bottom:20px; }
.layout-split .space-story-content { display:block; }
.layout-split .space-story-visual { margin-bottom:24px; }
.layout-split .space-story-detail > p { margin-top:20px; }
.layout-split .space-intro-details { grid-template-columns:1fr; gap:24px; }
.layout-split .space-intro-actions { justify-content:flex-start; }
.layout-thumb-journal { grid-template-columns:1fr; padding-inline:18px; }
.layout-thumb-gallery { grid-template-columns:repeat(3,1fr); }
.layout-thumb-split { grid-template-columns:1fr 1fr; }
.layout-thumb-split span:first-child { grid-row:span 2; }
.preview-device.layout-journal .preview-copy h2 { font-family:Georgia,'Times New Roman',serif; }
.preview-device.layout-journal .preview-blocks { grid-template-columns:1fr; padding-inline:28px; }
.preview-device.layout-journal .preview-block:first-child { grid-column:auto; }
.preview-device.layout-gallery .preview-blocks { grid-template-columns:repeat(3,minmax(0,1fr)); }
.preview-device.layout-gallery .preview-block:first-child { grid-column:auto; }
.preview-device.layout-split { display:grid; grid-template-columns:1fr 1fr; align-content:start; }
.preview-device.layout-split :is(.preview-nav,.preview-cover) { grid-column:1/-1; }
.preview-device.layout-split .preview-blocks { grid-template-columns:1fr; padding-top:24px; }
.preview-device.layout-split .preview-block:first-child { grid-column:auto; }
.preview-device.layout-split .preview-copy h2 { font-size:1.7rem; }
.preview-block { min-width:0; overflow-wrap:anywhere; }

/* Section icons belong to the heading, with a consistent open line treatment. */
.space-story.has-section-icon.no-media { grid-template-columns:minmax(0,1fr); }
.space-story.has-section-icon.has-media { grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); }
.space-story.has-section-icon.has-media:nth-child(even) { grid-template-columns:minmax(0,1fr) minmax(0,1.2fr); }
.space-story.has-section-icon.has-media:nth-child(even) .space-story-visual { grid-column:2; }
.space-story.has-section-icon.has-media:nth-child(even) .space-story-content { grid-column:1; }
.space-story.has-section-icon h3 { display:flex; align-items:flex-start; gap:clamp(18px,2.2vw,32px); }
.space-story.has-section-icon h3 > span:last-child { min-width:0; }
.space-section-icon { display:inline-flex; flex:0 0 auto; color:var(--theme-text); }
.space-section-icon svg { display:block; width:clamp(56px,5.3vw,76px); height:clamp(56px,5.3vw,76px); stroke-width:1.35; }
.space-story.has-section-icon.space-story-quote.no-media .space-story-content { padding-left:0; border-left:0; }
:is(.layout-grid,.layout-gallery,.layout-split) .space-section-icon svg { width:56px; height:56px; }
.layout-gallery .space-story.has-section-icon h3 { flex-direction:column; gap:22px; }
.layout-split .space-story.has-section-icon h3 { flex-direction:column; }
.layout-gallery .space-story.has-section-icon .space-section-icon { margin-bottom:2px; }
.section-marker-tools { margin:0 0 20px; font-size:.8rem; color:#64635f; }
.section-marker-tools > div { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.section-marker-controls { margin-top:20px; padding-top:16px; border-top:1px solid #dedbd3; }
.section-marker-controls > label { display:flex; flex-wrap:wrap; align-items:center; gap:10px; font-size:.78rem; color:#575650; }
.section-marker-controls select { padding:9px 12px; min-height:44px; max-width:100%; border:1px solid #ccc9c1; border-radius:8px; font:inherit; color:#171719; background:#faf9f6; }
.section-icon-picker { margin-top:12px; }
.section-icon-picker[hidden] { display:none; }
.section-icon-picker summary { display:flex; align-items:center; gap:12px; padding:8px 0; cursor:pointer; font-size:.78rem; }
.section-icon-picker summary::after { content:'⌄'; margin-left:auto; }
.section-icon-options { display:grid; grid-template-columns:repeat(auto-fit,minmax(72px,1fr)); gap:6px; margin:12px 0 0; }
.section-icon-options button { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; min-height:76px; padding:10px 4px; border:1px solid #ddd9d0; border-radius:9px; background:#faf9f6; color:#393832; cursor:pointer; }
.section-icon-options button span { font-size:.62rem; }
.section-icon-options button[aria-pressed="true"] { color:#111; background:#e4e8d8; border:2px solid #333e20; padding:9px 3px; }
.section-marker-controls :is(button,select,summary):focus-visible { outline:3px solid #3154b8; outline-offset:3px; }
.preview-block .preview-section-heading { display:flex; align-items:flex-start; gap:10px; }
.preview-section-heading svg { flex:0 0 30px; width:30px; height:30px; stroke-width:1.35; }
.preview-block .preview-section-heading span { margin:0; font:inherit; opacity:1; }
.preview-block .preview-section-number { margin:0 0 10px; font-size:.55rem; opacity:.7; }
.preview-device.layout-gallery .preview-section-heading { flex-direction:column; }
@media(max-width:700px) {
  .space-story.has-section-icon.has-media:nth-child(n) { grid-template-columns:minmax(0,1fr); }
  .space-story.has-section-icon.has-media:nth-child(n) :is(.space-story-visual,.space-story-content) { grid-column:auto; grid-row:auto; }
  .space-section-icon svg, :is(.layout-grid,.layout-gallery,.layout-split) .space-section-icon svg { width:48px; height:48px; }
  .space-story.has-section-icon h3 { flex-direction:column; gap:18px; }
}
@media(min-width:1000px) {
  .layout-split .space-page-main { display:grid; grid-template-columns:minmax(0,.85fr) minmax(0,1.15fr); gap:32px 56px; align-items:start; }
  .layout-split .space-intro { position:sticky; top:24px; }
  .layout-split .space-intro h1 { font-size:clamp(2.6rem,4vw,4.2rem); }
  .layout-split .space-work { margin-top:72px; }
  .layout-split :is(.space-next,.space-signature) { grid-column:1/-1; }
}
@media(max-width:1100px) { .layout-gallery .space-stories { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:650px) {
  .layout-gallery .space-stories { grid-template-columns:1fr; }
  .profile-page[data-background]:not([data-background="theme"]) :is(.space-intro,.space-work,.space-next,.space-signature,.space-page-footer) { padding:22px 18px; }
}
@media(max-width:900px) {
  .studio-page[data-studio-panel="style"] .live-preview { display:block; padding:20px 16px 90px; }
  .studio-page[data-studio-panel="style"] .preview-device { min-height:0; max-width:540px; margin:auto; }
}
