/* Semantic colors shared by every front-office view. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17151d; --bg2: #1d1a23; --panel: #211e28; --panel2: #2b2733;
  --elevated: #302b38; --text: #f3edf6; --dim: #b2a8bc; --line: #3b3445;
  --sidebar-bg: #1b1821; --input-bg: #19161f; --glass: rgba(23,21,29,.96);
  --gold: #e6c48d; --ok: #a1d5bd; --danger: #ff9aab; --on-accent: #261322;
  --accent: #f0afca; --accent2: #dd8fb1; --accent-soft: #352532; --accent-line: #634151;
  --hover: #2c2633; --shadow: 0 12px 36px rgba(0,0,0,.18); --art-halo: #533449;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #faf8fb; --bg2: #f1edf4; --panel: #ffffff; --panel2: #f3eff6;
  --elevated: #ffffff; --text: #302739; --dim: #74677f; --line: #e5dde9;
  --sidebar-bg: #f6f2f8; --input-bg: #fcfafd; --glass: rgba(250,248,251,.96);
  --gold: #8d6224; --ok: #286b51; --danger: #b62e4d; --on-accent: #ffffff;
  --accent: #a73e6a; --accent2: #92315b; --accent-soft: #f8e9f0; --accent-line: #dfb1c6;
  --hover: #f0eaf3; --shadow: 0 10px 34px rgba(68,42,77,.06); --art-halo: #f5dce9;
}
:root[data-theme="dark"][data-palette="violet"] { --accent: #c6b2f5; --accent2: #b09add; --accent-soft: #30283f; --accent-line: #57486f; --art-halo: #433253; --on-accent: #221735; }
:root[data-theme="light"][data-palette="violet"] { --accent: #7350ad; --accent2: #604093; --accent-soft: #f0eafa; --accent-line: #cebee7; --art-halo: #eadff6; }
:root[data-theme="dark"][data-palette="mist"] { --accent: #9dcedd; --accent2: #80b9cc; --accent-soft: #22333e; --accent-line: #3f6475; --art-halo: #294755; --on-accent: #132830; }
:root[data-theme="light"][data-palette="mist"] { --accent: #286f89; --accent2: #205b71; --accent-soft: #e7f2f6; --accent-line: #aacdd9; --art-halo: #dceef3; }
body { background: var(--bg); color: var(--text); }
::selection { background: var(--accent); color: var(--on-accent); }
input::placeholder, textarea::placeholder { color: var(--dim); opacity: .8; }
::-webkit-scrollbar-thumb { background: var(--line); }
.sidebar, .convList { background: var(--sidebar-bg); }
.topbar, .chatTop, .chatEmptyTop, .composerWrap, .detailBar, .mobileTabs { background: var(--glass); }
.panel, .listItem, .sheet, .detailCard, .characterCard, .dailyBanner { background: var(--panel); border-color: var(--line); }
.navGroupTitle, .navItem, .iconBtn, .pageBreadcrumb, .sideUserSub, .topTab,
.characterCard .cardDesc, .characterCard .cardFoot, .cardPop, .empty, .convTime, .convPreview,
.convMore, .statusKey, .unlockSub, .optionsTitle, .toolChip, .qfBtn, .composerFoot,
.enterHint, .directiveHint, .directiveBadgeText, .directiveClose, .detailTimes,
.detailStats, .supportHint, .typingHint, .sliderRow label, .mTab { color: var(--dim); }
.pageBreadcrumb > span:last-child, .dailyCopy strong, .empty h3, .chatEmpty h2, .storyMsg,
.storyMsg.assistant, .statusVal, .option, .notesBody, .detailTitle, .bountyPoolLabel,
.commentText, .pkg, button.listItem { color: var(--text); }
.navItem.active, .mTab.active, .topTab.active, .toolChip.on, .characterCard .cardTag,
.dailyIcon, .sideAvatar, .statusHead, .stNum, .unlockTitle, .sliderVal, .notesToggle,
.composerFoot button, .directiveHead, .directiveBadge, .commentPinned { color: var(--accent); }
.navItem.active, .topTab.active, .toolChip.on, .characterCard .cardTag, .sideAvatar,
.segTab.active, .directiveBadge, .commentPinned { background: var(--accent-soft); }
.navItem:hover, .iconBtn:hover, .convItem:hover, .qfBtn:hover, .toolChip:hover { background: var(--hover); color: var(--text); }
.navItem.active:hover, .convItem.active { background: var(--accent-soft); color: var(--accent); }
.introCopy h1 > span { color: var(--accent); }
.btnPrimary, .sendBtn, .startChatBtn { background: var(--accent); color: var(--on-accent); }
.sendBtn svg { stroke: var(--on-accent); }
.btnPrimary:hover:not(:disabled), .sendBtn:hover:not(:disabled), .startChatBtn:hover { background: var(--accent2); filter: none; }
.btnGhost { background: transparent; color: var(--accent); border-color: var(--accent-line); }
.btnGhost:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.btnDanger { color: var(--danger); border-color: var(--danger); background: transparent; }
.balanceChip { color: var(--gold); background: var(--panel); border-color: var(--line); }
.balancePlus { border-color: var(--line); }
.topTabs, .drawControls select, .pkg, .statusPanel, .authorRow, .directivePanel { background: var(--panel2); border-color: var(--line); }
.searchBox, .composer { background: var(--input-bg); border-color: var(--accent-line); }
.searchBox:focus-within, .composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.formRow input, .formRow textarea, .formRow select, .directiveSelect, .directiveInput { background: var(--input-bg); color: var(--text); border-color: var(--line); }
.directiveSelect option, .toolChip select option, select option { background: var(--panel); color: var(--text); }
.switch { background: var(--line); flex-shrink: 0; }
.switch.on { background: var(--accent); }
.switch::before { content: ''; position: absolute; inset: -11px -1px; }
.switch::after { background: #fff; box-shadow: 0 1px 3px #0002; }
.storyMsg.user { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
.stBar { background: var(--line); }
.stBar i, .toolChip.on::before, .mTab.active::before { background: var(--accent); }
.unlockCard { background: var(--panel); border-color: var(--accent-line); text-align: left; color: var(--text); }
.option { background: var(--panel); }
.option:hover { background: var(--accent-soft); border-color: var(--accent-line); }
.sheet { box-shadow: var(--shadow); }
.sheetMask { background: rgba(22,15,28,.48); }
.pkg, button.listItem { width: 100%; text-align: left; font: inherit; }
.pkg:hover { background: var(--accent-soft); border-color: var(--accent-line); }
.pkgTag { background: var(--accent); color: var(--on-accent); }
.toastMsg { background: var(--elevated); color: var(--text); border-color: var(--accent-line); box-shadow: var(--shadow); max-width: calc(100vw - 32px); width: max-content; }
.characterCard:hover { border-color: var(--accent-line); box-shadow: var(--shadow); }
.skeletonCard > div { background: var(--panel2); }
.characterCard .cardShade { background: linear-gradient(0deg,rgba(25,20,32,.28),transparent 45%); }
.discoveryEmpty { border-color: var(--accent-line); }
.detailTag, .bountyPoolRow { color: var(--text); background: var(--panel2); border-color: var(--line); }
.notesFade { background: linear-gradient(to top,var(--panel),transparent); }
.authorAvatarRing { background: var(--accent); }
.commentAvatar { color: var(--accent); background: var(--accent-soft); }
.commentItem { border-color: var(--line); }
.barIcon { background: var(--panel); color: var(--dim); }
.barIcon.on { color: var(--danger); background: var(--accent-soft); border-color: var(--accent-line); }
.barIcon.on.bm { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.galleryItem { padding: 0; border: 1px solid var(--line); }
.msgWarn { color: var(--danger); }
.unlockAllBtn, .authorLevel, .commentStars, .bountyPoolLabel b { color: var(--gold); }
[data-theme="light"] .detailTier { background: none; color: var(--gold); }
[data-theme="light"] .detailStat.hot { color: var(--gold); }
.segTab.active { color: var(--accent); }
[data-theme="light"] .detailHeroBg { filter: blur(42px) opacity(.22) saturate(.6); }
[data-theme="light"] .detailPoster { box-shadow: 0 18px 45px #34213b25; }

/* The provided character is the brand mark, with the portrait as an optional hero. */
.brand { gap: 9px; padding-left: 2px; padding-right: 2px; }
.brand > span:last-child { font-size: 19px; letter-spacing: 1px; }
.brandSeal { width: 40px; height: 40px; position: relative; overflow: hidden; flex-shrink: 0; border-radius: 50%; background: var(--accent-soft); border: 1px solid var(--accent-line); }
.brandSeal img { position: absolute; width: 62px; height: auto; max-width: none; top: -1px; left: -11px; }
.homeIntro { display: grid; grid-template-columns: minmax(0,1fr) 310px; gap: 20px; align-items: center; min-height: 230px; margin-bottom: 20px; isolation: isolate; }
.introCopy { padding: 8px 0; }
.introCopy h1 { font-size: clamp(28px,2.6vw,39px); margin: 0; line-height: 1.55; }
.introActions { margin-top: 22px; }
.brandArtwork { position: relative; align-self: stretch; min-height: 230px; overflow: hidden; border-radius: 48% 48% 24px 24px; }
.brandArtwork > img { position: absolute; height: 265px; width: 265px; bottom: -14px; left: 50%; transform: translateX(-50%); object-fit: contain; filter: drop-shadow(0 10px 16px #49234212); }
.brandOrbit { position: absolute; width: 228px; height: 228px; border-radius: 50%; top: 8px; left: 50%; transform: translateX(-50%); background: radial-gradient(circle at 45% 45%,var(--art-halo),transparent 72%); border: 1px solid var(--accent-line); opacity: .55; }
.brandStar { position: absolute; color: var(--accent); fill: var(--accent-soft); stroke-width: 1.2; z-index: 1; }
.starOne { top: 38px; right: 22px; width: 22px; height: 22px; transform: rotate(15deg); }
.starTwo { bottom: 48px; left: 18px; width: 13px; height: 13px; transform: rotate(-12deg); }
.homeIntro.withoutArtwork { grid-template-columns: 1fr; min-height: 190px; }
.homeUtility { max-width: 1280px; display: grid; grid-template-columns: minmax(220px,.8fr) minmax(0,1.4fr); gap: 16px; margin-bottom: 28px; }
.homeUtility.singleUtility { grid-template-columns: 1fr; }
.homeUtility .featuredStory { min-height: 80px; border-radius: 12px; border-color: var(--line); }
.homeUtility .featuredStory > img { object-position: 50% 30%; }
.homeUtility .featureShade { background: linear-gradient(90deg,rgba(26,17,32,.8),rgba(26,17,32,.48)); }
.homeUtility .featureCopy { inset: 0 18px; }
.homeUtility .featureCopy strong { font-size: 17px; font-weight: 500; line-height: 1.5; font-family: inherit; }
.dailyBanner { margin: 0; padding: 12px 16px; }
.dailyCopy > span { color: var(--dim); font-size: 12px; }
.dailyBanner .btnGhost { font-size: 12px; min-height: 44px; }
.characterCard .cardDesc { font-size: 13px; min-height: 46px; }
.characterCard .cardTag, .characterCard .cardFoot { font-size: 12px; }
.characterCard .cardFoot { flex-wrap: wrap; gap: 7px; }
.characterCard .cardCreator { max-width: 100%; }
.badgeNew { font-size: 11px; }

/* Compact, reusable appearance controls. */
.settingsContent > .panel { max-width: 960px; }
.appearanceControls { display: grid; gap: 22px; min-width: 0; }
.themePreview { position: relative; min-height: 126px; border: 1px solid var(--accent-line); background: var(--bg); border-radius: 14px; overflow: hidden; }
.previewCopy { position: relative; padding: 23px; }
.previewCopy strong { font-size: 19px; letter-spacing: 2px; }
.previewLines { display: grid; gap: 7px; margin-top: 12px; }
.previewLines i { width: 108px; height: 4px; border-radius: 4px; background: var(--line); }
.previewLines i:last-child { width: 74px; }
.previewPill { display: block; margin-top: 13px; width: 40px; height: 8px; border-radius: 8px; background: var(--accent); }
.themePreview > img { position: absolute; right: 28px; bottom: -44px; width: 128px; height: auto; transform: rotate(7deg); }
.previewConstellation { position: absolute; width: 140px; height: 140px; right: 26px; top: 4px; border: 1px solid var(--accent-line); border-radius: 50%; background: radial-gradient(var(--art-halo),transparent 70%); }
.previewConstellation span { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.previewConstellation span:nth-child(1) { top: 20px; right: 20px; }
.previewConstellation span:nth-child(2) { top: 46px; left: -3px; }
.previewConstellation span:nth-child(3) { bottom: 8px; right: 20px; }
.appearanceField { min-width: 0; border: 0; padding: 0; margin: 0; }
.appearanceField legend { margin-bottom: 12px; color: var(--dim); font-size: 13px; }
.modeChoices, .paletteChoices { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.modeChoice, .paletteChoice { min-height: 54px; padding: 10px 6px; border: 1px solid var(--line); color: var(--dim); background: var(--panel); border-radius: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; }
.modeChoice.selected, .paletteChoice.selected { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.modeChoice:hover, .paletteChoice:hover { border-color: var(--accent); }
.modeChoice .uiIcon { width: 18px; height: 18px; }
.paletteSwatch { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; }
.paletteSwatch .uiIcon { width: 14px; height: 14px; stroke-width: 2.5; }
.artworkSwitch { margin: 0; min-height: 44px; border-top: 1px solid var(--line); border-bottom: 0; padding-top: 20px; }
.sheetActions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.confirmCopy { margin: 4px 0 12px; line-height: 1.8; }
.sheetHead button { min-width: 44px; min-height: 44px; }

/* Readability, input grouping and pointer/keyboard hit areas. */
.formRow { margin-bottom: 18px; }
.formRow label { font-size: 13px; color: var(--dim); cursor: pointer; }
.sliderRow { display: grid; grid-template-columns: 130px minmax(0,1fr) 68px; align-items: center; min-height: 36px; }
.sliderRow label { width: auto; }
.sliderRow input[type="range"] { width: 100%; min-width: 0; height: 28px; cursor: pointer; }
.sliderVal { width: auto; font-variant-numeric: tabular-nums; }
.characterEditor > .formRow:nth-child(3), .characterEditor > .formRow:nth-child(7) { border-top: 1px solid var(--line); padding-top: 24px; margin-top: 24px; }
.characterEditor textarea { line-height: 1.8; }
.convTime, .convPreview, .chatTopSub, .composerFoot, .composerFoot button { font-size: 12px; }
.chatTopRight .iconBtn, .chatTop > .iconBtn, .chatEmptyTop > .iconBtn, .convClose { width: 44px; height: 44px; flex-shrink: 0; }
.convMore { min-width: 44px; min-height: 44px; }
.composerWrap { position: relative; }
.jumpToLatest { position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%); z-index: 2; border: 1px solid var(--accent-line); border-radius: 22px; color: var(--accent); background: var(--elevated); box-shadow: var(--shadow); min-height: 44px; padding: 8px 16px; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; cursor: pointer; font-size: 13px; }
.toolChip, .qfBtn { min-height: 36px; font-size: 12px; }
.toolChip select { font-size: inherit; max-width: 130px; }
.quickFormat { gap: 4px; }
.composerFoot button { min-height: 36px; }
.composerFoot { padding-top: 4px; }

@media (min-width: 1500px) { .homeIntro { min-height: 250px; grid-template-columns: minmax(0,1fr) 370px; } .brandArtwork > img { width: 290px; height: 290px; } }
@media (max-width: 1120px) and (min-width: 921px) { .brand > span:last-child { font-size: 17px; } .homeIntro { grid-template-columns: minmax(0,1fr) 230px; } .brandArtwork > img { width: 240px; height: 240px; } .dailyIcon { display: none; } }
@media (max-width: 920px) {
  .homeIntro { grid-template-columns: minmax(0,1fr) 250px; min-height: 210px; }
  .brandArtwork { min-height: 210px; }
  .brandArtwork > img { width: 245px; height: 245px; }
  .mTab { font-size: 12px; }
  .composerTools { flex-wrap: nowrap; overflow-x: auto; gap: 5px; padding-bottom: 5px; scrollbar-width: thin; scrollbar-color: var(--accent-line) transparent; mask-image: linear-gradient(to right,#000 calc(100% - 14px),transparent); }
  .composerTools::-webkit-scrollbar { display: block; height: 3px; }
  .composerTools::-webkit-scrollbar-thumb { background: var(--accent-line); border-radius: 4px; }
  .composerTools::after { content: ''; flex: 0 0 14px; }
  .toolChip { flex-shrink: 0; min-height: 44px; padding: 8px 10px; font-size: 12px; }
  .toolChip select { min-height: 26px; }
  .qfBtn { min-height: 44px; font-size: 12px; padding: 7px 9px; }
  .composerFoot button { min-height: 44px; font-size: 12px; padding: 6px 4px; }
  .sendBtn { min-width: 44px; width: 44px; height: 44px; }
}
@media (max-width: 600px) {
  .topbar { padding: 0 14px; gap: 6px; }
  .topRight { gap: 0; }
  .topRight .iconBtn { width: 44px; height: 44px; }
  .pageBreadcrumb > span:last-child { font-size: 14px; color: var(--text); }
  .balanceChip { font-size: 12px; padding: 6px 8px; gap: 3px; min-height: 40px; }
  .balancePlus { display: none; }
  .content { padding: 16px 16px 28px; }
  .homeIntro { grid-template-columns: minmax(0,1fr) 138px; gap: 0; min-height: 176px; margin-bottom: 14px; }
  .introCopy { padding: 8px 0; position: relative; z-index: 1; }
  .introCopy h1 { font-size: clamp(20px,5.65vw,25px); letter-spacing: 0; line-height: 1.6; white-space: nowrap; }
  .introActions { margin-top: 15px; }
  .introActions .btnPrimary { min-height: 44px; gap: 8px; padding: 9px 12px; font-size: 12px; }
  .brandArtwork { min-height: 176px; margin-left: -12px; margin-right: -10px; border-radius: 40% 40% 16px 16px; }
  .brandArtwork > img { width: 178px; height: 178px; bottom: 0; }
  .brandOrbit { width: 137px; height: 137px; top: 20px; }
  .starOne { width: 15px; height: 15px; top: 20px; right: 6px; }
  .starTwo { display: none; }
  .homeIntro.withoutArtwork { min-height: 160px; }
  .homeUtility { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; margin-bottom: 22px; }
  .homeUtility .featuredStory { min-height: 96px; border-radius: 10px; }
  .homeUtility .featureCopy { inset: auto 12px 13px; align-items: flex-end; gap: 8px; }
  .homeUtility .featureCopy strong { font-size: 15px; line-height: 1.6; }
  .homeUtility .featureCopy > .uiIcon { width: 16px; height: 16px; margin-bottom: 4px; }
  .dailyBanner { padding: 8px 11px; display: grid; grid-template-columns: 1fr; gap: 0; align-content: center; }
  .dailyIcon { display: none; }
  .dailyCopy { display: block; }
  .dailyCopy strong { font-size: 12px; }
  .dailyCopy > span { display: block; font-size: 11px; margin-top: 3px; }
  .dailyBanner .btnGhost { padding: 6px 0; min-height: 44px; border: 0; justify-content: flex-start; font-size: 12px; }
  .singleUtility .dailyBanner { display: flex; flex-direction: row; align-items: center; padding: 7px 12px; }
  .singleUtility .dailyCopy > span { display: block; margin-left: 8px; font-size: 12px; }
  .discoverHead { margin-bottom: 14px; }
  .discoverHead h2 { font-size: 20px; }
  .topTabs { margin-top: 12px; }
  .topTab { min-height: 40px; font-size: 13px; }
  .searchClose { min-width: 44px; min-height: 44px; }
  .characterCard .cardBody { padding: 12px 10px; }
  .characterCard .cardTitle { font-size: 15px; }
  .characterCard .cardDesc { font-size: 13px; min-height: 44px; line-height: 1.7; margin-bottom: 9px; }
  .characterCard .cardTags { gap: 4px; margin-bottom: 12px; }
  .characterCard .cardTag { font-size: 11px; padding: 4px 5px; }
  .characterCard .cardFoot { font-size: 11px; }
  .tier, .badgeNew { font-size: 10px; }
  .sliderRow { grid-template-columns: minmax(0,1fr) 56px; gap: 6px 12px; }
  .sliderRow label { grid-column: 1; grid-row: 1; width: auto; font-size: 13px; }
  .sliderVal { grid-column: 2; grid-row: 1; font-size: 13px; }
  .sliderRow input[type="range"] { grid-column: 1 / -1; grid-row: 2; }
  .chatTop { padding: 0 8px; gap: 4px; }
  .chatTopName { font-size: 14px; max-width: 124px; }
  .chatTopSub { font-size: 11px; max-width: 124px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chatTopRight { margin-left: auto; }
  .chatTopAvatar { width: 30px; height: 30px; }
  .composerWrap { padding: 5px 12px 4px; }
  .composerTools { margin-bottom: 2px; }
  .quickFormat { margin-bottom: 3px; gap: 0; flex-wrap: nowrap; overflow-x: auto; }
  .qfBtn { flex-shrink: 0; }
  .composerFoot { gap: 8px; font-size: 11px; padding-top: 0; }
  .appearanceControls { gap: 20px; }
  .modeChoice { flex-direction: column; gap: 8px; min-height: 76px; font-size: 12px; }
  .paletteChoice { gap: 6px; font-size: 12px; }
  .themePreview > img { right: 16px; }
}
@media (min-width: 601px) {
  .appearancePanel .appearanceControls { grid-template-columns: minmax(170px,.8fr) minmax(0,1.2fr); gap: 18px 24px; }
  .appearancePanel .themePreview { grid-column: 1; grid-row: 1 / 4; }
  .appearancePanel .themePreview > img { width: 190px; right: 50%; transform: translateX(50%) rotate(5deg); bottom: -62px; }
  .appearancePanel .previewConstellation { top: auto; bottom: -14px; right: calc(50% - 70px); }
  .appearancePanel .previewCopy { padding: 20px; }
}
@media (max-width: 360px) {
  .topbar { padding: 0 10px; }
  .pageBreadcrumb > span:last-child { font-size: 12px; }
  .balanceChip { padding: 6px; font-size: 11px; }
  .balanceChip > svg { display: none; }
  .homeIntro { grid-template-columns: minmax(0,1fr) 112px; }
  .introCopy h1 { font-size: 20px; }
  .brandArtwork > img { width: 157px; height: 157px; }
  .chatTopAvatar { display: none; }
  .characterCard .cardTags { gap: 3px; }
}
