:root {
  --bg: var(--ws-canvas);
  --surface: var(--ws-surface);
  --surface-soft: var(--ws-canvas-subtle);
  --ink: var(--ws-ink);
  --muted: var(--ws-muted);
  --line: var(--ws-line);
  --brand: var(--ws-accent);
  --brand-solid: var(--ws-accent);
  --brand-soft: var(--ws-accent-soft);
  --amber: var(--ws-warning);
  --danger: var(--ws-danger);
  --chat-wash: rgb(241 243 240 / 76%);
  --sidebar: 76px;
  --topbar: 68px;
  --shadow: var(--ws-shadow-float);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ws-font-sans);
  letter-spacing: 0;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
body.dark {
  --bg: var(--ws-canvas);
  --surface: var(--ws-surface);
  --surface-soft: var(--ws-canvas-subtle);
  --ink: var(--ws-ink);
  --muted: var(--ws-muted);
  --line: var(--ws-line);
  --brand: var(--ws-accent);
  --brand-solid: var(--ws-accent);
  --brand-soft: var(--ws-accent-soft);
  --amber: var(--ws-warning);
  --danger: var(--ws-danger);
  --chat-wash: rgb(21 26 23 / 76%);
  --shadow: var(--ws-shadow-float);
}
body.no-images .story-cover:not(.story-card .story-cover),
body.no-images .workspace-cover { display: none; }

.boot-shell { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); background: var(--bg); }
.boot-sidebar { padding: 20px 18px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; }
.boot-mark, .boot-line, .boot-dot, .boot-panel { display: block; background: var(--surface-soft); animation: boot-pulse 1.1s ease-in-out infinite alternate; }
.boot-mark { width: 36px; height: 36px; border-radius: 7px; margin-bottom: 12px; }
.boot-line { width: 68%; height: 12px; border-radius: 4px; }
.boot-line.wide { width: 84%; }
.boot-main { min-width: 0; }
.boot-topbar { height: var(--topbar); padding: 0 24px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); }
.boot-line.search { width: min(360px, 55%); height: 34px; }
.boot-dot { width: 34px; height: 34px; border-radius: 50%; }
.boot-workspace { height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar)); padding: 16px; display: grid; grid-template-columns: minmax(170px, 240px) minmax(0, 1fr) minmax(210px, 280px); gap: 12px; }
.boot-panel { min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
@keyframes boot-pulse { from { opacity: .55; } to { opacity: 1; } }

.app-shell { min-height: 100vh; min-height: 100dvh; padding-left: var(--sidebar); }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 18px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 10px 22px;
  font-weight: 850;
  font-size: 20px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--brand-solid);
  color: #fff;
}
.nav-group { margin-bottom: 20px; }
.nav-label {
  padding: 0 12px 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.nav-button {
  width: 100%;
  min-height: 42px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 680;
  text-align: left;
}
.nav-button:hover, .nav-button.active { background: var(--brand-soft); color: var(--brand); }
.nav-button svg { width: 18px; height: 18px; flex: none; }
.sidebar-footer { margin-top: auto; display: grid; gap: 10px; }
.account-strip {
  border-top: 1px solid var(--line);
  padding: 14px 8px 0;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--surface);
  font-weight: 800;
}
.account-name { min-width: 0; font-size: 13px; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-points { color: var(--muted); font-size: 11px; }
.account-strip > span:not(.avatar) { min-width: 0; display: grid; gap: 2px; }
.sidebar-tools { display: flex; gap: 6px; padding: 0 8px; }

.main-area { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--topbar);
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  gap: 12px;
}
.search-box { position: relative; width: min(600px, 100%); }
.search-box svg { position: absolute; left: 13px; top: 11px; width: 19px; color: var(--muted); }
.search-box input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  outline: none;
}
.search-box input:focus, .field input:focus, .field textarea:focus, .field select:focus, .composer textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}
.top-actions { margin-left: auto; display: flex; gap: 7px; }
.page { max-width: 1480px; margin: 0 auto; padding: 26px 28px 84px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-heading h1 { margin: 0; font-size: 26px; }
.page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

.button, .icon-button, .chip, .segment {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  font-weight: 700;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.button:hover:not(:disabled), .icon-button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brand) 42%, var(--line)); background: color-mix(in srgb, var(--brand-soft) 56%, var(--surface)); }
.button:active:not(:disabled), .icon-button:active:not(:disabled) { transform: translateY(1px); }
.button:focus-visible, .icon-button:focus-visible, .nav-button:focus-visible, .session-open:focus-visible, .segment:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.icon-button { width: 38px; padding: 0; flex: none; }
.button svg, .icon-button svg { width: 17px; height: 17px; }
.button.primary { color: #fff; background: var(--brand-solid); border-color: var(--brand-solid); }
.button.amber { color: #2b2112; background: var(--amber); border-color: var(--amber); }
.button.danger { color: var(--danger); }
.button.ghost { background: transparent; }
.button.small { min-height: 32px; padding: 0 10px; font-size: 12px; }

.model-picker { position: relative; min-width: 0; display: inline-flex; align-items: center; }
.model-picker-trigger { min-width: 0; max-width: 100%; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--ink); text-align: left; }
.model-picker-trigger:hover:not(:disabled) { background: var(--surface-soft); }
.model-picker-trigger > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker-trigger > svg { flex: none; color: var(--muted); }
.model-picker-menu { position: absolute; z-index: var(--ws-z-drawer); right: 0; bottom: calc(100% + 8px); width: min(380px, calc(100vw - 24px)); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised, var(--surface)); box-shadow: var(--ws-shadow-overlay); }
.model-picker-tabs { display: flex; gap: 2px; overflow-x: auto; padding: 7px 8px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.model-picker-tabs button { min-height: 30px; flex: none; padding: 0 8px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 12px; }
.model-picker-tabs button.active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 2px rgb(32 33 36 / 8%); }
.model-picker-list { max-height: min(360px, 52vh); overflow-y: auto; padding: 5px; }
.model-picker-option { width: 100%; min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); text-align: left; }
.model-picker-option:hover, .model-picker-option:focus-visible { background: var(--surface-soft); }
.model-picker-option-copy { min-width: 0; display: grid; gap: 6px; }
.model-picker-option strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-picker-option strong { font-size: 13px; }
.model-picker-option-prices { display: flex; flex-wrap: wrap; gap: 5px; }
.model-price-token { min-height: 24px; display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted-strong); font-size: 10px; line-height: 1; white-space: nowrap; }
.model-price-token i { width: 5px; height: 5px; flex: none; border-radius: 50%; background: var(--brand); }
.model-price-token.output i { background: var(--ink-soft); }
.model-price-token b { color: var(--ink); font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.model-price-token em { color: var(--muted); font-size: 9px; font-style: normal; }
.model-picker-option > svg { flex: none; color: var(--brand); }
.model-picker-details { margin: 0 12px 12px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.model-picker-details summary { color: var(--brand); cursor: pointer; }
.model-picker-details p { margin: 7px 0 0; }
.model-picker-mobile-dialog h2 { margin: 0 0 14px; font-size: 20px; }
.model-picker-mobile-dialog .model-picker-list { max-height: min(56dvh, 440px); }
@media (max-width: 620px) {
  .model-picker-trigger { min-height: 44px; padding-inline: 10px; }
  .model-picker-tabs { margin-inline: -2px; }
  .model-picker-tabs button { min-height: 38px; padding-inline: 10px; }
  .model-picker-option { min-height: 68px; }
}
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.ranking-tabs { display: flex; gap: 3px; padding: 3px; background: var(--surface-soft); border-radius: 7px; overflow-x: auto; }
.ranking-tabs { max-width: 100%; scrollbar-width: thin; }
.segment { white-space: nowrap; border: 0; background: transparent; min-height: 34px; padding: 0 12px; color: var(--muted); }
.segment.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.category-row { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 20px; }
.chip { min-height: 32px; border-radius: 999px; padding: 0 12px; font-size: 13px; color: var(--muted); }
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.story-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.story-card {
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  text-align: left;
  display: flex;
  flex-direction: column;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.story-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); box-shadow: var(--shadow); }
.story-cover { height: 168px; position: relative; background: var(--surface-soft); }
.story-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { width: 100%; height: 100%; display: grid; place-items: center; background: var(--surface-soft); color: var(--muted); }
.cover-fallback svg { opacity: .7; }
.story-badges { position: absolute; inset: 10px 10px auto; display: flex; justify-content: space-between; gap: 6px; }
.metric-badge { padding: 5px 8px; border-radius: 5px; background: rgba(25,29,26,.8); color: #fff; font-size: 11px; font-weight: 750; }
.story-body { padding: 14px; display: flex; flex: 1; flex-direction: column; }
.story-author { color: var(--brand); font-size: 12px; font-weight: 750; }
.story-body h3 { margin: 5px 0 7px; font-size: 17px; line-height: 1.35; }
.story-body p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; height: 42px; overflow: hidden; }
.story-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 11px; }
.tag-list { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 10px; }
.tag { padding: 3px 6px; border-radius: 4px; color: var(--brand); background: var(--brand-soft); font-size: 11px; }
.story-meta { margin-top: auto; padding-top: 12px; }
.story-grid.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.story-grid.compact .story-cover { height: 125px; }
.story-grid.compact .story-body p, .story-grid.compact .tag-list { display: none; }
.explore-search { display: none; }
.load-more { display: flex; justify-content: center; padding: 24px 0 4px; }
.rail-header, .inspector-header, .chat-header {
  min-height: 64px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
.session-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; align-items: center; }
.session-open {
  min-width: 0;
  border: 0;
  border-radius: 6px;
  padding: 10px 11px;
  background: transparent;
  text-align: left;
}
.session-open:hover { background: color-mix(in srgb, var(--brand-soft) 62%, transparent); }
.session-open.active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.session-open strong, .session-open span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-open strong { font-size: 12px; line-height: 1.35; }
.session-open span { color: var(--muted); font-size: 10px; margin-top: 5px; }
.chat-header-actions { margin-left: auto; display: flex; gap: 6px; }
.mobile-chat-more { display: none; }
.model-select { height: 36px; max-width: 190px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 0 9px; }
.external-renderer-host { position: relative; width: 100%; height: 100%; min-width: 0; min-height: 0; overflow: hidden; }
.external-renderer-frame { display: block; width: 100%; height: 100%; border: 0; background: transparent; }
.external-renderer-loading { position: absolute; z-index: 2; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); font-size: 13px; background: color-mix(in srgb, var(--surface) 86%, transparent); }
.external-renderer-host.is-ready .external-renderer-loading { display: none; }
.external-renderer-list > .older-messages { position: absolute; z-index: 4; top: 8px; left: 50%; transform: translateX(-50%); margin: 0; }
.message-markup-chat { display: flex; align-items: flex-start; gap: 10px; width: 100%; margin: 12px 0; text-align: left; }
.message-markup-chat--right { flex-direction: row-reverse; text-align: right; }
.message-markup-avatar-wrap { width: 42px; min-width: 42px; height: 42px; display: grid; place-items: center; }
.message-markup-avatar { display: block; width: 42px; height: 42px; object-fit: cover; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--line) 82%, transparent); background: var(--surface); }
.message-markup-avatar--placeholder { width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 18%, var(--surface)); }
.message-markup-content { min-width: 0; max-width: min(100%, 560px); display: grid; gap: 3px; }
.message-markup-name { color: var(--muted); font-size: 11px; line-height: 1.35; }
.message-markup-bubble { min-width: 0; padding: 10px 13px; border: 1px solid color-mix(in srgb, var(--line) 88%, transparent); border-radius: 8px; background: color-mix(in srgb, var(--surface) 96%, transparent); overflow-wrap: anywhere; white-space: pre-wrap; }
.message-markup-chat--right .message-markup-bubble { background: var(--brand-solid); color: #fff; border-color: var(--brand-solid); text-align: left; }
.typing { display: inline-flex; gap: 5px; align-items: center; color: var(--muted); }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite alternate; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { to { opacity: .25; transform: translateY(-2px); } }
.quick-actions { display: flex; gap: 7px; overflow-x: auto; }
.quick-actions button { white-space: nowrap; }
.stop-generation { min-width: 92px; }
.older-messages { display: flex; justify-content: center; padding: 0 0 18px; }
.empty-chat { flex: 1; display: grid; place-items: center; padding: 30px; text-align: center; }
.empty-chat-inner { max-width: 540px; }
.empty-chat h2 { margin: 0 0 8px; }
.empty-chat p { color: var(--muted); line-height: 1.7; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; margin: 18px 0 15px; border-block: 1px solid var(--line); }
.metric { padding: 12px 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric:nth-child(2n) { border-right: 0; }
.metric:nth-last-child(-n + 2) { border-bottom: 0; }
.metric strong, .metric span { display: block; }
.metric strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.metric span { color: var(--muted); font-size: 10px; margin-top: 4px; }
.rating-control { display: flex; min-width: 0; gap: 6px; }
.rating-control .model-select { width: 76px; min-width: 0; }
.comment-list { display: grid; gap: 12px; }
.comment { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.comment-head { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; }
.comment p { margin: 6px 0 0; color: var(--ink); }
.comment-form { display: grid; gap: 7px; margin-bottom: 14px; }
.comment-form textarea { min-height: 76px; resize: vertical; }
.comment-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 10px;
  outline: none;
}

.form-card { max-width: 940px; }
.profile-points { max-width: 940px; display: grid; gap: 30px; }
.points-summary { display: grid; gap: 14px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.points-summary .account-strip { grid-template-columns: 52px minmax(0, 1fr) auto; padding: 4px 0; }
.points-summary .avatar { width: 52px; height: 52px; }
.points-summary .account-name { font-size: 18px; }
.points-summary > .account-strip > strong { font-size: 26px; }
.points-summary > .account-strip > strong small { color: var(--muted); font-size: 11px; }
.claim-status { display: flex; color: var(--muted); }
.claim-status > span { display: flex; align-items: center; gap: 9px; }
.claim-status > span > span { display: grid; gap: 2px; }
.claim-status strong { color: var(--ink); font-size: 12px; }
.claim-status small { font-variant-numeric: tabular-nums; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.points-ledger { border-top: 1px solid var(--line); }
.points-entry { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.points-entry-icon { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-soft); color: var(--brand); }
.points-entry > span:nth-child(2) { min-width: 0; display: grid; gap: 3px; }
.points-entry strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.points-entry small { color: var(--muted); font-size: 10px; }
.points-entry b { font-variant-numeric: tabular-nums; }
.points-entry b.positive { color: #1f7a45; }
.points-entry b.negative { color: var(--danger); }
.points-skeleton { height: 230px; }
.form-section { display: grid; gap: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 750; }
.field small { color: var(--muted); }
.field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 11px 12px;
  outline: none;
}
.field textarea { min-height: 130px; resize: vertical; line-height: 1.6; }
.world-entry { border: 1px solid var(--line); border-radius: 7px; padding: 13px; display: grid; gap: 9px; background: var(--surface); }
.world-entry-head { display: flex; justify-content: space-between; align-items: center; }
.action-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
.form-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.preview-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 20px; }
.preview-cover { aspect-ratio: 16/10; border-radius: 7px; overflow: hidden; background: var(--surface-soft); }
.preview-cover img { width: 100%; height: 100%; object-fit: cover; }

.library-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.library-tab { padding: 10px 14px; border: 0; background: transparent; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 700; }
.library-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.conversation-table { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.conversation-row { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(140px, .7fr) 90px 150px auto; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.conversation-row:last-child { border-bottom: 0; }
.conversation-story { display: flex; gap: 10px; min-width: 0; align-items: center; }
.conversation-story-media { position: relative; width: 58px; height: 42px; flex: 0 0 58px; overflow: hidden; border-radius: 5px; background: var(--surface-soft); }
.conversation-story-media img { width: 100%; height: 100%; object-fit: cover; }
.conversation-story-media .cover-fallback svg { width: 16px; height: 16px; }
.conversation-story strong, .conversation-story span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-story span, .conversation-row > span { color: var(--muted); font-size: 11px; }
.consumption-summary { width: min(720px, 100%); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; border-block: 1px solid var(--line); }
.consumption-summary > div { display: grid; gap: 3px; padding: 16px 4px; }
.consumption-summary > div + div { padding-left: 24px; border-left: 1px solid var(--line); }
.consumption-summary span { color: var(--muted); font-size: 11px; }
.consumption-summary strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.consumption-summary small { color: var(--muted); font-size: 11px; }
.consumption-list { width: min(1120px, 100%); border-top: 1px solid var(--line); }
.consumption-row { min-width: 0; display: grid; grid-template-columns: 34px minmax(180px, 1.3fr) minmax(80px, .55fr) minmax(130px, .8fr) minmax(155px, .8fr) 90px; align-items: center; gap: 12px; padding: 13px 6px; border-bottom: 1px solid var(--line); }
.consumption-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; background: var(--surface-soft); color: var(--brand); }
.consumption-place { min-width: 0; display: grid; gap: 3px; }
.consumption-place strong, .consumption-place small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.consumption-place small, .consumption-kind, .consumption-model, .consumption-row time, .consumption-amount small { color: var(--muted); font-size: 11px; }
.consumption-amount { display: grid; justify-items: end; gap: 2px; }
.consumption-amount strong { color: var(--danger); font-size: 15px; font-variant-numeric: tabular-nums; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: rgba(14,17,15,.58); }
.modal { width: min(520px, 100%); max-height: min(780px, 92vh); overflow-y: auto; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 22px; position: relative; }
.modal.wide { width: min(760px, 100%); }

.modal.full { width: min(1280px, 100%); height: min(900px, calc(100dvh - 36px)); max-height: none; overflow: hidden; padding: 0; }
.modal h2 { margin: 0 0 6px; font-size: 21px; }
.modal > p { margin: 0 0 18px; color: var(--muted); }
.modal-close { position: absolute; top: 12px; right: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.auth-error { margin: 14px 0 0; padding: 9px 10px; border: 1px solid color-mix(in srgb, var(--danger) 42%, var(--line)); border-radius: 5px; background: color-mix(in srgb, var(--danger) 9%, var(--surface)); color: var(--danger); font-size: 13px; line-height: 1.45; }

.empty-chat-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.new-conversation-form { min-width: 0; }
.opening-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.opening-picker legend { margin-bottom: 7px; padding: 0; font-size: 12px; font-weight: 750; }
.opening-choice-list { max-height: min(320px, 36vh); overflow-y: auto; display: grid; gap: 7px; padding: 1px 4px 1px 1px; scrollbar-gutter: stable; }
.opening-choice {
  min-width: 0;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}
.opening-choice:hover { border-color: color-mix(in srgb, var(--brand) 42%, var(--line)); }
.opening-choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent); }
.opening-choice > input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--brand); }
.opening-choice > input:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.opening-choice-body { min-width: 0; display: grid; gap: 4px; }
.opening-choice-heading { min-width: 0; display: flex; align-items: center; gap: 7px; }
.opening-choice-heading strong { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.opening-default-badge { flex: none; padding: 2px 5px; border-radius: 4px; background: var(--brand-solid); color: #fff; font-size: 9px; font-weight: 750; }
.opening-choice-meta { display: flex; flex-wrap: wrap; gap: 4px; color: var(--muted); font-size: 10px; }
.opening-choice-meta b { color: var(--line); font-weight: 400; }
.opening-choice-preview { overflow-wrap: anywhere; color: var(--muted); font-size: 11px; line-height: 1.55; }
.custom-opening-field[hidden] { display: none; }
.custom-opening-field textarea { min-height: 104px; max-height: 220px; }
.settings-grid { display: grid; gap: 16px; }
.range-row { display: grid; grid-template-columns: 130px minmax(0,1fr) 54px; align-items: center; gap: 10px; }
.range-row output { text-align: right; font-variant-numeric: tabular-nums; }
.toast { position: fixed; z-index: 200; right: 22px; bottom: 22px; padding: 11px 15px; border-radius: 6px; background: var(--ink); color: var(--surface); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s; }
.toast.show { opacity: 1; transform: none; }
body:has(.modal-backdrop) .toast { z-index: 90; }
.empty-state { border: 1px dashed var(--line); border-radius: 8px; padding: 50px 20px; text-align: center; color: var(--muted); }
.loading-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.skeleton { height: 300px; border-radius: 8px; background: linear-gradient(90deg, var(--surface), var(--surface-soft), var(--surface)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.mobile-only { display: none; }
.mobile-nav { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1250px) {
  .story-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .story-grid.compact { grid-template-columns: repeat(4, minmax(0,1fr)); }

}
@media (max-width: 980px) {

  .brand > span:last-child, .nav-label, .nav-button span, .sidebar .account-strip > span:not(.avatar), .sidebar .account-strip > svg, .sidebar-tools .icon-button:not([data-theme]) { display: none; }
  .brand, .nav-button { justify-content: center; padding-inline: 0; }
  .account-strip { grid-template-columns: 1fr; justify-items: center; }
  .topbar .account-button { width: 40px; padding: 0; }
  .topbar .account-button span { display: none; }
  .story-grid, .story-grid.compact { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .mobile-only { display: inline-flex; }

}
@media (max-width: 700px) {
  :root { --sidebar: 0px; --topbar: 58px; }

  .sidebar { display: none; }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 70;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--line);
  }
  .mobile-nav .nav-button {
    min-height: 56px;
    padding: 6px 2px;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    border-radius: 0;
    font-size: 10px;
  }
  .mobile-nav .nav-button span { display: block; }
  .topbar { padding: 9px 12px; }
  .search-box { display: none; }
  .explore-search {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr) 38px;
    align-items: center;
    gap: 7px;
    margin-bottom: 16px;
  }
  .explore-search > svg { width: 19px; color: var(--muted); }
  .explore-search input { min-width: 0; height: 40px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); padding: 0 11px; outline: none; }
  .explore-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
  .explore-search.has-clear { grid-template-columns: 20px minmax(0, 1fr) 38px 38px; }
  .page { padding: 20px 13px 78px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 23px; }
  .story-grid, .story-grid.compact { grid-template-columns: 1fr; }
  .story-cover, .story-grid.compact .story-cover { height: 195px; }
  .ranking-tabs { width: 100%; }
  .chat-header-actions { min-width: 0; gap: 4px; }
  .desktop-chat-action { display: none; }
  .mobile-chat-more { display: inline-flex; }
  .model-select { max-width: 108px; padding-inline: 6px; }
  .quick-actions { padding-inline: 12px; }
  .profile-points { gap: 22px; }
  .points-summary .account-strip { grid-template-columns: 46px minmax(0, 1fr) auto; }
  .points-summary .avatar { width: 46px; height: 46px; }
  .points-summary > .account-strip > strong { font-size: 21px; }
  .points-entry { grid-template-columns: 30px minmax(0, 1fr) auto; }
  .points-entry-icon { width: 29px; height: 29px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .preview-layout { grid-template-columns: 1fr; }
  .conversation-row { grid-template-columns: minmax(0,1fr) auto; }
  .conversation-row > span { display: none; }
  .consumption-row { grid-template-columns: 30px minmax(0, 1fr) auto; align-items: start; gap: 5px 9px; padding-inline: 2px; }
  .consumption-icon { grid-column: 1; grid-row: 1 / 3; }
  .consumption-place { grid-column: 2; grid-row: 1; }
  .consumption-amount { grid-column: 3; grid-row: 1 / 3; }
  .consumption-kind { grid-column: 2; grid-row: 2; }
  .consumption-model { grid-column: 2; grid-row: 3; overflow-wrap: anywhere; }
  .consumption-row time { grid-column: 2; grid-row: 4; }
  .range-row { grid-template-columns: 1fr 54px; }
  .range-row label { grid-column: 1 / -1; }
  .top-actions .button span { display: none; }
  .modal-backdrop { padding: 8px; }
  .modal { max-height: calc(100dvh - 16px); padding: 18px 14px; }
  .modal.auth-dialog { padding: 18px; }
  .auth-dialog .modal-actions { display: grid; grid-template-columns: minmax(0, 1fr); }
  .auth-dialog .modal-actions > .button { width: 100%; }

  .modal.full { width: 100%; height: calc(100dvh - 16px); padding: 0; }
  .opening-choice-list { max-height: min(280px, 34dvh); padding-right: 2px; scrollbar-gutter: auto; }
  .opening-choice { grid-template-columns: 18px minmax(0, 1fr); gap: 8px; padding: 10px; }
  .new-conversation-form .modal-actions { position: sticky; bottom: -18px; margin-inline: -14px; padding: 12px 14px calc(2px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
  .new-conversation-form .modal-actions .button { width: 100%; }

}

@media (max-width: 700px) {
  .boot-shell { grid-template-columns: 1fr; }
  .boot-sidebar { display: none; }
  .boot-topbar { padding: 0 14px; }
  .boot-workspace { grid-template-columns: 1fr; padding: 10px; }
  .boot-panel.rail, .boot-panel.detail { display: none; }

}

@media (max-width: 700px) {
  body.keyboard-open .mobile-nav { display: none; }

}

/* Wonderstage UI 2.0: player platform and immersive playroom */
.app-shell { padding-left: 76px; }
.sidebar {
  width: 76px;
  padding: 14px 10px;
  background: color-mix(in srgb, var(--surface) 96%, var(--bg));
}
.brand { justify-content: center; min-height: 52px; padding: 0 0 18px; }
.brand > span:last-child,
.sidebar .nav-label,
.sidebar .nav-button span,
.sidebar .account-strip > span:not(.avatar),
.sidebar .account-strip > svg { display: none; }
.brand-mark { width: 40px; height: 40px; border-radius: 8px; }
.nav-group { display: grid; justify-items: center; gap: 5px; margin-bottom: 18px; }
.nav-button {
  position: relative;
  width: 48px;
  min-height: 48px;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
}
.nav-button.active::before {
  content: "";
  position: absolute;
  left: -10px;
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.nav-button:hover,
.nav-button.active { background: var(--brand-soft); color: var(--brand); }
.sidebar-footer { justify-items: center; }
.sidebar-tools { width: 48px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 0; }
.sidebar-tools .icon-button { width: 22px; min-height: 30px; border: 0; background: transparent; }
.sidebar .account-strip {
  width: 48px;
  min-height: 50px;
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
}
.sidebar .avatar { width: 36px; height: 36px; border-radius: 8px; }

.topbar {
  min-height: 68px;
  padding: 12px 30px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom-color: color-mix(in srgb, var(--line) 82%, transparent);
}
.search-box { width: min(560px, 62vw); }
.search-box input {
  height: 42px;
  border-color: transparent;
  background: var(--surface-strong, var(--surface));
  box-shadow: inset 0 0 0 1px var(--line);
}
.top-actions .icon-button,
.top-actions .button { min-height: 42px; }
.page { max-width: 1560px; padding: 38px 42px 96px; }
.page-heading { align-items: flex-start; margin-bottom: 28px; }
.page-heading h1 { font-size: clamp(30px, 3vw, 42px); font-weight: 760; line-height: 1.12; }
.page-heading p { max-width: 54ch; margin-top: 9px; font-size: 14px; line-height: 1.7; }
.explore-heading { min-height: 72px; }

.button,
.icon-button,
.chip,
.segment {
  min-height: var(--ws-control-height);
  border-radius: var(--ws-radius-control);
  border-color: var(--ws-line-strong);
  background: var(--surface-raised, var(--surface));
  transition: background-color var(--ws-duration-fast) var(--ws-ease), border-color var(--ws-duration-fast) var(--ws-ease), color var(--ws-duration-fast) var(--ws-ease), transform var(--ws-duration-fast) var(--ws-ease);
}
.button:hover:not(:disabled),
.icon-button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brand) 46%, var(--line)); }
.button:active:not(:disabled),
.icon-button:active:not(:disabled) { transform: scale(.98); }
.button.primary,
.icon-button.primary { background: var(--brand-solid); border-color: var(--brand-solid); color: #f7faf7; }
.button.primary:hover:not(:disabled),
.icon-button.primary:hover:not(:disabled) { background: var(--ws-accent-hover); border-color: var(--ws-accent-hover); }
.button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.button.amber { background: var(--ws-warning-soft); border-color: color-mix(in srgb, var(--amber) 28%, var(--line)); color: var(--amber); }
.ranking-tabs { padding: 2px; background: var(--surface-soft); border-radius: 8px; }
.segment.active { box-shadow: none; }
.category-row { gap: 8px; margin-bottom: 26px; }
.chip { border-radius: 6px; }
.chip.active { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); color: var(--brand); }

.story-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 22px 18px; align-items: stretch; }
.story-card {
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line);
}
.story-card:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 50%, var(--line)), var(--ws-shadow-float); }
.story-cover { position: relative; flex: 0 0 auto; width: 100%; height: auto; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 8px 8px 0 0; }
.story-cover img { position: absolute; inset: 0; transition: transform 420ms var(--ws-ease); }
.story-card:hover .story-cover img { transform: scale(1.025); }
.cover-fallback { align-content: center; gap: 6px; background: var(--ws-accent-softer); color: var(--brand); }
.cover-fallback strong { font-size: 32px; font-weight: 720; line-height: 1; }
.cover-fallback small { color: var(--muted); font-size: 11px; font-weight: 650; }
.story-body { padding: 16px 16px 17px; }
.story-kicker { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.story-metrics { flex: none; display: flex; gap: 9px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.story-metrics span + span { padding-left: 9px; border-left: 1px solid var(--line); }
.story-play-metrics { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 9px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.story-play-metrics span + span { padding-left: 10px; border-left: 1px solid var(--line); }
.story-config-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--line); font-variant-numeric: tabular-nums; }
.story-config-stats > span { min-width: 0; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--surface-soft); }
.story-config-stats small { color: var(--muted); font-size: 10px; }
.story-config-stats strong { color: var(--text); font-size: 15px; line-height: 1; }
.story-config-stats b { margin-left: 2px; color: var(--muted); font-size: 9px; font-weight: 600; }
.story-body h3 { display: -webkit-box; min-height: calc(1.35em * 2); margin: 8px 0 7px; overflow: hidden; font-size: 17px; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.story-body p { display: -webkit-box; height: calc(1.6em * 2); min-height: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.story-card .tag-list { max-height: 25px; overflow: hidden; }
.story-grid.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.story-grid.compact .story-kicker { align-items: flex-start; }
.story-grid.compact .story-metrics { display: none; }

.conversation-table,
.world-entry { border-radius: 8px; background: var(--surface); }
.conversation-row { min-height: 76px; padding: 14px 16px; }
.conversation-row:hover { background: var(--ws-accent-softer); }
.consumption-summary { border-block-color: var(--line-strong); }
.points-entry-icon,
.consumption-icon { background: var(--brand-soft); }
.empty-state { border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 48%, transparent); }
.modal-backdrop { background: var(--ws-backdrop); backdrop-filter: blur(5px); }
.modal { border-radius: 8px; box-shadow: var(--ws-shadow-overlay); }
.toast { background: var(--ws-ink); color: var(--ws-surface); box-shadow: var(--ws-shadow-float); }
.rail-header,
.chat-header,
.inspector-header { min-height: 60px; padding: 10px 13px; }
.session-open { border-radius: 6px; }
.session-open.active { box-shadow: inset 3px 0 0 var(--brand); }
.empty-chat { text-align: left; justify-items: start; }
.empty-chat-inner { max-width: 660px; margin-left: clamp(0px, 7vw, 100px); }
.empty-chat-inner .brand-mark { margin: 0 0 18px !important; }
.empty-chat h2 { max-width: 22ch; font-size: clamp(28px, 4vw, 48px); line-height: 1.2; }
.empty-chat p { max-width: 58ch; font-family: var(--ws-font-reading); font-size: 16px; line-height: 1.9; }
.empty-chat-actions { justify-content: flex-start; }

@media (max-width: 1250px) {
  .story-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .story-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }

}

@media (max-width: 980px) {
  :root { --sidebar: 76px; }
  .page { padding-inline: 28px; }
  .story-grid,
  .story-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }

}

@media (max-width: 700px) {
  .app-shell { padding-left: 0; }
  .page { padding: 22px 14px 84px; }
  .topbar { min-height: 58px; padding: 8px 12px; }
  .page-heading { margin-bottom: 20px; }
  .page-heading h1 { font-size: 28px; }
  .story-grid,
  .story-grid.compact { grid-template-columns: 1fr; gap: 16px; }
  .story-cover,
  .story-grid.compact .story-cover { height: auto; aspect-ratio: 16 / 10; }
  .chat-header-actions { flex: 1; justify-content: flex-end; }
  .model-select { max-width: min(35vw, 126px); }
  .empty-chat { padding: 24px 18px; }
  .empty-chat-inner { margin-left: 0; }
  .empty-chat h2 { font-size: 30px; }
  .empty-chat p { font-size: 15px; }

}

/* Explore refinement: keep frequent choices visible and disclose the long tail. */
.explore-filters {
  display: grid;
  gap: 10px;
  margin-bottom: 26px;
}
.explore-primary-filters {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.explore-primary-filters .category-row,
.explore-more-panel .category-row { margin-bottom: 0; }
.explore-more-filters { min-width: 0; }
.explore-more-filters > summary {
  width: fit-content;
  min-height: var(--ws-control-height);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  list-style: none;
}
.explore-more-filters > summary::-webkit-details-marker { display: none; }
.explore-more-filters > summary:hover { color: var(--ink); }
.explore-more-filters > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.explore-more-filters > summary svg { width: 16px; height: 16px; }
.explore-more-filters > summary small {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10px;
}
.explore-more-panel {
  display: grid;
  grid-template-columns: minmax(220px, auto) minmax(0, 1fr);
  gap: 20px;
  margin-top: 9px;
  padding: 16px 0 2px;
  border-top: 1px solid var(--line);
}
.explore-more-panel fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.explore-more-panel legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

/* Cards foreground the world itself; operational metrics belong in details. */
.story-card .tag-list { min-height: 25px; }

.actionable-empty { grid-column: 1 / -1; }
.actionable-empty h2 { margin: 0; color: var(--ink); font-size: 18px; }
.actionable-empty p { max-width: 52ch; margin: 8px auto 18px; color: var(--muted); line-height: 1.65; }

/* The compact desktop rail still names the current destination. */
@media (min-width: 701px) and (max-width: 980px) {
  :root { --sidebar: 112px; }
  .sidebar .nav-button.active {
    justify-content: flex-start;
    gap: 7px;
    padding-inline: 10px;
  }
  .sidebar .nav-button.active span {
    min-width: 0;
    display: block;
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

}

@media (max-width: 700px) {
  .button,
  .icon-button,
  .chip,
  .segment,
  .model-select,
  .session-open,
  .session-actions .icon-button,
  .message-tools .icon-button,
  .explore-more-filters > summary { min-height: 44px; }
  .icon-button,
  .session-actions .icon-button,
  .message-tools .icon-button { width: 44px; }
  .button.small { min-height: 44px; }
  .explore-search { grid-template-columns: 20px minmax(0, 1fr) 44px; }
  .explore-search.has-clear { grid-template-columns: 20px minmax(0, 1fr) 44px 44px; }
  .explore-search input { height: 44px; }
  .explore-primary-filters { display: grid; gap: 8px; }
  .explore-primary-filters .ranking-tabs,
  .explore-primary-filters .category-row { width: 100%; }
  .explore-primary-filters .category-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
  .explore-more-panel { grid-template-columns: 1fr; gap: 16px; }
  .explore-more-panel .ranking-tabs { width: 100%; }
  .chat-header-actions { gap: 2px; }
  .chat-header-actions .model-select { max-width: 88px; }

}
.rail-close { margin-left: auto; }
.chat-header-actions { min-width: 0; }
.story-theme-toggle { white-space: nowrap; }
@media (max-width: 1200px) and (min-width: 701px) {
  .workspace-primary-tools .button,
  .story-theme-toggle { width: 38px; padding-inline: 0; }
  .workspace-primary-tools .button span,
  .story-theme-toggle span { display: none; }

}

@media (max-width: 700px) {
  .chat-header-actions { flex: none; margin-left: 0; }
  .chat-header-actions .model-select,
  .chat-header-actions .desktop-chat-action { display: none; }

}

/* Mod marketplace and immutable conversation attachments. */
.page-kicker {
  display: block;
  margin-bottom: 7px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 760;
}
.mod-page-heading h1 { font-size: 34px; }
.mod-tabs {
  display: flex;
  gap: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.mod-tabs .segment {
  min-height: 42px;
  padding: 0 3px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.mod-tabs .segment.active { border-bottom-color: var(--brand); color: var(--ink); }
.mod-view { min-width: 0; }
.mod-filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(130px, 180px) auto;
  gap: 10px;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.mod-search { position: relative; min-width: 0; }
.mod-search svg { position: absolute; left: 12px; top: 12px; width: 17px; color: var(--muted); }
.mod-search input,
.mod-filters select,
.mod-rating-control select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  outline: none;
}
.mod-search input { padding: 0 12px 0 39px; }
.mod-filters select,
.mod-rating-control select { padding: 0 34px 0 11px; }
.mod-search input:focus,
.mod-filters select:focus,
.mod-rating-control select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.mod-result-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 1px;
  color: var(--muted);
  font-size: 11px;
}
.mod-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.mod-card {
  min-width: 0;
  min-height: 315px;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color var(--ws-duration-fast) var(--ws-ease), transform var(--ws-duration-fast) var(--ws-ease);
}
.mod-card:hover { border-color: color-mix(in srgb, var(--brand) 46%, var(--line)); transform: translateY(-2px); }
.mod-card.installed { box-shadow: inset 3px 0 0 var(--brand); }
.mod-card-head,
.mod-card footer,
.mod-card-actions,
.mod-card-title,
.mod-creator-toolbar { display: flex; align-items: center; }
.mod-card-head { min-height: 23px; justify-content: space-between; gap: 10px; }
.mod-category,
.mod-status,
.mod-price {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 740;
}
.mod-category { background: var(--brand-soft); color: var(--brand); }
.mod-price { background: color-mix(in srgb, var(--amber) 17%, var(--surface)); color: color-mix(in srgb, var(--amber) 78%, var(--ink)); }
.mod-status { background: var(--surface-soft); color: var(--muted); }
.mod-status.published { background: var(--brand-soft); color: var(--brand); }
.mod-status.archived { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.mod-card-title {
  width: 100%;
  justify-content: space-between;
  gap: 10px;
  margin-top: 13px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.mod-card-title h2 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 17px; line-height: 1.4; }
.mod-card-title span { flex: none; color: var(--muted); font-family: var(--ws-font-mono); font-size: 10px; }
.mod-card > p {
  min-height: 44px;
  display: -webkit-box;
  margin: 8px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.75;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.mod-card .tag-list { min-height: 23px; max-height: 23px; overflow: hidden; }
.mod-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 0;
  padding: 12px 0;
  border-block: 1px solid var(--line);
}
.mod-card:has(.mod-status) .mod-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mod-metrics div { min-width: 0; }
.mod-metrics dt { color: var(--muted); font-size: 9px; }
.mod-metrics dd { margin: 3px 0 0; overflow: hidden; font-size: 11px; font-weight: 740; text-overflow: ellipsis; white-space: nowrap; }
.mod-card footer { justify-content: space-between; gap: 9px; margin-top: auto; padding-top: 13px; }
.mod-card footer > span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.mod-card-actions { flex: none; justify-content: flex-end; gap: 5px; }
.mod-card-actions .icon-button { width: 32px; min-height: 32px; }
.mod-card-actions .button.quiet { border-color: transparent; background: transparent; }
.mod-notice { display: flex; gap: 7px; margin-top: 10px; padding: 8px; border-radius: 6px; font-size: 10px; line-height: 1.5; }
.mod-notice svg { width: 15px; flex: none; }
.mod-notice.danger { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); }
.mod-creator-toolbar { justify-content: space-between; gap: 18px; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.mod-creator-toolbar > div { display: grid; gap: 3px; }
.mod-creator-toolbar span { color: var(--muted); font-size: 11px; }
.mod-creator-toolbar .mod-creator-tools { display: flex; align-items: center; }
.mod-purchase-summary { display: flex; justify-content: space-between; gap: 18px; padding: 14px 0; border-block: 1px solid var(--line); }
.mod-detail header { padding-right: 38px; }
.mod-detail header h2 { margin: 10px 0 7px; font-size: 26px; }
.mod-detail header p,
.mod-detail-description p,
.mod-changelog p { color: var(--muted); line-height: 1.75; }
.mod-detail-byline { display: flex; justify-content: space-between; gap: 15px; margin-top: 17px; padding: 11px 0; border-block: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.mod-detail-description p { white-space: pre-wrap; }
.mod-detail-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 18px 0 0; border-block: 1px solid var(--line); }
.mod-detail-stats div { padding: 13px 9px; border-right: 1px solid var(--line); }
.mod-detail-stats div:last-child { border-right: 0; }
.mod-detail-stats dt { color: var(--muted); font-size: 11px; }
.mod-detail-stats dd { margin: 4px 0 0; font-size: 17px; font-weight: 760; }
.mod-detail-stats dd small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-weight: 600; }
.mod-changelog { margin-top: 18px; }
.mod-changelog h3 { margin: 0; font-size: 17px; }
.mod-changelog p { margin: 5px 0 0; white-space: pre-wrap; }
.mod-reviews { margin-top: 22px; }
.mod-reviews-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.mod-reviews-heading h3 { margin: 0; font-size: 17px; }
.mod-reviews-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.mod-reviews-heading > strong { color: var(--brand); font-size: 25px; line-height: 1; }
.mod-reviews-heading > strong small { color: var(--muted); font-size: 12px; font-weight: 600; }
.mod-rating-control { display: grid; grid-template-columns: minmax(100px, 1fr) 110px auto; align-items: center; gap: 8px; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.mod-rating-control > span { font-size: 14px; font-weight: 740; }
.mod-rating-control textarea { grid-column: 1 / -1; width: 100%; min-height: 76px; resize: vertical; }
.mod-rating-control > div { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mod-review-count { color: var(--muted); font-size: 11px; }
.mod-review-list { margin-top: 14px; border-top: 1px solid var(--line); }
.mod-review { padding: 14px 0; border-bottom: 1px solid var(--line); }
.mod-review header { display: flex; align-items: baseline; gap: 8px; }
.mod-review header strong { font-size: 13px; }
.mod-review header span { color: var(--brand); font-size: 12px; font-weight: 740; }
.mod-review header time { margin-left: auto; color: var(--muted); font-size: 11px; }
.mod-review p { margin: 7px 0 0; white-space: pre-wrap; color: var(--text); font-size: 13px; line-height: 1.7; }
.mod-detail .modal-actions { align-items: center; }
.mod-detail-price { margin-right: auto; color: var(--muted); font-size: 14px; font-weight: 740; }
.modal:has(.mod-editor-workbench) { width: min(1160px, 100%); }
.mod-editor-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-right: 38px; }
.mod-editor-heading > div:first-child { min-width: 0; }
.mod-editor-heading h2 { overflow-wrap: anywhere; }
.mod-editor-heading p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.65; }
.mod-editor-heading > div:last-child { display: flex; flex: none; gap: 7px; }
.mod-editor-workbench { min-width: 0; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(340px, .92fr); gap: 24px; align-items: start; margin-top: 18px; }
.mod-editor-preview { min-width: 0; position: sticky; top: -1px; padding-left: 24px; border-left: 1px solid var(--line); }
.mod-editor .form-grid { margin-top: 0; }
.mod-form-error { margin-top: 14px; padding: 10px 11px; border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); border-radius: 6px; background: color-mix(in srgb, var(--danger) 9%, var(--surface)); color: var(--danger); font-size: 14px; line-height: 1.6; }
.mod-form-error .button { margin-left: 8px; }
.mod-editor .mod-prompt-field textarea { min-height: 250px; font-family: var(--ws-font-mono); font-size: 14px; }
.mod-prompt-field label { display: flex; justify-content: space-between; gap: 12px; }
.mod-prompt-field label span { color: var(--muted); font-family: var(--ws-font-mono); font-size: 11px; }
.mod-trial-dialog > header { padding-right: 38px; }
.mod-trial-dialog > header h2 { margin: 10px 0 5px; font-size: 26px; overflow-wrap: anywhere; }
.mod-trial-dialog > header p { margin: 0; color: var(--muted); font-size: 14px; }
.mod-preview { min-width: 0; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.mod-editor-preview .mod-preview { margin-top: 0; padding-top: 0; border-top: 0; }
.mod-preview-head { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.mod-preview-head > div { min-width: 0; display: grid; gap: 2px; }
.mod-preview-head span { color: var(--brand); font-size: 11px; font-weight: 760; }
.mod-preview-head h3 { margin: 0; overflow-wrap: anywhere; font-size: 17px; }
.mod-preview-settings { display: grid; grid-template-columns: minmax(150px, .8fr) minmax(180px, 1.2fr); gap: 9px; margin-top: 12px; }
.mod-preview-settings label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 720; }
.mod-preview-settings select,
.mod-preview-settings input,
.mod-preview-composer textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); outline: none; }
.mod-preview-settings select,
.mod-preview-settings input { min-height: 38px; padding: 0 9px; }
.mod-preview-settings select:focus,
.mod-preview-settings input:focus,
.mod-preview-composer textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent); }
.mod-preview-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 13px 0 0; border-block: 1px solid var(--line); background: var(--surface-soft); }
.mod-preview-metrics div { min-width: 0; padding: 9px 7px; border-right: 1px solid var(--line); }
.mod-preview-metrics div:last-child { border-right: 0; }
.mod-preview-metrics dt { color: var(--muted); font-size: 11px; }
.mod-preview-metrics dd { margin: 3px 0 0; overflow: hidden; font-family: var(--ws-font-mono); font-size: 11px; font-weight: 720; text-overflow: ellipsis; white-space: nowrap; }
.mod-preview-messages { min-height: 280px; max-height: min(390px, 42dvh); overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding: 13px 2px; scrollbar-gutter: stable; }
.mod-preview-empty { min-height: 250px; display: grid; place-items: center; padding: 24px; color: var(--muted); font-size: 11px; line-height: 1.65; text-align: center; }
.mod-preview-message { width: min(88%, 520px); margin: 0; }
.mod-preview-message.user { align-self: flex-end; }
.mod-preview-message header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; color: var(--muted); }
.mod-preview-message header > span { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand); }
.mod-preview-message header svg { width: 12px; height: 12px; }
.mod-preview-message header strong { color: var(--ink); font-size: 11px; }
.mod-preview-message header small { margin-left: auto; font-size: 11px; }
.mod-preview-message p { margin: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.mod-preview-message.user p { border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); background: var(--brand-soft); }
.mod-preview-pending { align-self: flex-start; padding: 8px 10px; color: var(--muted); font-size: 11px; }
.mod-preview-status { min-height: 16px; margin: 0 0 7px; color: var(--muted); font-size: 11px; }
.mod-preview-composer { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 8px; align-items: end; }
.mod-preview-composer textarea { min-height: 70px; max-height: 170px; padding: 9px 10px; resize: vertical; font-size: 14px; line-height: 1.55; }
.mod-preview-composer .icon-button { min-height: 38px; }
.mod-version-dialog > p { margin: 0 0 17px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.mod-version-loading,
.mod-version-empty { min-height: 180px; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.mod-version-list { border-top: 1px solid var(--line); }
.mod-version-row { min-width: 0; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.mod-version-row.current { box-shadow: inset 3px 0 0 var(--brand); padding-left: 10px; }
.mod-version-index { display: grid; gap: 3px; }
.mod-version-index strong { font-family: var(--ws-font-mono); font-size: 14px; }
.mod-version-index span { width: max-content; color: var(--brand); font-size: 11px; font-weight: 760; }
.mod-version-row > div:nth-child(2) { min-width: 0; }
.mod-version-row p { margin: 0; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.mod-version-row small { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-family: var(--ws-font-mono); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.mod-version-confirm { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.mod-version-confirm > div { min-width: 0; display: grid; gap: 3px; margin-right: auto; }
.mod-version-confirm strong { font-size: 14px; }
.mod-version-confirm span { color: var(--muted); font-size: 11px; }
.modal:has(.new-conversation-form) { max-height: 92vh; }
.conversation-mod-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.conversation-mod-picker legend { width: 100%; display: flex; justify-content: space-between; gap: 12px; margin-bottom: 7px; font-size: 12px; font-weight: 750; }
.conversation-mod-picker legend small { color: var(--muted); font-weight: 600; }
.conversation-mod-picker > p { margin: 0 0 9px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.conversation-mod-choice-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 7px; scrollbar-gutter: stable; }
.conversation-mod-choice { min-width: 0; display: grid; grid-template-columns: 18px 22px minmax(0, 1fr); align-items: center; gap: 8px; padding: 10px 11px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conversation-mod-choice:last-child { border-bottom: 0; }
.conversation-mod-choice:has(input:checked) { background: var(--brand-soft); }
.conversation-mod-choice input { width: 17px; height: 17px; accent-color: var(--brand); }
.conversation-mod-choice > span:last-child { min-width: 0; display: grid; gap: 3px; }
.conversation-mod-choice strong,
.conversation-mod-choice small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-mod-choice strong { font-size: 12px; }
.conversation-mod-choice small { color: var(--muted); font-size: 10px; }
.conversation-mod-order { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-soft); color: var(--brand); font-size: 10px; font-weight: 760; }
.conversation-mod-picker .empty-state.compact { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; text-align: left; }
.new-conversation-status { display: grid; justify-items: start; gap: 7px; min-height: 112px; align-content: center; color: var(--muted); }
.new-conversation-status strong { color: var(--text); font-size: 14px; }
.new-conversation-status.danger strong { color: var(--danger); }
.new-conversation-status .button { margin-top: 5px; }

@media (max-width: 1180px) {
  .mod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mod-filters { grid-template-columns: minmax(220px, 1fr) minmax(130px, 170px); }
  .mod-filters .ranking-tabs { grid-column: 1 / -1; width: max-content; }

}

@media (max-width: 980px) {
  .modal:has(.mod-editor-workbench) { width: min(760px, 100%); }
  .mod-editor-workbench { grid-template-columns: 1fr; }
  .mod-editor-preview { position: static; padding: 20px 0 0; border-top: 1px solid var(--line); border-left: 0; }

}

@media (max-width: 700px) {
  .mod-page-heading { align-items: stretch; flex-direction: column; }
  .mod-page-heading h1 { font-size: 28px; }
  .mod-page-heading > .button { width: 100%; }
  .mod-tabs { gap: 10px; overflow-x: auto; }
  .mod-tabs .segment { min-width: max-content; flex: 1; }
  .mod-filters { grid-template-columns: 1fr; }
  .mod-filters .ranking-tabs { grid-column: auto; width: 100%; }
  .mod-result-meta { display: grid; gap: 4px; }
  .mod-grid { grid-template-columns: 1fr; }
  .mod-card { min-height: 0; padding: 14px; }
  .mod-card:hover { transform: none; }
  .mod-card footer { align-items: flex-end; flex-direction: column; }
  .mod-card footer > span { width: 100%; }
  .mod-card-actions { width: 100%; flex-wrap: wrap; }
  .mod-card-actions .icon-button { width: 44px; min-height: 44px; }
  .mod-card-actions .button:not(.quiet) { flex: 1; }
  .mod-creator-toolbar { align-items: stretch; flex-direction: column; }
  .mod-creator-toolbar .mod-creator-tools .button { width: 100%; }
  .mod-detail header h2 { font-size: 26px; }
  .mod-detail-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mod-detail-stats div:nth-child(2) { border-right: 0; }
  .mod-detail-stats div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .mod-rating-control { grid-template-columns: 1fr auto; }
  .mod-rating-control > span { grid-column: 1 / -1; }
  .mod-detail .modal-actions { flex-wrap: wrap; }
  .mod-detail-price { width: 100%; margin: 0; }
  .mod-detail .modal-actions .button { flex: 1; }
  .mod-editor-heading { align-items: stretch; flex-direction: column; gap: 12px; padding-right: 30px; }
  .mod-editor-heading > div:last-child .button { flex: 1; }
  .mod-editor-workbench { gap: 18px; margin-top: 14px; }
  .mod-editor .mod-prompt-field textarea { min-height: 240px; }
  .mod-preview-settings { grid-template-columns: 1fr; }
  .mod-preview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mod-preview-metrics div { border-bottom: 1px solid var(--line); }
  .mod-preview-metrics div:nth-child(2n) { border-right: 0; }
  .mod-preview-metrics div:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .mod-preview-messages { min-height: 230px; max-height: 38dvh; }
  .mod-preview-empty { min-height: 200px; }
  .mod-preview-message { width: 94%; }
  .mod-preview-composer { grid-template-columns: minmax(0, 1fr) 44px; }
  .mod-preview-composer .icon-button { min-height: 44px; }
  .mod-version-row { grid-template-columns: 55px minmax(0, 1fr); }
  .mod-version-row > .button { grid-column: 2; width: 100%; }
  .mod-version-confirm { align-items: stretch; flex-wrap: wrap; }
  .mod-version-confirm > div { width: 100%; }
  .mod-version-confirm .button { flex: 1; }
  .conversation-mod-choice-list { max-height: min(210px, 27dvh); }
  .conversation-mod-picker .empty-state.compact { align-items: stretch; flex-direction: column; }
  .conversation-mod-picker .empty-state.compact .button { width: 100%; }

}

/* Author introduction uses the existing platform stylesheet loader. */
.story-introduction { min-height: 360px; height: 60vh; }
.story-introduction > [data-external-renderer-host] { height: 100%; }
