.turn-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.turn-tools button {
  padding: 5px 10px;
  font-size: 11px;
}

.world-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.active-story select {
  margin-bottom: 8px;
}

.story-run {
  padding-left: 28px;
  font-size: 12px;
}

.story-heading {
  flex-wrap: wrap;
  gap: 12px;
}

.desktop-chapter-title {
  font: 13px/1.4 'Segoe UI', Arial, sans-serif;
  color: var(--muted);
  vertical-align: middle;
}

.story-title-block {
  min-width: 0;
}

.story-heading .story-title-block h1 {
  margin-bottom: 8px;
}

.story-top-actions {
  justify-content: flex-end;
  margin: 0;
}

.story-page-header {
  position: sticky;
  top: 0;
  z-index: 3;
  height: auto;
  min-height: 86px;
  padding-top: 12px;
  padding-bottom: 12px;
  justify-content: space-between;
  gap: 24px;
  background: #f5f4ef;
}

.story-page-header #breadcrumb {
  flex: 1;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  padding-left: 5%;
}

.desktop-page-heading {
  min-width: 0;
}

.desktop-page-heading h1 {
  display: block;
  margin: 0;
  color: #253b36;
  font-size: 39px;
  line-height: 1.1;
  font-weight: 400;
}

.world-title-link {
  padding: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.world-title-link:hover,
.world-title-link:focus-visible {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.desktop-page-heading .header-chapter {
  padding: 0;
  color: var(--muted);
  font: 13px/1.4 'Segoe UI', Arial, sans-serif;
}

.desktop-page-heading .world-summary {
  margin: 3px 0 0;
  font-size: 11px;
}

.desktop-chapter-title {
  margin-left: 8px;
}

.chapter-pencil {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  color: var(--muted);
  vertical-align: middle;
}

.world-summary {
  margin: 0;
}

.story-nav {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 15px 0 34px;
  border-bottom: 1px solid var(--line);
}

.story-nav .tabs {
  flex: 1;
  min-width: 0;
  margin: 0;
  border: 0;
}

.nav-difficulty {
  flex: 0 0 auto;
  margin: 0 0 9px;
}

.chapter-page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  gap: 10px;
}

.conversation-turn-count { color: var(--muted); font-size: 12px; }
.story-chat-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px; min-width: 0; }
.story-meta-group { white-space: nowrap; }
.story-context-link { padding: 3px 0; color: var(--green); background: transparent; font-size: 12px; text-align: left; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.story-context-link:hover, .story-context-link:focus-visible { color: var(--ink); }
.story-message-cost { color: var(--muted); font-size: 12px; }
.chapter-settings { position: relative; }
.gear-button { display: grid; place-items: center; width: 34px; height: 34px; margin: 0; border: 1px solid transparent; border-radius: 5px; color: var(--green); cursor: pointer; list-style: none; }
.gear-button svg { display: block; width: 19px; height: 19px; }
.gear-button::-webkit-details-marker { display: none; }
.gear-button:hover, .chapter-settings[open] .gear-button { background: #eaf0e5; border-color: #ccd5c8; }
.chapter-settings-menu { position: absolute; top: calc(100% + 7px); right: 0; z-index: 5; min-width: 190px; padding: 5px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px #172a2026; }
.chapter-settings-menu button { display: block; width: 100%; padding: 10px 12px; background: transparent; color: #253b36; border-radius: 4px; text-align: left; font-size: 12px; }
.chapter-settings-menu button:hover, .chapter-settings-menu button:focus-visible { background: #eaf0e5; }
.messages .message .prose { font-size: var(--conversation-prose-size, 17px); }
.messages .message.user .prose { font-size: var(--conversation-prose-size, 17px); }
.messages .prose h1,
.messages .prose h2,
.messages .prose h3 { font-size: var(--conversation-heading-size, 22px); }
.font-options { display: grid; gap: 7px; margin: 18px 0; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.font-options label { display: flex; align-items: center; gap: 10px; margin: 0; padding: 9px 10px; border-radius: 4px; font-weight: 400; cursor: pointer; }
.font-options label:has(input:checked) { background: #eaf0e5; color: var(--green); }
.font-options input { flex: 0 0 auto; width: auto; margin: 0; }
.font-options label span { margin-left: auto; color: var(--muted); font-size: 11px; }

#response-text {
  min-height: 260px;
}

.busy-visual { display: inline-block; white-space: nowrap; }
.busy-wave .busy-letter { display: inline-block; }
.busy-gradient {
  background-image: linear-gradient(90deg, #6e805e 40%, #c1d6af 48%, #c1d6af 52%, #6e805e 60%);
  background-size: 250% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.busy-screen-reader {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#chapter-reminder .notice {
  margin: 12px 18px;
}

.origin-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 20px;
}

.origin-suggestions button {
  padding: 7px 12px;
}

#edited-action {
  min-height: 160px;
}

.send-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.composer-footer {
  gap: 12px;
}

.context-meter {
  font-size: 10px;
  margin: 12px 0 0;
}

.chapter-alert {
  margin: 0 18px 18px;
  border: 1px solid #cab87d;
}

.chapter-archive details {
  margin-top: 18px;
}

.chapter-archive summary {
  cursor: pointer;
  color: var(--green);
  padding: 8px 0;
  font-size: 13px;
}

.chapter-archive details p,
.chapter-archive li {
  font-size: 13px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.chapter-archive details .message {
  margin-top: 18px;
}

@media(max-width:750px) {
  .composer-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .send-actions {
    width: 100%;
  }
}

.danger {
  color: #b34a42;
  border-color: #b34a4266;
}

.primary.danger {
  background: #a33832;
  color: #fff;
}

.lore-entry {
  border: 1px solid var(--border, #d7d0c4);
  border-radius: 10px;
  padding: 16px;
  margin: 16px 0;
}

.lore-entry label {
  display: block;
  margin-top: 12px;
}

.lore-entry .field-heading label {
  margin-top: 0;
}

.lore-entry textarea {
  min-height: 130px;
}
.lore-editor { min-width: 0; container-type: inline-size; }
@media(min-width:751px) { .lore-layout { grid-template-columns: 180px minmax(0, 1fr); } }
.lore-entry-heading { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(110px, 150px) auto 24px; gap: 12px; align-items: end; }
.lore-entry-heading > div { min-width: 0; }
.lore-entry-heading label { margin-top: 0; }
.lore-entry-heading .remove { align-self: center; padding: 0; }
.lore-entry-heading .lore-visibility { display: grid; justify-items: center; gap: 12px; font-size: 12px; white-space: nowrap; }
.lore-visibility input[type="checkbox"] { appearance: none; position: relative; width: 38px; height: 22px; padding: 0; margin: 0 0 10px; border: 0; border-radius: 12px; background: #bec8bf; cursor: pointer; }
.lore-visibility input::before { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; transition: transform 120ms ease; }
.lore-visibility input:checked { background: var(--green); }
.lore-visibility input:checked::before { transform: translateX(16px); }
.lore-visibility input:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
.lore-entry [data-lore-overview] { min-height: 75px; }
.lore-entry-visibility { margin-left: 12px; color: var(--green); }
.lore-reader { min-width: 0; }
.lore-reader h3 { overflow-wrap: anywhere; }
.world-lore-foundation .summary, .lore-reader .summary { white-space: pre-wrap; overflow-wrap: anywhere; }
.world-lore-categories .section-head { margin-bottom: 20px; }
.world-lore-actions { position: sticky; top: var(--lore-actions-top, 94px); z-index: 2; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 0; padding: 16px 29px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.world-lore-actions + .world-lore-foundation { border-top: 0; border-radius: 0 0 8px 8px; }
.world-lore-actions button { padding: 13px 23px; }
.world-lore-actions .primary { margin-left: auto; }
.world-lore-actions p { margin: 0; }
.creator-bio { white-space: pre-wrap; overflow-wrap: anywhere; }
.creator-creations { margin-top: 32px; }
.creator-creations .library-tile-grid { margin-top: 20px; }
.creator-creations > .tabs { gap: 24px; }
.creator-link { color: var(--green); text-underline-offset: 3px; }
.library-tile .creator-link { position: relative; z-index: 4; pointer-events: auto; }
.publication-tile .tile-author { position: absolute; z-index: 4; bottom: 54px; left: 18px; right: 18px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.publication-tile .tile-hover-summary { bottom: 76px; }
.tile-hover-summary { visibility: hidden; }
.library-tile:hover .tile-hover-summary, .library-tile:focus-within .tile-hover-summary { visibility: visible; }
.public-creator-page { max-width: 1200px; margin: auto; }
.public-creator-page > .creator-profile { margin-top: 24px; }
.creator-creation-tile { color: inherit; text-decoration: none; }
@media(max-width:640px) {
  .lore-entry-heading { grid-template-columns: minmax(0, 1fr) auto 24px; }
  .lore-entry-heading > div:first-child { grid-column: 1 / -1; }
}
@container(max-width:560px) {
  .lore-entry-heading { grid-template-columns: minmax(0, 1fr) auto 24px; }
  .lore-entry-heading > div:first-child { grid-column: 1 / -1; }
}

.collection-row {
  padding: 14px;
  margin: 12px 0;
  border: 1px solid #d7d0c4;
  border-radius: 8px;
}

.collection-row label {
  display: block;
  margin: 8px 0;
}

.collection-actions,
.field-kind {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.field-kind input {
  width: auto;
}

.stat {
  white-space: pre-line;
}

#author-records {
  max-height: 320px;
  overflow: auto;
  border-block: 1px solid var(--line);
  margin: 16px 0;
  padding: 8px 0
}

dialog {
  max-height: 90vh;
  overflow: auto
}

dialog details {
  margin: 14px 0
}

dialog summary {
  cursor: pointer;
  font-weight: 600
}

#record-options input[type=checkbox] {
  width: auto;
  margin-right: 8px
}

#continuity-form textarea {
  min-height: 75px
}

.context-profile-picker { position: relative; margin-bottom: 14px; }
.context-profile-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 45px; background: #fffefb; color: #293f36;
  border: 1px solid #d9ddd2; border-radius: 5px; padding: 12px 13px;
  font-size: 13px; text-align: left;
}
.context-mode-choice { font-size: 13px; line-height: 20px; font-weight: 400; color: #293f36; }
.context-mode-price { white-space: nowrap; }
.context-credit-icon { display: inline-block; vertical-align: middle; transform: translateY(-1px); }
.context-credit-unit { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.context-profile-options {
  position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 210px; overflow-y: auto; background: #fffefb;
  border: 1px solid #d9ddd2; border-radius: 5px; box-shadow: 0 6px 18px #293f3626; padding: 4px;
}
.context-profile-options [role="option"] {
  padding: 10px 9px; border-radius: 3px; font-size: 13px; cursor: pointer; overflow-wrap: anywhere;
}
.context-profile-options [role="option"]:hover,
.context-profile-options [aria-selected="true"] { background: #e5ede5; }
.context-profile-options .context-option-active { outline: 2px solid var(--green); outline-offset: -2px; }
.context-profile-trigger:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.context-meter .quiet {
  padding: 2px 6px
}

.auto-update-option {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  margin-bottom: .7rem;
}

.auto-update-option input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.character-changes {
  margin-top: .8rem;
  font-size: .85rem;
}

.character-sidebar-details {
  margin-top: 20px;
}

.character-sidebar-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.character-sidebar-section h3 {
  margin: 0 0 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.character-sidebar-value {
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.character-sidebar-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.trait-visibility {
  display: inline-flex;
  flex-shrink: 0;
  padding: 3px;
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
}

.trait-visibility:hover {
  background: #e9eddf;
  color: var(--green);
}

.trait-visibility svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.sidebar-visibility {
  margin: 20px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.sidebar-visibility legend {
  font-weight: 600;
}

.sidebar-visibility label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-visibility input {
  width: auto;
  margin: 0;
}

.mobile-topbar {
  display: none;
}

.mobile-layout.menu-open {
  overflow: hidden;
}

.display-settings {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px;
  margin: 20px 0;
}

.display-settings label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.display-settings input {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

.mobile-layout>.sidebar,
.mobile-layout main>header {
  display: none;
}

.mobile-layout main {
  margin: 0;
  padding-top: 68px;
}

.mobile-layout #app {
  padding: 18px 16px 28px;
}

.mobile-layout .mobile-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  inset: 0 0 auto;
  height: 68px;
  padding: 0 20px;
  background: var(--green, #183f36);
  z-index: 3;
}

.mobile-brand {
  color: #d7c789;
  text-decoration: none;
  font: 27px Georgia, serif;
}

.mobile-brand span {
  color: #f6f5eb;
  margin-left: 8px;
}

.mobile-topbar .mobile-credits { margin-left: auto; margin-right: 6px; gap: 5px; padding: 5px 8px; }
.credits-page { max-width: 760px; margin: 18px auto; }
.credits-page h1 { margin-bottom: 8px; }
.credit-balance-card { margin-top: 28px; background: linear-gradient(135deg,#f1f6ed,#e5eee1); }
.credit-balance-number { font: 64px Georgia,serif; line-height: 1.2; color: #153f36; margin: 12px 0 24px; overflow-wrap: anywhere; }
.credit-metrics { display: flex; gap: 32px; border-top: 1px solid #bdcdbd; padding-top: 18px; }
.credit-metrics p { flex: 1; margin: 0 0 18px; }
.credit-metrics strong { display: block; font-size: 22px; margin-bottom: 6px; }
.credit-metrics span { font-size: 13px; color: #53685c; }
.credit-metrics a { color: inherit; text-underline-offset: 3px; }
.credit-topup-card { margin-top: 20px; }
.daily-credit-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.daily-credit-heading h2 { margin: 0; }
#daily-credit-claim:disabled { cursor: not-allowed; }
.daily-credit-pool { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.daily-credit-pool summary { color: var(--green); font-weight: 600; cursor: pointer; }
.daily-credit-pool-content { padding: 8px 0 2px; }
.daily-credit-pool-content p { margin: 10px 0; }
.daily-credit-banked { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.daily-credit-banked strong { color: #153f36; font-size: 32px; line-height: 1; }
.daily-credit-banked span { color: #53685c; }
.credit-test-badge { display: inline-block; padding: 5px 9px; border-radius: 6px; background: #e5eee1; color: #24594d; font-size: 11px; letter-spacing: .06em; }
.credits-display:focus-visible { outline: 3px solid #b39149; outline-offset: 3px; }
@media(max-width:380px) {
  .mobile-topbar .mobile-brand { font-size: 21px; }
  .mobile-topbar .credits-display strong { font-size: 12px; }
  .credit-balance-number { font-size: 48px; }
}

#main-menu-toggle {
  color: #f6f5eb;
  background: transparent;
  font-size: 25px;
  width: 48px;
  min-height: 48px;
}

.mobile-world-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.mobile-world-heading h1 {
  font-size: 25px;
  margin: 0;
  overflow-wrap: anywhere;
}

#world-menu-toggle {
  font-size: 25px;
  width: 44px;
  min-height: 44px;
  flex-shrink: 0;
}

.mobile-layout .play-grid {
  grid-template-columns: minmax(0, 1fr);
}

.mobile-layout .play-side {
  display: none;
}

.mobile-layout .messages {
  height: clamp(240px, 45dvh, 620px);
  padding: 18px;
}

.mobile-layout #main-menu {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(360px, 92vw);
  height: 100dvh;
  max-height: 100dvh;
  max-width: 92vw;
  margin: 0;
  padding: 22px;
  border: 0;
  border-radius: 0;
  box-sizing: border-box;
  overflow-y: auto;
}

#main-menu::backdrop {
  background: #122e2888;
}

.menu-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.menu-heading h2 {
  margin: 0;
  font: 27px Georgia, serif;
}

#close-main-menu {
  font-size: 28px;
  min-width: 44px;
  min-height: 44px;
}

.menu-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.menu-links button,
.menu-links a {
  display: block;
  text-align: left;
  min-height: 44px;
  padding: 12px;
  background: transparent;
  color: var(--green);
  text-decoration: none;
  border-radius: 5px;
  overflow-wrap: anywhere;
}

.sidebar-bottom #cloud-account {
  display: block;
  color: #e9eee5;
  font-size: 12px;
  margin-bottom: 14px;
  text-decoration: none;
}

.sidebar-bottom #cloud-account[hidden] {
  display: none;
}

.menu-links button[aria-current] {
  background: #e3e9da;
}

.menu-links button:disabled {
  opacity: .45;
}

.menu-links button.danger {
  color: #a33832;
}

.menu-links small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  font-size: 12px;
}

.menu-links .menu-story {
  padding-left: 28px;
}

.menu-section {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 10px;
}

.menu-section>summary {
  cursor: pointer;
  padding: 12px 0;
  line-height: 1.5;
}

.menu-footer {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 16px;
}

/* Small browsers and Android share a keyboard-aware reading layout. */
.mobile-story {
  height: var(--story-viewport-height, 100dvh);
  overflow: hidden;
}

.mobile-story main {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.mobile-story #app {
  width: 100%;
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  padding: 8px 12px 10px;
  display: flex;
  flex-direction: column;
}

.mobile-story .mobile-world-heading {
  flex: 0 0 auto;
  gap: 4px;
  margin: 0 0 6px;
  min-height: 44px;
}

.mobile-story .mobile-world-heading h1 {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.mobile-chapter-title {
  font: 11px/1.4 'Segoe UI', Arial, sans-serif;
  color: var(--muted);
}

.mobile-story .chapter-pencil {
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  min-height: 36px;
}

.mobile-story .chapter-pencil svg {
  width: 12px;
  height: 12px;
}

.turn-tools {
  gap: 8px;
  margin-top: 8px;
}

.turn-tools button {
  min-height: 30px;
  height: 30px;
  padding: 4px 9px;
  font-size: 11px;
}

.turn-tools [data-reroll] {
  width: 30px;
  padding: 0;
  font-size: 17px;
}

.reroll-allowance {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  margin: 8px 0;
}

.reroll-allowance>span {
  flex: 1;
}

.reroll-allowance .dismiss-allowance {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 18px;
}

#context-ring-slot {
  flex: 0 0 40px;
}

#context-ring-slot[hidden] {
  display: none;
}

.context-ring {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 4px;
  background: transparent;
  border-radius: 50%;
}

.composer-footer {
  flex-direction: row;
}

.composer-footer>span {
  display: none;
}

.composer-footer .send-actions {
  width: auto;
  flex: 1;
}

.format-bar button[data-notation] {
  width: auto;
  min-width: 36px;
  padding: 3px 10px;
  height: 32px;
  font-size: 14px;
}

.format-bar button[data-notation="ooc"] {
  font-size: 12px;
}

.rich-editor {
  white-space: pre-wrap;
}

#context-tooltip {
  position: fixed;
  width: max-content;
  max-width: calc(100vw - 24px);
  overflow-wrap: anywhere;
  z-index: 10;
  padding: 10px 28px 10px 12px;
  border-radius: 6px;
  background: #263d35;
  color: #fffef8;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
  box-shadow: 0 3px 12px #0002;
}

#context-tooltip .context-tooltip-text { white-space: pre-line; }

#context-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

#context-tooltip .context-tooltip-close {
  position: absolute;
  top: 3px;
  right: 7px;
  font-size: 16px;
  line-height: 1;
}

#context-tooltip[hidden] {
  display: none;
}

.context-ring .ring-track {
  stroke: #dededb;
}

.context-ring .ring-fill {
  stroke: #777b78;
}

.context-ring.high .ring-fill {
  stroke: #df8b26;
}

.context-ring.over .ring-fill {
  stroke: #c4433c;
}

.context-ring:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.mobile-story #world-menu-toggle {
  width: 32px;
}

.mobile-story #panel,
.mobile-story .play-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mobile-story .chat {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mobile-layout .mobile-world-heading > div { min-width: 0; }
.mobile-layout .mobile-story-title { margin: 2px 0 0; font-size: 12px; overflow-wrap: anywhere; }
.mobile-layout .story-nav { flex: 0 0 auto; margin: 0 0 10px; }
.mobile-layout .story-nav .tabs { display: flex; overflow-x: auto; flex-wrap: nowrap; }
.mobile-layout .story-nav .tab { flex: 0 0 auto; min-height: 44px; padding: 10px 12px; white-space: nowrap; }
.mobile-story .mobile-world-heading { min-height: 0; }
.mobile-story .mobile-story-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mobile-story .chat { overflow: visible; }
.mobile-story .chat-head { flex: 0 0 auto; min-height: 44px; padding: 0 10px; }
.mobile-layout .gear-button { width: 44px; height: 44px; }
.mobile-layout .chapter-settings-menu { z-index: 6; width: min(250px, calc(100vw - 48px)); max-height: calc(var(--story-viewport-height, 100dvh) - 180px); overflow-y: auto; }
.mobile-layout .chapter-settings-menu button { min-height: 44px; font-size: 14px; }
.mobile-layout .turn-tools button { min-width: 44px; min-height: 44px; height: auto; }
.mobile-layout .format-bar button[data-notation] { min-width: 44px; min-height: 44px; height: auto; }
.mobile-story .composer { border-radius: 0 0 8px 8px; }
.mobile-story.compact-story-viewport .mobile-world-heading { display: none; }
.mobile-story.compact-story-viewport .story-nav { margin-bottom: 2px; }
.mobile-story.compact-story-viewport .chapter-settings-menu { max-height: calc(var(--story-viewport-height, 100dvh) - 145px); }

.mobile-story .messages {
  flex: 1;
  min-height: 0;
  height: auto;
  padding: 14px;
  overscroll-behavior: contain;
}

.mobile-story .composer {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 65%;
  overflow-y: auto;
  padding: 8px 10px;
}

.mobile-story .composer>label {
  margin-bottom: 4px;
}

.mobile-story .format-bar {
  padding: 2px 5px;
}

.mobile-story .format-bar button {
  min-height: 32px;
  height: 32px;
  width: 36px;
}

.mobile-story .format-bar button[data-notation="ooc"] {
  width: auto;
}

.mobile-story .format-bar>span,
.mobile-story .composer-footer>span {
  display: none;
}

.mobile-story .rich-editor {
  height: clamp(48px, 9dvh, 82px);
  min-height: 48px;
  overflow-y: auto;
  padding: 7px 10px;
  font-size: 16px;
}

.mobile-story .composer-footer {
  margin-top: 6px;
  flex-direction: row;
}

.mobile-story .send-actions {
  width: auto;
  flex: 1;
}

.mobile-story .send-actions button {
  min-height: 44px;
  padding: 9px 16px;
}

.mobile-story .context-meter {
  margin: 6px 0 0;
}

.mobile-story .error:empty {
  display: none;
}

.mobile-story .busy {
  flex-shrink: 0;
  padding: 5px 10px;
}

.mobile-story .reroll-allowance {
  margin: 10px 0 0;
  font-size: 11px;
}

.mobile-story.compact-story-viewport .mobile-topbar {
  height: 48px;
}

.mobile-story.compact-story-viewport main {
  padding-top: 48px;
}

.mobile-story.compact-story-viewport #app {
  padding: 3px 8px 4px;
}

.mobile-story.compact-story-viewport .mobile-world-heading {
  margin-bottom: 2px;
}

.mobile-story.compact-story-viewport .composer {
  padding: 4px 8px;
}

.mobile-story.compact-story-viewport .composer>label {
  display: none;
}

.mobile-story.compact-story-viewport .rich-editor {
  height: 48px;
}

/* Phone layouts keep navigation and authoring controls reachable. */
@media (max-width: 750px) {
  .sidebar .new-story {
    position: static;
    width: 100%;
    margin: 8px 0;
  }

  #stories {
    overflow-x: auto;
  }

  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .story-heading,
  .section-head {
    flex-wrap: wrap;
    gap: 12px;
  }

  .desktop-chapter-title {
    display: block;
    margin-top: 3px;
  }

  .story-top-actions {
    justify-content: flex-start;
  }

  .story-nav {
    align-items: center;
    flex-wrap: wrap;
  }

  .story-nav .tabs {
    flex-basis: 100%;
  }

  .nav-difficulty {
    margin: 0 0 10px;
  }

  .chapter-page-actions {
    justify-content: flex-start;
  }

  .world-actions {
    flex-wrap: wrap;
  }

  input,
  textarea,
  select,
  [contenteditable] {
    font-size: 16px;
  }

  button {
    min-height: 44px;
  }

  dialog {
    box-sizing: border-box;
    max-height: 85dvh;
    overflow-y: auto;
    padding: 20px;
  }

  .messages {
    height: clamp(220px, 45dvh, 480px);
  }

  header {
    gap: 12px;
  }

  #breadcrumb {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* Library navigation: only recent stories consume the remaining scroll space. */
.sidebar { padding: 26px 18px 14px; overflow: hidden; gap: 22px; }
.sidebar .brand { padding: 0 6px; color: inherit; }
.library-nav { display: grid; gap: 6px; flex-shrink: 0; }
.nav-link { background: transparent; color: inherit; text-align: left; border-radius: 6px; padding: 12px; width: 100%; font-size: 14px; }
.library-nav > a.nav-link { display: block; box-sizing: border-box; text-decoration: none; border: 1px solid #668073; border-radius: 5px; padding: 13px; background: #ffffff07; }
.nav-link:hover,.nav-link.active { background: #ffffff14; color: white; }
.library-nav > button { border: 1px solid #668073; border-radius: 5px; padding: 13px; background: #ffffff07; }
.library-drawer .library-nav > button { border-color: #668073; background: #153f3605; }
.nav-label { display: flex; align-items: center; justify-content: space-between; margin: 0 10px 10px; font: 11px 'Segoe UI',sans-serif; text-transform: uppercase; letter-spacing: 1.6px; color: #aabfb5; }
.nav-label small { font-size: 9px; letter-spacing: 0; text-transform: none; opacity: .8; }
.history-section { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.history-section[hidden], #explore-link[hidden] { display: none; }
.sidebar #stories,.drawer-history { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; margin: 0; flex: 1; }
.sidebar #stories { scrollbar-color: #6b877b transparent; }
.story-link { margin-bottom: 3px; padding: 11px 10px; }
.story-link span,.story-link small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.story-link small { margin: 5px 0 0; font-size: 11px; }
.sidebar-bottom { margin: 0; flex-shrink: 0; }
.profile-strip { display: flex; align-items: center; width: 100%; gap: 10px; padding: 14px 8px 2px; margin-top: 8px; border-top: 1px solid #ffffff20; background: transparent; color: inherit; cursor: pointer; text-align: left; text-decoration: none; }
.profile-strip:hover,.profile-strip:focus-visible { background: #ffffff12; }
.profile-strip:disabled { cursor: default; opacity: .65; }
.profile-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #e4d5af; color: #244c40; font-size: 23px; flex-shrink: 0; }
.profile-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.profile-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.profile-arrow { margin-left: auto; font-size: 24px; }
.settings-dropdown { position: relative; }
.settings-menu { position: absolute; bottom: calc(100% + 7px); left: 0; right: 0; z-index: 5; padding: 5px; margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px #172a2026; }
.settings-menu a,.settings-menu button { display: block; width: 100%; padding: 10px 12px; min-height: 40px; background: transparent; color: #253b36; border-radius: 4px; text-align: left; text-decoration: none; font-size: 12px; }
.settings-menu a:hover,.settings-menu button:hover,.settings-menu a:focus-visible,.settings-menu button:focus-visible { background: #eaf0e5; }
.settings-menu .settings-sign-out { display: flex; align-items: center; gap: 9px; margin-top: 5px; padding-top: 11px; border-top: 1px solid #dddeda; border-radius: 0 0 4px 4px; color: #a33832; }
.settings-menu .settings-sign-out:hover,.settings-menu .settings-sign-out:focus-visible { background: #f9e9e7; }
.settings-menu button:disabled { opacity: .55; cursor: default; }
.settings-menu small { display: block; margin-top: 4px; font-size: 10px; }
.settings-dropdown > button { width: 100%; }
.creation-sections { display: grid; gap: 28px; }
#library-results { padding-top: 18px; }
#main-menu.library-drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(360px,92vw); height: 100dvh; max-height: 100dvh; padding: 22px; border: 0; border-radius: 0; overflow: hidden; }
.library-drawer #main-menu-content { display: flex; flex-direction: column; gap: 18px; height: 100%; min-height: 0; }
.library-drawer .menu-heading { margin: 0; flex-shrink: 0; }
.library-drawer .nav-label { color: #526d60; }
.library-drawer .story-link { color: #274f42; }
.library-drawer .story-link.active { background: #dde8dd; }
.library-drawer .menu-footer { flex-shrink: 0; margin: 0; padding: 0; }
.library-drawer .profile-strip { display: flex; border-top-color: #274f4225; }
@media(max-width:750px) {
  body>.sidebar { display: none; }
  body>.mobile-topbar { display: flex; align-items: center; justify-content: space-between; position: fixed; inset: 0 0 auto; height: 68px; padding: 0 20px; background: #183f36; z-index: 3; }
  main { padding-top: 68px; }
  .library-drawer .story-link { width: 100%; }
  .dialog-actions { flex-wrap: wrap; }
}
@media(min-width:751px) and (max-height:700px) {
  .sidebar { gap: 12px; padding-top: 16px; }
  .sidebar .brand small { display: none; }
  .sidebar .nav-link { padding: 9px 12px; }
}

body:has(dialog[open]) { overflow: hidden; }

.search-select { position: relative; }
.search-select input { padding-right: 38px; }
.search-select input::placeholder { color: #293f36; opacity: 1; }
.search-select-chevron { position: absolute; right: 13px; top: 50%; transform: translateY(-55%); pointer-events: none; color: #293f36; }
.search-select-options { position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; right: 0; max-height: 210px; overflow-y: auto; background: #fffefb; border: 1px solid #d9ddd2; border-radius: 5px; box-shadow: 0 6px 18px #293f3626; padding: 4px; }
.search-select-options [role="option"] { padding: 10px 9px; border-radius: 3px; font-size: 13px; overflow-wrap: anywhere; cursor: pointer; }
.search-select-options [role="option"]:hover, .search-select-options [aria-selected="true"] { background: #e5ede5; color: var(--green); }
.search-select-empty { padding: 10px 9px; color: #617267; font-size: 13px; }

/* Home shelves and community discovery. */
.home-page #app, .explore-page #app { max-width: 1500px; width: 90%; padding: 26px 0 56px; }
.home-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.home-section { margin-top: 34px; min-width: 0; }
.home-page .home-section:first-child { margin-top: 0; }
.home-grid[hidden] { display: none; }
.home-title-tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; min-width: 0; }
.home-title-tabs h2 { font-size: 28px; }
.home-title-tabs .tab { padding: 12px 0; border-bottom: 2px solid transparent; }
.home-title-tabs .tab.active { border-bottom-color: var(--green); }
.home-library-heading { flex-wrap: wrap; }
.home-library-heading .tabs { margin: 0; }
.home-section h2 { font-size: 22px; margin: 0; }
.home-carousel { display: flex; gap: 16px; overflow-x: auto; padding: 16px 2px; scroll-snap-type: x proximity; scrollbar-width: none; -ms-overflow-style: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.home-carousel::-webkit-scrollbar { display: none; }
.home-carousel.is-dragging { scroll-snap-type: none; scroll-behavior: auto; }
.home-carousel.is-dragging, .home-carousel.is-dragging * { cursor: grabbing !important; }
.home-tile { display: flex; flex-direction: column; min-width: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); color: inherit; text-align: left; overflow: hidden; }
.home-carousel > .home-tile { flex: 0 0 235px; scroll-snap-align: start; }
.home-create-tile { min-height: 235px; align-items: center; justify-content: center; gap: 16px; padding: 24px; border-style: dashed; color: var(--green); text-align: center; }
.home-create-plus { font-size: 48px; font-weight: 400; line-height: 1; }
.home-create-tile strong { font-size: 18px; }
button.home-tile:hover { border-color: var(--green); box-shadow: 0 4px 14px #24594d15; }
.home-cover { display: grid; place-items: center; width: 100%; height: 100px; font-size: 36px; color: #52766b; background: radial-gradient(ellipse at 75% 10%, #edf0d8, transparent 70%), linear-gradient(145deg, #d4e1d3, #b8cfc5); }
.home-tile:nth-child(3n+2) .home-cover { background: linear-gradient(145deg, #e6e1cd, #c6d2bb); }
.home-tile:nth-child(3n+3) .home-cover { background: linear-gradient(145deg, #d5dfdf, #b5c6ca); }
.home-tile-copy { display: flex; flex-direction: column; gap: 10px; padding: 18px; width: 100%; flex: 1; overflow-wrap: anywhere; }
.home-tile-copy strong, .home-tile-copy h3 { font-size: 18px; margin: 0; }
.home-tile-copy small { color: #617267; font-size: 12px; }
.home-tile-description, .home-tile-copy p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; font-size: 14px; margin: 0; }
.home-tile-action { margin-top: auto; padding-top: 8px; color: var(--green); font-size: 13px; font-weight: 600; }
.library-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(235px, 100%), 1fr)); gap: 20px; }
.library-tile:focus-within, .library-tile:hover { border-color: var(--green); box-shadow: 0 4px 14px #24594d15; }
.library-tile { position: relative; cursor: pointer; height: 300px; background: #fff; }
.library-tile .home-cover { position: absolute; inset: 0 0 auto; transition: height 300ms ease; }
.library-tile .home-cover { z-index: 2; pointer-events: none; }
.library-tile .home-tile-copy { min-height: 0; padding-top: 118px; }
.tile-details { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.tile-footer { margin-top: auto; }
.tile-hover-summary { display: flex; flex-direction: column; gap: 10px; position: absolute; z-index: 3; bottom: calc(var(--tile-footer-height, 102px) - 34px); left: 18px; right: 18px; opacity: 0; transform: translateY(-35px); transition: opacity 180ms ease, transform 300ms ease; pointer-events: none; }
.tile-footer { position: static; }
.tile-hover-summary strong { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; line-height: 22px; }
.library-tile .tile-description { flex-shrink: 1; min-height: 0; }
.library-tile-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; flex-shrink: 0; }
.library-tile-actions button { padding: 8px 10px; font-size: 13px; white-space: nowrap; flex: 0 0 auto; }
.library-tile-actions button { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease; }
.library-tile-actions .secondary:not(.danger):hover,
.library-tile-actions .secondary:not(.danger):focus-visible { background: #f0f1ee; border-color: #b9c1b8; }
.library-tile-actions .secondary.danger:hover,
.library-tile-actions .secondary.danger:focus-visible { background: #f9e9e7; border-color: #e5b6b1; }
.library-tile-actions .primary:not(.danger):hover,
.library-tile-actions .primary:not(.danger):focus-visible { background: #347362; }
.library-tile-actions button:active { transform: translateY(1px); }
.library-tile-actions [data-template-view] { margin-left: auto; }
.library-tile:has([data-publishing-kind="character"]) { --tile-footer-height: 142px; }
.character-publication-status { font-size: 0.7em; font-weight: 400; color: var(--muted); white-space: nowrap; }
.character-sheet-actions { align-items: center; }
.character-sheet-actions .footer-actions { margin-top: 0; flex-wrap: wrap; }
.character-readonly-sheet h1 { overflow-wrap: anywhere; }
.character-readonly-sheet dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.library-tile-actions [data-open-story] { margin-left: auto; }
.library-tile-actions [data-library-world] { margin-left: auto; }
.library-tile-actions [data-story-character-view] { margin-left: auto; }
.story-character-profile h2 { overflow-wrap: anywhere; }
#dialog:has(.story-character-profile) { box-sizing: border-box; width: min(var(--story-conversation-width, 900px), calc(100vw - 40px)); max-width: calc(100vw - 40px); padding: 0; overflow: hidden; max-height: 90vh; max-height: 90dvh; }
.story-character-profile { display: flex; flex-direction: column; max-height: calc(90vh - 2px); max-height: calc(90dvh - 2px); }
.story-character-profile > header { display: block; height: auto; flex: 0 0 auto; padding: 24px 24px 0; margin: 0; border: 0; }
.story-character-profile > header h2 { margin: 8px 0; color: var(--green); }
.story-character-profile > header p { margin: 8px 0; }
.story-character-profile > .story-character-details { overflow-y: auto; min-height: 0; padding: 0 24px; margin: 16px 0 0; overscroll-behavior: contain; }
.story-character-profile > .dialog-actions { flex: 0 0 auto; margin: 0; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--paper); }
#character-form .character-editor-sheet { padding: 0; }
.character-sheet-header { position: sticky; top: 12px; z-index: 5; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 16px 29px; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; background: var(--paper); }
.character-sheet-header h3 { margin: 0; }
.character-sheet-header .footer-actions { margin: 0; flex-wrap: wrap; gap: 12px; }
.character-sheet-body { padding: 29px; }
main > header.character-editor-page-header { position: relative; }
.mobile-layout main > header.character-editor-page-header { display: flex; height: auto; }
@media(max-width:1100px) {
  .character-sheet-header { top: 76px; }
}
@media(max-width:600px) {
  .character-sheet-header { padding: 16px 20px; }
  .character-sheet-header .footer-actions { width: 100%; }
  .character-sheet-body { padding: 20px; }
}
.story-character-details { display: grid; gap: 22px; margin: 24px 0; }
.story-character-details > div { min-width: 0; padding-bottom: 18px; border-bottom: 1px solid #274f4225; }
.story-character-details dt { font-weight: 700; color: var(--green); margin-bottom: 8px; }
.story-character-details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
/* The tile surface handles its primary action; controls retain their own clicks. */
.library-tile button:not(.tile-primary) { position: relative; z-index: 4; }
.library-tile:focus-within .home-cover { height: calc(100% - var(--tile-footer-height, 102px)); }
.library-tile:focus-within .tile-details { visibility: hidden; }
.library-tile:focus-within .tile-hover-summary { opacity: 1; transform: translateY(0); }
@media (hover: hover) and (pointer: fine) {
  .library-tile:hover .home-cover { height: calc(100% - var(--tile-footer-height, 102px)); }
  .library-tile:hover .tile-details { visibility: hidden; }
  .library-tile:hover .tile-hover-summary { opacity: 1; transform: translateY(0); }
  .library-tile:not(:hover):not(:focus-within) .tile-hover-summary { opacity: 0; transform: translateY(-35px); transition: none; }
}
@media (prefers-reduced-motion: reduce) {
  .library-tile .home-cover, .tile-details, .tile-hover-summary { transition: none; }
}
.library-tile .world-story-title h3 { font-size: 18px; }
.library-tile .home-tile-copy h3 { font-family: inherit; font-weight: 700; }
.library-tile .world-story-title { flex-shrink: 0; }
.library-tile .world-story-title h3 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.home-search { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(140px, 200px) minmax(120px, 160px); gap: 14px; margin-top: 20px; }
.home-search label { display: grid; gap: 8px; font-size: 13px; }
.home-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.home-empty { margin-top: 16px; padding: 26px; border: 1px dashed #afc2b4; border-radius: 12px; }
.home-empty h3 { margin: 0; }
#discovery-more, #character-discovery-more { display: block; margin: 24px auto; }
#discovery-more[hidden], #character-discovery-more[hidden] { display: none; }
@media(max-width:1100px) { .home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media(max-width:750px) {
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .home-search { grid-template-columns: 1fr 1fr; }
  .home-search label:first-child { grid-column: 1 / -1; }
  .home-section-heading { flex-wrap: wrap; gap: 8px; }
  .home-tile-copy { padding: 14px; }
}

.credit-purchase-history { padding-left: 20px; }
.credit-purchase-history li { margin: 12px 0; }
.credit-purchase-history span { display: block; font-size: 13px; opacity: .75; }
.dev-response-data{margin-top:1rem;padding:.65rem .8rem;border:1px solid #d9ded2;border-radius:7px;background:#f7f8f3;font-size:.85rem;min-width:0}
.dev-response-data summary{cursor:pointer;font-weight:600;overflow-wrap:anywhere}
.dev-response-data summary:focus-visible{outline:2px solid #8ba890;outline-offset:3px}
.dev-response-content>details{margin:.75rem 0;padding:.4rem .6rem;border-left:2px solid #d9ded2}
.dev-response-content pre{font:12px/1.5 ui-monospace,Consolas,monospace;white-space:pre-wrap;overflow-wrap:anywhere;max-height:22rem;overflow:auto;margin:.6rem 0;padding:.6rem;background:#fff;border-radius:4px}
.dev-response-content p{margin:.6rem 0;overflow-wrap:anywhere}
.publication-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.content-visibility { align-self: center; color: var(--muted); }
.published-summary, .published-preview dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.published-preview { max-width: 760px; }
#dialog:has(.published-preview) { width: min(960px, calc(100vw - 40px)); max-width: calc(100vw - 40px); }
#dialog .published-preview { max-width: none; }
.recommended-worlds { display: flex; flex-wrap: wrap; gap: .5rem; }
.character-discovery select[multiple] { min-height: 8rem; }
.share-page main { margin: 0 auto; padding: 3rem 1.5rem; width: 100%; max-width: 850px; }
.share-page .published-preview { margin: auto; }
.share-page a.primary { display: inline-block; text-decoration: none; }
.chapter-archive-button { width: 100%; text-align: left; white-space: normal; line-height: 1.5; }
.chapter-details { padding-top: 1rem; }
.chapter-details .transcript-download { display: inline-block; margin-top: 1rem; text-decoration: none; }
@media (max-width: 640px) { .share-page main { padding: 1rem; } }

/* Mobile story reading and writing. Desktop retains its existing controls. */
.mobile-story-bar { display: none; }
.mobile-story-context .mobile-topbar { display: none; }
.mobile-story-context .mobile-story-bar {
  display: flex; align-items: center; gap: 4px; position: fixed;
  inset: 0 0 auto; height: 56px; padding: 0 8px;
  background: var(--green, #183f36); color: #fffef8; z-index: 4;
}
.mobile-story-bar button { background: transparent; color: inherit; min-width: 44px; min-height: 44px; padding: 4px 8px; }
.mobile-story-bar #mobile-story-back { font-size: 32px; }
.mobile-story-bar #mobile-story-title { flex: 1; min-width: 0; text-align: left; }
.mobile-story-bar strong, .mobile-story-bar span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-story-bar strong { font: 18px Georgia, serif; }
.mobile-story-bar .story-credits { flex-shrink: 0; min-height: 32px; height: 32px; gap: 5px; padding: 3px 8px; background: #eaf0e5; color: var(--green); border-radius: 22px; }
.mobile-story-bar .story-credits strong { font: 700 12px var(--font-sans, sans-serif); }
.mobile-story-bar span { font-size: 12px; opacity: .85; margin-top: 3px; }
.mobile-story-context main { padding-top: 56px; }
.mobile-story-context .mobile-world-heading, .mobile-story-context .story-nav { display: none; }
.mobile-story-context .mobile-story-menu { display: grid; gap: 4px; margin: 12px 0; }
.mobile-story-menu button { min-height: 48px; text-align: left; background: transparent; color: var(--green); }
.mobile-story-menu button[aria-current="page"] { background: #eaf0e5; font-weight: 700; }
.mobile-story #app { padding: 0; max-width: none; }
.mobile-story .chat { border: 0; border-radius: 0; background: var(--paper); }
.mobile-story .chat-head[hidden] { display: none; }
.mobile-story .messages { padding: 20px 16px 12px; scroll-padding-block: 16px; }
.mobile-story .message { padding: 0 0 20px; margin-bottom: 20px; }
.mobile-story .message .prose { line-height: 1.55; }
.mobile-story .message .prose p { margin-bottom: 1em; }
.mobile-story .turn-tools { gap: 6px; }
.mobile-story .turn-tools button { min-width: 33px; min-height: 33px; height: 33px; padding: 3px 7px; }
.mobile-story .turn-tools [data-reroll] { width: 33px; padding: 0; font-size: 15px; }
.mobile-story .composer { position: relative; flex: 0 0 auto; max-height: none; overflow: visible; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-radius: 0; }
.mobile-story .rich-editor { height: auto; min-height: 48px; max-height: min(168px, 30dvh); font-size: 16px; line-height: 1.5; padding: 10px 12px; overflow-y: auto; scroll-padding-block: 10px; }
.mobile-story .composer > .story-chat-meta { font-size: 11px; padding: 4px 0; }
.mobile-story .composer .conversation-turn-count, .mobile-story .composer .story-meta-group:not(.story-message-cost) { display: none; }
.mobile-story .composer-footer { margin-top: 4px; padding-left: 0; min-height: 44px; align-items: center; gap: 6px; }
.mobile-story .composer-footer > .story-chat-meta { display: block; order: 1; flex-shrink: 0; }
.mobile-story .composer-footer .story-message-cost { font-size: 0; }
.mobile-story .composer-footer #story-message-cost { min-height: 44px; padding: 6px 8px; background: transparent; color: var(--green); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; border-radius: 6px; }
.mobile-story .composer-footer .send-actions { order: 2; }
.mobile-story:not(.compact-composer) .composer-footer { flex-wrap: wrap; }
.mobile-story:not(.compact-composer) .composer-footer .send-actions { flex-basis: 100%; }
.mobile-story .send-actions { justify-content: flex-end; gap: 6px; }
.mobile-story .send-actions button { padding: 9px 12px; }
.mobile-story .send-actions #send { min-height: 32px; height: 32px; padding: 4px 12px; }
.mobile-story.compact-composer .composer > label { display: none; }
.mobile-story.compact-composer .format-bar { display: none; }
.mobile-story.compact-composer #end-chapter { display: none; }
.mobile-story.compact-composer .rich-editor { border-radius: 12px; }
.mobile-story.compact-composer .composer { margin: 0 8px 8px; padding: 8px; border: 1px solid var(--line); border-radius: 16px; }
.character-sheet-body > .field { margin: 16px 0; }
.character-sheet-body > details { border-block-start: 1px solid var(--line); margin: 20px 0; padding-top: 12px; }
.character-sheet-body > details > summary { cursor: pointer; font-weight: 600; margin-bottom: 14px; }
.recommendation-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.recommendation-chips .tag { display: inline-flex; align-items: center; gap: 6px; }
.recommendation-chips .quiet { padding: 2px 5px; font-size: 16px; line-height: 1; }
.response-commit { margin-top: 10px; }
.response-commit .hint { margin-top: 6px; }
.lore-visibility[hidden] { display: none; }
.campaign-prep { margin: 14px 0; }
.campaign-prep .footer-actions { flex-wrap: wrap; }
.pair-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 12px; margin-block: 12px; }
.pair-preview .card, .campaign-card { padding: 16px; }
.pair-preview h3 { margin-block: 4px 8px; }
.campaign-card .footer-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.library-tile .home-cover[data-cover="forest"] { color: #355849; background: radial-gradient(ellipse at 72% 14%, #ebefd1, transparent 62%), linear-gradient(145deg,#a8c4a6,#cbdad0); }
.library-tile .home-cover[data-cover="dusk"] { color: #635375; background: radial-gradient(ellipse at 24% 75%, #e9d4cf, transparent 58%), linear-gradient(135deg,#dad3e6,#c2bbd4); }
.library-tile .home-cover[data-cover="space"] { color: #344d69; background: radial-gradient(ellipse at 68% 20%, #e8edf5, transparent 54%), linear-gradient(165deg,#c8d7e2,#aabdcf); }
.library-tile .home-cover[data-cover="ember"] { color: #764d37; background: radial-gradient(ellipse at 76% 80%, #f1dfaa, transparent 62%), linear-gradient(150deg,#ded3bb,#d8b7a5); }
.campaign-matches button small { display: block; font-weight: normal; }
.campaign-selection { color: var(--green); margin-block: 4px; }
.official-tag { text-transform: none; letter-spacing: normal; white-space: nowrap; background: #e5eedc; color: #294437; }
#quick-story, #creation-assist { margin-bottom: 8px; }
.regenerate-button { display: inline-block; margin-top: 4px; min-height: 30px; }
.prep-opt-in { display: flex; align-items: center; gap: 8px; }
.prep-opt-in input { width: auto; }
.world-summary .world-title-link { font-size: inherit; text-decoration: underline; text-underline-offset: 2px; }
#rename-active-story { font-size: inherit; padding: 0 5px; }
#discard-turn { margin-right: auto; }

@media (min-width: 751px) {
  .desktop-play:not(.mobile-layout) #app { padding-block: 12px; }
  .desktop-play:not(.mobile-layout) .play-grid { height: max(400px, calc(var(--story-viewport-height, 100dvh) - var(--story-stage-top, 170px) - 12px)); }
  .desktop-play:not(.mobile-layout) .chat { display: flex; flex-direction: column; min-height: 0; }
  .desktop-play:not(.mobile-layout) .chat-head,
  .desktop-play:not(.mobile-layout) .composer { flex: 0 0 auto; }
  .desktop-play:not(.mobile-layout) .messages { flex: 1 1 0; min-height: 80px; height: auto; overscroll-behavior-y: contain; }
  .desktop-play:not(.mobile-layout) .play-side { overflow: auto; }
  .desktop-play:not(.mobile-layout) .rich-editor { min-height: 70px; max-height: min(160px, 24dvh); }
}
@media (min-width: 751px) and (max-width: 1190px) {
  .desktop-play:not(.mobile-layout) .play-grid { grid-template-columns: minmax(0, 1fr); height: auto; }
  .desktop-play:not(.mobile-layout) .chat { height: max(400px, calc(var(--story-viewport-height, 100dvh) - var(--story-stage-top, 170px) - 12px)); }
  .desktop-play:not(.mobile-layout) .play-side { max-height: 260px; }
}
.mobile-layout #dialog.mobile-text-editor { inset: 0; margin: 0; width: 100%; max-width: none; height: var(--story-viewport-height, 100dvh); max-height: var(--story-viewport-height, 100dvh); border: 0; border-radius: 0; padding: 16px; overflow: hidden; }
.mobile-layout .mobile-text-editor #dialog-content { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 8px; height: 100%; min-height: 0; }
.mobile-layout .mobile-text-editor h2 { font-size: 20px; margin: 0 0 8px; }
.mobile-layout .mobile-text-editor form { display: contents; }
.mobile-layout .mobile-text-editor form > label { display: none; }
.mobile-layout #dialog.mobile-text-editor textarea { grid-column: 1 / -1; grid-row: 3; height: 100%; min-height: 48px; resize: none; font-size: 16px; line-height: 1.5; margin-bottom: 0; }
.mobile-layout .mobile-text-editor h2 { grid-column: 1; grid-row: 1; align-self: center; margin: 0; }
.mobile-layout .mobile-text-editor .error { grid-column: 1 / -1; grid-row: 4; margin: 0; }
.mobile-layout .mobile-text-editor .error:empty { display: none; }
.mobile-layout .mobile-text-editor .dialog-actions { grid-column: 2; grid-row: 1; margin: 0; gap: 6px; }
.mobile-layout .mobile-text-editor .dialog-actions button { padding: 8px 12px; min-height: 44px; }
.mobile-layout .mobile-text-editor .editor-explanation { grid-column: 1 / -1; grid-row: 2; font-size: 13px; max-height: calc(var(--story-viewport-height, 100dvh) * .25); overflow: auto; margin: 0; }
.mobile-layout .mobile-text-editor .editor-explanation summary { min-height: 44px; padding: 12px 0; }
body[data-guest-app] .credits-display, body[data-guest-app] #home-link, body[data-guest-app] #settings { display: none; }
.guest-opening { margin-top: 1rem; }
.guest-opening button { margin-top: .75rem; }
.guest-builder .footer-actions { margin-top: 1rem; }
.guest-builder .card { min-width: 0; }

.archived-creations { margin-block-start: 2rem; }
.library-tile.creation-tile { height: auto; min-height: 300px; }
.library-tile.creation-tile .home-cover { position: static; height: 100px; flex: none; }
.library-tile.creation-tile .home-tile-copy { padding: 18px; }
.library-tile.creation-tile .tile-details { visibility: visible; }
.archived-creation, .library-tile.archived-creation:is(:hover, :focus-within) { border: 2px solid #c96661; }
.archived-label { background: #7b3a35; color: #fff3f0; margin-block: .25rem; }
.deleted-creation-notice {
  background: color-mix(in srgb, #ae463e 14%, transparent);
  border: 1px solid color-mix(in srgb, #ae463e 52%, transparent);
  border-radius: .55rem;
  padding: .75rem 1rem;
  margin-block: 1rem;
}
#campaign-inspection > button { margin-block-end: .75rem; }
