:root {
  --bg: #08070c;
  --panel: #111017;
  --panel-2: #17151e;
  --panel-3: #1e1b27;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #f6f2f8;
  --muted: #a7a0ad;
  --faint: #706977;
  --accent: #b758ff;
  --accent-2: #ef3f73;
  --accent-3: #ff8c42;
  --good: #61d4a5;
  --danger: #ff5578;
  --shadow: 0 24px 70px rgba(0, 0, 0, .42);
  --sidebar: 230px;
  --topbar: 70px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 76% -10%, rgba(125, 49, 168, .12), transparent 30%), var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: rgba(183, 88, 255, .45); color: white; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #37313e; border: 2px solid transparent; background-clip: padding-box; border-radius: 99px; }

.app-shell { min-height: 100vh; }
.topbar { position: fixed; inset: 0 0 auto 0; z-index: 30; height: var(--topbar); display: grid; grid-template-columns: var(--sidebar) minmax(260px, 620px) 1fr; align-items: center; gap: 28px; padding: 0 24px 0 18px; border-bottom: 1px solid var(--line); background: rgba(8, 7, 12, .88); backdrop-filter: blur(20px); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0; border: 0; background: none; text-align: left; }
.brand-avatar { width: 40px; height: 40px; overflow: hidden; border: 1px solid rgba(255,255,255,.24); border-radius: 13px; box-shadow: 0 0 24px rgba(183, 88, 255, .24); }
.brand-avatar img { width: 100%; height: 100%; object-fit: cover; }
.brand > span:last-child { display: flex; gap: 5px; align-items: baseline; letter-spacing: .12em; }
.brand strong { font-size: 15px; }
.brand em { color: var(--accent); font-size: 12px; font-style: normal; font-weight: 800; }
.global-search { position: relative; display: flex; align-items: center; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.04); color: var(--muted); transition: border-color .2s, background .2s; }
.global-search:focus-within { border-color: rgba(183, 88, 255, .48); background: rgba(255,255,255,.06); }
.global-search > span { padding-left: 14px; font-size: 23px; transform: translateY(-1px); }
.global-search input { min-width: 0; flex: 1; padding: 0 12px; border: 0; outline: 0; background: transparent; color: var(--text); }
.global-search kbd { margin-right: 9px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; background: #201d25; color: var(--faint); font-size: 10px; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.connection-pill { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.connection-pill i, .local-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-3); box-shadow: 0 0 10px currentColor; }
.connection-pill.is-ready i { background: var(--good); }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.035); color: var(--muted); font-size: 18px; }
.icon-button:hover { border-color: var(--line-strong); background: rgba(255,255,255,.07); color: white; }
.profile-chip { display: flex; align-items: center; gap: 9px; padding: 4px 9px 4px 4px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.035); }
.profile-chip span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 12px; font-weight: 900; }
.profile-chip b { max-width: 100px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.sidebar { position: fixed; z-index: 25; top: var(--topbar); bottom: 0; left: 0; display: flex; flex-direction: column; justify-content: space-between; width: var(--sidebar); padding: 22px 14px 18px; border-right: 1px solid var(--line); background: rgba(10, 9, 14, .94); }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { display: grid; grid-template-columns: 25px 1fr auto; align-items: center; width: 100%; padding: 11px 12px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); text-align: left; }
.nav-item span { color: var(--faint); font-size: 17px; text-align: center; }
.nav-item b { min-width: 21px; padding: 2px 6px; border-radius: 99px; background: rgba(255,255,255,.06); color: var(--faint); font-size: 10px; text-align: center; }
.nav-item:hover, .nav-item.is-active { background: rgba(255,255,255,.055); color: white; }
.nav-item.is-active { border-color: rgba(183,88,255,.17); box-shadow: inset 3px 0 var(--accent); }
.nav-item.is-active span { color: var(--accent); }
.sidebar-lower { display: grid; gap: 9px; }
.create-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-bottom: 6px; padding: 12px; border: 0; border-radius: 12px; background: linear-gradient(135deg, #7e36b4, #ad3065); box-shadow: 0 10px 24px rgba(123, 45, 155, .22); color: white; font-weight: 800; }
.create-button:hover { filter: brightness(1.12); }
.local-badge { display: flex; align-items: center; gap: 9px; margin-top: 8px; padding: 11px; border: 1px solid rgba(97,212,165,.12); border-radius: 12px; background: rgba(97,212,165,.035); }
.local-badge i { flex: 0 0 auto; background: var(--good); }
.local-badge span { display: grid; gap: 2px; }
.local-badge strong { font-size: 11px; }
.local-badge small { color: var(--faint); font-size: 9px; }

.main { min-height: 100vh; padding: calc(var(--topbar) + 26px) 34px 60px calc(var(--sidebar) + 34px); }
.view { display: none; width: min(1440px, 100%); margin: 0 auto; }
.view.is-active { display: block; animation: enter .26s ease both; }
.view[data-view="chat"].is-active { animation: none; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }

.hero { position: relative; display: flex; min-height: 460px; overflow: hidden; border: 1px solid var(--line); border-radius: 25px; background: radial-gradient(circle at 82% 32%, rgba(183,88,255,.30), transparent 20%), radial-gradient(circle at 63% 115%, rgba(239,63,115,.23), transparent 32%), linear-gradient(112deg, #17111f 0%, #0c0a10 54%, #120d18 100%); box-shadow: var(--shadow); isolation: isolate; }
.hero::before { content: ""; position: absolute; inset: 0; opacity: .28; background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to right, black, transparent 82%); }
.hero-copy { z-index: 2; align-self: center; width: min(720px, 68%); padding: 60px 40px 58px 58px; }
.eyebrow { display: block; margin-bottom: 10px; color: #b977e8; font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.hero h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(43px, 5.1vw, 76px); font-weight: 500; letter-spacing: -.045em; line-height: .98; }
.hero h1 em { color: #d59cff; font-style: italic; }
.hero-copy > p { max-width: 610px; margin: 24px 0 0; color: #bbb3c0; font-size: 15px; line-height: 1.72; }
.hero-actions { display: flex; gap: 11px; margin-top: 31px; }
.primary-button, .ghost-button, .wide-button, .danger-button, .text-button, .add-block-button { border-radius: 11px; font-weight: 800; transition: .18s ease; }
.primary-button { padding: 12px 17px; border: 0; background: linear-gradient(135deg, #9b45d4, #d33f77); box-shadow: 0 10px 28px rgba(152,56,175,.22); color: white; }
.primary-button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.primary-button:disabled { opacity: .5; cursor: wait; filter: none; transform: none; }
.ghost-button { padding: 11px 16px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.045); color: #ddd7e0; }
.ghost-button:hover { background: rgba(255,255,255,.09); }
.ghost-button:disabled { opacity: .35; cursor: default; }
.hero-mark { position: absolute; z-index: 2; top: 50%; right: 7%; display: grid; justify-items: center; transform: translateY(-50%) rotate(2deg); }
.hero-mark::before { content: ""; position: absolute; inset: -42px; z-index: -1; border: 1px solid rgba(255,255,255,.10); border-radius: 50%; box-shadow: 0 0 80px rgba(183,88,255,.15), inset 0 0 40px rgba(255,255,255,.025); }
.hero-mark img { width: 196px; height: 196px; object-fit: cover; border: 1px solid rgba(255,255,255,.23); border-radius: 48px; box-shadow: 0 30px 70px rgba(0,0,0,.44), 0 0 55px rgba(183,88,255,.28); }
.hero-mark span { margin-top: 21px; color: var(--faint); font-size: 8px; font-weight: 900; letter-spacing: .25em; }
.hero-mark strong { margin-top: 5px; font-family: Georgia, serif; font-size: 17px; letter-spacing: .08em; }
.hero-orbit { position: absolute; z-index: 1; border: 1px solid rgba(255,255,255,.07); border-radius: 50%; }
.orbit-one { top: -175px; right: -105px; width: 570px; height: 570px; }
.orbit-two { right: 30px; bottom: -305px; width: 680px; height: 680px; }

.genre-strip { display: flex; gap: 7px; overflow-x: auto; margin: 22px 0 34px; padding: 2px 0 8px; }
.genre-strip button { flex: 0 0 auto; padding: 8px 13px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.025); color: var(--muted); font-size: 11px; font-weight: 800; }
.genre-strip button:hover, .genre-strip button.is-active { border-color: rgba(183,88,255,.35); background: rgba(183,88,255,.12); color: #e8c7ff; }
.content-section { margin-top: 38px; }
.compact-section { margin-top: 52px; }
.section-heading, .page-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2, .page-header h1 { margin: 0; font-family: Georgia, serif; font-size: 28px; font-weight: 500; letter-spacing: -.025em; }
.page-header { align-items: center; min-height: 105px; margin-bottom: 26px; }
.page-header h1 { font-size: 43px; }
.page-header p { max-width: 650px; margin: 8px 0 0; color: var(--muted); line-height: 1.6; }
.page-header-actions { display: flex; align-items: center; gap: 9px; }
.section-heading .eyebrow, .page-header .eyebrow { margin-bottom: 7px; }
.section-meta { color: var(--faint); font-size: 11px; }
.text-button { padding: 5px; border: 0; background: none; color: #c88cf1; font-size: 12px; }
.text-button:hover { color: white; }

.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; }
.world-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); transition: transform .2s, border-color .2s, box-shadow .2s; cursor: pointer; }
.world-card:hover { transform: translateY(-4px); border-color: rgba(255,255,255,.17); box-shadow: 0 20px 44px rgba(0,0,0,.28); }
.world-card-cover { position: relative; display: flex; min-height: 220px; overflow: hidden; padding: 20px; flex-direction: column; justify-content: space-between; isolation: isolate; }
.world-cover-media { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.world-card-cover.has-media::after, .chat-cover.has-media::after, .modal-cover.has-media::after { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to bottom, rgba(8,6,10,.12), rgba(8,6,10,.66)); }
.world-card-cover.has-media .cover-glyph, .chat-cover.has-media > .chat-cover-letter, .modal-cover.has-media > strong { opacity: 0; }
.world-card-cover::before, .modal-cover::before, .mini-cover::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .65; background: repeating-linear-gradient(118deg, transparent 0 23px, rgba(255,255,255,.025) 24px 25px); }
.cover-violet { background: radial-gradient(circle at 72% 35%, rgba(225,157,255,.33), transparent 23%), linear-gradient(145deg, #2b1638, #100d16 60%, #321241); }
.cover-crimson { background: radial-gradient(circle at 74% 35%, rgba(255,86,122,.32), transparent 22%), linear-gradient(145deg, #351119, #100b10 60%, #40111e); }
.cover-gold { background: radial-gradient(circle at 74% 35%, rgba(255,201,92,.27), transparent 22%), linear-gradient(145deg, #3a2b12, #100d0a 60%, #392711); }
.cover-verdant { background: radial-gradient(circle at 74% 35%, rgba(98,230,162,.27), transparent 22%), linear-gradient(145deg, #123326, #09110e 60%, #153b29); }
.cover-azure { background: radial-gradient(circle at 74% 35%, rgba(82,181,255,.32), transparent 22%), linear-gradient(145deg, #102f48, #080e14 60%, #133b56); }
.cover-ember { background: radial-gradient(circle at 74% 35%, rgba(255,137,65,.35), transparent 22%), linear-gradient(145deg, #3d1b0d, #100b08 60%, #481a0a); }
.cover-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cover-type { padding: 5px 7px; border: 1px solid rgba(255,255,255,.16); border-radius: 7px; background: rgba(0,0,0,.18); color: rgba(255,255,255,.72); font-size: 8px; font-weight: 900; letter-spacing: .13em; }
.privacy-chip { color: rgba(255,255,255,.54); font-size: 14px; }
.cover-glyph { align-self: center; display: grid; place-items: center; width: 88px; height: 88px; margin: 1px 0 4px; border: 1px solid rgba(255,255,255,.2); border-radius: 31px; background: rgba(0,0,0,.18); box-shadow: inset 0 0 24px rgba(255,255,255,.05), 0 18px 40px rgba(0,0,0,.25); font-family: Georgia, serif; font-size: 42px; font-style: italic; }
.cover-credit { color: rgba(255,255,255,.34); font-size: 8px; font-weight: 900; letter-spacing: .2em; text-align: center; }
.world-card-body { padding: 18px; }
.world-card-body h3 { margin: 0; overflow: hidden; font-family: Georgia, serif; font-size: 21px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.world-card-body > p { min-height: 42px; margin: 7px 0 13px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-list span { padding: 4px 7px; border-radius: 6px; background: rgba(255,255,255,.055); color: var(--muted); font-size: 9px; }
.card-stats { display: flex; gap: 14px; margin-top: 15px; color: var(--faint); font-size: 10px; }
.card-stats b { color: #c6bdca; font-weight: 700; }

.character-row { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.character-card, .character-library-card { display: flex; gap: 12px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); text-align: left; }
.character-card:hover, .character-library-card:hover { border-color: rgba(183,88,255,.28); background: var(--panel-2); }
.character-portrait { flex: 0 0 auto; display: grid; place-items: center; width: 60px; height: 72px; border-radius: 11px; font-family: Georgia, serif; font-size: 25px; font-style: italic; }
.character-card > span:last-child { min-width: 0; align-self: center; }
.character-card strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.character-card small { display: -webkit-box; overflow: hidden; margin-top: 5px; color: var(--faint); font-size: 10px; line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.continue-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.continue-card { display: grid; grid-template-columns: 68px minmax(0,1fr) auto; gap: 13px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); text-align: left; }
.continue-card:hover { border-color: var(--line-strong); background: var(--panel-2); }
.mini-cover { position: relative; display: grid; place-items: center; width: 68px; height: 76px; overflow: hidden; border-radius: 10px; font-family: Georgia, serif; font-size: 26px; font-style: italic; }
.continue-card strong { display: block; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.continue-card p { display: -webkit-box; overflow: hidden; margin: 4px 0 0; color: var(--faint); font-size: 10px; line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.continue-card > b { color: var(--accent); }

.filter-bar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.filter-bar label { display: flex; align-items: center; width: min(460px, 100%); border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.filter-bar label span { padding-left: 13px; color: var(--faint); font-size: 20px; }
.filter-bar input { width: 100%; padding: 11px; border: 0; outline: 0; background: transparent; color: white; }
.filter-bar select { padding: 0 36px 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--muted); }
.character-library { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 13px; }
.character-library-card { position: relative; min-height: 142px; padding: 15px; cursor: pointer; }
.character-library-card .character-portrait { width: 82px; height: 110px; font-size: 35px; }
.character-library-card h3 { margin: 2px 0 4px; font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.character-library-card .role { color: #bd7fe8; font-size: 9px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.character-library-card p { display: -webkit-box; overflow: hidden; margin: 9px 0; color: var(--muted); font-size: 11px; line-height: 1.5; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.character-library-card small { color: var(--faint); font-size: 9px; }

.empty-state { grid-column: 1 / -1; display: grid; justify-items: center; padding: 70px 20px; border: 1px dashed var(--line-strong); border-radius: 18px; color: var(--muted); text-align: center; }
.empty-state b { margin-bottom: 8px; color: white; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.session-list { display: grid; gap: 10px; }
.session-row { display: grid; grid-template-columns: 68px minmax(0,1fr) auto; gap: 16px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.session-row:hover { border-color: var(--line-strong); background: var(--panel-2); }
.session-copy { min-width: 0; }
.session-copy h3 { margin: 0; overflow: hidden; font-family: Georgia, serif; font-size: 18px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.session-copy p { overflow: hidden; margin: 5px 0 0; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.session-copy small { display: block; margin-top: 7px; color: var(--faint); font-size: 9px; }
.session-row-actions { display: flex; gap: 7px; }

.creator-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 21px; }
.creator-stat { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); }
.creator-stat span { color: var(--faint); font-size: 9px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.creator-stat b { display: block; margin-top: 5px; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.title-table { overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); }
.title-row { display: grid; grid-template-columns: minmax(260px, 2fr) .7fr .7fr 1fr; gap: 15px; align-items: center; min-height: 88px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.title-row:last-child { border-bottom: 0; }
.title-row:hover { background: rgba(255,255,255,.02); }
.title-identity { display: grid; grid-template-columns: 54px minmax(0,1fr); gap: 12px; align-items: center; }
.title-identity .mini-cover { width: 54px; height: 62px; }
.title-identity h3 { margin: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.title-identity p { margin: 5px 0 0; overflow: hidden; color: var(--faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.title-cell { color: var(--muted); font-size: 11px; }
.table-actions { display: flex; justify-content: end; gap: 6px; }

.creator-layout { display: grid; grid-template-columns: 250px minmax(0, 940px); justify-content: center; gap: 30px; align-items: start; }
.creator-steps { position: sticky; top: calc(var(--topbar) + 25px); padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.creator-steps h2 { margin: 0; font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.creator-steps > p { margin: 8px 0 16px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.creator-file-tools { display: grid; gap: 7px; margin: 0 0 18px; padding: 11px; border: 1px solid rgba(183,88,255,.16); border-radius: 12px; background: rgba(183,88,255,.045); }
.creator-file-tools .ghost-button { width: 100%; padding: 9px 10px; font-size: 9px; }
.creator-file-tools small { color: var(--faint); font-size: 8px; line-height: 1.45; }
.creator-steps ol { display: grid; gap: 2px; max-height: calc(100vh - 245px); overflow-y: auto; margin: 0; padding: 0 3px 0 0; list-style: none; }
.creator-steps li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; padding: 9px; border-radius: 10px; color: var(--faint); }
.creator-steps li b { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--line); border-radius: 50%; font-size: 9px; }
.creator-steps li span { font-size: 11px; font-weight: 800; }
.creator-steps li small { display: block; margin-top: 2px; color: var(--faint); font-size: 8px; font-weight: 500; }
.creator-steps li.is-active { background: rgba(183,88,255,.09); color: white; }
.creator-steps li.is-active b { border-color: transparent; background: var(--accent); }
.creator-form { overflow: hidden; border: 1px solid var(--line); border-radius: 19px; background: var(--panel); box-shadow: var(--shadow); }
.creator-trail { display: flex; align-items: center; gap: 7px; overflow-x: auto; min-height: 55px; padding: 0 20px; border-bottom: 1px solid var(--line); background: rgba(0,0,0,.14); scrollbar-width: thin; }
.creator-trail > button { flex: 0 0 auto; padding: 7px 2px; border: 0; background: transparent; color: #aaa4ad; font-size: 10px; white-space: nowrap; }
.creator-trail > button:hover, .creator-trail > button.is-active { color: white; }
.creator-trail > button.is-active { box-shadow: inset 0 -2px var(--accent); }
.creator-trail > button i { margin-left: 3px; color: #b8ff59; font-style: normal; font-weight: 900; }
.creator-trail > span { flex: 0 0 auto; color: #69636d; font-size: 18px; }
.creator-panel { display: none; min-height: 650px; padding: 31px; }
.creator-panel.is-active { display: block; }
.panel-heading { display: grid; grid-template-columns: 42px 1fr; gap: 13px; align-items: center; margin-bottom: 28px; }
.panel-heading > span { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(183,88,255,.25); border-radius: 13px; background: rgba(183,88,255,.08); color: #cf9bf2; font-size: 11px; font-weight: 900; }
.panel-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.panel-heading h2 small { display: inline-block; margin-left: 7px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 99px; color: var(--faint); font-family: inherit; font-size: 8px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; vertical-align: middle; }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.field { display: grid; gap: 7px; margin-bottom: 17px; }
.field > span { color: #d7d0db; font-size: 11px; font-weight: 800; }
.field > span small { float: right; color: var(--faint); font-weight: 500; }
.field > span em { color: #c7ff37; font-style: normal; }
.field-help { display: block; margin: -2px 0 8px; color: var(--faint); font-size: 9px; line-height: 1.5; }
.field input, .field textarea, .field select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; outline: 0; background: #0c0b10; color: var(--text); resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: rgba(183,88,255,.48); box-shadow: 0 0 0 3px rgba(183,88,255,.07); }
.field input[type="range"] { padding: 0; accent-color: var(--accent); }
.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: 1fr 1fr; }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.prompt-tip { padding: 14px; border: 1px solid rgba(183,88,255,.15); border-radius: 11px; background: rgba(183,88,255,.055); color: var(--muted); font-size: 10px; line-height: 1.55; }
.prompt-tip b { color: #d6a7f5; }
.prompt-tip code { padding: 2px 5px; border-radius: 5px; background: rgba(0,0,0,.3); color: #e2bdf8; }
.form-actions { display: flex; align-items: center; gap: 10px; min-height: 70px; padding: 12px 24px; border-top: 1px solid var(--line); background: rgba(0,0,0,.16); }
.form-actions > span { flex: 1; color: var(--faint); font-size: 9px; text-align: center; }
.editor-block { position: relative; padding: 17px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.018); }
.editor-block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.editor-block-head b { font-family: Georgia, serif; font-size: 17px; font-weight: 500; }
.stat-scenario-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 5px 0 18px; padding-bottom: 3px; }
.stat-scenario-tabs button { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.025); color: var(--muted); }
.stat-scenario-tabs button.is-active { border-color: rgba(183,88,255,.45); background: #e8e4eb; color: #242027; }
.stat-scenario-tabs button b { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 99px; background: rgba(0,0,0,.12); font-size: 9px; }
.stat-editor { padding: 0; overflow: hidden; background: rgba(255,255,255,.025); }
.stat-editor > summary { justify-content: flex-start; padding: 15px 18px; margin: 0; cursor: pointer; list-style: none; }
.stat-editor > summary::-webkit-details-marker { display: none; }
.stat-editor > summary::after { content: "⌄"; margin-left: auto; color: var(--faint); }
.stat-editor[open] > summary::after { content: "⌃"; }
.stat-editor > summary small { color: var(--faint); font-size: 9px; }
.stat-summary-icon { display: grid; place-items: center; width: 31px; height: 31px; border: 1px solid color-mix(in srgb, var(--stat-color) 55%, transparent); border-radius: 9px; background: color-mix(in srgb, var(--stat-color) 16%, transparent); color: var(--stat-color); font-size: 16px; }
.stat-editor-body { padding: 19px; border-top: 1px solid var(--line); }
.stat-delete { position: absolute; z-index: 2; top: 16px; right: 48px; color: #ff756e; font-size: 9px; text-transform: uppercase; }
.stat-number-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-number-grid input { min-width: 0; }
.color-field { display: grid; grid-template-columns: 52px 1fr; gap: 8px; align-items: center; }
.color-field input[type="color"] { width: 52px; height: 42px; padding: 4px; cursor: pointer; }
.color-field code { padding: 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 10px; text-align: center; text-transform: uppercase; }
.auto-stat-button { margin: -4px 0 19px; padding: 9px 11px; border: 1px solid rgba(199,255,55,.5); border-radius: 8px; background: rgba(199,255,55,.07); color: #d9ff78; font-size: 9px; font-weight: 800; }
.auto-stat-button:disabled { opacity: .55; }
.stat-levels { margin-top: 7px; padding-top: 19px; border-top: 1px solid var(--line); }
.stat-levels-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.stat-levels-head b { display: block; font-size: 12px; }
.stat-levels-head b i { margin-left: 5px; color: var(--faint); font-size: 8px; font-style: normal; font-weight: 600; text-transform: uppercase; }
.stat-levels-head small { display: block; margin-top: 4px; color: var(--faint); font-size: 9px; }
.stat-levels-head button { border: 0; background: transparent; color: #ff625b; font-size: 9px; }
.stat-level-editor { margin: 10px 0; padding: 14px; border: 1px solid var(--line); border-radius: 11px; background: rgba(0,0,0,.13); }
.stat-level-title { display: flex; justify-content: space-between; margin-bottom: 12px; color: var(--muted); font-size: 10px; }
.stat-level-title button { border: 0; background: transparent; color: var(--faint); }
.add-level-button { width: 100%; padding: 11px; border: 1px dashed var(--line-strong); background: rgba(255,255,255,.015); color: var(--muted); }
.stat-empty { min-height: 150px; margin-bottom: 12px; }
.remove-block { padding: 4px 7px; border: 0; background: transparent; color: var(--faint); }
.remove-block:hover { color: var(--danger); }
.add-block-button { width: 100%; padding: 12px; border: 1px dashed var(--line-strong); background: transparent; color: #bd85e4; }
.add-block-button:hover { border-color: rgba(183,88,255,.4); background: rgba(183,88,255,.05); }
.subheading { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 13px; }
.subheading h3 { margin: 0; font-family: Georgia, serif; font-size: 20px; font-weight: 500; }
.subheading p { margin: 3px 0 0; color: var(--faint); font-size: 9px; }
.subheading button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); }
.finish-card { display: flex; align-items: center; gap: 18px; margin-top: 30px; padding: 22px; border: 1px solid rgba(183,88,255,.19); border-radius: 16px; background: radial-gradient(circle at 0 0, rgba(183,88,255,.12), transparent 42%), #0d0b12; }
.finish-card img { width: 82px; height: 82px; border-radius: 22px; object-fit: cover; }
.finish-card span { color: #c98cf1; font-size: 8px; font-weight: 900; letter-spacing: .2em; }
.finish-card h3 { margin: 5px 0; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.finish-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.toggle-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 7px 0 20px; }
.toggle-field { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.018); cursor: pointer; }
.toggle-field input { margin-top: 2px; accent-color: var(--accent); }
.toggle-field b { display: block; font-size: 10px; }
.toggle-field small { display: block; margin-top: 3px; color: var(--faint); font-size: 8px; line-height: 1.4; }
.media-drop { display: grid; justify-items: center; gap: 6px; padding: 28px 18px; border: 1px dashed rgba(183,88,255,.34); border-radius: 14px; background: rgba(183,88,255,.035); color: #d4a3f2; text-align: center; cursor: pointer; }
.media-drop:hover { background: rgba(183,88,255,.07); }
.media-drop strong { font-size: 12px; }
.media-drop span { color: var(--faint); font-size: 9px; }
.media-drop input { display: none; }
.media-library { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 17px 0; }
.media-item { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #0c0b10; }
.media-preview { display: grid; place-items: center; width: 100%; height: 132px; overflow: hidden; background: radial-gradient(circle, rgba(183,88,255,.13), transparent 60%); color: #c18de3; font-family: Georgia, serif; font-size: 30px; }
.media-preview img { width: 100%; height: 100%; object-fit: cover; }
.media-preview audio { width: calc(100% - 14px); height: 34px; }
.media-item-body { display: grid; gap: 7px; padding: 10px; }
.media-item-body input { min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; outline: 0; background: #141219; color: white; font-size: 9px; }
.media-item-actions { display: flex; justify-content: space-between; gap: 5px; }
.media-item-actions button { padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.035); color: var(--muted); font-size: 8px; }
.media-item-actions button.is-cover { border-color: rgba(183,88,255,.4); background: rgba(183,88,255,.11); color: #dcaff8; }
.media-item-actions button:hover { color: white; }
.stat-preview { display: flex; align-items: center; gap: 8px; }
.stat-preview input:first-child { flex: 1; }
.stat-preview input:last-child { width: 36%; }

.chat-shell { position: fixed; inset: var(--topbar) 0 0 var(--sidebar); z-index: 20; display: grid; grid-template-columns: 255px minmax(0,1fr); background: #09080c; }
.chat-info { overflow-y: auto; padding: 22px 18px; border-right: 1px solid var(--line); background: #0d0c11; }
.chat-cover { position: relative; display: grid; place-items: center; height: 185px; overflow: hidden; border-radius: 16px; font-family: Georgia, serif; font-size: 54px; font-style: italic; }
.chat-cover img { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.chat-info h2 { margin: 17px 0 5px; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.chat-info > p { color: var(--muted); font-size: 11px; line-height: 1.55; }
.chat-info-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.chat-info-section h3 { margin: 0 0 9px; color: var(--faint); font-size: 8px; letter-spacing: .17em; text-transform: uppercase; }
.chat-info-scroll { max-height: 300px; overflow-y: auto; overflow-x: hidden; padding-right: 5px; scrollbar-gutter: stable; overscroll-behavior: contain; }
.relationships-scroll { max-height: 320px; }
.stats-scroll { max-height: 300px; }
.chat-info-mobile-head { position: sticky; top: -22px; z-index: 4; grid-template-columns: 1fr auto; align-items: center; justify-content: space-between; margin: -22px -18px 16px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: rgba(13,12,17,.96); backdrop-filter: blur(14px); }
.chat-info-mobile-head b { font-size: 11px; }
.cast-chip { display: flex; align-items: center; gap: 8px; margin: 7px 0; color: var(--muted); font-size: 10px; }
.cast-chip b { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 9px; background: rgba(183,88,255,.12); color: #d3a5f2; font-family: Georgia, serif; }
.cast-relationship-card { margin: 9px 0 13px; padding: 9px 10px 10px; border: 1px solid rgba(183,88,255,.13); border-radius: 11px; background: rgba(183,88,255,.035); }
.cast-relationship-card .cast-chip { margin-top: 0; }
.cast-relationship { display: grid; gap: 6px; margin-top: 8px; }
.cast-relationship > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cast-relationship > span small { color: var(--faint); font-size: 8px; }
.cast-relationship > span strong { color: #dcaef8; font-size: 9px; }
.cast-relationship input { width: 100%; margin: 0; accent-color: var(--accent); cursor: pointer; }
.cast-relationship > i { display: flex; justify-content: space-between; color: #5f5965; font-size: 7px; font-style: normal; }
.cast-relationship > i em { font-style: normal; }
.character-relationship-field { margin-top: 19px; padding: 13px; border: 1px solid rgba(183,88,255,.16); border-radius: 11px; background: rgba(183,88,255,.04); }
.character-relationship-field > span { display: flex; justify-content: space-between; gap: 12px; }
.character-relationship-field > span b { color: #dcaef8; font-size: 10px; }
.character-relationship-field > small { color: var(--faint); font-size: 9px; line-height: 1.45; }
.session-stat { display: flex; align-items: center; gap: 9px; margin: 9px 0; padding: 9px; border: 1px solid color-mix(in srgb, var(--stat-color) 25%, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--stat-color) 6%, transparent); }
.session-stat-icon { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 9px; background: color-mix(in srgb, var(--stat-color) 18%, transparent); color: var(--stat-color); font-size: 16px; }
.session-stat-copy { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; flex: 1; min-width: 0; }
.session-stat-copy b { overflow: hidden; color: #ddd7e1; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.session-stat-copy strong { color: var(--stat-color); font-size: 11px; }
.session-stat-copy strong small { font-size: 8px; font-weight: 600; }
.session-stat-copy em { grid-column: 1 / -1; color: var(--faint); font-size: 8px; font-style: normal; }
.session-stat-copy i { grid-column: 1 / -1; height: 3px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.07); }
.session-stat-copy i u { display: block; height: 100%; border-radius: inherit; background: var(--stat-color); text-decoration: none; }
.chat-main { position: relative; display: grid; grid-template-rows: 68px minmax(0,1fr) auto auto; min-width: 0; height: calc(100vh - var(--topbar)); }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(12,11,16,.9); }
.chat-header h2 { max-width: 560px; overflow: hidden; margin: 2px 0 0; font-family: Georgia, serif; font-size: 18px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.chat-header > div > span { color: #af75d8; font-size: 8px; font-weight: 900; letter-spacing: .15em; }
.chat-header-actions { display: flex; align-items: center; gap: 7px; }
.mode-select { display: flex; align-items: center; gap: 7px; padding: 4px 7px 4px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--faint); font-size: 9px; }
.mode-select select { border: 0; outline: 0; background: transparent; color: #d7d1db; font-size: 10px; font-weight: 800; }
.engine-select select { max-width: 128px; }
.message-stream { overflow-y: auto; padding: 28px max(24px, calc((100% - 820px) / 2)) 18px; scroll-behavior: smooth; }
.message { position: relative; display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 12px; max-width: 820px; margin: 0 auto 24px; }
.message.user { grid-template-columns: minmax(0,1fr) 36px; }
.message-avatar { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel-2); color: #d4a2f3; font-family: Georgia, serif; font-size: 15px; }
.message.user .message-avatar { grid-column: 2; background: linear-gradient(135deg, #7d38aa, #ad305f); color: white; }
.message.user .message-content { grid-column: 1; grid-row: 1; justify-self: end; max-width: 82%; padding: 12px 14px; border-radius: 14px 4px 14px 14px; background: #21172a; }
.message.assistant .message-content { min-width: 0; padding-top: 2px; }
.message-name { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; color: #d0c9d4; font-size: 10px; font-weight: 900; }
.message-name time { color: var(--faint); font-size: 8px; font-weight: 500; }
.message-text { color: #ded9e2; font-family: Georgia, "Times New Roman", serif; font-size: 16px; line-height: 1.75; white-space: pre-wrap; word-break: break-word; }
.message.user .message-text { font-family: inherit; font-size: 12px; line-height: 1.55; }
.message-actions { display: flex; gap: 4px; margin-top: 8px; opacity: 0; transition: opacity .15s; }
.message:hover .message-actions { opacity: 1; }
.message-actions button { padding: 3px 6px; border: 0; border-radius: 6px; background: transparent; color: var(--faint); font-size: 9px; }
.message-actions button:hover { background: rgba(255,255,255,.06); color: white; }
.typing-dots { display: inline-flex; gap: 4px; padding-top: 8px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: #b878df; animation: pulse 1s infinite alternate; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { to { opacity: .25; transform: translateY(-3px); } }
.suggested-replies { display: flex; gap: 7px; overflow-x: auto; max-width: 860px; width: calc(100% - 36px); margin: 0 auto 9px; }
.suggested-replies button { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; background: rgba(255,255,255,.025); color: var(--muted); font-size: 9px; }
.suggested-replies button:hover { border-color: rgba(183,88,255,.35); color: white; }
.composer { width: min(860px, calc(100% - 36px)); margin: 0 auto 17px; border: 1px solid var(--line-strong); border-radius: 15px; background: #141219; box-shadow: 0 15px 45px rgba(0,0,0,.3); }
.composer:focus-within { border-color: rgba(183,88,255,.45); }
.composer textarea { display: block; width: 100%; max-height: 190px; padding: 14px 15px 8px; border: 0; outline: 0; background: transparent; color: white; resize: none; }
.composer-footer { display: flex; align-items: center; justify-content: space-between; padding: 4px 7px 7px 14px; }
.composer-footer > span { color: var(--faint); font-size: 8px; }
.composer-footer b { color: #a978c8; }
.send-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: linear-gradient(135deg, #9b45d4, #d33f77); color: white; }
.send-button:disabled { opacity: .45; cursor: wait; }
.rooms-drawer, .memory-drawer, .settings-drawer { position: absolute; z-index: 8; top: 0; right: 0; bottom: 0; width: min(380px, 100%); overflow-y: auto; padding: 21px; border-left: 1px solid var(--line); background: #111017; box-shadow: -25px 0 60px rgba(0,0,0,.34); transform: translateX(104%); transition: transform .25s ease; }
.rooms-drawer.is-open, .memory-drawer.is-open, .settings-drawer.is-open { transform: translateX(0); }

.chat-title-stack { min-width: 0; }
.chat-title-stack small { display: block; max-width: 560px; margin-top: 2px; overflow: hidden; color: #82778a; font-size: 8px; font-weight: 800; letter-spacing: .04em; text-overflow: ellipsis; white-space: nowrap; }
.room-help { margin: -4px 0 15px; }
.room-list { display: grid; gap: 9px; margin: 12px 0 20px; }
.room-card { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); }
.room-card.is-active { border-color: rgba(183,88,255,.5); background: rgba(183,88,255,.08); box-shadow: inset 3px 0 0 rgba(183,88,255,.7); }
.room-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.room-card-head b { color: #eee7f2; font-size: 12px; }
.room-card-head small { display: block; margin-top: 2px; color: #9f79b8; font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.room-card p { max-height: 92px; margin: 0; overflow: auto; color: var(--muted); font-size: 9px; line-height: 1.5; white-space: pre-wrap; }
.room-card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.room-card-actions button { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.035); color: #c9c0ce; font-size: 8px; font-weight: 850; }
.room-card-actions button:hover { border-color: rgba(183,88,255,.34); color: white; }
.room-card-actions .room-delete { color: #ff8099; }
.room-editor { padding-top: 14px; border-top: 1px solid var(--line); }
.room-editor .field { margin-top: 12px; }
.room-form-actions { display: flex; gap: 8px; align-items: center; }
.room-form-actions .wide-button { flex: 1; }
.room-form-actions .ghost-button { margin-top: 9px; }

.drawer-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.drawer-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 26px; font-weight: 500; }
.memory-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.memory-tabs button { padding: 6px 8px; border: 0; border-radius: 7px; background: transparent; color: var(--faint); font-size: 9px; font-weight: 800; }
.memory-tabs button.is-active { background: rgba(183,88,255,.1); color: #d9a7f8; }
.memory-list { display: grid; gap: 8px; margin: 14px 0; }
.memory-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.02); color: var(--muted); font-size: 10px; line-height: 1.5; }
.memory-item button { border: 0; background: transparent; color: var(--faint); }
.memory-item button:hover { color: var(--danger); }
.memory-add { display: grid; grid-template-columns: 1fr 36px; gap: 7px; }
.memory-add input { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; outline: 0; background: #0b0a0e; color: white; }
.memory-add button { border: 0; border-radius: 9px; background: var(--accent); color: white; }
.settings-drawer .field { margin-top: 20px; }
.length-control { margin-top: 8px; padding: 16px; border: 1px solid rgba(183,88,255,.2); border-radius: 14px; background: rgba(183,88,255,.055); }
.length-control .field { margin-top: 14px; }
.length-control-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.length-control-heading h3 { margin: 3px 0 0; color: #eee8f1; font-family: Georgia, serif; font-size: 19px; font-weight: 500; }
.length-control-heading strong { flex: 0 0 auto; color: #d7a2f5; font-size: 11px; }
.wide-button, .danger-button { width: 100%; margin-top: 9px; padding: 11px 13px; border: 1px solid var(--line); background: rgba(255,255,255,.05); }
.wide-button:hover { border-color: rgba(183,88,255,.32); background: rgba(183,88,255,.08); }
.danger-button { margin-top: 24px; border-color: rgba(255,85,120,.19); background: rgba(255,85,120,.06); color: #ff8099; }
.danger-button:hover { background: rgba(255,85,120,.12); }
.mobile-only { display: none; }
.mobile-nav-settings { display: none; }

.settings-grid { display: grid; grid-template-columns: 1.2fr .9fr .9fr; gap: 14px; align-items: start; }
.settings-card { padding: 22px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); }
.settings-card-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.settings-card-heading img, .connection-emblem { width: 52px; height: 52px; border-radius: 15px; object-fit: cover; }
.connection-emblem { display: grid; place-items: center; border: 1px solid rgba(183,88,255,.22); background: rgba(183,88,255,.08); color: #d5a2f5; font-family: Georgia, serif; font-size: 24px; font-style: italic; }
.settings-card-heading span { color: #ac75d2; font-size: 8px; font-weight: 900; letter-spacing: .16em; }
.settings-card-heading h2 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.status-list { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 0 0 19px; }
.status-list dt { color: var(--faint); font-size: 10px; }
.status-list dd { max-width: 180px; margin: 0; overflow: hidden; color: #d1cad5; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.engine-note { margin: -10px 0 18px; }
.fine-print { margin: 14px 0 0; color: var(--faint); font-size: 9px; line-height: 1.55; }
.file-button { display: block; text-align: center; cursor: pointer; }
.file-button input { display: none; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; overflow-y: auto; padding: 42px 18px; background: rgba(3,2,5,.83); backdrop-filter: blur(12px); }
.title-modal { position: relative; display: grid; grid-template-columns: 340px minmax(0,1fr); width: min(1050px, 100%); min-height: 680px; margin: 0 auto; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 22px; background: #100f14; box-shadow: 0 38px 110px rgba(0,0,0,.68); }
.modal-close { position: absolute; z-index: 3; top: 14px; right: 14px; display: grid; place-items: center; width: 37px; height: 37px; border: 1px solid var(--line); border-radius: 50%; background: rgba(0,0,0,.45); color: var(--muted); font-size: 20px; }
.modal-cover { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 680px; isolation: isolate; }
.modal-cover-media { position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover; }
.modal-cover > span { position: absolute; top: 32px; left: 28px; color: rgba(255,255,255,.57); font-size: 8px; font-weight: 900; letter-spacing: .17em; }
.modal-cover strong { display: grid; place-items: center; width: 150px; height: 150px; border: 1px solid rgba(255,255,255,.19); border-radius: 52px; background: rgba(0,0,0,.16); box-shadow: 0 27px 70px rgba(0,0,0,.3), inset 0 0 45px rgba(255,255,255,.04); font-family: Georgia, serif; font-size: 74px; font-style: italic; font-weight: 500; }
.modal-cover small { position: absolute; bottom: 30px; color: rgba(255,255,255,.35); font-size: 8px; font-weight: 900; letter-spacing: .2em; }
.modal-body { overflow-y: auto; max-height: min(830px, calc(100vh - 84px)); padding: 50px 47px 35px; }
.modal-body > h1 { margin: 0; font-family: Georgia, serif; font-size: 44px; font-weight: 500; letter-spacing: -.035em; }
.modal-tagline { margin: 8px 0 15px; color: #c9c1cd; font-family: Georgia, serif; font-size: 17px; font-style: italic; }
.modal-stats { display: flex; gap: 18px; margin: 18px 0; color: var(--faint); font-size: 10px; }
.modal-stats b { color: #d8d0db; }
.modal-description { margin: 25px 0; color: var(--muted); font-size: 12px; line-height: 1.72; }
.modal-body section { padding-top: 20px; margin-top: 20px; border-top: 1px solid var(--line); }
.modal-body section h3 { margin: 0 0 12px; font-family: Georgia, serif; font-size: 18px; font-weight: 500; }
.modal-cast { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal-cast-item { padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.02); }
.modal-cast-item b { display: block; font-size: 10px; }
.modal-cast-item small { color: var(--faint); font-size: 8px; }
.scenario-picker-section { position: relative; padding: 20px !important; border: 1px solid rgba(183,88,255,.27) !important; border-radius: 15px; background: linear-gradient(145deg, rgba(183,88,255,.08), rgba(255,255,255,.015)); }
.scenario-picker-heading { margin-bottom: 13px; }
.scenario-picker-heading h3 { margin: 4px 0 4px !important; font-size: 22px !important; }
.scenario-picker-heading p { margin: 0; color: var(--faint); font-size: 9px; }
.scenario-list { display: grid; gap: 9px; }
.scenario-option { appearance: none; width: 100%; display: grid; grid-template-columns: 20px minmax(0,1fr) auto; align-items: start; gap: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.025); color: inherit; text-align: left; cursor: pointer; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.scenario-option:hover { border-color: rgba(183,88,255,.38); background: rgba(183,88,255,.055); transform: translateY(-1px); }
.scenario-option.is-selected { border-color: rgba(183,88,255,.72); background: rgba(183,88,255,.12); box-shadow: 0 0 0 1px rgba(183,88,255,.12) inset; }
.scenario-option i { display: block; width: 15px; height: 15px; margin-top: 2px; border: 1px solid var(--line-strong); border-radius: 50%; }
.scenario-option.is-selected i { border: 4px solid var(--accent); }
.scenario-option b { display: block; color: #f2edf5; font-size: 11px; }
.scenario-option small { display: block; margin-top: 5px; color: #9f96a5; font-size: 9px; line-height: 1.55; }
.scenario-option > strong { align-self: center; padding: 5px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--faint); font-size: 7px; letter-spacing: .09em; }
.scenario-option.is-selected > strong { border-color: rgba(183,88,255,.45); color: #e2b9ff; background: rgba(183,88,255,.1); }
.scenario-preview { margin-top: 11px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: #0b0a0e; }
.scenario-preview b { display: block; margin-bottom: 7px; color: #e7dcec; font-family: Georgia, serif; font-size: 13px; }
.scenario-preview p { max-height: 190px; overflow: auto; margin: 0; color: #aaa0ae; font-family: Georgia, serif; font-size: 11px; line-height: 1.65; white-space: pre-wrap; }
.scenario-attention { animation: scenarioPulse .72s ease; }
@keyframes scenarioPulse { 0%,100% { box-shadow: none; } 45% { box-shadow: 0 0 0 3px rgba(183,88,255,.18), 0 0 32px rgba(183,88,255,.12); } }
.prologue-preview { max-height: 190px; overflow: auto; padding: 13px; border-radius: 10px; background: #0b0a0e; color: #bdb5c1; font-family: Georgia, serif; font-size: 12px; line-height: 1.7; white-space: pre-wrap; }
.inline-media { display: block; max-width: min(560px, 100%); max-height: 520px; margin: 14px 0; border: 1px solid var(--line-strong); border-radius: 13px; object-fit: contain; background: #08070c; }
.inline-audio { display: block; width: min(520px, 100%); margin: 14px 0; }
.modal-actions { display: flex; justify-content: end; gap: 9px; margin-top: 26px; }

.toast-stack { position: fixed; z-index: 200; right: 18px; bottom: 18px; display: grid; gap: 8px; pointer-events: none; }
.toast { width: min(340px, calc(100vw - 36px)); padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 11px; background: #1b1821; box-shadow: var(--shadow); color: #d9d3dd; font-size: 10px; line-height: 1.45; animation: toastIn .22s ease both; }
.toast.is-error { border-color: rgba(255,85,120,.35); }
.toast b { display: block; margin-bottom: 3px; color: white; font-size: 11px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1120px) {
  :root { --sidebar: 78px; }
  .topbar { grid-template-columns: 60px minmax(230px, 520px) 1fr; }
  .brand > span:last-child, .nav-item:not(.is-active) b, .nav-item { font-size: 0; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 11px 6px; }
  .nav-item span { font-size: 18px; }
  .nav-item b { position: absolute; margin: -23px 0 0 29px; font-size: 8px; }
  .create-button { font-size: 0; }
  .create-button span { font-size: 20px; }
  .local-badge span { display: none; }
  .local-badge { justify-content: center; }
  .card-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .character-library { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .character-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .settings-grid > :first-child { grid-row: span 2; }
  .connection-pill span { display: none; }
}

@media (max-width: 820px) {
  :root { --topbar: 62px; }
  .topbar { grid-template-columns: auto 1fr auto; gap: 10px; padding: 0 11px; }
  .brand-avatar { width: 37px; height: 37px; }
  .global-search kbd, .profile-chip b, .connection-pill { display: none; }
  .global-search { height: 38px; }
  .sidebar { top: auto; right: 0; bottom: 0; width: 100%; height: 64px; padding: 6px 8px; border-top: 1px solid var(--line); border-right: 0; }
  .sidebar nav { display: grid; grid-template-columns: repeat(4,1fr); }
  .sidebar-lower { display: none; }
  .nav-item { position: relative; gap: 2px; padding: 5px; font-size: 8px !important; }
  .nav-item span { font-size: 17px; }
  .nav-item b { right: 18%; margin: -24px 0 0; }
  .main { padding: calc(var(--topbar) + 14px) 13px 84px; }
  .hero { min-height: 590px; }
  .hero-copy { align-self: end; width: 100%; padding: 250px 25px 35px; background: linear-gradient(transparent, rgba(10,8,13,.94) 42%); }
  .hero h1 { font-size: 44px; }
  .hero-mark { top: 38px; right: 50%; transform: translateX(50%); }
  .hero-mark img { width: 140px; height: 140px; border-radius: 36px; }
  .hero-mark::before { inset: -28px; }
  .hero-mark span, .hero-mark strong { display: none; }
  .card-grid, .character-library, .continue-row { grid-template-columns: 1fr; }
  .page-header { align-items: flex-start; flex-direction: column; }
  .page-header-actions { width: 100%; flex-wrap: wrap; }
  .field-grid.two, .field-grid.three, .modal-cast, .settings-grid { grid-template-columns: 1fr; }
  .settings-grid > :first-child { grid-row: auto; }
  .creator-layout { display: block; }
  .creator-steps { position: static; margin-bottom: 12px; padding: 18px; }
  .creator-steps > p { display: none; }
  .creator-steps ol { display: flex; overflow-x: auto; margin-top: 14px; }
  .creator-steps li { flex: 0 0 auto; }
  .creator-steps li span { display: none; }
  .creator-panel { min-height: 0; padding: 22px 17px; }
  .creator-trail { padding: 0 13px; }
  .media-library, .toggle-grid { grid-template-columns: 1fr; }
  .stat-number-grid { grid-template-columns: 1fr; }
  .stat-editor-body { padding: 15px; }
  .form-actions { padding: 11px; }
  .form-actions > span { display: none; }
  .title-row { grid-template-columns: 1fr auto; }
  .title-cell { display: none; }
  .chat-shell { inset: var(--topbar) 0 64px 0; grid-template-columns: 1fr; }
  .chat-info { position: absolute; z-index: 12; inset: 0 auto 0 0; display: block; width: min(92vw, 390px); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 22px 0 60px rgba(0,0,0,.48); }
  .chat-info.is-open { transform: translateX(0); }
  .chat-info-scroll { max-height: 34vh; }
  .chat-main { height: calc(100vh - var(--topbar) - 64px); }
  .mobile-only { display: grid; }
  .chat-header { padding: 0 11px; }
  .chat-header > div:nth-child(2) { flex: 1; min-width: 0; }
  .mode-select span { display: none; }
  .message-stream { padding: 20px 14px 10px; }
  .composer { width: calc(100% - 20px); margin-bottom: 9px; }
  .composer-footer > span { display: none; }
  .suggested-replies { width: calc(100% - 20px); }
  .title-modal { display: block; }
  .modal-cover { min-height: 260px; }
  .modal-cover strong { width: 110px; height: 110px; border-radius: 37px; font-size: 54px; }
  .modal-body { max-height: none; padding: 31px 22px; }
  .modal-body > h1 { font-size: 35px; }
}

@media (max-width: 540px) {
  .top-actions .icon-button { display: none; }
  .hero-actions { align-items: stretch; flex-direction: column; }
  .character-row { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; }
  .creator-stats { grid-template-columns: 1fr 1fr; }
  .session-row { grid-template-columns: 58px minmax(0,1fr); }
  .session-row-actions { grid-column: 2; }
  .session-row .mini-cover { width: 58px; height: 68px; }
  .chat-header .icon-button { width: 34px; height: 34px; }
  .message.user .message-content { max-width: 94%; }
  .message-text { font-size: 15px; }
  .composer-footer { justify-content: end; }
  .modal-actions { align-items: stretch; flex-direction: column; }
}


/* 2.8.2: optional mobile-friendly layout on wider screens */
body.mobile-friendly { --topbar: 62px; }
body.mobile-friendly .topbar { grid-template-columns: auto 1fr auto; gap: 10px; padding: 0 11px; }
body.mobile-friendly .brand-avatar { width: 37px; height: 37px; }
body.mobile-friendly .global-search kbd,
body.mobile-friendly .profile-chip b,
body.mobile-friendly .connection-pill { display: none; }
body.mobile-friendly .global-search { height: 38px; }
body.mobile-friendly .sidebar { top: auto; right: 0; bottom: 0; width: 100%; height: 64px; padding: 6px 8px; border-top: 1px solid var(--line); border-right: 0; }
body.mobile-friendly .sidebar nav { display: grid; grid-template-columns: repeat(4,1fr); }
body.mobile-friendly .sidebar-lower { display: none; }
body.mobile-friendly .nav-item { position: relative; grid-template-columns: 1fr; justify-items: center; gap: 2px; padding: 5px; font-size: 8px !important; }
body.mobile-friendly .nav-item span { font-size: 17px; }
body.mobile-friendly .nav-item b { position: absolute; right: 18%; margin: -24px 0 0; font-size: 8px; }
body.mobile-friendly .main { padding: calc(var(--topbar) + 14px) 13px 84px; }
body.mobile-friendly .card-grid,
body.mobile-friendly .character-library,
body.mobile-friendly .continue-row,
body.mobile-friendly .character-row,
body.mobile-friendly .field-grid.two,
body.mobile-friendly .field-grid.three,
body.mobile-friendly .modal-cast,
body.mobile-friendly .settings-grid,
body.mobile-friendly .media-library,
body.mobile-friendly .toggle-grid { grid-template-columns: 1fr; }
body.mobile-friendly .settings-grid > :first-child { grid-row: auto; }
body.mobile-friendly .page-header { align-items: flex-start; flex-direction: column; }
body.mobile-friendly .page-header-actions { width: 100%; flex-wrap: wrap; }
body.mobile-friendly .creator-layout { display: block; }
body.mobile-friendly .creator-steps { position: static; margin-bottom: 12px; padding: 18px; }
body.mobile-friendly .creator-steps > p { display: none; }
body.mobile-friendly .creator-steps ol { display: flex; overflow-x: auto; margin-top: 14px; }
body.mobile-friendly .creator-steps li { flex: 0 0 auto; }
body.mobile-friendly .creator-steps li span { display: none; }
body.mobile-friendly .creator-panel { min-height: 0; padding: 22px 17px; }
body.mobile-friendly .creator-trail { padding: 0 13px; }
body.mobile-friendly .stat-number-grid { grid-template-columns: 1fr; }
body.mobile-friendly .stat-editor-body { padding: 15px; }
body.mobile-friendly .form-actions { padding: 11px; }
body.mobile-friendly .form-actions > span { display: none; }
body.mobile-friendly .title-row { grid-template-columns: 1fr auto; }
body.mobile-friendly .title-cell { display: none; }
body.mobile-friendly .chat-shell { inset: var(--topbar) 0 64px 0; grid-template-columns: 1fr; }
body.mobile-friendly .chat-info { position: absolute; z-index: 12; inset: 0 auto 0 0; display: block; width: min(92vw, 390px); transform: translateX(-105%); transition: transform .22s ease; box-shadow: 22px 0 60px rgba(0,0,0,.48); }
body.mobile-friendly .chat-info.is-open { transform: translateX(0); }
body.mobile-friendly .chat-info-scroll { max-height: 34vh; }
body.mobile-friendly .chat-main { height: calc(100vh - var(--topbar) - 64px); }
body.mobile-friendly .mobile-only { display: grid; }
body.mobile-friendly .chat-header { padding: 0 11px; }
body.mobile-friendly .chat-header > div:nth-child(2) { flex: 1; min-width: 0; }
body.mobile-friendly .mode-select span { display: none; }
body.mobile-friendly .message-stream { padding: 20px 14px 10px; }
body.mobile-friendly .composer,
body.mobile-friendly .suggested-replies { width: calc(100% - 20px); }
body.mobile-friendly .composer { margin-bottom: 9px; }
body.mobile-friendly .composer-footer > span { display: none; }
body.mobile-friendly .title-modal { display: block; }
body.mobile-friendly .modal-cover { min-height: 260px; }
body.mobile-friendly .modal-body { max-height: none; padding: 31px 22px; }
.settings-toggle { margin: 0; }


/* 2.8.5: true touch-tablet layout. Large Android/iPad-class screens should
   not inherit the three-column desktop composition just because they are wide. */
body.tablet-friendly { --topbar: 58px; }
body.tablet-friendly .topbar { grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; height: var(--topbar); padding: 0 14px; }
body.tablet-friendly .brand { gap: 9px; min-width: 0; }
body.tablet-friendly .brand-avatar { width: 38px; height: 38px; border-radius: 12px; }
body.tablet-friendly .brand strong { font-size: 14px; }
body.tablet-friendly .brand em { font-size: 10px; }
body.tablet-friendly .global-search { justify-self: center; width: min(460px,100%); height: 38px; }
body.tablet-friendly .global-search kbd,
body.tablet-friendly .profile-chip b,
body.tablet-friendly .connection-pill span { display: none; }
body.tablet-friendly.route-chat .global-search,
body.tablet-friendly.route-chat .connection-pill,
body.tablet-friendly.route-chat #backupButton { display: none; }
body.tablet-friendly.route-chat .topbar { grid-template-columns: minmax(0,1fr) auto; }

/* Tablet navigation belongs at the bottom, leaving the story width to the story. */
body.tablet-friendly .sidebar { z-index: 35; top: auto; right: 0; bottom: 0; left: 0; width: 100%; height: 62px; padding: 5px 8px; border-top: 1px solid var(--line); border-right: 0; }
body.tablet-friendly .sidebar nav { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 2px; }
body.tablet-friendly .sidebar-lower { display: none; }
body.tablet-friendly .mobile-nav-settings { display: grid; }
body.tablet-friendly .nav-item { position: relative; grid-template-columns: 1fr; justify-items: center; align-content: center; gap: 2px; min-width: 0; padding: 5px 3px; font-size: 8px !important; line-height: 1.1; text-align: center; }
body.tablet-friendly .nav-item span { font-size: 17px; }
body.tablet-friendly .nav-item b { display: none; }
body.tablet-friendly .main { width: 100%; max-width: 100%; padding: calc(var(--topbar) + 16px) 18px 80px; }

/* Library and builder pages remain roomy instead of collapsing to a phone column. */
body.tablet-friendly .card-grid,
body.tablet-friendly .character-library,
body.tablet-friendly .continue-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
body.tablet-friendly .settings-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
body.tablet-friendly .settings-grid > :first-child { grid-row: auto; }
body.tablet-friendly .creator-layout { grid-template-columns: minmax(180px,220px) minmax(0,1fr); gap: 18px; }
body.tablet-friendly .creator-steps { position: sticky; top: calc(var(--topbar) + 14px); }
body.tablet-friendly .creator-panel { min-width: 0; padding: 25px 22px; }
body.tablet-friendly .field-grid.three { grid-template-columns: repeat(2,minmax(0,1fr)); }
body.tablet-friendly .title-row { min-width: 0; }

/* Play mode: one broad reading column. World info becomes an on-demand drawer. */
body.tablet-friendly .chat-shell { inset: var(--topbar) 0 62px 0; width: 100%; max-width: 100vw; min-width: 0; overflow: hidden; grid-template-columns: minmax(0,1fr); }
body.tablet-friendly .chat-info { position: absolute; z-index: 14; inset: 0 auto 0 0; display: block; width: min(430px,52vw); max-width: 92vw; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 24px 0 70px rgba(0,0,0,.55); }
body.tablet-friendly .chat-info.is-open { transform: translateX(0); }
body.tablet-friendly .chat-info-scroll { max-height: 36vh; }
body.tablet-friendly .mobile-only { display: grid; }
body.tablet-friendly .chat-main { width: 100%; max-width: 100vw; min-width: 0; height: calc(100dvh - var(--topbar) - 62px); max-height: calc(100dvh - var(--topbar) - 62px); grid-template-rows: 60px minmax(0,1fr) auto auto; overflow: hidden; }
body.tablet-friendly .chat-header { width: 100%; min-width: 0; gap: 8px; padding: 0 14px; overflow: hidden; }
body.tablet-friendly .chat-header > div:nth-child(2) { flex: 1 1 auto; min-width: 0; overflow: hidden; }
body.tablet-friendly .chat-header h2 { width: 100%; max-width: 100%; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
body.tablet-friendly .chat-header-actions { flex: 0 0 auto; gap: 5px; }
body.tablet-friendly .engine-select select { max-width: 108px; }
body.tablet-friendly .mode-select { padding: 4px 6px; }
body.tablet-friendly .mode-select span { display: none; }
body.tablet-friendly .message-stream { width: 100%; max-width: 100%; min-width: 0; overflow-x: hidden; padding: 24px max(20px,calc((100% - 920px)/2)) 14px; }
body.tablet-friendly .message { max-width: 920px; }
body.tablet-friendly .message-text { font-size: 17px; line-height: 1.68; overflow-wrap: anywhere; }
body.tablet-friendly .suggested-replies { width: min(940px,calc(100% - 32px)); max-width: calc(100% - 32px); margin-bottom: 8px; }
body.tablet-friendly .composer { width: min(940px,calc(100% - 32px)); max-width: calc(100% - 32px); margin-bottom: 11px; }
body.tablet-friendly .rooms-drawer,
body.tablet-friendly .memory-drawer,
body.tablet-friendly .settings-drawer { width: min(440px,60vw); max-width: 92vw; }

/* 2.8.5: true phone layout. The <=820px rules are tablet/compact rules;
   this layer is deliberately tighter for narrow portrait phones. */
@media (max-width: 600px) {
  :root { --topbar: 56px; }
  html, body, .app-shell { width: 100%; max-width: 100%; overflow-x: hidden; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { min-width: 0; }

  /* Phone top bar: search/diagnostics belong on full pages, not above the story. */
  .topbar {
    grid-template-columns: minmax(0,1fr) auto;
    gap: 7px;
    height: var(--topbar);
    padding: 0 9px;
  }
  .global-search { display: none; }
  .brand { min-width: 0; gap: 8px; }
  .brand-avatar { width: 34px; height: 34px; border-radius: 11px; }
  .brand > span:last-child { min-width: 0; gap: 4px; }
  .brand strong { font-size: 13px; }
  .brand em { font-size: 10px; }
  .top-actions { gap: 5px; }
  .top-actions .connection-pill,
  #backupButton { display: none; }
  .profile-chip { padding: 3px; border-radius: 11px; }
  .profile-chip span { width: 30px; height: 30px; border-radius: 9px; }
  .profile-chip b { display: none; }

  /* Five real phone tabs, including Settings. */
  .sidebar {
    z-index: 35;
    height: 58px;
    padding: 4px 3px 5px;
  }
  .sidebar nav { grid-template-columns: repeat(5, minmax(0,1fr)); gap: 0; }
  .mobile-nav-settings { display: grid; }
  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    align-content: center;
    gap: 1px;
    min-width: 0;
    padding: 4px 1px;
    border-radius: 8px;
    font-size: 7px !important;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
  }
  .nav-item span { font-size: 15px; line-height: 1; }
  .nav-item b { display: none; }
  .main { width: 100%; max-width: 100%; padding: calc(var(--topbar) + 10px) 9px 72px; }

  /* Phone chat owns the viewport and must never establish a desktop-width child. */
  .chat-shell {
    inset: var(--topbar) 0 58px 0;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow: hidden;
    grid-template-columns: minmax(0,1fr);
  }
  .chat-main {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    height: calc(100dvh - var(--topbar) - 58px);
    max-height: calc(100dvh - var(--topbar) - 58px);
    grid-template-rows: 54px minmax(0,1fr) auto auto;
    overflow: hidden;
  }
  .chat-header {
    width: 100%;
    min-width: 0;
    gap: 5px;
    padding: 0 7px;
    overflow: hidden;
  }
  .chat-header > .mobile-only:first-child {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
  }
  .chat-header > div:nth-child(2) {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
  }
  #chatTitleKind { display: none; }
  .chat-header h2 {
    width: 100%;
    max-width: 100%;
    margin: 0;
    font-size: 14px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .chat-header-actions {
    flex: 0 0 auto;
    min-width: 0;
    gap: 3px;
  }
  .chat-header-actions .engine-select { display: none; }
  .chat-header-actions .mode-select {
    max-width: 72px;
    height: 32px;
    gap: 0;
    padding: 2px 4px;
  }
  .chat-header-actions .mode-select span { display: none; }
  .chat-header-actions .mode-select select {
    width: 62px;
    max-width: 62px;
    padding: 0;
    font-size: 9px;
  }
  .chat-header .icon-button {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    font-size: 15px;
  }

  .message-stream {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    padding: 14px 9px 8px;
    scroll-padding-bottom: 12px;
  }
  .message {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: 30px minmax(0,1fr);
    gap: 8px;
    margin: 0 0 17px;
  }
  .message.user { grid-template-columns: minmax(0,1fr) 30px; }
  .message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 13px;
  }
  .message-content,
  .message.assistant .message-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }
  .message.user .message-content { width: auto; max-width: 90%; padding: 10px 11px; }
  .message-name { margin-bottom: 5px; font-size: 9px; }
  .message-text {
    width: 100%;
    max-width: 100%;
    font-size: 16px;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
  }
  .message.user .message-text { font-size: 12px; line-height: 1.5; }

  .suggested-replies {
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    min-width: 0;
    margin: 0 8px 7px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .suggested-replies::-webkit-scrollbar { display: none; }
  .suggested-replies button { padding: 6px 9px; font-size: 8px; }

  .composer {
    width: calc(100% - 16px);
    max-width: calc(100% - 16px);
    min-width: 0;
    margin: 0 8px 8px;
    border-radius: 13px;
  }
  .composer textarea {
    width: 100%;
    min-width: 0;
    max-height: 132px;
    padding: 11px 12px 7px;
    font-size: 15px;
    line-height: 1.4;
  }
  .composer-footer { padding: 3px 5px 5px 10px; }
  .composer-footer > span { display: none; }
  .send-button { width: 34px; height: 34px; }

  /* Full-screen drawers make far more sense than narrow desktop sidebars on a phone. */
  .chat-info,
  .rooms-drawer,
  .memory-drawer,
  .settings-drawer {
    width: 100vw;
    max-width: 100vw;
  }
  .chat-info { padding: 17px 14px; }
  .chat-info-mobile-head {
    top: -17px;
    margin: -17px -14px 14px;
    padding: 9px 11px;
  }
  .chat-info-scroll { max-height: 30dvh; }

  /* Builder/pages: no control is allowed to force horizontal desktop width. */
  .view,
  .page-header,
  .creator-layout,
  .creator-panel,
  .creator-form,
  .field,
  .field input,
  .field textarea,
  .field select,
  .title-row,
  .session-row,
  .settings-card { min-width: 0; max-width: 100%; }
  .creator-panel { padding: 17px 12px; }
  .creator-trail { padding: 0 8px; overflow-x: auto; }
  .form-actions { gap: 6px; }
  .form-actions button { min-width: 0; padding-left: 11px; padding-right: 11px; }
}
