:root {
  --bg: #0f0d17;
  --bg-2: #171425;
  --card: #1c1830;
  --card-2: #241f3b;
  --line: #312a4d;
  --text: #ece8f6;
  --muted: #a49cbc;
  --accent: #ffb661;
  --accent-2: #a98bff;
  --accent-text: var(--accent);  /* links and accent-colored text: darker on light themes (WCAG AA 4.5:1) */
  --ok: #6fd3a0;
  --warn: #f5c16c;
  --bad: #f07a7a;
  --discord: #5865f2;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf7f2;
    --bg-2: #f2ede4;
    --card: #ffffff;
    --card-2: #f7f3ec;
    --line: #e6dfd2;
    --text: #221d33;
    --muted: #6d6680;
    --accent: #d9771f;
    --accent-text: #9e500f;
    --ok: #2b7a52;  /* status colors readable on light backgrounds (WCAG AA) */
    --warn: #7d5800;
    --bad: #b83228;
    --accent-2: #6d4fe0;
    --shadow: 0 8px 24px rgba(60, 40, 10, .08);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
.halo {
  position: fixed; inset: -30vh -20vw auto; height: 80vh; z-index: -1; pointer-events: none;
  background: radial-gradient(closest-side, rgba(255, 182, 97, .18), transparent 70%),
              radial-gradient(closest-side at 30% 60%, rgba(169, 139, 255, .14), transparent 70%);
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 600; line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(30px, 6vw, 48px); }
h2 { font-size: 20px; }
.top, main, .foot { width: 100%; max-width: 1040px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.top { display: flex; align-items: center; justify-content: space-between; padding-top: 18px; padding-bottom: 18px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font: 600 20px Fraunces, Georgia, serif; }
.brand:hover { text-decoration: none; }
#nav { display: flex; align-items: center; gap: 10px; }
main { flex: 1; padding-top: 12px; padding-bottom: 40px; outline: none; }
.foot { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; padding-top: 18px; padding-bottom: 28px;
  color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.foot a, .profile-counts a { display: inline-flex; align-items: center; min-height: 24px; }
.loading { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); padding: 10px 16px; border-radius: 999px; font: 500 14px Inter, sans-serif;
  cursor: pointer; transition: transform .08s ease, background .15s ease; }
.btn:hover { background: var(--card-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn.primary { background: var(--discord); border-color: var(--discord); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { padding: 14px 22px; font-size: 16px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }

.hero { padding: 36px 0 28px; max-width: 640px; }
.hero p { color: var(--muted); font-size: 17px; margin: 0 0 22px; }
.hero .privacy-note { margin-top: 12px; font-size: 13px; }
.notice { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 12px;
  padding: 12px 14px; margin: 0 0 18px; }
.notice.bad { border-left-color: var(--bad); }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card .sub { color: var(--muted); font-size: 13px; }
.feature .icon { font-size: 22px; }
.feature p { color: var(--muted); margin: 6px 0 0; }

.welcome { display: flex; align-items: center; gap: 14px; margin: 8px 0 22px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--card-2); border: 2px solid var(--line); object-fit: cover; flex: none; }
.avatar.small { width: 30px; height: 30px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--card-2); border: 1px solid var(--line); }
.badge.premium { background: linear-gradient(90deg, #ffb661, #f08a4b); color: #2a1600; border: 0; }
.badge.ok { color: var(--ok); } .badge.off { color: var(--muted); } .badge.bad { color: var(--bad); }
.meter { margin: 12px 0 4px; }
.meter .label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.bar { height: 8px; background: var(--card-2); border-radius: 999px; overflow: hidden; margin-top: 5px; }
.bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: inherit; }
.soon li { color: var(--muted); margin: 4px 0; }
.soon { padding-left: 18px; margin: 8px 0 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

.menu { position: relative; }
.menu > button { display: flex; align-items: center; gap: 8px; background: transparent; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px 4px 4px; color: var(--text); font: 500 14px Inter, sans-serif; cursor: pointer; }
.menu .pop { position: absolute; right: 0; top: calc(100% + 8px); background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 210px; display: none; z-index: 5; }
.menu.open .pop { display: block; }
.pop button, .pop a { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  padding: 9px 12px; border-radius: 8px; font: 14px Inter, sans-serif; cursor: pointer; }
.pop button:hover, .pop a:hover { background: var(--card-2); text-decoration: none; }

.policy { max-width: 760px; }
.policy section { margin: 0 0 26px; }
.policy p, .policy li { color: var(--text); }
.policy ul { padding-left: 20px; }
.policy code { background: var(--card-2); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
.toc { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 24px; }
.toc a { font-size: 13px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; background: var(--card-2);
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 18px; transition: .2s ease; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px); box-sizing: border-box; text-align: center; overflow-wrap: anywhere; z-index: 90; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .menu > button .uname { display: none; }
  .hero { padding-top: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* -- navigation ------------------------------------------------------------------- */
.navlinks { display: flex; gap: 4px; }
.navlink { color: var(--muted); padding: 7px 12px; border-radius: 999px; font-weight: 500; font-size: 14px; }
.navlink:hover { color: var(--text); background: var(--card); text-decoration: none; }
.navlink.current { color: var(--text); background: var(--card-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #2a1600); font-weight: 600; }
.btn.accent:hover { filter: brightness(1.06); background: var(--accent); }
.btn.disabled, .btn:disabled { opacity: .5; pointer-events: none; }
.badge.warn { color: var(--warn); }

/* -- lists --------------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.page-head h1 { margin: 0; font-size: clamp(26px, 5vw, 36px); }
.page-head .row { margin: 0; }
.back { display: inline-block; margin-bottom: 6px; }
.entity { display: flex; flex-direction: column; }
.entity.is-active { border-color: var(--accent); }
.entity-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.entity-head h2 { margin: 0; font-size: 20px; }
.entity-head h2 a { color: var(--text); }
.entity .blurb { flex: 1; margin: 10px 0 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.entity .row { margin-top: 12px; }
.empty { text-align: center; padding: 36px 18px; }

/* -- editor ------------------------------------------------------------------------- */
.form-section { margin: 0 0 16px; scroll-margin-top: 16px; }
.field { margin: 16px 0 0; display: flex; flex-direction: column; gap: 6px; }
.field:first-of-type { margin-top: 8px; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.field label { font-weight: 600; }
.req { color: var(--accent-text); }
.hint { color: var(--muted); font-size: 13px; }
.count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; flex: none; }
.count.near { color: var(--warn); }
input, textarea, select {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: 15px/1.5 Inter, system-ui, sans-serif; transition: border-color .15s ease;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(169, 139, 255, .18); }
::placeholder { color: var(--muted); opacity: .7; }
.savebar { position: sticky; bottom: 12px; z-index: 4; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 8px 8px 18px; box-shadow: var(--shadow); }
.savebar #dirty { margin-right: auto; color: var(--warn); }
.savebar-note { margin: 8px 6px 0; text-align: right; }
.tip { margin-top: 14px; }
.toc { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 8px 0; }

@media (max-width: 560px) {
  .navlinks { display: none; }
  .savebar { border-radius: 14px; flex-wrap: wrap; padding: 8px; gap: 8px; }
  .savebar #dirty:empty { display: none; }
  .savebar-note { text-align: left; }
}

/* -- phase 3: story, voice, settings ------------------------------------------------- */
.section-title { margin: 28px 0 12px; }
section.card { margin: 16px 0 0; }
.card h3 { font: 600 15px Inter, sans-serif; margin: 18px 0 8px; }
.mem-list { list-style: none; margin: 0; padding: 0; }
.mem { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.mem:first-child { border-top: 0; }
.mem-text { flex: 1; overflow-wrap: anywhere; }
.mem-actions { display: flex; gap: 4px; flex: none; align-items: center; }
.mem-edit { flex: 1; }
.icon-btn { background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 7px; cursor: pointer; font-size: 15px; color: var(--text); }
.icon-btn:hover { background: var(--card-2); border-color: var(--line); }
.add-mem input, #newSave input, #redeem input, #deleteAll input { flex: 1; min-width: 180px; }
.recap { margin: 12px 0 0; padding: 12px 14px; border-left: 3px solid var(--accent-2); background: var(--bg-2); border-radius: 8px; white-space: pre-wrap; }
.feel { margin: 10px 0 14px; }
.feel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.meter.small { margin: 6px 0 0; }
.meter.small .bar { height: 6px; }
.upsell { border-style: dashed; }
.danger-zone { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.voice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.voice-chip { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; color: var(--text); cursor: pointer; font: 14px Inter, sans-serif; }
.voice-chip:hover { background: var(--card-2); }
.voice-chip .sub { display: block; font-size: 12px; }
.voice-chip .play { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink, #2a1600); font-size: 12px; }
.voice-char .field { margin-top: 10px; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.filter .btn.active { background: var(--card-2); border-color: var(--accent-2); }
.filter { margin: 0 0 12px; }
.check, .switch-row { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; cursor: pointer; }
.check input, .switch-row input { width: auto; margin-top: 4px; accent-color: var(--accent); }
.check input[type="checkbox"], .switch-row input[type="checkbox"] { width: 18px; height: 18px; flex: none; }  /* easier to tap */
.switch-row input:disabled + span { opacity: .6; }
#rec.recording { border-color: var(--bad); color: var(--bad); }
#vCheck { width: 100%; margin-top: 10px; }
.perks { padding-left: 18px; margin: 10px 0; }
.perks li { margin: 3px 0; }
.code-big { font-size: 18px; letter-spacing: .08em; padding: 6px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; }
#aiPick { width: auto; min-width: 180px; }

/* -- phase 4: gallery ----------------------------------------------------------------- */
.gallery-search { margin-bottom: 14px; }
.gallery-search input { flex: 1; min-width: 200px; }
.filter .sep { width: 1px; background: var(--line); margin: 0 4px; align-self: stretch; }
.gallery-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.gcard { display: flex; flex-direction: column; padding: 0; overflow: hidden; color: var(--text); transition: transform .12s ease, border-color .12s ease; }
.gcard:hover { text-decoration: none; transform: translateY(-2px); border-color: var(--accent-2); }
.gcard .gbody { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.gcard h2 { font-size: 18px; margin: 0; }
.gcard .sub { margin: 0; }
.gsummary { margin: 6px 0; color: var(--text); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; flex: 1; }
.portrait { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--card-2); display: block; }
.portrait.placeholder { display: grid; place-items: center; font: 600 44px Fraunces, Georgia, serif; color: var(--muted);
  background: radial-gradient(circle at 30% 20%, rgba(255, 182, 97, .25), transparent 60%), radial-gradient(circle at 70% 80%, rgba(169, 139, 255, .25), transparent 60%), var(--card-2); }
.gcard .portrait { max-height: 340px; object-position: 50% 15%; }  /* faces are near the top */
.pager { justify-content: center; align-items: center; margin-top: 18px; }
.mine summary, #publish summary { cursor: pointer; list-style: none; }
.mine summary::-webkit-details-marker, #publish summary::-webkit-details-marker { display: none; }
.mine { margin-bottom: 16px; }
.listing { margin-top: 10px; }
.listing-head { display: grid; grid-template-columns: minmax(150px, 240px) 1fr; gap: 20px; align-items: start; }
.portrait.big { border-radius: 14px; }
.listing .lead { font-size: 17px; margin: 18px 0 6px; }
.sheet-part h3 { margin-top: 16px; }
.sheet-part p { white-space: pre-wrap; margin: 0; color: var(--text); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 640px) { .listing-head { grid-template-columns: 1fr; } .portrait.big { max-width: 260px; } }

/* -- phase 5: chat -------------------------------------------------------------------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 460px; }
.head-note { margin-left: auto; }
.notice.slim { padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.feed { flex: 1; overflow-y: auto; padding: 6px 4px 12px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; overscroll-behavior: contain; }
.msg { display: flex; flex-direction: column; max-width: min(760px, 92%); }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg .meta { font-size: 12px; margin: 0 6px 4px; }
.bubble { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; line-height: 1.6; overflow-wrap: anywhere; }
.msg.user .bubble { background: color-mix(in srgb, var(--accent-2) 18%, var(--card)); border-color: color-mix(in srgb, var(--accent-2) 35%, var(--line)); border-bottom-right-radius: 6px; }
.msg.assistant .bubble { border-bottom-left-radius: 6px; }
.msg.pending { opacity: .6; }
/* One bubble per speaker: side characters get their own bubble, name above, a color per name (mixed with the
   theme's own colors so it reads on every theme) */
.parts { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.part { display: flex; flex-direction: column; max-width: 100%; --spk: var(--accent-2); }  /* .tone-N (below) wins */
.part .speaker { font-size: 12px; font-weight: 600; margin: 0 6px 3px; color: var(--muted); }
.part.side { margin-left: 14px; }
.part.side .speaker { color: color-mix(in srgb, var(--spk) 55%, var(--text)); }
.part.side .bubble { background: color-mix(in srgb, var(--spk) 9%, var(--card)); border-color: color-mix(in srgb, var(--spk) 45%, var(--line)); }
.tone-0 { --spk: #e4766a; } .tone-1 { --spk: #3fb3a3; } .tone-2 { --spk: #d39b2c; }
.tone-3 { --spk: #6b98ea; } .tone-4 { --spk: #c277d6; } .tone-5 { --spk: #74b957; }
/* Stories with several AIs: the cast and who made each AI (chat header), and the "new story" picker */
.cast-line { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 6px 0 0; font-size: 13px; }
.cast-chip { padding: 2px 10px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--spk, var(--accent-2)) 45%, var(--line));
  background: color-mix(in srgb, var(--spk, var(--accent-2)) 9%, var(--card)); }
.cast-chip b { color: color-mix(in srgb, var(--spk, var(--accent-2)) 55%, var(--text)); }
.cast-credits { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.cast-credits li { border-left: 3px solid var(--spk, var(--line)); padding-left: 8px; display: flex; flex-direction: column; }
.cast-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-top: 10px; }
.cast-opt { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.cast-opt:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.cast-opt.off { opacity: .6; cursor: not-allowed; }
.cast-opt input { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.cast-opt > span { display: flex; flex-direction: column; min-width: 0; }
.cast-opt .hint { margin: 0; }
.cast-pic { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; background: var(--card-2); }
.cast-pic.cover-ph { font-size: 15px; color: var(--muted); }
.story-new fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
.story-new .indent { margin: 6px 0 0 28px; }
.bubble .scene { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0; font-size: .9333em;
  color: var(--muted); font-style: italic; white-space: normal; }
.bubble .scene:first-child { margin-top: 0; }
.bubble blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.bubble .subtext, .sysline .subtext { display: block; font-size: 12px; color: var(--muted); }
.bubble .subtext { font-size: .8em; }  /* follows the reading size (12px at the default) */
.spoiler { background: var(--muted); color: transparent; border-radius: 4px; cursor: pointer; padding: 0 2px; transition: .15s; }
.spoiler.revealed { background: var(--card-2); color: inherit; cursor: auto; }
.hidden-msg { color: var(--muted); font-style: italic; }
.sysline { align-self: center; max-width: 90%; text-align: center; font-size: 13px; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin: 4px 2px 0; }
.controls .tweak { width: auto; padding: 4px 8px; font-size: 13px; border-radius: 8px; }
.controls .sub { font-size: 12px; padding: 0 2px; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.media { margin-top: 8px; max-width: 360px; }
.media img { width: 100%; border-radius: 12px; display: block; }
audio.media { width: 320px; max-width: 100%; }
.edit-box { min-height: 160px; margin-bottom: 8px; }
.older { text-align: center; }
.typing { color: var(--muted); font-size: 13px; padding: 4px 6px; display: flex; align-items: center; gap: 3px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; margin-right: 6px; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.composer { display: flex; gap: 8px; align-items: flex-end; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 8px; }
.composer textarea { border: 0; background: transparent; resize: none; min-height: 40px; max-height: 220px; box-shadow: none !important; }
.composer-actions { display: flex; gap: 6px; }
@media (max-width: 560px) {
  .chat { height: calc(100vh - 120px); }
  .head-note { display: none; }
  .msg { max-width: 96%; }
}

/* -- phase 6: mobile pass + language picker ---------------------------------------------------- */
[hidden] { display: none !important; }
.initials { display: grid; place-items: center; font: 600 13px Inter, sans-serif; color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 45%, var(--card-2)), color-mix(in srgb, var(--accent-2) 45%, var(--card-2))); }
.avatar.initials { font-size: 22px; }
.avatar.small.initials { font-size: 12px; }
.menu > button .burger { font-size: 16px; line-height: 1; padding: 0 2px; }
.lang-pick { display: inline-flex; gap: 4px; align-items: center; }
.lang-pick select { width: auto; padding: 3px 8px; font-size: 13px; border-radius: 8px; }
@media (max-width: 560px) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gcard .portrait { max-height: 250px; }
  .gcard .gbody { padding: 10px 10px 12px; }
  .gcard h2 { font-size: 15px; }
  .gsummary { -webkit-line-clamp: 3; font-size: 13px; }
  .portrait.placeholder { font-size: 32px; }
  .top { padding-top: 12px; padding-bottom: 12px; }
}

/* -- story focus (hexagon) ----------------------------------------------------------------- */
.focus-box { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; margin-top: 12px; }
.radar { max-width: 100%; height: auto; overflow: visible; }
.radar .ring { fill: none; stroke: var(--line); stroke-width: 1; }
.radar .axis { stroke: var(--line); stroke-width: 1; }
.radar .shape { fill: color-mix(in srgb, var(--accent-2) 30%, transparent); stroke: var(--accent-2); stroke-width: 2; stroke-linejoin: round; }
.radar .dot { fill: var(--accent); }
.radar text { font: 600 11px Inter, sans-serif; fill: var(--muted); }
.radar .val { fill: var(--text); }
.focus-sliders { display: flex; flex-direction: column; gap: 6px; }
.slider { display: grid; grid-template-columns: 80px 1fr 22px; gap: 8px; align-items: center; font-size: 13px; }
.slider input { padding: 0; accent-color: var(--accent-2); }
.slider b { text-align: right; font-variant-numeric: tabular-nums; }
.focus-view .radar { display: block; margin: 0 auto; }
@media (max-width: 560px) { .focus-box { grid-template-columns: 1fr; justify-items: center; } .focus-sliders { width: 100%; } }

#focus .points { font-size: 13px; font-weight: 600; color: var(--warn); margin: 6px 0 0; }
#focus .points.ok { color: var(--ok); }

/* main picture: current one + a set of drawn portraits to pick from */
#portrait { margin-top: 16px; }
.portrait-current { display: block; max-width: 220px; width: 100%; border-radius: 12px; margin-bottom: 12px; }
.portrait-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); margin: 10px 0 14px; }
.portrait-pick { padding: 0; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card);
  cursor: pointer; display: flex; flex-direction: column; color: inherit; font: inherit; }
.portrait-pick:hover, .portrait-pick:focus-visible { border-color: var(--accent); }
.portrait-pick img { width: 100%; aspect-ratio: 832 / 1216; object-fit: cover; display: block; }
.portrait-pick span { padding: 6px; font-size: 13px; text-align: center; }
.portrait-pick:disabled { opacity: .6; cursor: wait; }
@media (max-width: 560px) { .portrait-grid { gap: 6px; } .portrait-pick span { padding: 4px; font-size: 12px; } }

/* texting mode: one reply = several text messages */
.texts { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.msg.assistant .texts .bubble { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .msg.assistant .texts .bubble { animation: none; } }

/* lorebook */
#lore { margin-top: 16px; }
.lore-entry { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; }
.lore-entry.off { opacity: .6; }
.lore-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lore-text { white-space: pre-wrap; margin: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--line); }
.card.inset { box-shadow: none; margin: 10px 0; }

/* chat over the AI's main picture: the picture fills the screen, the chat stays readable on translucent glass */
#chatBackdrop { position: fixed; inset: 0; z-index: -1; background-size: cover; background-position: center 20%;
  background-repeat: no-repeat; }
#chatBackdrop::after { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 55%, transparent) 0%,
    color-mix(in srgb, var(--bg) 25%, transparent) 40%, color-mix(in srgb, var(--bg) 70%, transparent) 100%); }
body.chat-backdrop { background: var(--bg); }
body.chat-backdrop .halo { display: none; }
body.chat-backdrop .top, body.chat-backdrop .foot { background: color-mix(in srgb, var(--bg) 60%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
body.chat-backdrop .top { position: relative; z-index: 20; }  /* the blur makes it a layer: keep ☰'s menu above the page */
/* Wide screens (a computer, a phone or tablet held sideways, 1.7.1): the chat is a column in the middle, and the AI's
   picture sits behind it with soft edges instead of being blown up to the whole screen; the site's (or your own)
   background shows around it. A chat theme's own background still fills the screen. */
@media (min-width: 720px) and (min-aspect-ratio: 1/1) {
  body.in-chat main { max-width: 860px; }
  #chatBackdrop:not(.lk-backdrop) { left: 50%; right: auto; width: min(100vw, clamp(420px, 82vh, 900px)); transform: translateX(-50%);
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent); }
  body.chat-backdrop:has(#chatBackdrop:not(.lk-backdrop)) .halo { display: block; z-index: -2; }
}
.chat.has-bg .bubble, .chat.has-bg .composer, .chat.has-bg .notice,
.chat.has-bg .sysline, .chat.has-bg .typing {
  background: color-mix(in srgb, var(--card) 68%, transparent);
  -webkit-backdrop-filter: blur(8px) saturate(1.1); backdrop-filter: blur(8px) saturate(1.1); }
.chat.has-bg .msg.user .bubble { background: color-mix(in srgb, color-mix(in srgb, var(--accent-2) 22%, var(--card)) 72%, transparent); }
.chat.has-bg .bubble .scene { background: color-mix(in srgb, var(--bg-2) 60%, transparent); }
.chat.has-bg .part.side .bubble { background: color-mix(in srgb, color-mix(in srgb, var(--spk) 12%, var(--card)) 72%, transparent); }
.chat.has-bg .msg .meta, .chat.has-bg .part .speaker, .chat.has-bg .head-note { text-shadow: 0 1px 3px color-mix(in srgb, var(--bg) 90%, transparent); }
.chat.has-bg .typing { border-radius: 999px; align-self: flex-start; padding: 4px 12px; }
.chat.has-bg .feed { scrollbar-color: color-mix(in srgb, var(--text) 30%, transparent) transparent; }
@media (prefers-reduced-transparency: reduce) {
  .chat.has-bg .bubble, .chat.has-bg .composer { background: var(--card); backdrop-filter: none; }
  .chat.has-bg .part.side .bubble { background: color-mix(in srgb, var(--spk) 9%, var(--card)); }
}
/* installed app: full height, safe areas (notch, home bar) */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .foot { display: none; }
  .chat { height: calc(100dvh - 86px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}

/* story tracking */
#tracking .person { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
#tracking .person:first-of-type { border-top: 0; }
#tracking h3 { margin: 4px 0 6px; font-size: 15px; }
.quests { margin: 4px 0 0; padding-left: 18px; }
.quests li { list-style: none; margin-left: -18px; }
.quests li.done, .quests li.failed { color: var(--muted); }
.sim-footer { font-size: 12px; color: var(--muted); margin: 4px 8px 0; }
.sim-footer p { margin: 0; }

/* feelings over time */
.card.wide { grid-column: 1 / -1; }
.feel-chart { margin: 8px 0 0; }
.feel-chart figcaption { font-size: 14px; margin-bottom: 2px; }
.feel-chart svg { width: 100%; height: auto; display: block; }
.feel-chart text { font-size: 11px; fill: var(--muted); }
.feel-chart .grid { stroke: var(--line); stroke-width: 1; }
.feel-chart .zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 4; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

/* shared story moments */
.share-panel { margin-top: 8px; max-width: 520px; }
.share-url { flex: 1; min-width: 0; }
.share-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--line); }
.share-row:first-child { border-top: 0; }
.share-page main { max-width: 760px; margin: 0 auto; padding: 16px; }
.share-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.share-head h1 { margin: 0; }
.share-pic { width: 96px; height: 140px; object-fit: cover; border-radius: 14px; box-shadow: var(--shadow); }
.share-feed { display: flex; flex-direction: column; gap: 14px; }
.share-foot { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-top: 24px; }
.share-report { margin: 0; }
.share-page .spoiler:hover, .share-page .spoiler:focus { background: var(--card-2); color: inherit; }

/* age verification */
.privacy-note { border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 12px; padding: 10px 14px; margin: 12px 0; }
.privacy-note h3 { margin: 0 0 6px; font-size: 15px; }
.privacy-note ul { margin: 6px 0; padding-left: 18px; }
.privacy-note li { margin: 4px 0; }
.age-steps { padding-left: 20px; }
.age-steps li { margin: 6px 0; }
.age-code { font-size: 20px; letter-spacing: 2px; font-family: ui-monospace, monospace; }

/* Sign-in buttons and the sign-up form (Google accounts) */
.login-buttons { justify-content: center; }
.google-btn { background: #fff; color: #1f1f1f; border-color: #dadce0; }
.google-btn:hover { background: #f2f2f2; }
.signup { max-width: 520px; margin: 24px auto; }
.signup .stack label { display: block; margin-top: 14px; }
.signup .stack input[name="name"] { margin-top: 6px; }
.signup .btn.big { margin-top: 18px; width: 100%; }

/* The AI's texting photos and voice notes; the microphone button */
.ai-photo img { max-width: min(320px, 100%); border-radius: 16px; display: block; }
.photo-wait { padding: 18px 16px; border-radius: 16px; background: var(--card-2); color: var(--muted); font-size: 14px; }
.voice-note { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 16px; background: var(--card); max-width: 100%; }
.voice-note audio { width: 100%; max-width: 300px; }
.voice-note details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
#mic.recording, #dictate.recording { color: #fff; background: #d64545; border-color: #d64545; }
@media (max-width: 560px) {  /* phone: the message box keeps its room next to 🎲 ✍️ 🎙️ */
  .dictate-btn { display: none; }  /* phone keyboards have their own dictation mic */
  .composer { flex-wrap: wrap; }
  .composer textarea { flex: 1 1 100%; }
  .composer-actions { width: 100%; justify-content: flex-end; }
}

/* -- public profiles (profile.js) ------------------------------------------------------------------------ */
/* Accent colors are fixed classes (the page never takes a raw color value from a user). */
.profile, .swatch { --p-accent: var(--accent-2); }
.accent-amber { --p-accent: #f5a524; }
.accent-rose { --p-accent: #ec5f8c; }
.accent-violet { --p-accent: #9b7bff; }
.accent-sky { --p-accent: #4aa8f0; }
.accent-teal { --p-accent: #2fb8a6; }
.accent-lime { --p-accent: #8cc63f; }
.accent-coral { --p-accent: #f27a5a; }
.accent-slate { --p-accent: #8a94a8; }
.profile { border-top: 4px solid var(--p-accent); position: relative; overflow: hidden; }
.profile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 120px; pointer-events: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--p-accent) 22%, transparent), transparent); }
.profile-head { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.profile-head.small { margin-bottom: 10px; }
.profile-id { flex: 1; min-width: 180px; }
.profile-id h1 { margin: 0; font-size: clamp(24px, 5vw, 34px); overflow-wrap: anywhere; }
.profile-id .sub { margin: 4px 0 0; }
.profile-actions { margin: 0; }
.avatar.xl { width: 104px; height: 104px; border: 3px solid var(--p-accent, var(--line)); }
.avatar.xl.initials { font-size: 38px; }
.avatar.initials { display: inline-grid; place-items: center; font-weight: 600; color: var(--muted); }
.profile-bio { position: relative; white-space: pre-wrap; overflow-wrap: anywhere; margin: 18px 0 0; font-size: 16px; }
.profile-stats { position: relative; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-top: 18px; }
.profile-stats > div { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  display: flex; flex-direction: column; }
.profile-stats b { font-size: 22px; color: color-mix(in srgb, var(--p-accent) 75%, var(--text)); }  /* readable with any custom color */
.profile-stats span { color: var(--muted); font-size: 13px; }
.section-title { margin: 26px 0 12px; font-size: 20px; }
.join-card { margin-top: 22px; text-align: center; }
.handle-input { display: flex; align-items: center; gap: 6px; }
.handle-input span { color: var(--muted); font-weight: 600; }
.handle-input input { flex: 1; min-width: 0; }
.hint.bad { color: var(--bad); }
.accents { border: 0; padding: 0; }
.accents legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px 6px 8px; border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer; font-size: 13px; }
.swatch::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--p-accent); }
.swatch.none::before { background: var(--accent-2); }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch:has(input:checked) { border-color: var(--p-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--p-accent) 40%, transparent); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.portrait-pick.chosen { border-color: var(--accent); }
.portrait-pick .avatar.initials { width: 100%; height: auto; aspect-ratio: 832 / 1216; border-radius: 0; border: 0; font-size: 28px; }
@media (max-width: 560px) {
  .profile-head { flex-direction: column; align-items: flex-start; }
  .profile-actions { width: 100%; }
}
.custom-color { margin-top: 10px; align-items: center; gap: 10px; }
.custom-color input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); cursor: pointer; }
.custom-color #accentHex { width: 110px; font-family: ui-monospace, monospace; }
.custom-color #accentHex.bad { border-color: var(--bad); }

/* -- social: follows, friends, relationships ------------------------------------------------------------- */
.rels { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0; font-size: 14px; }
.rel-label { color: var(--muted); }
.lock { font-size: .6em; vertical-align: middle; }
.profile-counts { position: relative; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 16px 0 0; color: var(--muted); }
.profile-counts b { color: var(--text); }
.profile-counts a { color: var(--muted); }
.profile-counts a:hover b { text-decoration: underline; }
.profile-actions { position: relative; margin-top: 14px; flex-wrap: wrap; }
.profile-actions .menu > button { padding: 8px 14px; }
.profile-actions .pop { min-width: 210px; z-index: 5; }
.private-card { margin-top: 16px; }
.people { list-style: none; margin: 0; padding: 0; }
.card.people { padding: 6px 16px; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.person:last-child { border-bottom: 0; }
.person .avatar.small { width: 40px; height: 40px; }
.person .avatar.small.initials { font-size: 15px; }
.person-name { flex: 1; min-width: 140px; color: var(--text); overflow-wrap: anywhere; }
.person-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rel-row { gap: 8px; margin-top: 8px; flex-wrap: nowrap; }
.rel-row input { flex: 1 1 40%; min-width: 0; }
.rel-row select { flex: 1 1 50%; min-width: 0; }
.rels-edit { border: 0; padding: 0; }
.rels-edit legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); display: inline-block; margin-left: -6px; align-self: flex-start; }
.dot-count { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff;
  font-size: 12px; font-weight: 700; text-align: center; margin-left: 6px; }

/* -- badges ---------------------------------------------------------------------------------------------- */
.pbadges { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.pbadge { background: var(--card-2); border: 1px solid var(--line); color: var(--text); font-weight: 500; cursor: default; }
.pbadge.official { border-color: var(--p-accent, var(--accent-2)); color: var(--text); font-weight: 600; }
.verified { display: inline-grid; place-items: center; width: .8em; height: .8em; border-radius: 50%; font-size: .55em;
  background: var(--p-accent, var(--accent-2)); color: #fff; vertical-align: middle; margin-left: 4px; }
.badges-edit { border: 0; padding: 0; }
.badges-edit legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.badge-pick { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.badge-pick input { width: auto; accent-color: var(--accent); }

/* -- favorites -------------------------------------------------------------------------------------------- */
.fav-mark { color: var(--warn); font-size: 16px; margin-left: 6px; }
.btn.fav-on { border-color: var(--warn); color: var(--warn); }

/* -- shared stories ----------------------------------------------------------------------------------------- */
.shared-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 14px; }
.shared-head h1 { margin: 0; font-size: clamp(22px, 4.5vw, 30px); }
.shared-head .avatar:not(.small) { width: 64px; height: 64px; }
.shared-head .members { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
.member { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--card-2); font-size: 13px; }
.member.invited { opacity: .7; border-style: dashed; }
.member .avatar.small { width: 26px; height: 26px; }
.shared-chat { min-height: 50vh; }
.shared-tools { margin-top: 16px; }
.shared-tools select { width: 100%; }
.wait-note { margin: 6px 4px 0; min-height: 1em; }
#waitRange { width: 100%; accent-color: var(--accent); }

/* -- name fonts (core.js NAME_FONTS) -------------------------------------------------------------------- */
.name-font-sans { font-family: Inter, sans-serif; font-weight: 600; }
.name-font-playfair { font-family: "Playfair Display", Georgia, serif; }
.name-font-cinzel { font-family: Cinzel, Georgia, serif; }
.name-font-pacifico { font-family: Pacifico, cursive; font-weight: 400; }
.name-font-dancing { font-family: "Dancing Script", cursive; }
.name-font-greatvibes { font-family: "Great Vibes", cursive; font-weight: 400; font-size: 1.2em; }
.name-font-caveat { font-family: Caveat, cursive; font-size: 1.15em; }
.name-font-marker { font-family: "Permanent Marker", cursive; font-weight: 400; }
.name-font-bangers { font-family: Bangers, cursive; font-weight: 400; letter-spacing: .04em; }
.name-font-orbitron { font-family: Orbitron, sans-serif; }
.name-font-pixel { font-family: "Press Start 2P", monospace; font-weight: 400; font-size: .62em; line-height: 1.6; }
.name-font-typewriter { font-family: "Special Elite", monospace; font-weight: 400; }
.name-font-creepster { font-family: Creepster, cursive; font-weight: 400; letter-spacing: .03em; }
.name-font-gothic { font-family: UnifrakturMaguntia, serif; font-weight: 400; }
.fonts-edit { border: 0; padding: 0; }
.fonts-edit legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.font-picks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-top: 8px; }
.font-pick { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer; background: var(--card); overflow: hidden; }
.font-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.font-pick .fp-name { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-pick .fp-name:not(.name-font) { font-family: Fraunces, Georgia, serif; }  /* the default; fonts use their class */
.font-pick small { color: var(--muted); font-size: 12px; }
.font-pick:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.font-pick:has(input:focus-visible) { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* -- the feed --------------------------------------------------------------------------------------------------- */
.composer-card textarea { width: 100%; resize: vertical; }
.composer-row { align-items: center; gap: 10px; margin-top: 8px; }
.composer-row { flex-wrap: nowrap; }
.composer-row select { flex: 0 1 auto; width: auto; max-width: 60%; }
.composer-row .btn { margin-left: auto; }
.post { margin-top: 14px; }
.post-head { display: flex; align-items: center; gap: 10px; }
.post-head .avatar.small, .comment .avatar.small { width: 40px; height: 40px; }
.post-who { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.post-who a { color: var(--text); }
.post-menu { position: relative; }
.post-menu .pop { right: 0; min-width: 180px; }
.post-body { margin: 10px 0 0; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.post-char { display: flex; gap: 12px; align-items: center; margin-top: 10px; padding: 8px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card-2); color: var(--text); }
.post-char:hover { text-decoration: none; border-color: var(--accent-2); }
.post-char img, .post-char-ph { width: 56px; height: 72px; object-fit: cover; border-radius: 8px; flex: none;
  display: grid; place-items: center; background: var(--card); font: 600 20px Fraunces, Georgia, serif; color: var(--muted); }
.post-char.attached { justify-content: space-between; margin: 8px 0 0; }
.post-actions { display: flex; gap: 6px; margin-top: 10px; }
.post-actions .liked { color: var(--bad); border-color: var(--bad); }
.comments { margin-top: 14px; }
.comment { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.comment-main { flex: 1; min-width: 0; }
.comment-main a { color: var(--text); }
.comment-body { margin: 2px 0; overflow-wrap: anywhere; }
.comment-actions { display: flex; gap: 12px; }
.replies { margin-left: 44px; }
.replies .comment .avatar.small { width: 30px; height: 30px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--muted); font: 500 13px Inter, sans-serif; cursor: pointer; }
.link-btn:hover { color: var(--accent-text); text-decoration: underline; }
.comment-form { margin-top: 12px; }
.comment-form textarea { width: 100%; }

/* -- themes (html[data-theme], home.js / theme.js) — beat the device's light / dark setting ------------------------ */
html[data-theme="dark"] { color-scheme: dark;
  --bg: #0f0d17; --bg-2: #171425; --card: #1c1830; --card-2: #241f3b; --line: #312a4d; --text: #ece8f6; --muted: #a49cbc;
  --accent: #ffb661; --accent-text: var(--accent); --accent-2: #a98bff; --ok: #6fd3a0; --warn: #f5c16c; --bad: #f07a7a; --shadow: 0 10px 30px rgba(0, 0, 0, .35); }
html[data-theme="light"] { color-scheme: light;
  --bg: #faf7f2; --bg-2: #f2ede4; --card: #ffffff; --card-2: #f7f3ec; --line: #e6dfd2; --text: #221d33; --muted: #6d6680;
  --accent: #d9771f; --accent-text: #9e500f; --accent-2: #6d4fe0; --ok: #2b7a52; --warn: #7d5800; --bad: #b83228; --shadow: 0 8px 24px rgba(60, 40, 10, .08); }
html[data-theme="sepia"] { color-scheme: light;
  --bg: #f3ead6; --bg-2: #eadfc5; --card: #fbf5e6; --card-2: #f1e6cc; --line: #d9c8a3; --text: #3a2c1c; --muted: #75644b;
  --accent: #a2541b; --accent-text: #94491a; --accent-2: #7a4e8c; --ok: #2f6b3c; --warn: #74500e; --bad: #9e3a30; --shadow: 0 8px 22px rgba(80, 55, 20, .12); }
html[data-theme="midnight"] { color-scheme: dark;
  --bg: #060a17; --bg-2: #0b1226; --card: #0f1831; --card-2: #15203f; --line: #22305a; --text: #e6ecff; --muted: #93a1c7;
  --accent: #6cc4ff; --accent-text: var(--accent); --accent-2: #a594ff; --ok: #6fd3a0; --warn: #f5c16c; --bad: #f07a7a; --shadow: 0 10px 30px rgba(0, 0, 0, .45); }
html[data-theme="sakura"] { color-scheme: light;
  --bg: #fff5f8; --bg-2: #fde7ef; --card: #ffffff; --card-2: #fff0f5; --line: #f5d0dd; --text: #3a2330; --muted: #8b6577;
  --accent: #d2427a; --accent-text: #b8336a; --accent-2: #8b5cf6; --ok: #2b7a52; --warn: #7d5800; --bad: #b83228; --shadow: 0 8px 24px rgba(160, 60, 100, .10); }
html[data-theme="sepia"] .halo { opacity: .55; }
html[data-theme="midnight"] .halo { filter: hue-rotate(170deg); }
html[data-theme="sakura"] .halo { filter: hue-rotate(300deg); opacity: .8; }

/* -- the appearance picker ------------------------------------------------------------------------------------- */
.look { position: relative; margin-left: auto; }
.look > summary { list-style: none; cursor: pointer; }
.look > summary::-webkit-details-marker { display: none; }
.look-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 6; width: min(92vw, 520px); }
.look-group { margin-top: 10px; }
.look-group:first-child { margin-top: 0; }
.look-themes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.look-theme { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; font: 500 13px Inter, sans-serif; }
.look-theme i { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(127, 127, 127, .4); }
.look-theme.on, .look-layout.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.theme-swatch-auto i { background: linear-gradient(135deg, #0f0d17 50%, #faf7f2 50%); }
.theme-swatch-dark i { background: linear-gradient(135deg, #0f0d17 55%, #ffb661); }
.theme-swatch-light i { background: linear-gradient(135deg, #faf7f2 55%, #d9771f); }
.theme-swatch-sepia i { background: linear-gradient(135deg, #f3ead6 55%, #a2541b); }
.theme-swatch-midnight i { background: linear-gradient(135deg, #060a17 55%, #6cc4ff); }
.theme-swatch-sakura i { background: linear-gradient(135deg, #fff5f8 55%, #d2427a); }
.look-layouts { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-top: 6px; }
.look-layout { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; font: 400 13px Inter, sans-serif; }
.look-layout .ll-icon { font-size: 22px; }
.home-top { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; }
.home-hi { margin: 0; font-size: clamp(24px, 5vw, 34px); }
.welcome .look { align-self: flex-start; }
.home-shortcuts { margin: 22px 0 8px; flex-wrap: wrap; }
.cover-ph { display: grid; place-items: center; font: 600 28px Fraunces, Georgia, serif; color: rgba(255, 255, 255, .92); }
.tint-0 { background: linear-gradient(160deg, #6d4fe0, #2b1d6b); } .tint-1 { background: linear-gradient(160deg, #d9771f, #7a2e0e); }
.tint-2 { background: linear-gradient(160deg, #2fb8a6, #0f4f5c); } .tint-3 { background: linear-gradient(160deg, #ec5f8c, #6b1438); }
.tint-4 { background: linear-gradient(160deg, #4aa8f0, #163b7a); } .tint-5 { background: linear-gradient(160deg, #8cc63f, #2c5a17); }
.tint-6 { background: linear-gradient(160deg, #a98bff, #5b2a86); } .tint-7 { background: linear-gradient(160deg, #f5a524, #8a3b12); }

/* -- Webtoon layout -------------------------------------------------------------------------------------------- */
.wt-hero { position: relative; display: block; border-radius: 22px; overflow: hidden; min-height: 360px; color: #fff;
  box-shadow: var(--shadow); isolation: isolate; }
.wt-hero:hover { text-decoration: none; }
.wt-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; font-size: 72px; }
.wt-hero::after { content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(180deg, transparent 25%, rgba(0, 0, 0, .55) 60%, rgba(0, 0, 0, .88)); }
.wt-hero-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px; }
.wt-hero-text h2 { margin: 8px 0 6px; font-size: clamp(28px, 7vw, 44px); color: #fff; }
.wt-hero-text p { margin: 0 0 14px; color: rgba(255, 255, 255, .88); display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; }
.wt-chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .18);
  backdrop-filter: blur(6px); font-size: 12px; font-weight: 600; }
.wt-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.wt-row { display: flex; gap: 14px; align-items: center; padding: 10px; border-radius: 16px; background: var(--card);
  border: 1px solid var(--line); color: var(--text); }
.wt-row:hover { text-decoration: none; border-color: var(--accent-2); }
.wt-thumb { width: 72px; height: 96px; border-radius: 10px; object-fit: cover; flex: none; font-size: 22px; }
.wt-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wt-row-text b { font-size: 16px; }
.wt-snippet { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wt-go { font-size: 26px; color: var(--muted); }
.strip { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x mandatory; }
.strip-card { position: relative; flex: 0 0 140px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.strip-card:hover { text-decoration: none; }
.strip-img { width: 140px; height: 186px; border-radius: 14px; object-fit: cover; margin-bottom: 4px; }
.strip-card .rank { position: absolute; left: 8px; top: 4px; font: 700 34px Fraunces, Georgia, serif; color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
.home-posts { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.home-post { display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.home-post:hover { text-decoration: none; border-color: var(--accent-2); }
.home-post-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* -- Library layout -------------------------------------------------------------------------------------------- */
.shelf { margin-top: 8px; }
.shelf-row, .shelf-grid { display: flex; gap: 18px; padding: 6px 4px 18px;
  border-bottom: 10px solid color-mix(in srgb, var(--accent) 35%, var(--card-2));
  border-radius: 0 0 6px 6px; box-shadow: 0 10px 14px -12px rgba(0, 0, 0, .5); }
.shelf-row { overflow-x: auto; }
.shelf-grid { flex-wrap: wrap; }
.book { flex: 0 0 116px; width: 116px; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.book:hover { text-decoration: none; }
.book:hover .book-cover { transform: translateY(-4px) rotate(-1deg); }
.book-cover { position: relative; display: block; width: 116px; height: 164px; border-radius: 4px 10px 10px 4px; overflow: hidden;
  box-shadow: inset 6px 0 8px -4px rgba(0, 0, 0, .55), 4px 6px 12px rgba(0, 0, 0, .28); transition: transform .15s ease; }
.book-img { width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; }
.book-title { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 8px; color: #fff;
  font: 600 14px/1.2 Fraunces, Georgia, serif; background: linear-gradient(transparent, rgba(0, 0, 0, .8)); overflow-wrap: anywhere; }
.book-sub { font-size: 12px; }
.book-new .cover-ph { width: 100%; height: 100%; background: var(--card-2); color: var(--muted); font-size: 40px; }
.book-new .book-title { color: var(--text); background: none; }
.reading-stats { margin-top: 18px; }
@media (max-width: 560px) {
  .wt-hero { min-height: 300px; }
  .book, .book-cover { width: 100px; flex-basis: 100px; }
  .book-cover { height: 142px; }
  .shelf-row, .shelf-grid { gap: 12px; }
}
.wt-hero-img.cover-ph { font-size: 0; }  /* no picture: the color alone (the name is written below) */

/* -- Halloween theme ------------------------------------------------------------------------------------------- */
html[data-theme="halloween"] { color-scheme: dark;
  --bg: #120a14; --bg-2: #1b0f1e; --card: #221326; --card-2: #2c1931; --line: #45263f; --text: #f6ece2; --muted: #b9a3ad;
  --accent: #ff8a1f; --accent-text: var(--accent); --accent-2: #a56cff; --ok: #8ee07a; --warn: #ffb347; --bad: #ff5f5f; --shadow: 0 10px 30px rgba(0, 0, 0, .5); }
html[data-theme="halloween"] .halo { filter: hue-rotate(-20deg) saturate(1.6); }
.theme-swatch-halloween i { background: linear-gradient(135deg, #120a14 55%, #ff8a1f); }

/* -- Magazine layout ------------------------------------------------------------------------------------------- */
.mag-mast { border-bottom: 3px double var(--line); padding-bottom: 10px; align-items: flex-end; }
.mag-title { margin: 0; font: 600 clamp(28px, 6vw, 46px)/1.05 Fraunces, Georgia, serif; letter-spacing: -.01em; }
.mag-kicker { margin: 0; color: var(--accent-text); font: 700 11px/1.4 Inter, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.mag { display: grid; gap: 28px; grid-template-columns: minmax(0, 2.2fr) minmax(220px, 1fr); margin-top: 18px; }
.mag-main, .mag-side { min-width: 0; }
.mag-cover { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 18px; color: var(--text); }
.mag-cover:hover { text-decoration: none; }
.mag-cover:hover h2 { text-decoration: underline; }
.mag-cover-img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 4px; font-size: 64px; }
.mag-cover-text h2 { margin: 6px 0 10px; font: 600 clamp(30px, 5vw, 48px)/1.05 Fraunces, Georgia, serif; }
.mag-lead { font: 400 17px/1.6 Georgia, serif; margin: 0 0 12px; }
.mag-lead::first-letter { float: left; font: 600 3.1em/0.85 Fraunces, Georgia, serif; margin: 4px 6px 0 0; color: var(--accent-text); }
.mag-more { font-weight: 600; color: var(--accent-text); }
.mag-section { margin: 24px 0 10px; padding-top: 8px; border-top: 2px solid var(--text); font: 700 13px Inter, sans-serif;
  letter-spacing: .1em; text-transform: uppercase; }
.mag-cols { columns: 2 220px; column-gap: 22px; }
.mag-article { display: block; break-inside: avoid; margin-bottom: 18px; color: var(--text); }
.mag-article:hover { text-decoration: none; }
.mag-article:hover h3 { text-decoration: underline; }
.mag-art-img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; margin-bottom: 6px; font-size: 32px; }
.mag-article h3 { margin: 2px 0 4px; font: 600 21px/1.2 Fraunces, Georgia, serif; }
.mag-article p { margin: 0; color: var(--muted); font: 400 14px/1.55 Georgia, serif; }
.mag-brief { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.mag-brief:hover { text-decoration: none; }
.mag-brief:hover b { text-decoration: underline; }
.mag-rank { flex-direction: row; align-items: center; gap: 12px; }
.mag-rank > span:last-child { display: flex; flex-direction: column; }
.mag-num { font: 700 30px/1 Fraunces, Georgia, serif; color: var(--accent-text); min-width: 26px; }
@media (max-width: 760px) {
  .mag { grid-template-columns: 1fr; }
  .mag-cover { grid-template-columns: 1fr; }
  .mag-cover-img { aspect-ratio: 4 / 3; }
}

/* -- Compact layout -------------------------------------------------------------------------------------------- */
.cp-tools { margin-bottom: 10px; flex-wrap: nowrap; }
.cp-tools input { flex: 1; min-width: 0; }
.cp-list { list-style: none; margin: 0; padding: 4px 10px; }
.cp-list li { border-bottom: 1px solid var(--line); }
.cp-list li:last-child { border-bottom: 0; }
.cp-row { display: grid; grid-template-columns: 34px minmax(80px, 160px) minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 7px 2px; color: var(--text); font-size: 14px; }
.cp-row:hover { text-decoration: none; background: var(--card-2); }
.cp-pic { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; font-size: 14px; }
.cp-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-dot { color: var(--ok); font-size: 10px; vertical-align: middle; }
.cp-last { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cp-meta, .cp-count { white-space: nowrap; font-size: 12px; }
.cp-usage { margin-top: 12px; }
@media (max-width: 560px) {
  .cp-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .cp-last, .cp-count { display: none; }
}
.look > summary { white-space: nowrap; flex: none; }

/* -- several chats per AI (chat.js) --------------------------------------------------------------------------- */
.chat-list { list-style: none; margin: 10px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.chat-list a { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 10px; color: var(--text); }
.chat-list a:hover { background: var(--card-2); text-decoration: none; }
.chat-list a.current { background: var(--card-2); border-left: 3px solid var(--accent); }

/* -- /app (getapp.js) ------------------------------------------------------------------------------------------- */
.app-steps { padding-left: 20px; }
.app-steps li { margin: 6px 0; }
.checksum { display: inline-block; max-width: 100%; overflow-wrap: anywhere; font-size: 12px; }
.app-safety { margin-top: 16px; }

/* -- feed: pictures, edits ------------------------------------------------------------------------------------- */
.post-pic { display: block; width: 100%; max-height: 520px; object-fit: contain; margin-top: 10px; border-radius: 12px;
  background: var(--card-2); }
.post-pic-note { margin: 8px 0 0; }
.pic-preview { position: relative; margin-top: 8px; display: inline-block; }
.pic-preview img { max-width: 220px; max-height: 220px; border-radius: 10px; display: block; }
.pic-preview .icon-btn { position: absolute; top: 4px; right: 4px; background: var(--card); }
.pic-pick { cursor: pointer; }
.post-edit textarea, .comment-edit textarea { width: 100%; }

/* -- sections: the bottom tab bar (phones and small tablets) + the Social sub-tabs ------------------------------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; border-radius: 12px;
    color: var(--muted); font: 600 11px Inter, sans-serif; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.current { color: var(--accent-text); background: color-mix(in srgb, var(--accent) 12%, transparent); }
  .tb-icon { position: relative; font-size: 21px; line-height: 1.1; }
  .tb-dot { position: absolute; top: -2px; right: -6px; width: 9px; height: 9px; border-radius: 50%; background: var(--bad);
    border: 2px solid var(--bg); }
  body.has-tabbar { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  body.has-tabbar #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  body.has-tabbar .savebar { bottom: calc(80px + env(safe-area-inset-bottom)); }  /* above the tab bar, not behind it */
  .savebar > a.btn.ghost { display: none; }  /* Cancel: the back link at the top does the same; room for the buttons */
  .navlinks { display: none; }  /* the tab bar replaces the top links */
}
.subtabs { display: flex; gap: 6px; margin: 4px 0 12px; overflow-x: auto; }
.subtabs a { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); white-space: nowrap;
  font: 500 14px Inter, sans-serif; }
.subtabs a:hover { text-decoration: none; background: var(--card-2); }
.subtabs a.current { border-color: var(--accent); color: var(--accent-text); background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* -- the Chats tab (chats.js) --------------------------------------------------------------------------------- */
.cl-search { width: 100%; margin-bottom: 10px; }
.cl-list { list-style: none; margin: 0; padding: 4px 8px; }
.cl-list li { border-bottom: 1px solid var(--line); }
.cl-list li:last-child { border-bottom: 0; }
.cl-row { display: flex; gap: 12px; align-items: center; padding: 10px 4px; color: var(--text); }
.cl-row:hover { text-decoration: none; background: var(--card-2); border-radius: 10px; }
.cl-pic { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; flex: none; font-size: 18px; }
.cl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cl-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.cl-top b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cl-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cl-time { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; flex: none; }
.cl-line { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* -- icons (core.js icon(), static/icons.svg) ------------------------------------------------------------------- */
.i { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; display: inline-block; fill: none; }
.i.fill { fill: currentColor; }  /* a filled heart / star (Lucide icons are outlines; brand logos are always filled) */
.i.gold { color: #d4a017; } .i.silver { color: #9aa4b2; } .i.bronze { color: #b87333; }
.i.big { width: 1.6em; height: 1.6em; }
.app-card h2 .i { width: 1.3em; height: 1.3em; }
.i.android { color: #3ddc84; }
.platform-logos { display: inline-flex; gap: 6px; }
.legal { margin-top: 18px; font-size: 12px; }
.ll-icon .i.big { width: 26px; height: 26px; }
.tb-icon .i { width: 23px; height: 23px; vertical-align: middle; }
.feature .icon .i.big { width: 30px; height: 30px; color: var(--accent-text); }

/* -- Custom theme (Premium, theme.js paint()): the user's colors (--custom-bg, --tint, --custom-accent) on a dark or
   light base, picked for readable text. Cards take a hint of the colors; the page shows the gradient itself. ------ */
html[data-theme="custom"][data-base="dark"] { color-scheme: dark;
  --card-base: #1c1830; --card-base-2: #241f3b; --line-base: #3a325a; --text: #ece8f6; --muted: #b8b0cc; --accent-2: #a98bff;
  --ok: #6fd3a0; --warn: #f5c16c; --bad: #f07a7a;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35); }
html[data-theme="custom"][data-base="light"] { --ok: #2b7a52; --warn: #7d5800; --bad: #b83228; color-scheme: light;
  --card-base: #ffffff; --card-base-2: #f7f3ec; --line-base: #e2dacb; --text: #221d33; --muted: #5d5670; --accent-2: #6d4fe0;
  --shadow: 0 8px 24px rgba(40, 30, 10, .10); }
html[data-theme="custom"] {
  --bg: var(--tint); --bg-2: color-mix(in srgb, var(--tint) 16%, var(--card-base-2));
  --card: color-mix(in srgb, var(--tint) 9%, var(--card-base)); --card-2: color-mix(in srgb, var(--tint) 15%, var(--card-base-2));
  --line: color-mix(in srgb, var(--tint) 22%, var(--line-base)); --accent: var(--custom-accent); --accent-text: var(--custom-accent); }
html[data-theme="custom"] body::before { content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none; background: var(--custom-bg); }
html[data-theme="custom"] .halo { display: none; }
.theme-swatch-custom i { background: conic-gradient(#ff6b6b, #ffd93d, #6bcb77, #4d96ff, #b06bff, #ff6b6b); }
.theme-swatch-custom.has-colors i { background: var(--swatch); }
.premium-tag { display: inline-flex; align-items: center; gap: 3px; font: 600 11px Inter, sans-serif; color: var(--accent-text);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.premium-tag .i { width: 1em; height: 1em; }

/* the custom colors editor (in the appearance picker) */
.ct-editor { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); display: grid; gap: 12px; }
.ct-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ct-row > b { min-width: 64px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--card); }
.seg button { border: 0; background: none; color: var(--text); padding: 6px 12px; font: 500 13px Inter, sans-serif; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 22%, var(--card)); font-weight: 600; }
.ct-stop { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.ct-stop input[type="color"], .ct-accent input[type="color"] { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
.ct-stop input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.ct-stop input[type="color"]::-webkit-color-swatch, .ct-accent input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(127, 127, 127, .5); border-radius: 50%; }
.ct-stop input[type="text"], .ct-accent input[type="text"] { width: 84px; padding: 4px 8px; font: 13px ui-monospace, Consolas, monospace; }
.ct-stop input.bad, .ct-accent input.bad { border-color: var(--bad); }
.ct-angle { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.ct-angle input[type="range"] { flex: 1; padding: 0; accent-color: var(--accent); }
.ct-dial { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); position: relative; flex: none; background: var(--card); }
.ct-dial i { position: absolute; left: 50%; top: 3px; width: 2px; height: 12px; margin-left: -1px; background: var(--accent); border-radius: 2px; transform-origin: 50% 12px; }
.ct-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.ct-preset { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.ct-preset:hover, .ct-preset:focus-visible { border-color: var(--accent); }
.ct-warn { margin: 0; font-size: 13px; color: var(--warn); }
.ct-warn:empty { display: none; }
.upsell { margin-top: 10px; padding: 10px 12px; border-radius: 12px; border: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--line)); font-size: 14px; }
.ct-num { width: 64px; padding: 4px 6px; }

/* -- Custom home layout (Premium, home.js homeCustom): blocks on a 12-column grid; one column on phones ------------ */
.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; }
.cg-top { justify-content: flex-end; }
.cg-top .look { margin-left: 0; }
/* a block's height is a minimum: rows grow to fit what's inside rather than cutting it off */
.cg { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: minmax(52px, auto); gap: 10px; }
.cg-block { min-width: 0; }
.cg-block.card { padding: 14px 16px; }
.cg-title { margin: 0 0 8px; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.cg-greeting { display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.cg-greeting .sub, .cg-greeting .mag-kicker { margin: 4px 0 0; }
.cg-greeting .mag-kicker { order: -1; }
.cg-continue { overflow: hidden; border-radius: 22px; box-shadow: var(--shadow); }
.cg-hero { position: relative; display: flex; align-items: flex-end; height: 100%; min-height: 220px; color: #fff; isolation: isolate; }
.cg-hero:hover { text-decoration: none; }
.cg-hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; font-size: 0; }
.cg-hero::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, transparent 20%, rgba(0, 0, 0, .55) 60%, rgba(0, 0, 0, .88)); }
.cg-hero-text { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 20px; }
.cg-hero-text .mag-kicker { color: rgba(255, 255, 255, .85); }
.cg-hero-name { font: 600 clamp(26px, 4vw, 40px)/1.1 Fraunces, Georgia, serif; }
.cg-hero-line { color: rgba(255, 255, 255, .88); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cg-covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 14px; }
.cg-covers .book, .cg-covers .book-cover { width: 100%; }
.cg-covers .book-cover { height: auto; aspect-ratio: 116 / 164; }
.cg-list { padding: 0; }
.cg-shortcuts { flex-wrap: wrap; }
@media (max-width: 760px) {
  .cg { display: flex; flex-direction: column; gap: 12px; }
}

/* -- the layout editor (layout.js) ------------------------------------------------------------------------------ */
.le-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.le-add .row { flex-wrap: wrap; gap: 6px; }
.le-phone-hint { display: none; }
.le-canvas { position: relative; border: 1px dashed var(--line); border-radius: 14px; background-color: color-mix(in srgb, var(--card) 55%, transparent);
  background-image: linear-gradient(to right, color-mix(in srgb, var(--line) 70%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) 70%, transparent) 1px, transparent 1px);
  background-size: var(--col, 8.33%) var(--row, 52px); min-height: 300px; user-select: none; margin-bottom: 24px; }
.le-block { position: absolute; display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 12px; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); cursor: grab;
  transition: left .16s ease, top .16s ease, width .16s ease, height .16s ease; }
.le-block:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.le-block.dragging { transition: none; z-index: 5; cursor: grabbing; opacity: .92; box-shadow: 0 18px 40px rgba(0, 0, 0, .35); }
.le-head { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; }
.le-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.le-grip { color: var(--muted); cursor: grab; touch-action: none; display: inline-flex; padding: 2px; }
.le-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px; border-radius: 6px; display: inline-flex; }
.le-x:hover { color: var(--bad); background: var(--card-2); }
.le-variant { width: auto; max-width: 100%; padding: 3px 8px; font-size: 13px; align-self: flex-start; }
.le-size { margin-top: auto; font-size: 12px; }
.le-art { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: var(--text); opacity: .09; }
.le-art .i { width: min(64px, 45%); height: min(64px, 45%); }
.le-resize { position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, transparent 50%, color-mix(in srgb, var(--accent) 70%, transparent) 50%); border-bottom-right-radius: 12px; }
.le-ghost { position: absolute; border-radius: 12px; border: 2px dashed var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent);
  pointer-events: none; transition: left .1s ease, top .1s ease, width .1s ease, height .1s ease; }
@media (max-width: 760px) {
  .le-phone-hint { display: block; }
  .le-block { padding: 6px; gap: 2px; }
  .le-head { font-size: 12px; gap: 3px; }
  .le-head > .i:not(.le-grip .i) { display: none; }
  .le-variant, .le-size { display: none; }
}

/* -- the AI editor: AI help (✨) and Advanced (entities.js) ------------------------------------------------------- */
.assist-card { margin-bottom: 14px; }
.assist-card textarea { width: 100%; margin: 6px 0 8px; }
.assist-btn { border: 1px solid var(--line); background: var(--card-2); color: var(--accent-text); border-radius: 999px; padding: 2px 8px;
  cursor: pointer; display: inline-flex; align-items: center; margin-left: 6px; }
.assist-btn:hover { border-color: var(--accent); }
.assist-btn:disabled { opacity: .5; cursor: default; }
.assist-btn.working .i, #assistAll.working .i, #draft.working .i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.field-top .badge { margin-left: 6px; font-size: 11px; }
.form-section h3 { margin: 16px 0 6px; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.form-section h3:first-of-type { margin-top: 4px; }
.adv-options { display: grid; gap: 10px; margin-top: 6px; }
.adv-options .check { align-items: flex-start; gap: 10px; }
.adv-options .check > span { display: flex; flex-direction: column; gap: 2px; }
.adv-warn { margin-top: 10px; }
/* story currency editor (currency.js) */
.cur-units { margin-top: 12px; display: grid; gap: 8px; }
.cur-unit-list { display: grid; gap: 8px; }
.cur-unit { flex-wrap: wrap; align-items: center; gap: 8px; }
.cur-unit > input { flex: 1 1 140px; min-width: 0; }
.cur-unit input[type="number"], .cur-custom-rate input { width: 84px; }
.cur-custom-rate { display: inline-flex; align-items: center; gap: 6px; }
.cur-custom-rate[hidden] { display: none; }
#tracking .purse { font-weight: 600; }
/* Gift Premium (gift.js) */
.gift-lengths { border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 12px; margin: 14px 0 4px; }
.gift-lengths legend { padding: 0 6px; font-weight: 600; }
.gift-sent { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
#genderSel { max-width: 170px; }
@media (prefers-reduced-motion: reduce) { .assist-btn.working .i, #assistAll.working .i, #draft.working .i { animation: none; } }

/* Feedback tab (feedback.js) */
.fb-kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-kinds button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
  color: var(--text); padding: 7px 14px; font: 500 14px Inter, sans-serif; cursor: pointer; }
.fb-kinds button[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--card)); font-weight: 600; }
.fb-note { margin: 12px 0 0; font-size: 13px; }
.fb-item { margin-bottom: 12px; }
.fb-head { gap: 8px; align-items: center; }
.fb-text { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0 0; }
.fb-reply { margin-top: 10px; padding: 10px 12px; border-left: 3px solid var(--accent); border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, transparent); }
.tabbar a { min-width: 0; }
.tb-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check > span > .hint { display: block; margin-top: 2px; font-weight: 400; }

/* Profile links (profile.js): under the bio, and their rows in the editor */
.profile-links { position: relative; list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; }
.profile-links a { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 85%, transparent); color: var(--text); font-weight: 600; font-size: 14px; }
.profile-links a:hover { text-decoration: none; border-color: var(--accent); }
.profile-links a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-links small { color: var(--muted); font-weight: 500; }
.links-edit { border: 0; padding: 0; }
.links-edit legend { font-weight: 600; padding: 0; margin-bottom: 4px; }
.link-sites summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.link-sites p { margin: 6px 0 0; font-size: 13px; }
.link-row { gap: 8px; margin-top: 8px; flex-wrap: nowrap; }
.link-row .link-label { flex: 1 1 38%; min-width: 0; }
.link-row .link-url { flex: 1 1 62%; min-width: 0; }

/* Roadmap (roadmap.js) */
.road-actions { margin: 4px 0 18px; }
.road-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); align-items: start; }
.road-col h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.road-col > .sub { margin: 0 0 10px; }
.road-item { margin-bottom: 10px; }
.road-item h3 { font-size: 16px; margin: 0 0 4px; }
.road-item p { margin: 0; color: var(--muted); }
.road-item .badge { margin-bottom: 8px; }
.road-done { margin-top: 26px; }
.road-done .road-item { max-width: 760px; }
.road-now .road-item { border-left: 3px solid var(--accent); }

/* First-visit tour (welcome.js) */
dialog.welcome-dlg { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line);
  border-radius: 18px; background: var(--card); color: var(--text); display: flex; flex-direction: column; overflow: hidden; }
dialog.welcome-dlg:not([open]) { display: none; }
dialog.welcome-dlg::backdrop { background: rgb(0 0 0 / .55); backdrop-filter: blur(3px); }
.wl-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 0 20px; }
.wl-step { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.wl-body { padding: 4px 22px 8px; overflow-y: auto; }
.wl-icon { color: var(--accent-text); margin-bottom: 6px; }
.wl-icon .i { width: 38px; height: 38px; }
.wl-body h2 { font-size: 24px; margin: 0 0 6px; }
.wl-lead { margin: 0 0 12px; color: var(--muted); }
.wl-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.wl-points li { display: flex; gap: 12px; align-items: flex-start; }
.wl-points li > .i { flex: none; width: 22px; height: 22px; margin-top: 2px; color: var(--accent-text); }
.wl-points b { display: block; }
.wl-points span { color: var(--muted); font-size: 14px; }
.wl-start { display: grid; gap: 10px; margin-top: 4px; }
.wl-start .btn { justify-content: center; }
.wl-hint { margin: 14px 0 0; font-size: 13px; }
.wl-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 18px 16px;
  border-top: 1px solid var(--line); }
.wl-dots { display: flex; gap: 6px; }
.wl-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.wl-dots i.on { background: var(--accent); }

/* Invite links (app.js joinPage, settings.js) */
.invite-banner { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 18px; border-color: var(--accent); }
.invite-banner .ib-icon { color: var(--accent-text); flex: none; }
.invite-banner h2 { margin-bottom: 6px; }
.invite-banner p { margin: 0 0 6px; }
.invite-link { gap: 8px; flex-wrap: wrap; }
.invite-link input { flex: 1 1 220px; min-width: 0; font-family: ui-monospace, monospace; font-size: 13px; }
.creator-stats { display: flex; gap: 22px; margin: 6px 0 12px; }
.creator-stats div { display: flex; flex-direction: column; }
.creator-stats b { font-size: 20px; font-variant-numeric: tabular-nums; }
.creator-stats span { color: var(--muted); font-size: 13px; }

/* Offline and app-update bars (app.js) */
.status-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 40; display: flex; align-items: center;
  gap: 10px; max-width: calc(100vw - 32px); padding: 9px 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); box-shadow: 0 6px 24px rgb(0 0 0 / .25); font-size: 14px; }
body.has-tabbar .status-bar { bottom: calc(80px + env(safe-area-inset-bottom)); }
.status-bar .i { flex: none; color: var(--accent-text); }
#offlineBar .i { color: var(--warn); }
.update-bar span { flex: 1; min-width: 0; }

/* Share into Parhelion (sharein.js) */
.share-ais { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 8px 0 16px; }
.share-ai { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); color: var(--text); font: 600 14px Inter, sans-serif; cursor: pointer; text-align: left; min-width: 0; }
.share-ai:hover { border-color: var(--accent); }
.share-ai img, .share-initial { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.share-initial { display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.share-ai span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#shareText { width: 100%; margin-top: 6px; }

/* "Are you 18 or older?" (settings.js askAdult) */
dialog.age-ask { width: min(420px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 22px;
  background: var(--card); color: var(--text); }
dialog.age-ask::backdrop { background: rgb(0 0 0 / .55); }
dialog.age-ask h2 { margin-top: 0; }
dialog.age-ask .row { gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* Pictures with feedback (feedback.js) */
.fb-pic-row { gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.fb-pic-row .hint { flex: 1 1 200px; }
.fb-pic-preview { position: relative; display: inline-block; margin-top: 10px; }
.fb-pic-preview img { max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--line); display: block; }
.fb-pic-preview .icon-btn { position: absolute; top: 4px; right: 4px; background: var(--card); border-radius: 50%; }
.fb-sent-pic { display: block; max-width: min(100%, 360px); max-height: 260px; margin-top: 8px; border-radius: 10px;
  border: 1px solid var(--line); object-fit: contain; }

/* About us (about.js) */
.about { max-width: 760px; }
.about .card { margin-bottom: 16px; }
.about-values { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.about-values li { display: flex; gap: 12px; align-items: flex-start; }
.about-values li > .i { flex: none; width: 22px; height: 22px; margin-top: 2px; color: var(--accent-text); }
.about-values b { display: block; }
.about-values span { color: var(--muted); }
.about-links { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.about-links .disabled { opacity: .6; cursor: default; }
.about-links small { color: var(--muted); font-weight: 500; }
.about-more { gap: 10px; flex-wrap: wrap; }

/* Creator page (creator.js) and update notes (updates.js) */
.menu > button .burger { position: relative; }
.menu-dot { position: absolute; top: -1px; right: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.creator-page .lead { font-size: 17px; color: var(--muted); margin: 0 0 18px; }
.creator-progress { margin: 12px 0; }
.creator-progress .row { justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.creator-progress .bar { height: 10px; }
.creator-page .note { background: var(--card-2); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.creator-page .note p { margin: 4px 0 0; }
.creator-yes { display: flex; gap: 8px; align-items: center; }
.creator-yes .i { color: var(--accent-text); }
.creator-form { display: grid; gap: 8px; margin-top: 12px; }
.creator-form textarea { width: 100%; box-sizing: border-box; }
.creator-form .btn { justify-self: start; }
.release h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.release h2 small { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 13px; }
.release ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.release li { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: start; }
.upd-kind { display: inline-flex; gap: 4px; align-items: center; justify-self: start; font-size: 12px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--card-2); white-space: nowrap; }
.upd-new .upd-kind { color: var(--accent-text); }
.upd-better .upd-kind { color: var(--ok); }
.upd-fix .upd-kind { color: var(--muted); }
@media (max-width: 520px) { .release li { grid-template-columns: 1fr; gap: 4px; } }

/* -- loading: a thin bar at the top, grey shapes where the page will be (both appear only after a moment) -- */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1000; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent); background-size: 50% 100%;
  background-repeat: no-repeat; transition: opacity .2s; }
html.busy #progress { opacity: 1; transition-delay: .15s; animation: progress 1.1s ease-in-out infinite; }
@keyframes progress { from { background-position: -50% 0; } to { background-position: 150% 0; } }
.skeleton { display: grid; gap: 14px; animation: sk-in .3s .12s both; }
.skeleton .sk { display: block; border-radius: var(--radius); background: var(--card); position: relative; overflow: hidden; border: 1px solid var(--line); }
.skeleton .sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 6%, transparent), transparent); animation: shimmer 1.3s infinite; }
.sk-title { height: 34px; width: min(280px, 60%); border-radius: 10px !important; margin: 6px 0 4px; }
.sk-card { height: 130px; }
.sk-card.short { height: 80px; width: 70%; }
.sk-row { display: flex; align-items: center; gap: 12px; }
.sk-row .sk-dot { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.sk-row .sk-line { flex: 1; }
.sk-line { height: 14px; border-radius: 7px !important; }
.sk-line.short { width: 60%; }
.sk-lines { gap: 10px; }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.sk-tile { height: 190px; }
.card .skeleton .sk { background: var(--card-2); }
@keyframes sk-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton .sk::after, html.busy #progress { animation: none; } }

/* -- quick settings: a panel from the right (computers) or from the bottom (phones) -- */
.quick-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 999px; }
.quick-btn .i { width: 18px; height: 18px; }
dialog.quick-panel { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(400px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--bg-2); color: var(--text); box-shadow: var(--shadow);
  animation: qp-side .22s ease-out; }
dialog.quick-panel::backdrop { background: rgb(0 0 0 / .45); }
.qp-inner { display: flex; flex-direction: column; height: 100%; }
.qp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 8px; }
.qp-head h2 { margin: 0; font-size: 20px; }
.qp-body { flex: 1; overflow-y: auto; padding: 6px 18px 18px; display: grid; gap: 14px; align-content: start; }
.qp-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.qp-group { display: grid; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.qp-group > b { font-size: 14px; }
.qp-group .look-themes { margin: 0; }
.qp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; }
.qp-row[hidden] { display: none; }
.qp-row > span { display: inline-flex; align-items: center; gap: 8px; }
.qp-row select { width: auto; max-width: 60%; }
body > dialog.quick-panel .qp-body > .qp-row { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.qp-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 4px 0; }
.qp-switch > span { display: flex; gap: 10px; align-items: flex-start; }
.qp-switch > span > .i { margin-top: 3px; flex: none; }
.qp-switch b { display: block; }
.qp-switch .sub { display: block; font-size: 13px; }
.qp-switch input { appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; margin: 0; border-radius: 999px;
  background: var(--line); position: relative; cursor: pointer; transition: background .15s; }
.qp-switch input::before { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgb(0 0 0 / .3); }
.qp-switch input:checked { background: var(--accent); }
.qp-switch input:checked::before { transform: translateX(18px); }
.qp-switch input:disabled { opacity: .5; cursor: default; }
.qp-switch input:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
@keyframes qp-side { from { transform: translateX(100%); } to { transform: none; } }
@keyframes qp-up { from { transform: translateY(100%); } to { transform: none; } }
@media (max-width: 640px) {
  dialog.quick-panel { inset: auto 0 0 0; width: 100vw; height: auto; max-height: 88dvh; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0; animation-name: qp-up; }
  .qp-head::before { content: ""; position: absolute; top: 6px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--line); }
  .qp-head { position: relative; padding-top: 18px; }
  .quick-btn { width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) { dialog.quick-panel { animation: none; } }

/* -- settings search -- */
.finder { position: sticky; top: 8px; z-index: 5; display: flex; align-items: center; gap: 8px; background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 14px; box-shadow: var(--shadow); margin-bottom: 4px; }
.finder:focus-within { border-color: var(--accent); }
.finder-icon { color: var(--muted); display: inline-flex; }
.finder input { flex: 1; border: 0; background: transparent; padding: 8px 0; min-width: 0; box-shadow: none; outline: none; }
.finder input::-webkit-search-cancel-button { display: none; }
.finder-status { min-height: 1em; margin: 6px 4px 12px; }
#settingsAll .ss-out { display: none !important; }
#settingsAll:not(.searching) .finder-elsewhere { display: none; }
.finder-link { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); color: var(--text); }
.finder-link:first-of-type { border-top: 0; }
.finder-link:hover { text-decoration: none; background: var(--card-2); border-radius: 10px; }
.finder-link > span:nth-child(2) { flex: 1; }
.finder-link .sub { display: block; font-size: 13px; }
.lang-field { margin-top: 14px; }
.lang-field select { width: auto; }
::highlight(finder) { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; }

/* -- comments on a gallery character (comments.js) ---------------------------------------------------------------- */
.gcomments h2 { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.gcomments h2 .sub { font: 500 14px Inter, sans-serif; }
.gcomments > .comment-form { margin: 4px 0 8px; }
.gcomments .comments-switch { margin: 0 0 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; }
.copy-note .i { vertical-align: -3px; }
.comment-form .row { justify-content: flex-end; align-items: center; gap: 10px; }
.comment-form .row > .sub { margin-right: auto; }
.gcomments .comment .avatar.initials svg { width: 16px; height: 16px; }
.comment.removed { padding: 8px 0; }
.comment.removed .sub { margin: 0; font-style: italic; }
.creator-badge { color: var(--accent-text); border-color: var(--accent); }
.creator-badge svg { width: 11px; height: 11px; vertical-align: -1px; }
.reply-form { margin: 6px 0 10px; }
.empty-comments { padding: 10px 0; border-top: 1px solid var(--line); }
@media (max-width: 640px) { .gcomments .replies { margin-left: 22px; } }

/* 👍 / 👎 under the AI's replies, the hold / right-click menu on a reply, and the "What went wrong?" box */
.controls .rate { display: inline-flex; gap: 2px; margin-left: auto; }
.controls .rate .icon-btn { opacity: .6; }
.controls .rate .icon-btn:hover, .controls .rate .icon-btn.on { opacity: 1; }
.controls .rate .icon-btn.on { color: var(--accent-text); background: var(--card-2); border-color: var(--line); }
.msg.assistant .bubble, .msg.assistant .texts { -webkit-touch-callout: none; }
.msg-menu { position: fixed; z-index: 50; display: flex; flex-direction: column; gap: 2px; padding: 6px; margin: 0; min-width: 200px; box-shadow: var(--shadow); }
.msg-menu button { display: flex; align-items: center; gap: 10px; background: none; border: 0; border-radius: 8px; padding: 9px 10px;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.msg-menu button:hover, .msg-menu button:focus-visible { background: var(--card-2); }
.msg-menu button.on { color: var(--accent-text); }
.report-panel { display: grid; gap: 8px; max-width: 560px; margin: 8px 0 0; }
.report-panel p { margin: 0; }
.report-panel .reasons { display: flex; flex-wrap: wrap; gap: 6px; }
.report-panel .reason { border: 1px solid var(--line); background: var(--card-2); color: var(--text); border-radius: 999px;
  padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.report-panel .reason.on { border-color: var(--accent); color: var(--accent-text); }
.report-panel textarea { width: 100%; }

/* The main picture on the AI / persona editor: example picture, persona style, the pick while creating */
.portrait-pick.picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.portrait-pick.picked span { color: var(--accent-text); font-weight: 600; }
.portrait-example { margin: 4px 0 10px; }
.portrait-example .row { align-items: center; }
.portrait-upload { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line, rgba(127,127,127,.2)); }
.example-thumb { position: relative; display: inline-flex; }
.example-thumb img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.example-thumb .icon-btn { position: absolute; top: -8px; right: -8px; background: var(--card); border-color: var(--line); padding: 2px 4px; }
.portrait-style { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 10px; }
.portrait-style select { width: auto; }
.portrait-direction { display: block; font-weight: 600; margin: 4px 0 4px; }
#portraitDirection { width: 100%; box-sizing: border-box; margin-bottom: 10px; }
.entity-pic { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); flex: none; }
@media (min-width: 700px) { .portrait-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); } }

/* -- Reading comfort (Settings → Appearance, Quick settings; home.js applyReading): the chat's text size, line spacing
   and column width, as data attributes on <html>. Defaults have no attribute. ---------------------------------- */
html[data-text="s"] .bubble { font-size: 14px; }
html[data-text="l"] .bubble { font-size: 17px; }
html[data-text="xl"] .bubble { font-size: 19px; }
html[data-spacing="relaxed"] .bubble { line-height: 1.8; }
html[data-spacing="airy"] .bubble { line-height: 2; }
html[data-width="narrow"] .msg { max-width: min(600px, 92%); }
html[data-width="wide"] .msg { max-width: min(1040px, 96%); }
html[data-width="wide"] main:has(.chat) { max-width: 1280px; }
.reading-box > .sub { display: block; margin: 2px 0 8px; }
.reading-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin: 8px 0; }
.reading-row > span { font-size: 14px; }
.reading-sample { margin-top: 10px; max-width: 100%; }

/* -- the 🔔 inbox (inbox.js): the header button with its count, and the list in the Quick settings panel -- */
.inbox-btn { position: relative; }
.inbox-count { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--bad); color: #fff; font: 700 11px/18px Inter, sans-serif; text-align: center; }
.inbox-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.inbox-item { display: grid; gap: 4px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 12px; color: var(--text); font: inherit; }
button.inbox-item { cursor: pointer; }
button.inbox-item:hover { border-color: var(--accent-2); }
.inbox-list li.unread .inbox-item { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.inbox-text { overflow-wrap: anywhere; white-space: pre-line; }
.inbox-new { color: var(--accent-text); }

/* -- Download my data (Settings → Privacy) -- */
.export-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; margin: 12px 0 4px; }
.export-row > span { flex: 1 1 240px; }

/* -- hidden gallery tags (gallery.js bindHide) -- */
.hide-panel { margin: 10px 0 14px; }
.hide-panel h2 { font-size: 17px; }
.hide-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.hide-chips .chip { display: inline-flex; align-items: center; gap: 4px; }
.hide-chips .link-btn { display: inline-flex; min-width: 24px; min-height: 24px; align-items: center; justify-content: center; }
#hideForm input { flex: 1; min-width: 0; }

/* Opening scenes 2-5 in the character editor (1.3.0): folded under the first message */
.more-openings { margin: 4px 0 14px; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; }
.more-openings > summary { cursor: pointer; font-weight: 600; min-height: 24px; }
.more-openings[open] > summary { margin-bottom: 6px; }

/* The weekly creator challenge (1.3.0): the gallery banner and /challenge */
.challenge-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 12px; color: var(--text); text-decoration: none; }
.challenge-banner > span { flex: 1; min-width: 0; }
.challenge-banner > svg:first-child { width: 28px; height: 28px; color: var(--accent-text); flex: none; }
.challenge-banner:hover { border-color: var(--accent); }
.challenge-theme { font-size: 1.35em; font-weight: 700; margin: 4px 0; color: var(--accent-text); }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.past-challenges .mem-text a { color: var(--accent-text); }

/* Chats kept only on this device (1.3.0, static/local.js): the move panel and its warning */
.device-panel, .import-panel { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.device-panel > summary, .import-panel > summary { cursor: pointer; padding: 4px 0; }
.device-warn { border-left: 4px solid var(--warn); background: var(--bg); border-radius: 10px; padding: 8px 12px; margin: 8px 0;
  font-size: 13px; line-height: 1.45; }
.device-warn p { margin: 4px 0; }
.device-warn svg.i { color: var(--warn); }

/* The team's Moderation page (its code comes from /api/staff/ui.js, for the team only) */
.staff-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.staff-card { margin-bottom: 10px; }
.staff-card .row { flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.staff-excerpt { white-space: pre-wrap; background: var(--bg2, rgba(127,127,127,.08)); border-radius: 8px; padding: 8px 10px; margin: 6px 0; max-height: 240px; overflow: auto; }
.staff-excerpt.staff-rated { border-left: 3px solid var(--warn, #f5a524); }
.staff-pic { margin: 6px 0; max-width: 280px; cursor: pointer; }
.staff-pic img { width: 100%; border-radius: 8px; filter: blur(22px); transition: filter .2s; }
.staff-pic.revealed img { filter: none; }
.staff-table { width: 100%; border-collapse: collapse; }
.staff-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.staff-answer textarea { width: 100%; margin: 6px 0; }
.creator-fast { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.creator-fast > summary { cursor: pointer; font-weight: 600; }
.creator-fast input[type=url] { width: 100%; margin: 4px 0; }
/* Support Us (static/support.js): the Supporter ranks' colors, on the page and on profile badges */
.sup-emblem { --sa: #b0703c; --sb: #e9b07a; display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--sb), var(--sa)); color: #fffaf0; box-shadow: inset 0 -2px 4px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.18); }
.sup-emblem .i { width: 58%; height: 58%; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.sup-emblem.big { width: 68px; height: 68px; }
.sup-bronze { --sa: #9a5a2a; --sb: #e9b07a; }
.sup-silver { --sa: #7d8792; --sb: #eef2f6; }
.sup-gold { --sa: #b07c10; --sb: #ffe08a; }
.sup-platinum { --sa: #5f9fb6; --sb: #f1fbff; }
.sup-mithril { --sa: #6a5cff; --sb: #9ff3ff; background: conic-gradient(from 200deg, #9ff3ff, #c8a6ff, #fff7d6, #9ff3ff); }
.sup-mithril.big { animation: sup-shine 6s linear infinite; }
@keyframes sup-shine { to { filter: hue-rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sup-mithril.big { animation: none; } }
.pbadge.sup { border-color: var(--sa); }
.pbadge.sup .i { color: var(--sa); }
.support-page .lead { font-size: 17px; color: var(--muted); margin: 0 0 18px; }
.sup-thanks { display: flex; gap: 8px; align-items: center; }
.sup-form { display: grid; gap: 10px; }
.sup-form > .btn { justify-self: start; }
.sup-amounts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sup-other { display: inline-flex; align-items: center; gap: 6px; }
.sup-other input { width: 96px; }
.sup-ranks { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 12px; margin: 10px 0; }
.sup-rank { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 12px 8px; border: 1px solid var(--line); border-radius: 14px; }
.sup-rank.mine { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.sup-ways { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sup-soon { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; flex: 1 1 260px; }
.sup-soon > div { display: flex; flex-direction: column; }
.sup-board { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.sup-board li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.sup-pos { width: 22px; text-align: right; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.sup-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sup-who .sub { overflow-wrap: anywhere; }
.sup-pts { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sup-empty { justify-content: center; color: var(--muted); }
/* the Guide: illustrated cards that turn over (static/guide.js) */
.help-link { display: inline-flex; vertical-align: middle; color: var(--muted); margin-left: 4px; }
.help-link .i { width: 20px; height: 20px; }
.help-link:hover, .help-link:focus-visible { color: var(--accent-text); }
.guide-search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; margin: 4px 0 18px; }
.guide-search input { border: 0; background: none; flex: 1; min-width: 0; font: inherit; color: var(--text); padding: 4px 0; outline: none; }
.guide-sec { margin: 0 0 26px; }
.guide-sec > h2 { margin: 0 0 4px; }
.guide-sec > .sub { margin: 0 0 10px; }
.guide-toc { margin: 4px 0 18px; }
.guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; margin-top: 10px; }
.gd-card, .gc-front { position: relative; display: flex; flex-direction: column; aspect-ratio: 3 / 4; padding: 0; overflow: hidden; border-radius: 16px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); text-align: left; font: inherit; cursor: pointer;
  box-shadow: 0 6px 18px rgba(30, 20, 50, .12); transition: transform .25s ease, box-shadow .25s ease; }
.gd-card:hover, .gd-card:focus-visible { transform: translateY(-4px) rotate(-.6deg); box-shadow: 0 12px 26px rgba(30, 20, 50, .2); }
.gd-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.gd-card.gc-away { visibility: hidden; }
.gd-card img, .gc-front img { width: 100%; flex: 1 1 auto; min-height: 0; object-fit: cover; display: block; background: var(--card-2); }
.gc-body { display: flex; flex-direction: column; gap: 3px; padding: 9px 11px 11px; }
.gc-body b { font: 600 15px/1.2 Fraunces, Georgia, serif; }
.gc-body b .i { width: 15px; height: 15px; vertical-align: -2px; color: var(--accent-text); }
.gc-line { font-size: 12.5px; line-height: 1.35; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gc-tier { position: absolute; top: 8px; left: 8px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: rgba(20, 14, 34, .72); color: #fff3d6; display: inline-flex; gap: 4px; align-items: center; }
.gc-tier.premium { background: linear-gradient(90deg, #f2a93b, #d97a2b); color: #241503; }
.gc-tier .i { width: 11px; height: 11px; }
html.gc-lock { overflow: hidden; }
.gc-overlay { position: fixed; inset: 0; z-index: 80; }
.gc-dim { position: absolute; inset: 0; background: rgba(14, 10, 24, .55); backdrop-filter: blur(3px); }
.gc-flip { position: fixed; transform-origin: top left; perspective: 1600px; }
.gc-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; }
.gc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 18px; }
.gc-front { width: 100%; height: 100%; aspect-ratio: auto; cursor: default; }
.gc-back { transform: rotateY(180deg); background: var(--card); color: var(--text); border: 1px solid var(--line); overflow: hidden auto;
  box-shadow: 0 24px 60px rgba(10, 6, 20, .45); overscroll-behavior: contain; }
.gc-banner { height: clamp(120px, 38%, 230px); overflow: hidden; border-radius: 18px 18px 0 0; }
.gc-banner img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; display: block; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.gc-text { padding: 4px 18px 18px; }
.gc-text h2 { margin: 0 0 2px; font-size: 21px; }
.gc-text h2 .i { color: var(--accent-text); }
.gc-text h3 { margin: 12px 0 2px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-text); }
.gc-text p { margin: 0; line-height: 1.5; }
.gc-tierline { font-size: 13px; color: var(--muted); }
.gc-actions { margin-top: 16px; flex-wrap: wrap; gap: 8px; }
@media (prefers-reduced-motion: reduce) { .gd-card, .gd-card:hover { transition: none; transform: none; } }
/* worlds (1.4.0 Stage 7) */
.world-banner { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 12px; display: block; margin-bottom: 8px; }
.world-banner.big { max-height: 320px; margin: 4px 0 14px; }
.world-pics { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.world-pics h3 { margin: 0 0 6px; }
.world-pic { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 10px; display: block; margin-bottom: 8px; }
.lore-entry.scene .world-pic { max-width: 360px; }
.scene-list, .lore-list { display: grid; gap: 10px; margin: 10px 0; }
.world-page .page-head { flex-wrap: wrap; gap: 10px; }
.world-scenes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
/* the creator dashboard (1.4.0 Stage 6) */
.cd-head { justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.cd-head h2 { margin: 0; }
.creator-stats.cd-grid, .creator-stats.cd-totals { flex-wrap: wrap; gap: 12px 22px; }
.cd-best { background: var(--card-2); border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.cd-best h3 { margin: 2px 0 6px; }
.cd-best > p { margin: 0 0 6px; }
.cd-list { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.cd-list details { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.cd-list summary { cursor: pointer; }
.cd-list details[open] summary { margin-bottom: 6px; }
.cd-share { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin: 6px 0; }
.cd-share .bar { height: 8px; }
.cd-reasons { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0; }
.proof-code { user-select: all; font-weight: 700; letter-spacing: .5px; }
.about-team { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.about-team a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; color: inherit; text-decoration: none; }
.about-team a:hover, .about-team a:focus-visible { background: var(--bg2, rgba(127,127,127,.08)); }
.about-team a > span:nth-of-type(1) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pbadge.team { border-color: var(--accent); }

/* Simple / Expert creation (entities.js modeChoice, simpleMode) */
.mode-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin: 12px 0; }
.mode-card { display: grid; gap: 6px; justify-items: start; text-align: left; cursor: pointer; padding: 18px; font: inherit; color: inherit; border: 1px solid var(--line); }
.mode-card > .i { width: 28px; height: 28px; color: var(--accent); }
.mode-card b { font-size: 18px; }
.mode-card span { color: var(--muted); }
.mode-card.last, .mode-card:hover, .mode-card:focus-visible { border-color: var(--accent); }
.simple-mode .field:not(.in-step), .simple-mode details.more-openings, .simple-mode .form-section > h2 { display: none; }
.simple-mode .form-section:not(:has(.in-step)):not(.step-show) { display: none; }
.simple-mode:not(.last-step) .savebar, .simple-mode:not(.last-step) .savebar-note { display: none; }
.steps-head .row { justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-dots { display: flex; gap: 6px; margin: 8px 0 4px; }
.step-dots i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.step-dots i.on { background: var(--accent); }
.steps-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.fill-rest { display: flex; gap: 8px; align-items: flex-start; flex: 1; min-width: 220px; }
.fill-rest .sub { display: block; color: var(--muted); font-size: 13px; }

/* Rich-text tags in messages (richtext.js; values set through the CSSOM) */
mark.rt-mark { background: color-mix(in srgb, var(--warn) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.rt-grad { background-clip: text; -webkit-background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.rt-size { line-height: 1.25; }
.rt-upper { text-transform: uppercase; } .rt-lower { text-transform: lowercase; } .rt-smallcaps { font-variant: small-caps; }
.rt-align { display: block; } .rt-align-left { text-align: left; } .rt-align-center { text-align: center; }
.rt-align-right { text-align: right; } .rt-align-justify { text-align: justify; }
.rt-font.name-font { font-size: 1em; }
.rt-font.name-font-pixel { font-size: .7em; }
.rt-shake { display: inline-block; animation: rt-shake .32s linear infinite; }
.rt-wave { display: inline-block; animation: rt-wave 1.8s ease-in-out infinite; }
@keyframes rt-shake { 0%, 100% { transform: translate(0, 0); } 25% { transform: translate(-1px, 1px) rotate(-.6deg); }
  50% { transform: translate(1px, -1px); } 75% { transform: translate(-1px, -1px) rotate(.6deg); } }
@keyframes rt-wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .rt-shake, .rt-wave { animation: none; } }

/* The one-time "Text effects in replies?" question (richask.js) */
dialog.rich-ask { max-width: 560px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); padding: 18px; }
dialog.rich-ask::backdrop { background: rgba(0, 0, 0, .45); }
.rich-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.rich-compare figure { margin: 0; }
.rich-compare figcaption { font-weight: 600; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.rich-compare .msg { margin: 0; }
@media (max-width: 560px) { .rich-compare { grid-template-columns: 1fr; } }
dialog.rich-ask .row { justify-content: flex-end; gap: 8px; }

/* The AI editor's text effects guide and live preview (entities.js effectsGuide, preview) */
.rt-guide > summary { cursor: pointer; list-style: none; }
.rt-guide > summary h2 { display: inline; }
.rt-guide > summary::after { content: " ›"; color: var(--muted); }
.rt-guide[open] > summary::after { content: " ⌄"; }
.rt-guide-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.rt-guide-list li { display: grid; grid-template-columns: minmax(150px, auto) minmax(90px, 1fr); gap: 2px 10px; align-items: center; }
.rt-guide-list li > .sub { grid-column: 1 / -1; font-size: 12.5px; }
.rt-guide-list code { font-size: 12px; white-space: nowrap; }
.rt-example { overflow-wrap: anywhere; }
.rt-preview { margin-top: 6px; }
.rt-preview > .sub { font-size: 12px; }
.rt-preview .msg { margin: 2px 0 0; }

/* Chat themes (chattheme.js): the creator's look for a chat with their AI; text colors are set to stay readable */
#chatBackdrop.lk-backdrop::after { display: none; }
.themed.lk-bg .msg .meta, .themed.lk-bg .sysline, .themed.lk-bg .typing, .themed.lk-bg .part .speaker { color: var(--lk-on-bg); }
:is(.chat, .lk-preview).themed .msg.assistant .bubble, :is(.chat, .lk-preview).themed .msg.assistant .texts .bubble { background: var(--lk-ai, var(--card)); color: var(--lk-ai-text, var(--text));
  border-color: color-mix(in srgb, var(--lk-accent, var(--line)) 35%, transparent); }
:is(.chat, .lk-preview).themed .msg.user .bubble { background: var(--lk-user, var(--card)); color: var(--lk-user-text, var(--text));
  border-color: color-mix(in srgb, var(--lk-accent, var(--line)) 35%, transparent); }
.themed .msg .meta b, .themed .part .speaker { color: var(--lk-accent, inherit); }
.themed #sendBtn { background: var(--lk-accent, var(--accent)); color: var(--lk-on-accent, #111); }
.themed.lk-font .msg.assistant .bubble { font-family: var(--lk-font), Georgia, serif; }
.themed.lk-sharp .bubble { border-radius: 4px; }
.themed.lk-parchment .bubble { border-radius: 3px; border-width: 1px; border-style: solid;
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--lk-accent, #8b5a2b) 12%, transparent), 0 1px 2px rgba(0, 0, 0, .15); }
.themed.lk-speech .bubble { border-radius: 20px; position: relative; }
.themed.lk-speech .msg.assistant .bubble::after, .themed.lk-speech .msg.user .bubble::after { content: ""; position: absolute; bottom: -7px;
  width: 14px; height: 14px; transform: rotate(45deg); }
.themed.lk-speech .msg.assistant .bubble::after { left: 18px; background: var(--lk-ai, var(--card)); }
.themed.lk-speech .msg.user .bubble::after { right: 18px; background: var(--lk-user, var(--card)); }
.themed.lk-speech .msg { margin-bottom: 14px; }
/* on a theme's own background, the chat's buttons and small text keep readable colors */
.chat.themed.lk-bg .chat-top { color: var(--lk-ai-text, var(--lk-on-bg)); background: color-mix(in srgb, var(--lk-ai, var(--bg)) 70%, transparent); }
.chat.themed.lk-bg .chat-top .sub { color: inherit; opacity: .8; }
.chat.themed.lk-bg .chat-top .quick-btn { background: color-mix(in srgb, currentColor 12%, transparent); border-color: color-mix(in srgb, currentColor 30%, transparent); }
.chat.themed.lk-bg .ct-back { color: inherit; }
.chat.themed.lk-bg .controls .icon-btn, .chat.themed.lk-bg .controls .sub, .chat.themed.lk-bg .notice.slim { color: var(--lk-on-bg); }

/* The editor's Chat look builder */
.lk-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.lk-preset { flex: 0 0 auto; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.lk-preset.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.lk-swatch { flex-shrink: 0; display: inline-flex; align-items: flex-end; gap: 2px; width: 26px; height: 18px; border-radius: 5px; padding: 2px;
  border: 1px solid var(--line); box-sizing: border-box; }
.lk-swatch b { flex: 1; height: 6px; border-radius: 2px; }
.lk-swatch.lk-site { background: linear-gradient(135deg, var(--card), var(--bg)); }
.lk-custom > summary { cursor: pointer; margin: 6px 0; }
.lk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.lk-grid label { display: grid; gap: 4px; font-size: 13px; }
.lk-grid input[type=color] { width: 100%; height: 34px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); }
.lk-colors span { display: flex; gap: 6px; }
.lk-preview { margin-top: 10px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); display: grid; gap: 4px; }
.lk-preview.lk-site-look { background: var(--bg); }
.lk-preview .msg { margin: 0; }
.lk-preview .msg.user { justify-self: end; }

/* Highlights and quote cards (1.4.0 Stage 5: chat.js star/quote/branch, story.js, quotecard.js) */
.star-mark .i { width: 13px; height: 13px; color: var(--warn, #f2a93b); fill: currentColor; vertical-align: -2px; }
.hl-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.hl-list li { border-top: 1px solid var(--line); padding-top: 10px; }
.hl-list li:first-child { border-top: 0; padding-top: 0; }
.hl-list blockquote { margin: 0 0 6px; padding-left: 12px; border-left: 3px solid var(--warn, #f2a93b); white-space: pre-wrap; }
.hl-list .row { gap: 8px; flex-wrap: wrap; align-items: center; }
dialog.quote-dlg { max-width: 520px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); padding: 18px; }
dialog.quote-dlg::backdrop { background: rgba(0, 0, 0, .5); }
dialog.quote-dlg textarea { width: 100%; margin: 6px 0 10px; }
.qc-preview img { display: block; width: 100%; max-width: 300px; margin: 0 auto 12px; border-radius: 12px; aspect-ratio: 1080 / 1350; background: var(--bg); }
dialog.quote-dlg .row { justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Ask Lumi on the Guide page (guide.js) */
.lumi-box { display: flex; gap: 14px; align-items: flex-start; margin: 14px 0 6px; }
.lumi-face { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; object-position: 50% 20%; flex: none; }
.lumi-main { flex: 1; min-width: 0; }
.lumi-main h2 { margin: 0 0 4px; }
.lumi-form { display: flex; gap: 8px; margin-top: 10px; }
.lumi-form input { flex: 1; min-width: 0; }
.lumi-left { margin-top: 6px; }
.lumi-answer { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.lumi-says { margin: 0; line-height: 1.5; }
.lumi-cards { margin-top: 10px; flex-wrap: wrap; }
@media (max-width: 560px) { .lumi-face { width: 56px; height: 56px; } .lumi-form { flex-wrap: wrap; } .lumi-form .btn { flex: 1 1 100%; } }

/* 1.7.0: inside a chat, its own header (chat.js) replaces the site's header and footer, like a messaging app.
   The chat fills the screen; everything about the chat is in the Chat settings panel (a quick-panel). */
body.in-chat > header.top, body.in-chat > .foot { display: none; }
body.in-chat main { padding-top: 0; padding-bottom: 10px; }
body.in-chat .chat { height: calc(100vh - 10px); height: calc(100dvh - 10px); min-height: 380px; }
@media (display-mode: standalone) {
  body.in-chat .chat { height: calc(100dvh - 10px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
}
.chat-top { display: flex; align-items: center; gap: 8px; padding: 10px 0; margin-bottom: 4px; flex: none; }
.chat.has-bg .chat-top { margin: 0 -16px 4px; padding: 10px 16px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  background: color-mix(in srgb, var(--bg) 55%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.ct-back { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 999px; color: var(--text); flex: none; }
.ct-back:hover { background: var(--card); text-decoration: none; }
.ct-back .i { width: 22px; height: 22px; }
.ct-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 0; border-radius: 999px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.ct-who:hover { background: color-mix(in srgb, var(--card) 70%, transparent); }
.ct-who .avatar { width: 40px; height: 40px; flex: none; object-fit: cover; object-position: 50% 15%; }
.ct-names { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ct-names b { font: 600 17px Fraunces, Georgia, serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-names .sub { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-top .quick-btn { flex: none; color: inherit; background: color-mix(in srgb, var(--card) 60%, transparent); }
.chat-panel .qp-body { gap: 12px; }
.cp-hero { display: flex; align-items: center; gap: 12px; }
.cp-hero .avatar { width: 64px; height: 64px; flex: none; object-fit: cover; object-position: 50% 15%; font-size: 22px; }
.cp-hero b { display: block; font: 600 19px Fraunces, Georgia, serif; }
.cp-hero .sub { display: inline-flex; align-items: center; gap: 4px; }
.cp-hero .cast-line { margin: 4px 0 0; }
.chat-panel .qp-row select { max-width: 58%; min-width: 0; }
.chat-panel .chat-list { margin: 0; max-height: 34vh; }
.chat-panel .row { flex-wrap: wrap; gap: 6px; }
.chat-panel .hint { margin: 0; }
.cp-links { gap: 2px; padding: 6px; }
.cp-link { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 10px; color: var(--text); }
.cp-link:hover { background: var(--card-2); text-decoration: none; }
.chat-panel details > summary { cursor: pointer; }
/* over a picture, the name and time sit on a small frosted pill so they stay readable on any picture */
.chat.has-bg .msg .meta { width: fit-content; padding: 1px 9px; border-radius: 999px; text-shadow: none;
  background: color-mix(in srgb, var(--card) 72%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.chat.has-bg .msg .meta .sub { color: var(--text); opacity: .75; }
.chat.has-bg.themed .msg .meta { background: color-mix(in srgb, var(--lk-ai, var(--card)) 88%, transparent); color: var(--lk-ai-text, var(--text)); }
.chat.has-bg.themed .msg .meta .sub { color: inherit; }

/* Chats page: ⋮ on a chat (pin on top / delete), pinned chats first (chats.js, 1.7.0) */
.cl-list li { position: relative; display: flex; align-items: center; }
.cl-list li .cl-row { flex: 1; min-width: 0; }
.cl-more { flex: none; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; color: var(--muted); }
.cl-more:hover, .cl-more:focus-visible { background: var(--card-2); color: var(--text); }
.cl-pin .i { width: 13px; height: 13px; color: var(--accent); }
.cl-menu { position: absolute; right: 4px; top: calc(100% - 6px); z-index: 8; display: grid; padding: 6px; min-width: 200px; box-shadow: var(--shadow); }
.cl-menu button { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 10px; background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.cl-menu button:hover, .cl-menu button:focus-visible { background: var(--card-2); }
.cl-menu button.danger { color: var(--bad, #d64545); }

/* Story rules (1.7.0, storyrules.js): the editor's quests and limits, the chat's quest bar and list */
.sr-box { border-left: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); padding: 2px 0 6px 14px; margin: 8px 0 4px; }
.sr-assist { gap: 8px; margin: 10px 0; }
.sr-assist input { flex: 1; min-width: 0; }
.sr-steps { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.sr-step { display: flex; align-items: flex-start; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.sr-step.dragging { opacity: .7; border-color: var(--accent); box-shadow: 0 6px 18px rgb(0 0 0 / .18); }
.sr-grip { cursor: grab; touch-action: none; flex: none; color: var(--muted); }
.sr-step.dragging .sr-grip { cursor: grabbing; }
.sr-num { flex: none; min-width: 1.6em; padding-top: 8px; font-weight: 700; color: var(--accent); text-align: center; }
.sr-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.sr-fields [data-step="done_when"] { font-size: 13px; }
.sr-move { display: flex; flex-direction: column; flex: none; }
.sr-move .icon-btn { width: 30px; height: 26px; }
.quest-bar-box:empty { display: none; }
.quest-bar { display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 6px; padding: 7px 12px; border-radius: 999px; font: inherit; font-size: 14px;
  color: var(--text); background: color-mix(in srgb, var(--card) 85%, transparent); border: 1px solid var(--line); cursor: pointer; text-align: left; }
.chat.has-bg .quest-bar { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.chat.themed .quest-bar { color: var(--lk-ai-text, var(--text)); background: color-mix(in srgb, var(--lk-ai, var(--card)) 82%, transparent); }
.quest-bar .i { color: var(--accent); flex: none; }
.quest-bar.complete .i { color: var(--warn, #d4a017); }
.qb-goal { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quest-bar b { flex: none; font-variant-numeric: tabular-nums; }
.sysline.quest-mark { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; color: var(--text);
  background: color-mix(in srgb, var(--accent) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.sysline.quest-mark .i { color: var(--accent); flex: none; }
.qd-goal { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.qd-goal > .i { color: var(--accent); margin-top: 4px; flex: none; }
.qd-goal div { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.qd-goal.complete > .i { color: var(--warn, #d4a017); }
.qd-steps { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 4px; }
.qd-steps li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.qd-steps li.done { color: var(--muted); }
.qd-steps li.done span:not(.badge) { text-decoration: line-through; }
.qd-steps li.done .i { color: var(--ok, #2e9e5b); }
.qd-steps li.current { background: var(--card); border: 1px solid var(--accent); font-weight: 600; }
.qd-steps li.current .i { color: var(--accent); }
.qd-steps li.next { color: var(--muted); }
.qd-steps li span:not(.badge) { flex: 1; }
.cp-rules .btn { margin-top: 6px; }
/* 1.7.1: quest rewards, the Story complete card, My goal */
.sr-reward { display: flex; align-items: center; gap: 6px; }
.sr-reward > .i { color: var(--accent); flex: none; }
.sr-reward input { flex: 1; min-width: 0; font-size: 13px; }
.sr-move .icon-btn.on { color: var(--accent); }
.qb-goal .sub { margin-right: 2px; }
.qm-reward, .qd-reward { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; font-size: 13px; font-weight: 400; color: var(--muted); }
.qm-reward .i, .qd-reward .i { color: var(--accent); }
.qd-steps li span.qd-reward, .qd-steps li.done span.qd-reward { display: inline-flex; flex: none; text-decoration: none; }
.story-end { max-width: 420px; margin: 10px auto 14px; padding: 18px 16px 14px; text-align: center; border-radius: 18px; color: var(--text);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 18%, var(--card)), var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  box-shadow: 0 8px 24px rgb(0 0 0 / .12); }
.story-end .se-icon .i { width: 34px; height: 34px; color: var(--warn, #d4a017); }
.story-end h3 { margin: 6px 0 2px; font-size: 20px; }
.story-end .se-goal { margin: 0 0 4px; font-weight: 600; }
.story-end .se-rewards { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.story-end .se-rewards li { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 13px; background: var(--card); border: 1px solid var(--line); }
.story-end .se-rewards .i { color: var(--accent); }
.story-end .row { justify-content: center; }
.qd-my-goal.divided { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.goal-row { gap: 6px; flex-wrap: nowrap; }
.goal-row input { flex: 1; min-width: 0; }
.qd-my-goal .field-top label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.qd-my-goal .field-top label .i { color: var(--accent); }
@media (max-width: 560px) {  /* phones: the quest's words get the width, its buttons go under them */
  .sr-step { flex-wrap: wrap; }
  .sr-fields { flex-basis: calc(100% - 80px); }
  .sr-move { flex-direction: row; width: 100%; justify-content: flex-end; gap: 4px; margin-top: -2px; }
  .sr-move .icon-btn { width: 36px; height: 32px; }
}

/* -- suggested personas & Adapt my persona (suggested.js, 1.8.0) -- */
dialog.sp-dialog { width: min(480px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--line);
  border-radius: 18px; background: var(--card); color: var(--text); overflow: hidden; }
dialog.sp-dialog::backdrop { background: rgb(0 0 0 / .55); backdrop-filter: blur(3px); }
.sp-inner { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 16px; max-height: calc(100dvh - 26px); overflow-y: auto; }
.sp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sp-head h2 { margin: 0; font-size: 20px; }
.sp-inner > p { margin: 0; }
.sp-stage { display: flex; align-items: center; gap: 6px; }
.sp-nav { flex: none; }
.sp-nav:disabled { opacity: .3; }
.sp-view { flex: 1; min-width: 0; overflow: hidden; border-radius: 14px; }
.sp-track { display: flex; transition: transform .25s ease; touch-action: pan-y; user-select: none; }
.sp-track.dragging { transition: none; cursor: grabbing; }
.sp-card { flex: 0 0 100%; min-width: 0; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; padding: 14px;
  border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--accent) 6%, var(--bg-2)); }
.sp-top { display: flex; gap: 12px; align-items: center; }
.sp-top > div { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 0; }
.sp-top h3 { margin: 0; font-size: 18px; overflow-wrap: anywhere; }
.sp-pic { width: 72px; height: 72px; flex: none; border-radius: 16px; object-fit: cover; }
.avatar.sp-pic { font-size: 24px; }
.sp-text { max-height: min(34dvh, 260px); overflow-y: auto; font-size: 14px; line-height: 1.5; overscroll-behavior: contain; }
.sp-text b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 6px; }
.sp-text p { margin: 2px 0 0; white-space: pre-line; overflow-wrap: anywhere; }
.sp-actions .btn { flex: 1; justify-content: center; }
.sp-dots { display: flex; justify-content: center; gap: 8px; }
.sp-dots button { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 50%; background: var(--line); cursor: pointer; }
.sp-dots button[aria-selected="true"] { background: var(--accent); }
.sp-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.ad-pick select { flex: 1; min-width: 0; }
.adapt-dialog .field { display: flex; flex-direction: column; gap: 4px; }
.adapt-dialog .field > span { font-size: 13px; color: var(--muted); }
.ad-changes { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.ad-changes ul { margin: 4px 0 0; padding-left: 20px; }
.ad-changes p { margin: 0; display: flex; gap: 6px; align-items: center; }
#adResult { display: grid; gap: 10px; }
#adResult:empty { display: none; }
.cp-persona-tools { gap: 6px; }
.new-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 4px; vertical-align: top;
  box-shadow: 0 0 0 2px var(--card); }
#ctMenu { position: relative; }
#ctMenu .new-dot { position: absolute; top: 2px; right: 2px; margin: 0; }
.sug-list { display: grid; gap: 8px; }
.sug-rows { display: grid; gap: 6px; max-height: 330px; overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.sug-rows > label[hidden] { display: none; }
.sp-foot { justify-content: flex-end; }
.sp-foot > [data-sp-adapt] { margin-right: auto; }
@media (prefers-reduced-motion: reduce) { .sp-track { transition: none; } }

/* Private feedback to a character's creator (1.8.1, creatorfeedback.js) */
dialog.fb-dlg { max-width: 540px; width: calc(100% - 32px); border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--text); padding: 18px; }
dialog.fb-dlg::backdrop { background: rgba(0, 0, 0, .5); }
dialog.fb-dlg h2 { margin-top: 0; font-size: 1.15rem; }
dialog.fb-dlg textarea { width: 100%; margin: 6px 0 8px; }
dialog.fb-dlg .row { justify-content: flex-end; gap: 8px; flex-wrap: wrap; align-items: center; }
dialog.fb-dlg .row [data-count] { margin-right: auto; }
.fb-why { margin: 0 0 10px; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--warn, #f2a93b) 14%, transparent); }
.cfeedback .comment.fb-new { background: color-mix(in srgb, var(--accent) 7%, transparent); border-radius: 12px; padding-inline: 8px; }
.fb-tone .i { width: 13px; height: 13px; vertical-align: -2px; }
.badge.fb-count { color: var(--accent); }
.fb-tone.fb-positive { color: var(--ok); } .fb-tone.fb-negative { color: var(--warn); }
