:root {
  /* Neutrals (LIGHT MODE) */
  --bg: #eaeaea;            /* page background */
  --surface: #ffffff;       /* cards, inputs */
  --surface-2: #f4f4f5;     /* subtle sections */
  --text: #111315;          /* primary text */
  --muted: #6b7280;         /* secondary text */
  --border: rgba(17, 19, 21, 0.12);

  /* Accent (DEFAULT: Blue) */
  --accent: #51bdec;
  --accent-hover: rgb(55, 127, 158);
  --accent-soft: rgba(81, 189, 236, 0.14);
  --focus: rgba(81, 189, 236, 0.28);

  /* Status */
  --danger: #ef4444;

  /* Compatibility tokens */
  --white: #ffffff;

  /* Radius / Shadow */
  --radius: 16px;
  --radius-sm: 12px;

  --shadow: 0 10px 30px rgba(17, 19, 21, 0.10);
  --shadow-soft: 0 6px 18px rgba(17, 19, 21, 0.08);
}

/* DARK MODE */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315;
    --surface: #202226;
    --surface-2: #17181b;
    --text: #eaeaea;
    --muted: #9ca3af;
    --border: rgba(234, 234, 234, 0.12);

    --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.25);
  }

  a { color: var(--text); }
}

/* Accent variants */
html[data-accent="orange"]{
  --accent:#f97316; --accent-hover:#ea580c; --accent-soft:rgba(249,115,22,.14); --focus:rgba(249,115,22,.28);
}
html[data-accent="purple"]{
  --accent:#8b5cf6; --accent-hover:#7c3aed; --accent-soft:rgba(139,92,246,.14); --focus:rgba(139,92,246,.28);
}
html[data-accent="pink"]{
  --accent:#ec4899; --accent-hover:#db2777; --accent-soft:rgba(236,72,153,.14); --focus:rgba(236,72,153,.28);
}

/* -----------------------------
   Base
------------------------------ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.4;
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a {
  color: var(--text);
  text-decoration: none;
}

a:hover { opacity: 0.92; }

.container{
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 22px;
}

/* -----------------------------
   Header / Nav
------------------------------ */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

@media (prefers-color-scheme: dark) {
  .header { background: rgba(17,19,21,0.72); }
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 6px;
  object-fit: contain;
  border: 1px solid var(--border);
}

.brand-logo-horizontal{
  height: 42px;
  width: auto;
  display: block;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 16px;
}
.brand-tag {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  padding: 10px 10px;
  border-radius: 12px;
  color: var(--text);
}

.nav-link:hover { background: var(--accent-soft); }

/* -----------------------------
   Typography
------------------------------ */
h1 {
  margin: 10px 0 14px;
  font-size: 28px;
  letter-spacing: -0.3px;
}

h2 { margin: 16px 0 10px; font-size: 20px; }
h3 { margin: 16px 0 8px; font-size: 16px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.is-hidden { display: none !important; }

/* -----------------------------
   Cards / Sections
------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 12px 0;
}

.sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

/* -----------------------------
   Buttons
------------------------------ */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;

  font-weight: 700;
  font-size: 14px;
  line-height: 1;

  transition: transform 0.04s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

button:active, .btn:active { transform: translateY(1px); }

.btn, button {
  background: var(--accent);
  color: var(--white);
  box-shadow: var(--shadow-soft);
}

.btn:hover, button:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: rgba(17, 19, 21, 0.06); }

@media (prefers-color-scheme: dark) {
  .btn-secondary:hover { background: rgba(234, 234, 234, 0.06); }
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-danger:hover { filter: brightness(0.95); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
}

.btn-ghost:hover { background: rgba(17, 19, 21, 0.05); }

@media (prefers-color-scheme: dark) {
  .btn-ghost:hover { background: rgba(234, 234, 234, 0.06); }
}

.btn-disabled,
.btn[aria-disabled="true"] {
  opacity: 0.52;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

/* -----------------------------
   Forms
------------------------------ */
label {
  display: block;
  font-weight: 700;
  margin: 10px 0 6px;
  font-size: 13px;
}

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  font-size: 14px;
  margin-bottom: 12px;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus);
}

.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #b52b27;
  padding: 10px 12px;
  border-radius: 14px;
}

.flash-message--success{
  color: #1b7f3a;
  margin: 0 0 12px;
}

.photo-preview-wrap{
  margin-top: 12px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.55);
}

@media (prefers-color-scheme: dark) {
  .photo-preview-wrap{ background: rgba(32,34,38,0.55); }
  .photo-preview-empty{ background: rgba(32,34,38,0.55); }
}

.photo-preview{
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  display: block;
}

.preview-comparison{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.preview-card{
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.preview-label{
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.photo-preview--contain{
  object-fit: contain;
  padding: 8px;
}

.photo-preview-empty{
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.28);
}

@media (max-width: 680px){
  .preview-comparison{
    grid-template-columns: 1fr;
  }
}

.photo-preview--portrait{
  width: 220px;
  max-width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: contain;
  background: #fff;
}

.photo-preview--transparent{
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, rgba(17, 19, 21, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(17, 19, 21, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(17, 19, 21, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(17, 19, 21, 0.08) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

/* -----------------------------
   Characters page layout
------------------------------ */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; }
  .nav { justify-content: flex-start; }
}

.char-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.char-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-2);
}

.char-item.active{
  border-color: var(--accent);
  background: var(--accent-soft);
}

.char-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.char-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(0,0,0,0.08);
  flex: 0 0 auto;
}

@media (prefers-color-scheme: dark) {
  .char-avatar { border: 1px solid rgba(234,234,234,0.10); }
}

.char-avatar--empty { background: rgba(0,0,0,0.06); }
@media (prefers-color-scheme: dark) {
  .char-avatar--empty { background: rgba(234,234,234,0.08); }
}

.char-name { font-weight: 800; }

.char-sub {
  margin-top: 4px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pill{
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.pill-gray { background: rgba(49, 46, 45, 0.08); }
@media (prefers-color-scheme: dark) {
  .pill-gray { background: rgba(234,234,234,0.10); }
}

/* Push actions to far right */
.char-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.char-actions form{
  margin: 0;
}

.char-reference-status{
  margin-top: 10px;
}

.char-reference-status + .char-reference-status{
  margin-top: 4px;
}

.char-reference-wrap{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.char-reference-wrap.is-hidden{
  display: none;
}

.char-reference-preview{
  margin-top: 8px;
}

/* Books buttons on right */
.book-item{
  padding: 14px;
}

.book-row{
  gap: 16px;
}

.book-main{
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1 1 auto;
}

.book-thumb{
  width: 78px;
  aspect-ratio: 3 / 4;
  flex: 0 0 78px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.12);
  box-shadow: var(--shadow-soft);
}

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

.book-thumb-placeholder{
  width: 100%;
  height: 100%;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(81, 189, 236, 0.16), rgba(17, 19, 21, 0.04));
  color: var(--muted);
}

.book-cover{
  width: 100%;
  height: 100%;
  min-height: 104px;
  padding: 12px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(81, 189, 236, 0.16), rgba(17, 19, 21, 0.04));
  color: var(--muted);
}

.book-cover--loading{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.book-cover-spinner{
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 60%;
}

.book-cover-spinner .story-loading-spinner{
  width: 32px;
  height: 32px;
  margin: 0;
  border-width: 4px;
}

.book-cover-label{
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.book-thumb-placeholder--ready{
  background:
    linear-gradient(180deg, rgba(81, 189, 236, 0.22), rgba(81, 189, 236, 0.08));
}

.book-thumb-placeholder__eyebrow{
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.book-thumb-placeholder__label{
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.book-info{
  min-width: 0;
}

.book-info .char-name{
  overflow-wrap: anywhere;
}

.book-meta{
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.book-actions{
  margin-left: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.book-status{
  font-weight: 700;
}

.book-status--success{
  color: #5cb85c;
}

.book-status--warning{
  color: #f0ad4e;
}

.book-status--danger{
  color: #ef4444;
}

@media (prefers-color-scheme: dark) {
  .book-thumb{
    background: rgba(32,34,38,0.65);
  }

  .book-thumb-placeholder{
    background:
      linear-gradient(180deg, rgba(81, 189, 236, 0.18), rgba(32, 34, 38, 0.68));
  }

  .book-cover{
    background:
      linear-gradient(180deg, rgba(81, 189, 236, 0.18), rgba(32, 34, 38, 0.68));
  }

  .book-thumb-placeholder--ready{
    background:
      linear-gradient(180deg, rgba(81, 189, 236, 0.22), rgba(32, 34, 38, 0.72));
  }
}

@media (max-width: 760px){
  .book-row{
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .book-actions{
    width: 100%;
    margin-left: 92px;
  }
}

@media (max-width: 520px){
  .book-thumb{
    width: 70px;
    flex-basis: 70px;
  }

  .book-thumb-placeholder{
    min-height: 94px;
  }

  .book-cover{
    min-height: 94px;
  }

  .book-actions{
    margin-left: 0;
  }

  .book-actions .btn,
  .book-actions .btn-disabled{
    flex: 1 1 140px;
  }
}

/* -----------------------------
   Generator: dropdown preview + supporting avatars
------------------------------ */
.select-with-avatar{
  display: flex;
  align-items: center;
  gap: 12px;
}

.select-avatar{
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(0,0,0,0.08);
  flex: 0 0 auto;
  background: rgba(255,255,255,0.6);
}

@media (prefers-color-scheme: dark) {
  .select-avatar{ background: rgba(32,34,38,0.6); border: 1px solid rgba(234,234,234,0.10); }
}

.support-pick{
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;
}

/* Default support avatar = 44px */
.support-avatar{
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(0,0,0,0.08);
  flex: 0 0 auto;
}

@media (prefers-color-scheme: dark) {
  .support-avatar{ border: 1px solid rgba(234,234,234,0.10); }
}

.support-avatar--empty{ background: rgba(0,0,0,0.06); }
@media (prefers-color-scheme: dark) {
  .support-avatar--empty{ background: rgba(234,234,234,0.08); }
}

/* In “pick” rows, use smaller avatar */
.support-pick .support-avatar{
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.support-name{
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.support-title{ font-weight: 800; }

.support-rel{
  flex: 1;
  min-width: 320px;
  margin: 0;
}

/* Generator supporting rows (KEEP GRID VERSION ONLY) */
.support-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin: 10px 0;
}

@media (max-width: 680px) {
  .support-row { grid-template-columns: 1fr; }
}

/* -----------------------------
   Footer
------------------------------ */
.footer {
  border-top: 1px solid var(--border);
  padding: 22px 16px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.footer a { text-decoration: underline; }

.prewrap {
  white-space: pre-wrap;
  background: rgba(17, 19, 21, 0.04);
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: var(--radius);
  overflow: auto;
}

@media (prefers-color-scheme: dark) {
  .prewrap { background: rgba(234,234,234,0.06); }
}

/* -----------------------------
   Landing Page
------------------------------ */
.hero-sub { font-size: 15px; margin-top: 6px; }

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

body.example-viewer-open {
  overflow: hidden;
}

.example-books-section {
  position: relative;
  overflow: hidden;
  padding-top: 12px;
}

.example-books-section h2 {
  margin: 2px 0 8px;
  font-size: clamp(1.5rem, 2vw, 1.85rem);
  line-height: 1.08;
}

.example-books-section > .muted {
  max-width: 680px;
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.55;
}

.book-examples-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 18px;
}

.example-books-empty {
  grid-column: 1 / -1;
  padding: 28px;
  border-radius: 22px;
  border: 1px solid rgba(81, 189, 236, 0.16);
  background:
    radial-gradient(circle at top, rgba(81, 189, 236, 0.12), transparent 58%),
    rgba(10, 15, 22, 0.64);
  color: rgba(245, 247, 251, 0.82);
  text-align: center;
  box-shadow: 0 18px 40px rgba(6, 11, 18, 0.18);
}

.example-book-card {
  appearance: none;
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top, rgba(81, 189, 236, 0.18), transparent 48%),
    linear-gradient(180deg, rgba(14, 20, 28, 0.98), rgba(8, 12, 18, 0.96));
  color: #f6fbff;
  overflow: hidden;
  box-shadow:
    0 18px 38px rgba(6, 11, 18, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}

.example-book-card:hover,
.example-book-card:focus-visible {
  background:
    radial-gradient(circle at top, rgba(81, 189, 236, 0.24), transparent 52%),
    linear-gradient(180deg, rgba(16, 22, 31, 1), rgba(9, 13, 20, 0.98));
  border-color: rgba(81, 189, 236, 0.72);
  box-shadow:
    0 24px 48px rgba(6, 11, 18, 0.34),
    0 0 0 1px rgba(81, 189, 236, 0.22),
    0 0 28px rgba(81, 189, 236, 0.18);
  transform: translateY(-8px);
  opacity: 1;
}

.example-book-card:focus-visible {
  outline: none;
}

.example-book-card--loading {
  pointer-events: none;
}

.example-book-cover {
  position: relative;
  flex: 0 0 auto;
  aspect-ratio: 3 / 4.2;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top, rgba(81, 189, 236, 0.18), transparent 46%),
    linear-gradient(180deg, rgba(28, 38, 52, 0.92), rgba(11, 16, 24, 0.98));
}

.example-book-cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.36s ease;
}

.example-book-card:hover .example-book-cover img,
.example-book-card:focus-visible .example-book-cover img {
  transform: scale(1.05);
}

.example-book-cover__placeholder,
.example-book-cover--loading {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.example-book-cover__placeholder {
  color: rgba(245, 247, 251, 0.76);
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.example-book-cover--loading,
.example-book-skeleton {
  background:
    linear-gradient(
      110deg,
      rgba(255, 255, 255, 0.06) 12%,
      rgba(81, 189, 236, 0.18) 30%,
      rgba(255, 255, 255, 0.06) 50%
    );
  background-size: 220% 100%;
  animation: example-card-shimmer 1.5s linear infinite;
}

.example-book-card__body {
  flex: 1 1 auto;
  display: grid;
  grid-template-rows: auto minmax(2.7em, auto) auto;
  align-content: start;
  gap: 8px;
  padding: 16px 16px 18px;
  min-height: 138px;
}

.example-book-card__eyebrow {
  color: rgba(131, 221, 255, 0.82);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.example-book-card__title {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.3;
  color: #f8fbff;
  min-height: 2.6em;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.example-book-card__hint {
  color: rgba(225, 231, 239, 0.68);
  font-size: 0.88rem;
  line-height: 1.35;
  min-height: 1.35em;
}

.example-book-skeleton {
  height: 12px;
  border-radius: 999px;
}

.example-book-skeleton--title {
  width: 72%;
}

.example-book-skeleton--meta {
  width: 48%;
  height: 10px;
}

.example-viewer.hidden {
  display: none;
}

.example-viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.example-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 16, 0.76);
  backdrop-filter: blur(18px);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.example-viewer-dialog {
  position: relative;
  width: min(1220px, calc(100vw - 40px));
  max-height: min(90vh, 920px);
  margin: min(5vh, 36px) auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(circle at top, rgba(81, 189, 236, 0.12), transparent 46%),
    linear-gradient(180deg, rgba(14, 19, 27, 0.98), rgba(7, 10, 16, 0.96));
  color: #f7fbff;
  box-shadow:
    0 34px 80px rgba(0, 0, 0, 0.46),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px) scale(0.96);
  transition: opacity 0.24s ease, transform 0.28s ease;
}

.example-viewer.is-open .example-viewer-backdrop {
  opacity: 1;
}

.example-viewer.is-open .example-viewer-dialog {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.example-viewer-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 24, 34, 0.72);
  color: #f7fbff;
  font-size: 1.6rem;
  line-height: 1;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.22);
}

.example-viewer-close:hover,
.example-viewer-close:focus-visible {
  background: rgba(20, 30, 44, 0.92);
  border-color: rgba(81, 189, 236, 0.58);
}

.example-viewer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-right: 62px;
}

.example-viewer-title {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
  line-height: 1.12;
  color: #f8fbff;
}

.example-viewer-subtitle {
  margin: 6px 0 0;
  color: rgba(225, 231, 239, 0.7);
  font-size: 0.92rem;
  line-height: 1.4;
}

.example-viewer-counter {
  flex: 0 0 auto;
  align-self: center;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(17, 24, 34, 0.56);
  color: rgba(235, 241, 247, 0.82);
  font-size: 0.9rem;
  font-weight: 700;
}

.example-viewer-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: stretch;
  padding: 0 64px;
}

.example-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(17, 24, 34, 0.72);
  color: #f7fbff;
  font-size: 0;
  transform: translateY(-50%);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.example-nav__glyph {
  display: block;
  font-size: 2.2rem;
  line-height: 1;
  transform: translateY(-1px);
}

.example-nav--prev {
  left: 0;
}

.example-nav--next {
  right: 0;
}

.example-nav:hover,
.example-nav:focus-visible {
  background: rgba(20, 30, 44, 0.92);
  border-color: rgba(81, 189, 236, 0.58);
}

.example-nav:disabled {
  opacity: 0.34;
  cursor: not-allowed;
  transform: translateY(-50%);
  box-shadow: none;
}

.example-page-shell {
  width: 100%;
  height: clamp(470px, 64vh, 690px);
  min-height: 0;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(15, 20, 28, 0.92), rgba(9, 12, 18, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.example-page {
  width: 100%;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(320px, 0.88fr);
  gap: 18px;
  padding: 18px;
  overflow: hidden;
  opacity: 0;
  transform: translateX(28px) scale(0.985);
  transition: opacity 0.26s ease, transform 0.28s ease;
}

.example-page.is-visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}

.example-page.is-entering-prev {
  transform: translateX(-28px) scale(0.985);
}

.example-page.is-entering-next {
  transform: translateX(28px) scale(0.985);
}

.example-page.is-leaving-prev {
  opacity: 0;
  transform: translateX(22px) scale(0.985);
}

.example-page.is-leaving-next {
  opacity: 0;
  transform: translateX(-22px) scale(0.985);
}

.example-page--status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 420px;
  padding: 34px;
}

.example-page-status {
  width: min(100%, 520px);
  display: grid;
  gap: 10px;
  padding: 28px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(17, 24, 34, 0.62);
  text-align: center;
}

.example-page-status__title {
  font-size: 1.2rem;
  font-weight: 800;
  color: #f8fbff;
}

.example-page-status__body {
  color: rgba(225, 231, 239, 0.72);
  line-height: 1.6;
}

.example-page-image {
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top, rgba(81, 189, 236, 0.12), transparent 48%),
    rgba(17, 24, 34, 0.72);
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.18);
}

.example-page-image img,
.example-page-image__placeholder {
  width: 100%;
  height: 100%;
  display: block;
}

.example-page-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(8, 12, 18, 0.5);
}

.example-page-image__placeholder {
  display: grid;
  place-items: center;
  padding: 28px;
  color: rgba(225, 231, 239, 0.72);
  text-align: center;
}

.example-page-text {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 22px 20px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    rgba(17, 24, 34, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
  overflow: auto;
}

.example-page-number {
  align-self: flex-start;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(81, 189, 236, 0.16);
  color: #8fdcff;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.example-page-title {
  color: #f8fbff;
  font-size: clamp(1.18rem, 1.4vw, 1.34rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.example-page-body {
  color: rgba(244, 247, 252, 0.92);
  font-family: "Trebuchet MS", "Verdana", system-ui, sans-serif;
  font-size: clamp(0.98rem, 1.08vw, 1.05rem);
  line-height: 1.64;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.example-viewer-footer {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}

.example-viewer-cta {
  min-width: min(100%, 320px);
  padding: 16px 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, #51bdec, #1c8cc1);
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 18px 34px rgba(81, 189, 236, 0.24);
}

.example-viewer-cta:hover,
.example-viewer-cta:focus-visible {
  background: linear-gradient(135deg, #62c8f4, #2297ce);
  color: #ffffff;
}

@keyframes example-card-shimmer {
  to { background-position: -220% 0; }
}

.landing-lower-stack {
  margin: 26px 0 18px;
  display: grid;
  gap: 24px;
}

.landing-feature-section,
.landing-final-cta {
  position: relative;
  overflow: hidden;
  padding: clamp(28px, 4vw, 40px);
  border-radius: 32px;
  border: 1px solid rgba(81, 189, 236, 0.12);
  background:
    radial-gradient(circle at top right, rgba(81, 189, 236, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(14, 19, 27, 0.96), rgba(8, 12, 18, 0.98));
  box-shadow:
    0 28px 60px rgba(4, 8, 14, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.landing-feature-section::before,
.landing-final-cta::before {
  content: "";
  position: absolute;
  inset: auto auto -90px -70px;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(81, 189, 236, 0.18), transparent 70%);
  pointer-events: none;
}

.landing-section-header {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  max-width: 760px;
  margin-bottom: 26px;
}

.landing-section-header h2,
.landing-final-cta h2 {
  margin: 0;
  color: #f8fbff;
  font-size: clamp(1.7rem, 2.5vw, 2.25rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.landing-section-support,
.landing-final-cta p {
  margin: 0;
  color: rgba(223, 231, 241, 0.76);
  font-size: 1rem;
  line-height: 1.65;
}

.flow-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.flow-card {
  position: relative;
  display: grid;
  gap: 16px;
  min-height: 250px;
  padding: 24px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02)),
    rgba(17, 24, 34, 0.78);
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.flow-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.flow-step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  height: 54px;
  padding: 0 16px;
  border-radius: 18px;
  background: rgba(81, 189, 236, 0.16);
  color: #8fdcff;
  font-size: 0.96rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.flow-step-accent {
  width: 56px;
  height: 14px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, rgba(81, 189, 236, 0.85), rgba(81, 189, 236, 0.1));
  opacity: 0.9;
}

.flow-card h3,
.perfect-card h3 {
  margin: 0;
  color: #f8fbff;
  font-size: 1.2rem;
  line-height: 1.2;
}

.flow-card p,
.perfect-card p {
  margin: 0;
  color: rgba(223, 231, 241, 0.72);
  line-height: 1.65;
}

.flow-card__connector {
  position: absolute;
  top: 50%;
  right: -40px;
  width: 58px;
  height: 1px;
  background: linear-gradient(90deg, rgba(81, 189, 236, 0.34), rgba(81, 189, 236, 0.08));
  transform: translateY(-50%);
}

.flow-card__connector::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 2px;
  width: 9px;
  height: 9px;
  border-top: 1px solid rgba(81, 189, 236, 0.48);
  border-right: 1px solid rgba(81, 189, 236, 0.48);
  transform: translateY(-50%) rotate(45deg);
}

.audience-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.perfect-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 16px;
  display: block;
}

.perfect-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 182px;
  padding: 28px;
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.16);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.perfect-card:hover {
  transform: translateY(-6px);
  border-color: rgba(100,200,255,0.35);
  box-shadow: 0 12px 35px rgba(0,0,0,0.45), 0 0 20px rgba(80,180,255,0.15);
}

.perfect-card h3 {
  margin-top: 6px;
  margin-bottom: 10px;
}

.perfect-card p {
  opacity: 0.85;
  line-height: 1.45;
}

.faq-accordion {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
}

.faq-card {
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.028), rgba(255, 255, 255, 0.016)),
    rgba(17, 24, 34, 0.74);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.16);
  overflow: hidden;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.faq-card.is-open {
  border-color: rgba(81, 189, 236, 0.42);
  box-shadow:
    0 22px 40px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(81, 189, 236, 0.12);
}

.faq-card__toggle {
  width: 100%;
  padding: 22px 24px;
  border: 0;
  border-radius: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  justify-content: stretch;
  background: transparent;
  color: #f8fbff;
  box-shadow: none;
  text-align: left;
}

.faq-card__toggle:hover,
.faq-card__toggle:focus-visible {
  background: rgba(255, 255, 255, 0.02);
  color: #f8fbff;
  box-shadow: none;
  transform: none;
}

.faq-card__question {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.45;
}

.faq-card__icon {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  flex: 0 0 auto;
}

.faq-card__icon::before,
.faq-card__icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 1.5px;
  background: rgba(248, 251, 255, 0.85);
  border-radius: 999px;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.faq-card__icon::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.faq-card.is-open .faq-card__icon::after {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(90deg) scaleX(0);
}

.faq-card__panel {
  padding: 0 24px 24px;
}

.faq-card__panel p {
  margin: 0;
  color: rgba(223, 231, 241, 0.72);
  line-height: 1.68;
}

.landing-final-cta {
  text-align: center;
  padding-top: clamp(36px, 5vw, 52px);
  padding-bottom: clamp(36px, 5vw, 52px);
}

.landing-final-cta__content {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  margin: 0 auto;
  display: grid;
  gap: 16px;
  justify-items: center;
}

.landing-final-cta__button {
  margin-top: 6px;
  min-width: min(100%, 320px);
  padding: 16px 32px;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow:
    0 18px 34px rgba(81, 189, 236, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.example-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.example-cover {
  height: 92px;
  border-radius: 14px;
  border: 1px dashed rgba(49, 46, 45, 0.20);
  background: rgba(17, 19, 21, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: rgba(49, 46, 45, 0.65);
}

@media (prefers-color-scheme: dark) {
  .example-cover {
    border: 1px dashed rgba(234,234,234,0.20);
    background: rgba(234,234,234,0.06);
    color: rgba(234,234,234,0.70);
  }
}

.samples {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.sample-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface-2);
}

.sample-thumb {
  height: 110px;
  border-radius: 14px;
  border: 1px dashed rgba(37, 37, 37, 0.20);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: rgba(37, 37, 37, 0.65);
}

@media (prefers-color-scheme: dark) {
  .sample-thumb {
    border: 1px dashed rgba(234,234,234,0.20);
    color: rgba(234,234,234,0.75);
  }
}

.sample-title { margin-top: 10px; font-weight: 900; }

.how-grid {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.how-step {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.how-num {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.how-title { font-weight: 900; }

.faq {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface-2);
}

.faq summary { cursor: pointer; font-weight: 800; }
.faq-body { margin-top: 8px; }

@media (max-width: 980px) {
  .hero-inner { grid-template-columns: 1fr; }
  .samples { grid-template-columns: 1fr; }

  .landing-lower-stack {
    gap: 20px;
  }

  .flow-grid {
    grid-template-columns: 1fr;
  }

  .flow-card {
    min-height: 0;
  }

  .flow-card__connector {
    display: none;
  }

  .audience-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .book-examples-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .example-viewer-stage {
    padding: 0 56px;
  }

  .example-page {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  }
}

@media (max-width: 820px) {
  .book-examples-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .example-viewer-dialog {
    width: min(820px, calc(100vw - 18px));
    max-height: calc(100vh - 18px);
    margin: 9px auto;
    padding: 18px;
    gap: 18px;
    border-radius: 24px;
  }

  .example-viewer-header {
    flex-direction: column;
    align-items: flex-start;
    padding-right: 54px;
  }

  .example-viewer-counter {
    align-self: flex-start;
  }

  .example-viewer-stage {
    padding: 0;
  }

  .example-nav {
    width: 48px;
    height: 48px;
    font-size: 1.7rem;
    top: 50%;
    transform: translateY(-50%);
  }

  .example-nav--prev {
    left: 10px;
  }

  .example-nav--next {
    right: 10px;
  }

  .example-nav:disabled {
    transform: translateY(-50%);
  }

  .example-page {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
    overflow: auto;
  }

  .example-page-image {
    min-height: 250px;
    max-height: 42vh;
    aspect-ratio: auto;
  }

  .example-page-text {
    padding: 20px;
    justify-content: flex-start;
  }

  .example-page-shell {
    height: auto;
    max-height: calc(100vh - 240px);
  }
}

@media (max-width: 560px) {
  .landing-feature-section,
  .landing-final-cta {
    padding: 24px 18px;
    border-radius: 26px;
  }

  .landing-section-header {
    margin-bottom: 20px;
  }

  .landing-section-header h2,
  .landing-final-cta h2 {
    font-size: 1.55rem;
  }

  .audience-grid {
    grid-template-columns: 1fr;
  }

  .faq-card__toggle,
  .faq-card__panel {
    padding-left: 18px;
    padding-right: 18px;
  }

  .book-examples-grid {
    gap: 14px;
  }

  .example-book-card__body {
    padding: 14px 14px 16px;
    min-height: 126px;
  }

  .example-book-card__title {
    min-height: 2.5em;
  }

  .example-viewer-title {
    font-size: 1.28rem;
  }

  .example-viewer-subtitle {
    font-size: 0.9rem;
  }

  .example-page-body {
    font-size: 0.98rem;
    line-height: 1.62;
  }

  .example-viewer-cta {
    width: 100%;
    min-width: 0;
  }
}

/* -----------------------------
   Hero carousel
------------------------------ */
.carousel{
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 0;
  border-radius: 0;
}

.car-viewport{ overflow: hidden; border-radius: 0; }

.car-track{
  display: flex;
  transition: transform 420ms ease;
  will-change: transform;
}

.car-slide{ min-width: 100%; }

.car-slide img{
  width: 100%;
  height: 420px;
  object-fit: cover;
  border-radius: 0;
  display: block;
}

@media (max-width: 680px){
  .car-slide img{ height: 260px; }
}

.hero{ margin-top: 0; }

.hero-fullbleed{
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 0;
}

body.landing .card{
  border: none;
  box-shadow: none;
  background: rgba(255,255,255,0.55);
}

@media (prefers-color-scheme: dark) {
  body.landing .card{ background: rgba(32,34,38,0.55); }
}

.car-btn{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.75);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .car-btn{
    background: rgba(32,34,38,0.75);
    color: var(--text);
  }
}

.car-btn.prev{ left: 12px; }
.car-btn.next{ right: 12px; }

.car-dots{
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(49,46,45,0.18);
  cursor: pointer;
}

@media (prefers-color-scheme: dark) {
  .dot{ background: rgba(234,234,234,0.18); }
}

.dot.active{ background: var(--accent); }

/* Landing page layout container */
.main-landing{
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 22px;
}

.main-landing .hero.hero-fullbleed{
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding: 0;
}

/* -----------------------------
   Book Reader (landscape spread)
------------------------------ */
.book-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: 14px;
  margin: 8px 0 14px;
}

.book-head-right{
  margin-left:auto;
  display:flex;
  align-items:center;
}

.book-reader{ display: grid; gap: 14px; }

.book-status-banner{
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(240, 173, 78, 0.28);
  background: rgba(240, 173, 78, 0.12);
  color: var(--text);
  font-weight: 600;
}

.book-status-banner--complete{
  border-color: rgba(92, 184, 92, 0.28);
  background: rgba(92, 184, 92, 0.10);
}

.book-spread{
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
  align-items: start;

  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.55);
}

@media (prefers-color-scheme: dark) {
  .book-spread{ background: rgba(32,34,38,0.55); }
}

.book-illus-wrap{
  width: 100%;
  display: flex;
  justify-content: center;
}

.book-illus-placeholder{
  min-height: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background:
    linear-gradient(180deg, rgba(81, 189, 236, 0.10), rgba(17, 19, 21, 0.04));
  color: var(--text);
}

.book-illus-placeholder__title{
  font-size: 18px;
  font-weight: 800;
}

.book-illus-placeholder__body{
  max-width: 320px;
  color: var(--muted);
}

.book-illus{
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 520px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.10);
  display: block;
}

@media (prefers-color-scheme: dark) {
  .book-illus{
    border: 1px solid rgba(234,234,234,0.12);
  }
}

.book-text{
  font-family: "Comic Sans MS", "Trebuchet MS", "Verdana", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  background: rgba(255,255,255,0.75);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 14px;
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  .book-text{
    background: rgba(32,34,38,0.75);
    border: 1px solid rgba(234,234,234,0.10);
  }
}

.book-text p{
  margin: 0;
  white-space: pre-wrap;
}

.book-debug{ margin-top: 10px; }

@media (max-width: 980px){
  .book-spread{ grid-template-columns: 1fr; }
  .book-illus{ max-height: 420px; }
  .book-text{ font-size: 16px; }
}

/* -----------------------------
   Story loading screen
------------------------------ */
.story-loading-page{
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top, rgba(81, 189, 236, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(234,234,234,0.98));
}

.story-loading-shell{
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.story-loading-card{
  width: min(100%, 560px);
  padding: 48px 36px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 24px 60px rgba(17, 19, 21, 0.16);
  text-align: center;
}

.story-loading-spinner{
  width: 76px;
  height: 76px;
  margin: 0 auto 24px;
  border-radius: 999px;
  border: 6px solid rgba(81, 189, 236, 0.18);
  border-top-color: var(--accent);
  animation: story-loading-spin 0.9s linear infinite;
}

.story-loading-title{
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.1;
}

.story-loading-text{
  margin: 0;
  font-size: 18px;
  color: var(--muted);
}

.story-loading-note{
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.story-loading-error{
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #b52b27;
  font-weight: 700;
}

.story-loading-actions{
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

.story-loading-actions .btn{
  min-width: 190px;
  justify-content: center;
}

@keyframes story-loading-spin{
  to { transform: rotate(360deg); }
}

@media (prefers-color-scheme: dark) {
  .story-loading-page{
    background:
      radial-gradient(circle at top, rgba(81, 189, 236, 0.18), transparent 42%),
      linear-gradient(180deg, rgba(17,19,21,0.98), rgba(32,34,38,0.98));
  }

  .story-loading-card{
    background: rgba(32, 34, 38, 0.9);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  }
}

/* -----------------------------
   Generator: stepper / accordion
------------------------------ */
.generator-wizard{
  display: grid;
  gap: 14px;
  padding: 22px;
}

.wizard-progress{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 82%, transparent);
  width: fit-content;
}

.generator-step{
  border: 1px solid var(--border);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background 0.22s ease, opacity 0.22s ease;
}

.generator-step-header{
  width: 100%;
  border: 0;
  background: transparent;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(180px, 0.9fr);
  gap: 16px;
  align-items: center;
  text-align: left;
}

.generator-step-header:hover{
  background: transparent;
}

.generator-step-header:disabled{
  cursor: default;
  opacity: 1;
}

.generator-step-header:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.generator-step-index{
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.generator-step-heading,
.generator-step-meta{
  display: grid;
  gap: 4px;
  min-width: 0;
}

.generator-step-kicker{
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.generator-step-title{
  font-size: 1rem;
  font-weight: 700;
  color: color-mix(in srgb, var(--text) 78%, var(--muted));
  line-height: 1.2;
  transition: color 0.22s ease, font-size 0.22s ease;
}

.generator-step-meta{
  justify-items: end;
  text-align: right;
}

.generator-step-status{
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.generator-step-summary{
  max-width: 100%;
  color: var(--text);
  line-height: 1.35;
}

.generator-step-summary.is-placeholder{
  color: var(--muted);
}

.generator-step-panel{
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s ease, opacity 0.2s ease;
}

.generator-step-content{
  display: grid;
  gap: 12px;
  padding: 0 20px 18px;
}

.generator-step-actions{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px 20px;
}

.generator-step-action-spacer{
  flex: 1 1 auto;
}

.generator-back-button,
.generator-nav-button,
#btnGenerate{
  min-width: 132px;
}

.generator-review-note{
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.generator-checkbox-row{
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 4px;
}

.generator-checkbox-row input{
  margin-top: 2px;
}

.generator-step.is-active{
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.16);
  background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%);
}

.generator-step.is-active .generator-step-title{
  font-size: 1.28rem;
  font-weight: 800;
  color: var(--white);
}

.generator-step.is-active .generator-step-kicker,
.generator-step.is-active .generator-step-status{
  color: color-mix(in srgb, var(--white) 70%, var(--muted));
}

.generator-step.is-active .generator-step-summary{
  color: color-mix(in srgb, var(--white) 82%, var(--muted));
}

.generator-step.is-complete .generator-step-index{
  color: var(--white);
  background: color-mix(in srgb, var(--accent) 72%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 72%, var(--border));
}

.generator-step.is-complete .generator-step-title{
  color: color-mix(in srgb, var(--text) 86%, var(--muted));
}

.generator-step.is-locked{
  opacity: 0.72;
}

.generator-step.is-locked .generator-step-header{
  cursor: default;
}

.generator-step.is-locked .generator-step-title,
.generator-step.is-locked .generator-step-status,
.generator-step.is-locked .generator-step-summary,
.generator-step.is-locked .generator-step-kicker{
  color: var(--muted);
}

.generator-step.is-available .generator-step-header{
  cursor: pointer;
}

@media (max-width: 900px){
  .generator-step-header{
    grid-template-columns: auto minmax(0, 1fr);
  }

  .generator-step-meta{
    grid-column: 1 / -1;
    justify-items: start;
    text-align: left;
    padding-left: 54px;
  }
}

@media (max-width: 640px){
  .generator-wizard{
    padding: 18px;
    gap: 12px;
  }

  .generator-step-header,
  .generator-step-content,
  .generator-step-actions{
    padding-left: 16px;
    padding-right: 16px;
  }

  .generator-step-actions{
    flex-wrap: wrap;
  }

  .generator-back-button,
  .generator-nav-button,
  #btnGenerate{
    width: 100%;
  }

  .generator-step-action-spacer{
    display: none;
  }
}

/* -----------------------------
   Generator: Participants grid (photo cards)
------------------------------ */
.country-grid,
.illustration-style-grid{
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  margin-top: 12px;
  margin-bottom: 14px;
}

.illustration-style-helper{
  margin: 4px 0 10px;
  letter-spacing: 0.01em;
}

.country-card,
.illustration-style-card{
  appearance: none;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  padding: 10px;
  display: grid;
  gap: 10px;
  align-content: start;
  justify-items: stretch;
  text-align: left;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.country-card-media,
.illustration-style-card-media{
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 14px;
  overflow: hidden;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
}

.country-card img,
.illustration-style-card img{
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.country-card-body,
.illustration-style-card-body{
  display: grid;
  gap: 2px;
  width: 100%;
}

.country-card-name,
.illustration-style-card-name{
  display: block;
  padding: 0 2px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}

.country-card:hover,
.illustration-style-card:hover{
  background: var(--surface);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.country-card.selected,
.illustration-style-card.selected{
  background: var(--surface);
  border-color: #ffd44d;
  box-shadow: 0 0 0 3px rgba(255, 212, 77, 0.18);
}

.country-card:focus-visible,
.illustration-style-card:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.generator-location-block{
  display: grid;
  gap: 8px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-8px);
  pointer-events: none;
  transition: max-height 0.22s ease, opacity 0.18s ease, transform 0.22s ease;
}

.generator-location-block.is-visible{
  max-height: 180px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (max-width: 980px){
  .country-grid,
  .illustration-style-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px){
  .country-grid,
  .illustration-style-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.participants-grid{
  display: grid;
  gap: 12px;
  margin: 10px 0 0;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1100px){
  .participants-grid{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 860px){
  .participants-grid{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px){
  .participants-grid{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.participant-tile{
  /* override base button styling */
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);

  padding: 10px;
  border-radius: 16px;
  cursor: pointer;

  display: grid;
  gap: 10px;
  justify-items: stretch;
  text-align: left;

  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.participant-tile:hover{
  box-shadow: var(--shadow);
  transform: translateY(-3px);
}

.participant-tile:active{ transform: translateY(1px); }

.participant-tile.selected{
  border: 2px solid #2d7bff;
  box-shadow: 0 0 0 4px rgba(45, 123, 255, 0.18);
  opacity: 1;
}

.participant-tile:not(.selected){ opacity: 0.88; }

.participant-photo{
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.participant-photo img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.participant-tile:hover .participant-photo img{
  transform: scale(1.05);
}

.participant-photo--empty{
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.06);
}

@media (prefers-color-scheme: dark) {
  .participant-photo--empty{ background: rgba(234,234,234,0.08); }
}

.participant-meta{ display: grid; gap: 2px; }

.participant-name{
  font-weight: 900;
  line-height: 1.15;
}

.participant-kind{ margin: 0; }

/* Generator: step / buttons polish */
.participants-title{
  display:block;
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 6px;
}

/* Make wizard Next buttons use accent system */
.btn-next, #btnNextParticipants {
  background: var(--accent);
  color: var(--white);
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
}

.btn-next:hover, #btnNextParticipants:hover{
  background: var(--accent-hover);
}

.btn-next[disabled], #btnGenerate[disabled], #btnNextParticipants[disabled] {
  opacity: .45;
  cursor: not-allowed;
}

.color-row { display:flex; align-items:center; gap:10px; }
.swatch {
  width:16px; height:16px; border-radius:4px;
  border:1px solid rgba(0,0,0,0.25);
  background:#fff;
  flex: 0 0 auto;
}

/* -----------------------------
   Characters page enhancements (PATCH)
------------------------------ */

/* Make left column slimmer + sticky */
.grid-characters{
  grid-template-columns: 0.85fr 1.15fr;
  align-items: start;
}

@media (max-width: 980px){
  .grid-characters{ grid-template-columns: 1fr; }
}

.card--sticky{
  position: sticky;
  top: 86px; /* below sticky header */
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
}

/* Small button variant */
.btn-sm{
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 13px;
}

/* Header row inside cards */
.card-header-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.card-header-row h2{ margin: 0; }

/* Tighten saved list */
.char-list.compact{ gap: 8px; }
.char-list.compact .char-item{ padding: 10px; }
.char-avatar-link{ display: inline-flex; }

/* Form: 2-column grids */
.form-grid-2{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

@media (max-width: 680px){
  .form-grid-2{ grid-template-columns: 1fr; }
}

.field label{ margin-top: 0; }
.field input,
.field select,
.field textarea{ margin-bottom: 0; }

/* Buttons/status row under photo preview */
.toolbar-row{
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar-status{
  min-height: 1.2em;
}

.toolbar-status.is-error{
  color: #b52b27;
}

/* Details sections (collapsible groups) */
.section{
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 10px 12px;
  margin: 12px 0;
}

.section summary{
  cursor: pointer;
  list-style: none;
}

.section summary::-webkit-details-marker{ display:none; }

/* Make the summary look like a header */
.section summary h3{
  display: inline-block;
  margin: 0;
  font-size: 16px;
}

.section-intro{
  margin-top: 6px;
}

/* Clothing rows: item + colour + swatch in one line */
.clothing-row{
  display: grid;
  grid-template-columns: 160px 1fr 1fr 22px;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
}

@media (max-width: 680px){
  .clothing-row{
    grid-template-columns: 1fr;
  }
  .clothing-row .swatch{ justify-self: start; }
}

/* Make swatches look good on white + dark */
.swatch{
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.25);
  background: #fff;
}
@media (prefers-color-scheme: dark){
  .swatch{ border: 1px solid rgba(234,234,234,0.20); }
}
