@font-face {
  font-family: Manrope;
  src: url("./assets/manrope-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --canvas: #151515;
  --text: #f5f5f7;
  --text-secondary: #b7b3bd;
  --text-muted: #a29aa9;
  --sidebar-width: 248px;
  --nav-inset: 16px;
  --session-width: 720px;
  --item-radius: 10px;
  --font-ui: Manrope, "PingFang SC", "Microsoft YaHei", sans-serif;
  /* Layers: shared canvas 0, application 1. No floating overlays in this phase. */
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--text);
  font: 14px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse 620px 540px at 70px 0, rgb(108 48 105 / 53%), transparent 76%),
    radial-gradient(ellipse 460px 360px at 290px 70px, rgb(67 41 89 / 22%), transparent 80%),
    var(--canvas);
  background-attachment: fixed;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}
button { cursor: pointer; }
img { display: block; }
[hidden] { display: none !important; }

.app-shell { min-height: 100dvh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }

.sidebar {
  height: 100dvh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgb(8 9 12 / 24%);
  box-shadow: inset -1px 0 rgb(255 255 255 / 2%);
}

.sidebar-header { flex-shrink: 0; padding: 36px 24px 0; }
.brand { display: flex; align-items: center; gap: 12px; height: 36px; }
.brand span { color: #fff; font-size: 25px; font-weight: 750; letter-spacing: -1.1px; }
.brand-mark { flex: 0 0 22px; }

.search {
  height: 44px;
  margin-top: 30px;
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 14px;
  background: rgb(255 255 255 / 6%);
}
.search:focus-within { background: rgb(255 255 255 / 9%); }
.search-icon { position: absolute; left: 13px; opacity: .8; pointer-events: none; }
.search input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 35px 0 40px;
  border: 0;
  border-radius: inherit;
  color: var(--text);
  background: transparent;
  font-size: 13px;
}
.search input:focus, .search input:focus-visible { outline: none; box-shadow: none; }
.search input::placeholder { color: var(--text-secondary); opacity: 1; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.clear-search {
  position: absolute;
  right: 0;
  width: 32px;
  height: 36px;
  display: grid;
  place-content: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  opacity: .7;
}
.clear-search:hover { opacity: 1; }

.sidebar-navigation {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  padding: 32px var(--nav-inset) 24px;
}
.sidebar-navigation::-webkit-scrollbar { width: 3px; }
.sidebar-navigation:hover { scrollbar-color: rgb(255 255 255 / 12%) transparent; }
.sidebar-navigation::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.sidebar-navigation:hover::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 12%); }
.nav-group + .nav-group { margin-top: 30px; }
.nav-group h2 {
  margin: 0 0 12px;
  padding: 0 13px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 1px;
}
.nav-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; margin: 0; padding: 0; list-style: none; }
.nav-list li { min-width: 0; }
.group-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; padding-right: 13px; }
.group-heading h2 { margin-bottom: 0; }
.history-all {
  padding: 4px 0 4px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 16px;
}
.history-all:hover { color: #fff; }
.nav-item {
  width: 100%;
  height: 44px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 13px;
  border: 0;
  border-radius: var(--item-radius);
  color: var(--text-secondary);
  background: transparent;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}
.selection-indicator {
  position: absolute;
  right: var(--nav-inset);
  top: 0;
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: #fff;
  pointer-events: none;
}
.nav-item img { width: 19px; height: 19px; flex: 0 0 19px; opacity: .6; filter: brightness(0) invert(1); }
.nav-icon { position: relative; display: block; flex: 0 0 19px; width: 19px; height: 19px; }
.nav-icon img { position: absolute; inset: 0; }
.nav-icon .icon-filled { opacity: 0; }
.nav-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover .icon-outline { opacity: 1; }
.nav-item.is-current .icon-outline { opacity: 0; }
.nav-item.is-current .icon-filled { opacity: 1; }
.history-list { gap: 4px; }
.history-item { height: 64px; gap: 10px; padding-right: 20px; font-size: 13px; font-weight: 400; }
.history-cover {
  display: block;
  flex: 0 0 32px;
  width: 32px;
  height: 48px;
  aspect-ratio: 2 / 3;
  border-radius: 5px;
  background: rgb(255 255 255 / 8%);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 5%);
}
.history-item:hover .history-cover, .history-item.is-current .history-cover { background: rgb(255 255 255 / 14%); }
.history-copy { display: flex; flex: 1; flex-direction: column; gap: 3px; }
.history-title { display: block; color: var(--text); font-size: 13px; line-height: 19px; font-weight: 600; }
.history-preview { display: block; color: var(--text-secondary); font-size: 12px; line-height: 18px; }
.search-empty { color: var(--text-secondary); margin: 0; padding: 0 13px; font-size: 13px; }
.history-list-status { margin: 8px 0 0; padding: 0 13px; color: var(--text-muted); font-size: 12px; line-height: 1.6; }

/* Structural placeholders are present in HTML, before any data or scripts arrive. */
.skeleton { position: relative; display: block; overflow: hidden; isolation: isolate; background: #302e33; border-radius: 5px; pointer-events: none; }
.skeleton::after { content: ''; position: absolute; inset: 0; z-index: 1; background: linear-gradient(105deg, transparent 20%, rgb(255 255 255 / 9%) 48%, transparent 76%); transform: translateX(-100%); animation: skeleton-sweep 1.8s ease-in-out infinite; }
.skeleton > img { opacity: 0; }
.history-cover.skeleton, .story-card-cover.skeleton { background: #302e33; }
.history-skeleton-row { display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 20px 0 13px; }
.history-skeleton-row .history-copy { gap: 8px; }
.skeleton-history-title { width: 82%; height: 12px; }
.skeleton-history-preview { width: 96%; height: 10px; }
.history-preview.skeleton-history-preview { margin-block: 4px; }
.history-skeleton:nth-child(even) .skeleton-history-title { width: 66%; }
.history-skeleton:nth-child(3) .skeleton-history-preview { width: 78%; }
.skeleton-featured-title { width: 88%; height: 35px; }
.skeleton-featured-description { width: 100%; height: 16px; margin-block: 6px; }
.home-view.is-loading .play-button > * { visibility: hidden; }
.home-view.is-loading .play-button { background: #302e33; }
.home-view.is-loading .carousel-arrow { visibility: hidden; }
.home-view[data-state="empty"] .home-hero, .home-view[data-state="error"] .home-hero { min-height: 180px; grid-template-columns: minmax(0, 1fr); }
.cover-placeholder { position: absolute; left: 50%; top: 47%; width: var(--cover-width); height: var(--cover-height); margin-left: calc(var(--cover-width) / -2); margin-top: calc(var(--cover-height) / -2); border-radius: 9px; }
.cover-placeholder:nth-child(1) { transform: translateX(-135%) scale(.9); opacity: .6; }
.cover-placeholder:nth-child(2) { transform: translateX(-76%) scale(.95); opacity: .8; z-index: 1; }
.cover-placeholder:nth-child(3) { z-index: 2; }
.cover-placeholder:nth-child(4) { transform: translateX(76%) scale(.95); opacity: .8; z-index: 1; }
.cover-placeholder:nth-child(5) { transform: translateX(135%) scale(.9); opacity: .6; }
.skeleton-story-title { width: 88%; height: 13px; margin-top: 14px; }
.skeleton-story-subtitle { width: 60%; height: 11px; margin-top: 9px; }
@keyframes skeleton-sweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; display: none; } }
@media (max-width: 767px) {
  .history-skeleton-row { justify-content: center; padding-inline: 0; }
  .history-list-status { padding-inline: 0; font-size: 10px; overflow-wrap: anywhere; text-align: center; }
}

.profile {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 20px 28px max(20px, env(safe-area-inset-bottom));
  background: rgb(11 11 14 / 40%);
  box-shadow: inset 0 1px rgb(255 255 255 / 5%);
}
.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #39333f;
  color: #eee9f1;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 12%);
  font-size: 15px;
  font-weight: 600;
}
.nickname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; }
.workspace { min-width: 0; min-height: 100dvh; }
.chat-view { position: sticky; top: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; min-width: 0; overflow: clip; }
.chat-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 68px; padding: 10px 32px; }
.chat-identity { display: flex; align-items: center; flex: 1; min-width: 0; gap: 12px; }
.chat-identity > img { flex: 0 0 32px; width: 32px; height: 48px; object-fit: cover; border-radius: 5px; }
.chat-identity h1 { margin: 0; overflow: hidden; color: var(--text); font-size: 17px; line-height: 1.4; font-weight: 650; letter-spacing: -.35px; white-space: nowrap; text-overflow: ellipsis; }
.chat-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 10px; }
.model-picker { position: relative; display: inline-flex; align-items: center; height: 40px; gap: 8px; padding: 0 12px; border-radius: 10px; background: rgb(255 255 255 / 5%); }
.model-picker > img { flex-shrink: 0; opacity: .85; pointer-events: none; }
.model-picker select { max-width: 150px; padding: 0 17px 0 0; border: 0; border-radius: 3px; appearance: none; background: transparent; color: var(--text); font: 600 13px/40px var(--font-ui); cursor: pointer; }
.model-picker select:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.model-picker option { background: #242127; color: var(--text); }
.model-picker .model-caret { position: absolute; right: 12px; }
.chat-icon-button { display: grid; place-items: center; width: 38px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; }
.chat-icon-button:hover, .chat-icon-button[aria-expanded="true"] { background: rgb(255 255 255 / 6%); }
.chat-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 12%) transparent; }
.chat-scroll:focus-visible { outline: 1px solid rgb(255 255 255 / 25%); outline-offset: -1px; }
.chat-messages { width: min(var(--session-width), calc(100% - 64px)); margin: 0 auto; padding: 36px 0 22px; }
.chat-message + .chat-message { margin-top: 28px; }
.message-author { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; color: var(--text); font-size: 12px; font-weight: 650; }
.message-author > img { flex: 0 0 16px; width: 16px; height: 16px; }
.message-body { color: #d6d2da; font-size: 15px; line-height: 1.85; overflow-wrap: anywhere; }
.message-body p { margin: 0; white-space: pre-wrap; }
.message-body p + p { margin-top: 14px; }
.message-user { width: fit-content; max-width: 86%; margin-left: auto; padding: 13px 18px; border-radius: 18px 18px 4px 18px; background: rgb(255 255 255 / 7%); }
.message-user .message-body { color: var(--text); font-size: 14px; line-height: 1.7; }
.chat-message.is-editing { width: 100%; max-width: 100%; }
.message-inline-editor { display: grid; gap: 12px; min-width: 0; }
.message-inline-editor textarea { box-sizing: border-box; width: 100%; min-height: 160px; max-height: min(440px, 40dvh); overflow-y: auto; resize: vertical; padding: 16px 18px; border: 1px solid #655670; border-radius: 12px; background: #242028; color: #eee8f3; font: 14px/1.8 var(--font-ui); scrollbar-width: thin; }
.message-inline-editor textarea:focus { outline: 1px solid #b5a1c8; border-color: #b5a1c8; }
.message-edit-toolbar { display: flex; align-items: center; gap: 10px; }
.message-edit-count { flex: 1; color: #a99bb2; font-size: 11px; }
.message-edit-count.is-over-limit { color: #efa6b5; }
.message-edit-help { margin: 0; color: #a99bb2; font-size: 11px; line-height: 1.6; }
.message-edit-toolbar button { padding: 9px 18px; border: 1px solid #5a4d63; border-radius: 22px; background: transparent; color: #d8ccdf; font-size: 12px; font-weight: 600; }
.message-edit-toolbar .message-edit-save { color: #251e2a; background: #ece3f4; border-color: #ece3f4; }
.message-edit-toolbar button:hover { filter: brightness(1.12); }
.message-edit-toolbar button:disabled, .message-inline-editor textarea:disabled { opacity: .5; cursor: default; }
.message-edit-feedback { margin: 0; color: #b6a5c2; font-size: 12px; line-height: 1.6; }
.message-edit-feedback.is-error { color: #efabb9; }
.composer-dock { position: relative; padding: 18px 0 max(20px, env(safe-area-inset-bottom)); }
.chat-bottom-controls { position: absolute; inset: auto 0 calc(100% + 12px); width: min(var(--session-width), calc(100% - 64px)); margin-inline: auto; display: flex; justify-content: flex-end; pointer-events: none; }
.chat-jump-bottom { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid rgb(255 255 255 / 14%); border-radius: 50%; color: var(--text-secondary); background: #27252b; box-shadow: 0 4px 14px rgb(0 0 0 / 20%); pointer-events: auto; transform: translateX(52px); }
.chat-jump-bottom[hidden] { display: none; }
.chat-jump-bottom:hover { color: var(--text); background: #35323a; }
.chat-jump-bottom:focus-visible { outline: 2px solid rgb(255 255 255 / 50%); outline-offset: 3px; }
@media (max-width: 1100px) { .chat-jump-bottom { transform: none; } }
.message-form { position: relative; display: flex; flex-direction: column; gap: 8px; width: min(var(--session-width), calc(100% - 64px)); min-height: 112px; margin: 0 auto; padding: 12px 12px 10px 16px; border: 1px solid rgb(255 255 255 / 10%); border-radius: 18px; background: rgb(255 255 255 / 5%); }
.message-form:focus-within { border-color: rgb(255 255 255 / 45%); }
.message-form textarea { width: 100%; min-width: 0; min-height: 44px; max-height: 160px; padding: 4px 2px; border: 0; outline: none; resize: none; background: transparent; color: var(--text); font: 15px/1.75 var(--font-ui); scrollbar-width: thin; }
.message-form textarea::placeholder { color: #a19aa8; opacity: 1; }
.composer-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer-tools { display: flex; align-items: center; gap: 10px; }
.composer-tool { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); transition: background .15s, color .15s; }
.composer-tool > img { opacity: .65; }
.composer-tools > .composer-tool { width: 30px; height: 30px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 50%; background: rgb(0 0 0 / 14%); transition: border-color .15s, background .15s; }
.composer-tools > .composer-tool > img { opacity: .8; }
.composer-tools > .composer-tool:hover:not(:disabled), .composer-tools > .composer-tool[aria-expanded="true"] { border-color: rgb(255 255 255 / 42%); background: rgb(255 255 255 / 6%); }
.composer-tools > .composer-tool[aria-pressed="true"] { border-color: rgb(255 255 255 / 65%); background: rgb(255 255 255 / 12%); }
.composer-tools > .composer-tool[aria-pressed="true"] > img { opacity: 1; }
.composer-tools > .composer-tool[aria-busy="true"] { border-style: dashed; }
.composer-tool:hover:not(:disabled), .composer-tool[aria-expanded="true"] { background: rgb(255 255 255 / 7%); color: #fff; }
.composer-tool:hover:not(:disabled) > img { opacity: 1; }
.composer-tool:active:not(:disabled) { transform: translateY(1px); }
.composer-tool:disabled { opacity: .3; cursor: default; }
.composer-commands { position: absolute; z-index: 4; bottom: calc(100% + 10px); left: 0; width: min(420px, 100%); max-height: min(360px, 55dvh); display: flex; flex-direction: column; padding: 8px; border: 1px solid rgb(255 255 255 / 12%); border-radius: 14px; background: #242127; box-shadow: 0 12px 36px rgb(0 0 0 / 30%); }
.composer-commands-header { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; padding: 2px 4px 6px 10px; }
.composer-commands-header h2 { margin: 0; color: var(--text); font-size: 13px; font-weight: 650; }
.composer-command-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.composer-command { display: grid; gap: 4px; width: 100%; padding: 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; }
.composer-command:hover, .composer-command:focus-visible { background: rgb(255 255 255 / 7%); }
.composer-command-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.composer-command-description { color: var(--text-secondary); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.composer-commands-empty { margin: 8px 10px 16px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.composer-commands-help { flex-shrink: 0; margin: 6px 10px 4px; padding-top: 10px; border-top: 1px solid rgb(255 255 255 / 7%); color: var(--text-muted); font-size: 11px; line-height: 1.6; }
.send-message { display: grid; flex: 0 0 36px; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: #f5f5f7; }
.send-message:hover:not(:disabled) { background: #dedbe3; }
.send-message:disabled { cursor: default; background: rgb(255 255 255 / 9%); }
.send-message:disabled > img { filter: invert(1); opacity: .3; }
.send-message.is-generating > img { display: none; }
.send-message.is-generating::after { content: ''; width: 12px; height: 12px; border-radius: 2px; background: #242127; }
.send-message.is-generating:disabled::after { background: var(--text-secondary); opacity: .5; }
.composer-hint { width: min(var(--session-width), calc(100% - 64px)); margin: 11px auto 0; color: var(--text-muted); font-size: 10px; line-height: 16px; text-align: center; }
.composer-hint span { margin-inline: 6px; }
.home-view { max-width: 1440px; margin-inline: auto; padding: 64px 48px; }
.home-hero { display: grid; grid-template-columns: minmax(230px, .85fr) minmax(0, 1.6fr); align-items: center; gap: 50px; min-height: 430px; }
.hero-copy { position: relative; min-width: 0; padding-bottom: 12px; }
.hero-copy h1 { max-width: 100%; margin: 0; overflow: hidden; color: var(--text); font-size: 28px; line-height: 1.25; letter-spacing: -.8px; font-weight: 650; white-space: nowrap; text-overflow: ellipsis; }
.hero-copy > p { max-width: 100%; margin: 18px 0 28px; overflow: hidden; color: var(--text-secondary); font-size: 16px; line-height: 1.7; white-space: nowrap; text-overflow: ellipsis; }
.play-button { display: inline-flex; min-width: 146px; height: 50px; align-items: center; justify-content: center; gap: 10px; padding: 0 28px; border: 0; border-radius: 999px; background: #fff; color: #151515; font-size: 14px; font-weight: 750; white-space: nowrap; }
.play-button:hover { background: #e4e2e8; }
.play-button:active { transform: scale(.98); }
.cover-carousel { --cover-width: 180px; --cover-height: 270px; position: relative; width: 100%; height: 430px; min-width: 0; outline-offset: -2px; }
.cover-carousel:focus-visible { outline: 2px solid rgb(255 255 255 / 50%); border-radius: 14px; }
.cover-stage { position: absolute; inset: 0 -24px; overflow: visible; isolation: isolate; }
.cover-ring { position: absolute; inset: 0; overflow: visible; isolation: isolate; }
.cover-card { position: absolute; left: 50%; top: 47%; width: var(--cover-width); height: var(--cover-height); margin-left: calc(var(--cover-width) / -2); margin-top: calc(var(--cover-height) / -2); padding: 0; border: 0; border-radius: 9px; background: #242226; backface-visibility: hidden; box-shadow: -18px 0 24px -10px rgb(0 0 0 / 82%), 18px 0 24px -10px rgb(0 0 0 / 82%), 0 8px 18px rgb(0 0 0 / 30%); -webkit-tap-highlight-color: transparent; }
.cover-card > img { display: block; width: 100%; height: 100%; object-fit: cover; aspect-ratio: 2 / 3; border-radius: inherit; pointer-events: none; }
.cover-shade { position: absolute; inset: 0; border-radius: inherit; background: #0b0b0e; pointer-events: none; }
.carousel-arrow { position: absolute; z-index: 1; top: 47%; display: grid; place-items: center; width: 42px; height: 42px; padding: 0; margin-top: -21px; border: 1px solid rgb(255 255 255 / 13%); border-radius: 50%; background: rgb(27 26 30 / 80%); backdrop-filter: blur(12px); opacity: 0; pointer-events: none; }
.carousel-previous { left: 0; }
.carousel-next { right: 0; }
.cover-carousel:hover .carousel-arrow, .cover-carousel:focus-within .carousel-arrow { opacity: 1; pointer-events: auto; }
.carousel-arrow:hover { background: #444047; }
.carousel-arrow:active { transform: scale(.94); }
.story-library { margin-top: 16px; min-width: 0; }
.story-filters { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; padding: 4px 3px 12px; overflow-x: auto; scrollbar-width: none; }
.story-filters::-webkit-scrollbar { display: none; }
.genre-filter { flex: 0 0 auto; min-height: 38px; padding: 8px 19px; border: 0; border-radius: 999px; background: rgb(255 255 255 / 6%); color: var(--text-secondary); font-size: 13px; line-height: 22px; font-weight: 600; white-space: nowrap; }
.genre-filter:hover { background: rgb(255 255 255 / 10%); color: var(--text); }
.genre-filter.is-selected { background: #f5f5f7; color: #151515; }
.genre-filter.is-selected:hover { background: #e3e1e7; }
.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); column-gap: 22px; row-gap: 28px; margin: 0; padding: 0; list-style: none; }
.story-grid > li { min-width: 0; }
.story-card { display: block; width: 100%; padding: 0; border: 0; border-radius: 12px; background: transparent; color: var(--text); text-align: left; }
.story-card-cover { display: block; width: 100%; aspect-ratio: 2 / 3; border-radius: 12px; background: #232125; }
.story-card-cover > img { display: block; width: 100%; height: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: inherit; }
.story-card-title { display: -webkit-box; height: 40px; margin-top: 12px; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: var(--text); font-size: 16px; line-height: 20px; font-weight: 700; text-overflow: ellipsis; overflow-wrap: anywhere; }
.story-card:hover .story-card-cover, .story-card:focus-visible .story-card-cover { box-shadow: 0 0 12px rgb(227 220 244 / 16%); }
.story-grid-empty { padding-block: 32px; color: var(--text-secondary); font-size: 14px; }
.story-preview { position: fixed; max-width: min(680px, calc(100vw - 40px)); width: 680px; padding: 28px; border: 1px solid rgb(255 255 255 / 10%); border-radius: 22px; background: #1c1a20; color: var(--text); box-shadow: 0 30px 100px rgb(0 0 0 / 45%); }
.story-preview[open] { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 28px; }
.story-preview::backdrop { background: rgb(6 5 9 / 78%); backdrop-filter: blur(8px); }
.preview-cover { width: 180px; height: 270px; object-fit: cover; border-radius: 10px; }
.preview-close { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: rgb(255 255 255 / 6%); }
.preview-close:hover { background: rgb(255 255 255 / 12%); }
.preview-label { margin: 0 0 12px; color: var(--text-secondary); font-size: 12px; }
.preview-copy h2 { margin: 0 0 18px; font-size: 25px; line-height: 1.25; letter-spacing: -.6px; }
.preview-copy > p:last-child { margin: 0; color: var(--text-secondary); font-size: 14px; line-height: 1.8; }
.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 (prefers-reduced-motion: no-preference) {
  .nav-item img, .history-cover, .history-all, .search, .clear-search {
    transition: opacity 160ms ease, background-color 160ms ease, color 160ms ease, transform 180ms cubic-bezier(.2,.8,.2,1);
  }
  .carousel-arrow, .play-button { transition: opacity 180ms ease, background-color 180ms ease, transform 180ms ease; }
  .genre-filter { transition: background-color 160ms ease, color 160ms ease; }
  .story-card-cover { transition: box-shadow 150ms ease, transform 150ms cubic-bezier(.2,.8,.2,1); }
  .story-card:hover .story-card-cover, .story-card:focus-visible .story-card-cover { transform: translateY(0px); }
}

@media (max-width: 1199px) {
  .home-view { padding: 48px 32px; }
  .home-hero { grid-template-columns: minmax(215px, .85fr) minmax(0, 1.2fr); gap: 12px; }
  .hero-copy h1 { font-size: 28px; }
}

@media (max-width: 900px) {
  .home-view { padding: 40px 28px; }
  .home-hero { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .hero-copy { max-width: 460px; }
  .hero-copy h1 { max-width: 100%; font-size: 28px; }
  .hero-copy > p { min-height: 0; margin-top: 18px; margin-bottom: 24px; }
  .cover-carousel { height: 360px; }
}

@media (hover: none) {
  .carousel-arrow { opacity: 1; pointer-events: auto; }
  .genre-filter { min-height: 44px; }
}

@media (max-width: 600px) {
  :root { --sidebar-width: 224px; --nav-inset: 12px; }
  body { background-size: auto; }
  .sidebar-header { padding: 28px 20px 0; }
  .profile { padding-right: 24px; padding-left: 24px; }
  .home-view { padding: 32px 18px; }
  .hero-copy h1 { font-size: 24px; letter-spacing: -.6px; }
  .hero-copy > p { font-size: 15px; }
  .play-button { min-width: 112px; padding-inline: 20px; }
  .cover-carousel { height: 280px; }
  .story-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); column-gap: 16px; row-gap: 24px; }
  .story-filters { gap: 8px; }
  .genre-filter { padding-inline: 16px; }
  .story-preview[open] { grid-template-columns: 1fr; padding: 24px; }
  .preview-cover { width: 100px; height: 150px; }
  .chat-header { flex-wrap: wrap; gap: 12px; padding: 16px; }
  .chat-identity { flex-basis: 100%; }
  .chat-actions { margin-left: auto; }
  .chat-messages, .message-form, .composer-hint, .chat-bottom-controls { width: calc(100% - 32px); }
  .chat-messages { padding-top: 24px; }
  .message-body { font-size: 14px; }
  .message-user { max-width: 92%; padding-inline: 14px; }
  .composer-dock { padding-top: 12px; }
  .message-form { gap: 8px; padding-left: 14px; }
  .composer-hint { font-size: 9px; }
}

@media (max-width: 767px) {
  :root { --sidebar-width: 72px; --nav-inset: 12px; }
  .sidebar-header { padding: 28px 12px 0; }
  .brand { justify-content: center; gap: 0; }
  .brand > span, .nickname, .nav-item > span:not(.nav-icon):not(.history-cover), .history-copy { display: none; }
  .search { margin-top: 24px; }
  .search input { padding: 0; color: transparent; }
  .search input::placeholder { color: transparent; }
  .search:focus-within { width: 200px; background: #352b3b; z-index: 1; }
  .search:focus-within input { padding-left: 40px; padding-right: 35px; color: var(--text); }
  .search:focus-within input::placeholder { color: var(--text-secondary); }
  .clear-search { right: 0; }
  .sidebar-navigation { padding-top: 28px; }
  .nav-item { justify-content: center; padding-inline: 0; }
  .nav-group h2 { padding-inline: 0; text-align: center; font-size: 8px; letter-spacing: .5px; }
  .group-heading { display: block; padding-right: 0; }
  .history-all { display: block; width: 100%; padding: 4px 0; }
  .profile { justify-content: center; padding-inline: 0; }
}

@media (max-height: 650px) {
  .sidebar-header { padding-top: 24px; }
  .search { margin-top: 22px; }
  .sidebar-navigation { padding-top: 24px; }
  .nav-group + .nav-group { margin-top: 24px; }
  .profile { min-height: 76px; padding-top: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-transparency: reduce) {
  .sidebar { background: #1b171e; }
  .profile { background: #151417; }
  .search { background: #39313d; }
}
