/* ============================================================
   梦泽 · AI 创作台 — stylesheet
   ============================================================ */

:root {
  --bg: #08080b;
  --bg-deep: #050507;
  --surface: #121217;
  --surface-2: #17171d;
  --surface-3: #1d1d24;
  --haze-rgb: 255, 255, 255;
  --bg-rgb: 8, 8, 11;
  --line: rgba(var(--haze-rgb), 0.075);
  --line-strong: rgba(var(--haze-rgb), 0.13);
  --ink: #f1ede4;
  --ink-2: #b6b2a8;
  --ink-3: #807d75;
  --ink-4: #5a5852;
  --acc: #e2643f;
  --acc-bright: #f0805a;
  --acc-soft: rgba(226, 100, 63, 0.12);
  --acc-line: rgba(226, 100, 63, 0.38);
  --gold: #d8b98c;
  --ok: #74c3a0;
  --danger: #e06a6a;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "HarmonyOS Sans SC", "MiSans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong",
    "SimSun", Georgia, serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --app-w: 470px;
  --ease: cubic-bezier(0.22, 0.9, 0.3, 1);
  --radius: 20px;
  --page-veil-top: rgba(8, 8, 11, 0.5);
  --page-veil-bottom: rgba(8, 8, 11, 0.78);
  --reader-veil-top: rgba(8, 8, 11, 0.7);
  --reader-veil-bottom: rgba(8, 8, 11, 0.87);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

input,
textarea,
select {
  -webkit-appearance: none;
  appearance: none;
}

::selection {
  background: rgba(226, 100, 63, 0.32);
  color: #fff;
}

/* ambient page light */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(90% 60% at 82% -12%, rgba(226, 100, 63, 0.14), transparent 62%),
    radial-gradient(70% 50% at -10% 108%, rgba(120, 140, 190, 0.07), transparent 60%),
    radial-gradient(50% 40% at 50% 50%, rgba(var(--haze-rgb), 0.015), transparent 70%);
  z-index: 0;
}
.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.038;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.78' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

/* app frame */
.app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--app-w);
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 55% at 78% -8%, rgba(226, 100, 63, 0.075), transparent 55%),
    linear-gradient(180deg, #0b0b0f 0%, #08080b 55%, #070709 100%);
  overflow: hidden;
}

@media (min-width: 560px) {
  .ambient {
    background:
      radial-gradient(55% 55% at 78% 2%, rgba(226, 100, 63, 0.12), transparent 60%),
      radial-gradient(45% 50% at 18% 100%, rgba(110, 135, 190, 0.07), transparent 65%),
      #050506;
  }
  .app {
    border-left: 1px solid rgba(var(--haze-rgb), 0.06);
    border-right: 1px solid rgba(var(--haze-rgb), 0.06);
    box-shadow: 0 30px 120px -30px rgba(0, 0, 0, 0.9);
  }
}

.view {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  animation: screenIn 0.32s var(--ease);
}

@keyframes screenIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* scroll areas */
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 4px 18px 122px;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--haze-rgb), 0.14) transparent;
}
.scroll::-webkit-scrollbar {
  width: 4px;
}
.scroll::-webkit-scrollbar-thumb {
  background: rgba(var(--haze-rgb), 0.12);
  border-radius: 4px;
}

/* ---------------- tab bar ---------------- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 26px), calc(var(--app-w) - 26px));
  height: 64px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  padding: 6px;
  border-radius: 22px;
  background: rgba(20, 20, 26, 0.78);
  border: 1px solid rgba(var(--haze-rgb), 0.085);
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(var(--haze-rgb), 0.05);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  z-index: 40;
  transition: transform 0.32s var(--ease), opacity 0.25s ease;
}
body.immersive .tabbar {
  transform: translate(-50%, 140%);
  opacity: 0;
  pointer-events: none;
}
.tabbar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 16px;
  color: var(--ink-4);
  transition: color 0.2s ease, background 0.2s ease;
  position: relative;
}
.tabbar button svg {
  width: 21px;
  height: 21px;
}
.tabbar button span {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.tabbar button.active {
  color: var(--acc-bright);
  background: linear-gradient(180deg, rgba(226, 100, 63, 0.13), rgba(226, 100, 63, 0.04));
}
.tabbar button.active::before {
  content: "";
  position: absolute;
  top: 4px;
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--acc);
  box-shadow: 0 0 10px rgba(226, 100, 63, 0.8);
  opacity: 0;
}
.tabbar button:active {
  transform: scale(0.96);
}

/* ---------------- headers ---------------- */
.app-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: max(22px, env(safe-area-inset-top)) 20px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 14px;
  font-family: var(--font-serif);
  font-size: 23px;
  color: var(--ink);
  background:
    radial-gradient(90% 90% at 25% 12%, rgba(226, 100, 63, 0.26), transparent 60%),
    linear-gradient(160deg, #1b1a20, #0e0e12);
  border: 1px solid rgba(var(--haze-rgb), 0.1);
  box-shadow: inset 0 1px 0 rgba(var(--haze-rgb), 0.08), 0 8px 24px -14px #000;
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 10px;
  border: 1px solid rgba(226, 100, 63, 0.3);
  pointer-events: none;
}
.brand-txt {
  min-width: 0;
}
.brand h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.2;
}
.brand p {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
}

.view-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0.94), rgba(var(--bg-rgb), 0.55) 80%, transparent);
  position: relative;
  z-index: 5;
}
.view-header .head-title {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.view-header .head-title h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.view-header .head-title p {
  margin: 2px 0 0;
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.view-header > .icon-btn:first-child {
  margin-left: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-grid;
  place-items: center;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.035);
  color: var(--ink-2);
  transition: all 0.18s ease;
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}
.icon-btn:active {
  transform: scale(0.94);
  background: rgba(var(--haze-rgb), 0.07);
}
.icon-btn.accent {
  color: var(--acc-bright);
  border-color: var(--acc-line);
  background: var(--acc-soft);
}
.icon-btn.sm {
  width: 32px;
  height: 32px;
  border-radius: 11px;
}
.icon-btn.sm svg {
  width: 15px;
  height: 15px;
}

/* ---------------- generic ui ---------------- */
.pad {
  padding-left: 20px;
  padding-right: 20px;
}
.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 2px 10px;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  text-transform: uppercase;
}
.section-label .count {
  letter-spacing: 0.04em;
  color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
  order: 2;
  margin-left: 4px;
}
.section-label .count {
  order: 3;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px;
  border-radius: 15px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
  white-space: nowrap;
}
.btn svg {
  width: 17px;
  height: 17px;
}
.btn:active {
  transform: scale(0.975);
}
.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}
.btn-primary {
  color: #24100a;
  background: linear-gradient(180deg, #ef8358 0%, #e2643f 55%, #d75834 100%);
  box-shadow: 0 12px 30px -14px rgba(226, 100, 63, 0.75), inset 0 1px 0 rgba(var(--haze-rgb), 0.32);
}
.btn-primary:active {
  filter: brightness(0.96);
}
.btn-ghost {
  color: var(--ink);
  background: rgba(var(--haze-rgb), 0.045);
  border-color: var(--line-strong);
}
.btn-quiet {
  color: var(--ink-2);
  background: transparent;
  border-color: var(--line);
}
.btn-danger {
  color: #200b0b;
  background: linear-gradient(180deg, #ea8a8a, #dc6868);
}
.btn-block {
  width: 100%;
}
.btn-sm {
  height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 33px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.035);
  color: var(--ink-2);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  transition: all 0.18s ease;
  white-space: nowrap;
}
.chip:active {
  transform: scale(0.96);
}
.chip.on {
  color: #f4c3b0;
  background: rgba(226, 100, 63, 0.13);
  border-color: rgba(226, 100, 63, 0.42);
  box-shadow: inset 0 0 0 1px rgba(226, 100, 63, 0.08);
}
.chip svg {
  width: 14px;
  height: 14px;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 30px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 30px), transparent 100%);
}
.chip-scroll::-webkit-scrollbar {
  display: none;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.04);
  color: var(--ink-2);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}
.model-chip .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px rgba(116, 195, 160, 0.6);
  flex: none;
}
.model-chip .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 150px;
}
.model-chip svg {
  width: 12px;
  height: 12px;
  opacity: 0.6;
}
.model-chip:active {
  background: rgba(var(--haze-rgb), 0.07);
}

.field {
  margin-bottom: 15px;
}
.field:last-child {
  margin-bottom: 0;
}
.field > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 2px 7px;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}
.field > label .hint {
  letter-spacing: 0;
  color: var(--ink-4);
  font-size: 11px;
}
.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.035);
  color: var(--ink);
  border-radius: 13px;
  padding: 12px 13px;
  font-size: 14.5px;
  line-height: 1.55;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--ink-4);
}
.input:focus,
.textarea:focus {
  border-color: rgba(226, 100, 63, 0.45);
  background: rgba(var(--haze-rgb), 0.05);
  box-shadow: 0 0 0 3px rgba(226, 100, 63, 0.07);
}
.textarea {
  resize: vertical;
  min-height: 88px;
}
.textarea.tall {
  min-height: 120px;
}
.select {
  color-scheme: dark;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23807d75' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-row .input {
  flex: 1;
  min-width: 0;
}

.card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(var(--haze-rgb), 0.035), rgba(var(--haze-rgb), 0.012));
  overflow: hidden;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.muted {
  color: var(--ink-3);
}
.faint {
  color: var(--ink-4);
}
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
.nowrap {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hidden {
  display: none !important;
}
.spin {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* empty states */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 54px 20px 30px;
}
.empty .glyph {
  width: 76px;
  height: 76px;
  border-radius: 26px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  font-family: var(--font-serif);
  font-size: 32px;
  color: var(--gold);
  background:
    radial-gradient(100% 100% at 25% 10%, rgba(226, 100, 63, 0.16), transparent 65%),
    linear-gradient(160deg, #17161b, #0d0d11);
  border: 1px solid rgba(var(--haze-rgb), 0.08);
  box-shadow: inset 0 1px 0 rgba(var(--haze-rgb), 0.06), 0 16px 40px -24px #000;
  position: relative;
}
.empty .glyph::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 18px;
  border: 1px solid rgba(216, 185, 140, 0.14);
}
.empty h3 {
  margin: 0 0 7px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink);
}
.empty p {
  margin: 0 0 20px;
  max-width: 272px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-3);
}
.empty .btn {
  height: 42px;
  font-size: 13.5px;
  padding: 0 20px;
}

/* notice */
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(226, 100, 63, 0.22);
  background: rgba(226, 100, 63, 0.07);
  color: #e8b8a4;
  font-size: 12.5px;
  line-height: 1.65;
  margin: 12px 0;
}
.notice svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
  color: var(--acc-bright);
}
.notice.dim {
  border-color: var(--line);
  background: rgba(var(--haze-rgb), 0.025);
  color: var(--ink-3);
}
.notice.dim svg {
  color: var(--ink-3);
}
.link-btn {
  color: var(--gold);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(216, 185, 140, 0.4);
  padding: 0 1px;
}

/* ---------------- chat: list ---------------- */
.conv-list {
  display: flex;
  flex-direction: column;
}
.conv-row {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 10px;
  margin: 0 -10px;
  border-radius: 16px;
  border-bottom: 1px solid rgba(var(--haze-rgb), 0.05);
  transition: background 0.16s ease;
  text-align: left;
}
.conv-row:last-child {
  border-bottom: 0;
}
.conv-row:active {
  background: rgba(var(--haze-rgb), 0.045);
}
.conv-avatar {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 15px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 19px;
  color: #f6ecdd;
  border: 1px solid rgba(var(--haze-rgb), 0.1);
  background:
    radial-gradient(90% 90% at 20% 0%, rgba(var(--haze-rgb), 0.18), transparent 55%),
    linear-gradient(150deg, hsl(var(--hue, 24) 45% 30%), hsl(calc(var(--hue, 24) + 40) 35% 14%));
  box-shadow: inset 0 1px 0 rgba(var(--haze-rgb), 0.12);
  position: relative;
  overflow: hidden;
}
.conv-avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, transparent 40%, rgba(0, 0, 0, 0.28));
}
.conv-main {
  flex: 1;
  min-width: 0;
}
.conv-title {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-snippet {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-meta {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}
.conv-meta time {
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.02em;
}
.conv-tag {
  font-size: 9.5px;
  letter-spacing: 0.04em;
  color: var(--ink-4);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(var(--haze-rgb), 0.07);
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-note {
  margin: 6px 0 22px;
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink-2);
  letter-spacing: 0.03em;
}
.hero-note em {
  font-style: normal;
  color: var(--gold);
}

/* ---------------- page background photo ---------------- */
.screen.has-bg {
  position: relative;
  background: var(--bg);
}
.page-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
}
.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    var(--page-veil-top) 0%,
    var(--page-veil-bottom) 60%,
    var(--page-veil-bottom) 100%
  );
}
.reader-screen .page-bg::after {
  background: linear-gradient(
    180deg,
    var(--reader-veil-top) 0%,
    var(--reader-veil-bottom) 55%,
    var(--reader-veil-bottom) 100%
  );
}
.chat-screen.has-bg > *:not(.page-bg),
.reader-screen.has-bg > *:not(.page-bg) {
  position: relative;
  z-index: 1;
}

/* ---------------- chat: thread ---------------- */
.chat-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.chat-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: max(12px, env(safe-area-inset-top)) 12px 9px;
  border-bottom: 1px solid rgba(var(--haze-rgb), 0.045);
  background: rgba(var(--bg-rgb), 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 6;
}
.chat-head .title-wrap {
  flex: 1;
  min-width: 0;
  padding: 0 4px;
  text-align: center;
}
.chat-head .title-wrap h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-head .title-wrap p {
  margin: 3px 0 0;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.chat-head .title-wrap p .live-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ok);
}

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 22px 18px 10px;
  scroll-behavior: smooth;
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12vh 20px 24px;
  text-align: center;
  animation: screenIn 0.5s var(--ease);
}
.chat-empty .seal-big {
  width: 68px;
  height: 68px;
  border-radius: 23px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 30px;
  color: var(--ink);
  background:
    radial-gradient(100% 100% at 28% 10%, rgba(226, 100, 63, 0.28), transparent 65%),
    linear-gradient(160deg, #1b1a20, #0d0d11);
  border: 1px solid rgba(var(--haze-rgb), 0.1);
  box-shadow: inset 0 1px 0 rgba(var(--haze-rgb), 0.1), 0 20px 50px -24px #000;
  position: relative;
  margin-bottom: 20px;
}
.chat-empty .seal-big::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 17px;
  border: 1px solid rgba(226, 100, 63, 0.3);
}
.chat-empty h2 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.08em;
}
.chat-empty p {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.8;
  max-width: 280px;
}
.starter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 340px;
}
.starter {
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.028);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.starter svg {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--acc-bright);
  opacity: 0.85;
}
.starter:active {
  background: rgba(var(--haze-rgb), 0.06);
  border-color: var(--line-strong);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 26px;
  max-width: 100%;
}
.msg {
  display: flex;
  flex-direction: column;
  animation: msgIn 0.3s var(--ease);
}
@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}
.msg.user {
  align-items: flex-end;
}
.msg.user .bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 18px;
  border-bottom-right-radius: 7px;
  background: linear-gradient(172deg, rgba(226, 100, 63, 0.2), rgba(226, 100, 63, 0.1));
  border: 1px solid rgba(226, 100, 63, 0.26);
  box-shadow: inset 0 1px 0 rgba(var(--haze-rgb), 0.06);
  font-size: 14.5px;
  line-height: 1.7;
  color: #f7e9e1;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.assistant {
  position: relative;
  padding-left: 37px;
}
.msg.assistant .seal {
  position: absolute;
  left: 0;
  top: 0;
  width: 27px;
  height: 27px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 14px;
  color: #f4c6b4;
  background: linear-gradient(160deg, rgba(226, 100, 63, 0.22), rgba(226, 100, 63, 0.06));
  border: 1px solid rgba(226, 100, 63, 0.3);
}
.msg.assistant .md {
  font-size: 14.8px;
  line-height: 1.8;
  color: #e9e5dc;
  padding-top: 2px;
}
.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.04em;
}
.msg.user .msg-meta {
  justify-content: flex-end;
  margin-right: 2px;
}
.msg-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  opacity: 0.55;
  transition: opacity 0.2s ease;
}
.msg.assistant:hover .msg-actions {
  opacity: 1;
}
.msg-action {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink-3);
  transition: all 0.16s ease;
}
.msg-action svg {
  width: 14px;
  height: 14px;
}
.msg-action:active {
  background: rgba(var(--haze-rgb), 0.07);
  color: var(--ink);
}

.reasoning {
  margin: 0 0 10px;
  border-left: 2px solid rgba(216, 185, 140, 0.25);
  padding: 2px 0 2px 12px;
}
.reasoning summary {
  list-style: none;
  cursor: pointer;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--gold);
  opacity: 0.72;
  display: flex;
  align-items: center;
  gap: 6px;
}
.reasoning summary::-webkit-details-marker {
  display: none;
}
.reasoning summary svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}
.reasoning[open] summary svg {
  transform: rotate(90deg);
}
.reasoning .r-body {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-3);
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
}

.msg-error {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid rgba(224, 106, 106, 0.28);
  background: rgba(224, 106, 106, 0.08);
  color: #e7b0b0;
  font-size: 12.5px;
  line-height: 1.7;
  margin-top: 6px;
}
.msg-error svg {
  width: 15px;
  height: 15px;
  flex: none;
  margin-top: 2px;
}

.typing-cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  border-radius: 2px;
  background: var(--acc-bright);
  vertical-align: -2px;
  margin-left: 3px;
  animation: blink 1.05s steps(2, start) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

.thinking-state {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  padding: 4px 0;
}
.thinking-state .pulse {
  display: flex;
  gap: 3px;
}
.thinking-state .pulse i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--acc);
  animation: pulseDot 1.2s ease-in-out infinite;
}
.thinking-state .pulse i:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking-state .pulse i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes pulseDot {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  45% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

.composer-wrap {
  flex: none;
  padding: 10px 13px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), rgba(var(--bg-rgb), 0.86) 38%);
  position: relative;
  z-index: 5;
}
.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 6px 8px;
}
.composer-bar .model-chip {
  height: 27px;
  font-size: 10.5px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--ink-4);
}
.composer-bar .model-chip .dot {
  width: 5px;
  height: 5px;
}
.composer-bar .model-chip .name {
  max-width: 190px;
}
.composer-bar .model-chip:active {
  background: rgba(var(--haze-rgb), 0.05);
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  background: #131318;
  border: 1px solid rgba(var(--haze-rgb), 0.115);
  border-radius: 23px;
  padding: 7px 7px 7px 16px;
  box-shadow: 0 14px 44px -22px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(var(--haze-rgb), 0.035);
  transition: border-color 0.2s ease;
}
.composer:focus-within {
  border-color: rgba(226, 100, 63, 0.4);
}
.composer textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  font-size: 14.8px;
  line-height: 1.55;
  padding: 9px 0 8px;
  max-height: 132px;
  scrollbar-width: thin;
}
.composer textarea::placeholder {
  color: var(--ink-4);
}
.send-btn {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #24100a;
  background: linear-gradient(180deg, #f08a5f, #dd5f3a);
  box-shadow: 0 6px 18px -8px rgba(226, 100, 63, 0.9), inset 0 1px 0 rgba(var(--haze-rgb), 0.3);
  transition: all 0.18s ease;
}
.send-btn svg {
  width: 17px;
  height: 17px;
}
.send-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}
.send-btn.stop {
  color: #f4ded4;
  background: rgba(226, 100, 63, 0.16);
  border: 1px solid rgba(226, 100, 63, 0.4);
  box-shadow: none;
}
.send-btn.stop svg {
  width: 13px;
  height: 13px;
}
.send-btn:active {
  transform: scale(0.94);
}

/* markdown */
.md > *:first-child {
  margin-top: 0;
}
.md > *:last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0 0 0.85em;
}
.md h1,
.md h2,
.md h3,
.md h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #f5f0e6;
  margin: 1.35em 0 0.55em;
  line-height: 1.45;
}
.md h1 {
  font-size: 1.35em;
}
.md h2 {
  font-size: 1.22em;
}
.md h3 {
  font-size: 1.1em;
}
.md h4 {
  font-size: 1em;
}
.md strong {
  color: #f7f1e7;
  font-weight: 600;
}
.md em {
  color: #e4d6c3;
}
.md a {
  color: var(--acc-bright);
  text-decoration: none;
  border-bottom: 1px solid rgba(240, 128, 90, 0.3);
}
.md ul,
.md ol {
  margin: 0.3em 0 0.9em;
  padding-left: 1.35em;
}
.md li {
  margin: 0.28em 0;
}
.md li::marker {
  color: rgba(226, 100, 63, 0.75);
}
.md blockquote {
  margin: 0.8em 0;
  padding: 2px 0 2px 13px;
  border-left: 2px solid rgba(226, 100, 63, 0.4);
  color: var(--ink-2);
}
.md hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 1.2em 0;
}
.md code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: #e8c9a6;
  background: rgba(var(--haze-rgb), 0.06);
  border: 1px solid rgba(var(--haze-rgb), 0.06);
  border-radius: 5px;
  padding: 1px 5px;
}
.md .code-block {
  margin: 0.9em 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #0c0c10;
}
.md .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 11px;
  background: rgba(var(--haze-rgb), 0.03);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
}
.md .code-copy {
  font-size: 10px;
  color: var(--ink-3);
  padding: 2px 6px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.md .code-copy svg {
  width: 11px;
  height: 11px;
}
.md .code-copy:active {
  background: rgba(var(--haze-rgb), 0.08);
}
.md pre {
  margin: 0;
  padding: 12px 13px;
  overflow-x: auto;
}
.md pre code {
  background: none;
  border: 0;
  padding: 0;
  color: #ddd8cd;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre;
}
.md img {
  max-width: 100%;
  border-radius: 10px;
  display: block;
  margin: 0.6em 0;
}
.md table {
  border-collapse: collapse;
  margin: 0.8em 0;
  font-size: 0.92em;
  display: block;
  overflow-x: auto;
}
.md th,
.md td {
  border: 1px solid var(--line);
  padding: 6px 9px;
  text-align: left;
}
.md th {
  background: rgba(var(--haze-rgb), 0.04);
  font-weight: 600;
}

/* ---------------- stories ---------------- */
.story-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.story-card {
  border-radius: 22px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(var(--haze-rgb), 0.085);
  background: #101014;
  transition: transform 0.18s ease;
  cursor: pointer;
}
.story-card:active {
  transform: scale(0.985);
}
.story-cover {
  height: 158px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  background:
    radial-gradient(120% 130% at 88% -20%, hsl(var(--hue, 24) 65% 42% / 0.55), transparent 58%),
    radial-gradient(100% 100% at -10% 110%, hsl(calc(var(--hue, 24) + 40) 50% 30% / 0.35), transparent 60%),
    linear-gradient(150deg, hsl(var(--hue, 24) 30% 18%), hsl(calc(var(--hue, 24) + 30) 26% 9%));
  overflow: hidden;
}
.story-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}
.story-cover::after {
  content: "";
  position: absolute;
  inset: 13px;
  border: 1px solid rgba(var(--haze-rgb), 0.13);
  border-radius: 13px;
  pointer-events: none;
}
.story-genre {
  position: absolute;
  top: 24px;
  left: 26px;
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: rgba(var(--haze-rgb), 0.66);
  border: 1px solid rgba(var(--haze-rgb), 0.22);
  padding: 3px 8px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.story-cover h3 {
  margin: 0 0 5px;
  font-family: var(--font-serif);
  font-size: 25px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: #fbf5e9;
  text-shadow: none;
  position: relative;
  z-index: 1;
  max-width: 88%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.story-cover p {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.11em;
  color: rgba(var(--haze-rgb), 0.55);
  position: relative;
  z-index: 1;
}
.new-story-card {
  height: 104px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-radius: 22px;
  border: 1px dashed rgba(var(--haze-rgb), 0.16);
  background: rgba(var(--haze-rgb), 0.018);
  color: var(--ink-2);
  text-align: left;
  transition: all 0.18s ease;
}
.new-story-card:active {
  background: rgba(var(--haze-rgb), 0.04);
  border-color: rgba(226, 100, 63, 0.35);
}
.new-story-card .plus {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--acc-soft);
  border: 1px solid rgba(226, 100, 63, 0.28);
  color: var(--acc-bright);
  flex: none;
}
.new-story-card .plus svg {
  width: 19px;
  height: 19px;
}
.new-story-card h4 {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.new-story-card p {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-4);
  letter-spacing: 0.02em;
}

/* wizard */
.wizard-head {
  flex: none;
  padding: max(14px, env(safe-area-inset-top)) 16px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.wizard-head .wz-title {
  flex: 1;
  min-width: 0;
}
.wizard-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.wizard-head p {
  margin: 2px 0 0;
  font-size: 10.5px;
  color: var(--ink-4);
  letter-spacing: 0.12em;
}
.wizard-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 18px 24px;
  scrollbar-width: thin;
}
.form-card {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(var(--haze-rgb), 0.032), rgba(var(--haze-rgb), 0.012));
  padding: 17px 16px;
  margin-bottom: 13px;
  position: relative;
}
.form-card .step-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.form-card .step-tag .num {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--acc-bright);
  opacity: 0.8;
  min-width: 14px;
}
.form-card .step-tag h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--ink-2);
}
.form-card .step-tag .line {
  flex: 1;
  height: 1px;
  background: var(--line);
}
.form-hint {
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-4);
  margin: 10px 2px 0;
}
.char-card {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
  padding: 14px;
  margin-bottom: 11px;
  position: relative;
}
.char-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
}
.char-head .idx {
  font-family: var(--font-serif);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--gold);
  opacity: 0.85;
}
.char-head .del {
  color: var(--ink-4);
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}
.char-head .del svg {
  width: 14px;
  height: 14px;
}
.char-head .del:active {
  background: rgba(224, 106, 106, 0.12);
  color: #e0a0a0;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  gap: 8px;
}
.add-char {
  width: 100%;
  height: 44px;
  border-radius: 13px;
  border: 1px dashed rgba(var(--haze-rgb), 0.16);
  color: var(--ink-2);
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  letter-spacing: 0.04em;
}
.add-char svg {
  width: 14px;
  height: 14px;
  color: var(--acc-bright);
}
.add-char:active {
  background: rgba(var(--haze-rgb), 0.035);
}
.wizard-foot {
  flex: none;
  padding: 10px 18px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  gap: 9px;
  background: linear-gradient(180deg, transparent, rgba(var(--bg-rgb), 0.9) 35%);
}
.wizard-foot .btn-primary {
  flex: 1;
}
.sample-btn {
  font-size: 11px;
  color: var(--gold);
  opacity: 0.85;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
}
.sample-btn svg {
  width: 12px;
  height: 12px;
}

/* reader */
.reader-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: max(12px, env(safe-area-inset-top)) 12px 6px;
}
.reader-head .r-title {
  flex: 1;
  min-width: 0;
  text-align: center;
}
.reader-head .r-title h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.05em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader-head .r-title p {
  margin: 3px 0 0;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--ink-4);
}
.chapter-strip {
  flex: none;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 16px 10px;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(var(--haze-rgb), 0.04);
}
.chapter-strip::-webkit-scrollbar {
  display: none;
}
.chapter-strip .chap {
  flex: none;
  height: 28px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--ink-4);
  font-size: 11px;
  letter-spacing: 0.05em;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.chapter-strip .chap.on {
  color: #f2c0ac;
  background: var(--acc-soft);
  border-color: rgba(226, 100, 63, 0.28);
}
.chapter-strip .chap .gen-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--acc-bright);
  animation: blink 1s infinite;
}
.story-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 25px 130px;
  scrollbar-width: thin;
}
.story-chapter {
  max-width: 100%;
}
.chapter-eyebrow {
  font-size: 9.5px;
  letter-spacing: 0.26em;
  color: var(--ink-4);
  text-align: center;
  margin-bottom: 10px;
}
.chapter-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.04em;
  text-align: center;
  color: #f6f0e4;
}
.chapter-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  margin-bottom: 26px;
}
.chapter-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 28px;
  color: rgba(216, 185, 140, 0.4);
}
.chapter-ornament::before,
.chapter-ornament::after {
  content: "";
  width: 34px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(216, 185, 140, 0.3));
}
.chapter-ornament::after {
  background: linear-gradient(90deg, rgba(216, 185, 140, 0.3), transparent);
}
.chapter-ornament i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(226, 100, 63, 0.6);
  transform: rotate(45deg);
}
.story-text {
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 2.02;
  color: #e7e2d7;
  letter-spacing: 0.012em;
}
.story-text p {
  margin: 0 0 0.92em;
  text-indent: 2em;
}
.story-text p.no-indent {
  text-indent: 0;
}
.scene-break {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 20px 0 24px;
  opacity: 0.55;
}
.scene-break i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--gold);
}
.scene-break i:nth-child(2) {
  width: 4px;
  height: 4px;
  background: var(--acc);
}
.story-text em {
  font-style: normal;
  color: #f0e7d6;
}
.story-text .story-cursor {
  display: inline-block;
  width: 6px;
  height: 16px;
  background: var(--acc);
  border-radius: 2px;
  vertical-align: -2px;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
  text-indent: 0;
}
.story-placeholder {
  padding: 30px 0;
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: 0.04em;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  font-family: var(--font-sans);
}
.story-placeholder .quill {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--gold);
  opacity: 0.6;
}
.story-toast-line {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(var(--haze-rgb), 0.06);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-4);
  text-align: center;
  font-family: var(--font-sans);
  line-height: 1.8;
}

.story-toolbar {
  flex: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 15px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0), rgba(var(--bg-rgb), 0.92) 40%);
  z-index: 5;
}
.story-toolbar .btn {
  height: 46px;
}
.story-toolbar .btn-primary {
  flex: 1;
}

/* ---------------- images ---------------- */
.studio {
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(var(--haze-rgb), 0.04), rgba(var(--haze-rgb), 0.012));
  padding: 13px;
  margin-top: 4px;
}
.studio-preview {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(var(--haze-rgb), 0.07);
  background:
    radial-gradient(90% 90% at 30% 20%, rgba(226, 100, 63, 0.12), transparent 60%),
    radial-gradient(80% 80% at 80% 90%, rgba(120, 145, 200, 0.1), transparent 60%),
    #0b0b0f;
  display: grid;
  place-items: center;
}
.studio-preview > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.studio-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--ink-4);
  text-align: center;
  padding: 24px;
}
.studio-empty .sigil {
  width: 58px;
  height: 58px;
  border-radius: 19px;
  border: 1px solid rgba(var(--haze-rgb), 0.08);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 23px;
  color: rgba(216, 185, 140, 0.55);
  background: rgba(var(--haze-rgb), 0.025);
}
.studio-empty p {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  line-height: 1.8;
}
.studio-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background:
    linear-gradient(110deg, rgba(var(--haze-rgb), 0.025) 20%, rgba(226, 100, 63, 0.08) 40%, rgba(var(--haze-rgb), 0.025) 60%),
    #0c0c10;
  background-size: 240% 100%;
  animation: shimmer 2.1s linear infinite;
  z-index: 2;
}
@keyframes shimmer {
  to {
    background-position: -140% 0;
  }
}
.studio-loading .ring {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(226, 100, 63, 0.2);
  border-top-color: var(--acc-bright);
  animation: spin 0.9s linear infinite;
}
.studio-loading p {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}
.studio-preview .preview-actions {
  position: absolute;
  right: 9px;
  bottom: 9px;
  display: flex;
  gap: 6px;
  z-index: 3;
}
.studio-preview .preview-actions .icon-btn {
  background: rgba(10, 10, 14, 0.62);
  backdrop-filter: blur(10px);
  border-color: rgba(var(--haze-rgb), 0.16);
  color: #eee;
}
.prompt-box {
  margin-top: 11px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  padding: 4px 4px 4px 13px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}
.prompt-box textarea {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  min-height: 46px;
  max-height: 130px;
  padding: 11px 0 10px;
  font-size: 14px;
  line-height: 1.55;
}
.prompt-box textarea::placeholder {
  color: var(--ink-4);
}
.ref-add {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 11px;
  border: 1px dashed rgba(var(--haze-rgb), 0.18);
  color: var(--ink-3);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
  transition: all 0.18s ease;
  position: relative;
}
.ref-add svg {
  width: 16px;
  height: 16px;
}
.ref-add:active {
  background: rgba(var(--haze-rgb), 0.05);
  color: var(--ink);
}
.ref-thumb {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 11px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(226, 100, 63, 0.4);
  margin-bottom: 2px;
}
.ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ref-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  display: grid;
  place-items: center;
}
.ref-thumb button svg {
  width: 9px;
  height: 9px;
}
.studio-options {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.studio-options .spacer {
  flex: 1;
}
.ratio-chips {
  display: flex;
  gap: 5px;
}
.ratio-chip {
  height: 27px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.03);
  color: var(--ink-4);
  font-size: 10.5px;
  letter-spacing: 0.02em;
}
.ratio-chip.on {
  color: #f0c3b1;
  border-color: rgba(226, 100, 63, 0.4);
  background: var(--acc-soft);
}
.generate-btn {
  width: 100%;
  margin-top: 11px;
  height: 46px;
}
.gallery {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.gallery-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 15px;
  overflow: hidden;
  border: 1px solid rgba(var(--haze-rgb), 0.075);
  background: #0d0d11;
  padding: 0;
  transition: transform 0.18s ease;
}
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-item:active {
  transform: scale(0.97);
}
.gallery-empty {
  grid-column: 1 / -1;
  padding: 24px 0 8px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
  line-height: 1.9;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(4, 4, 6, 0.94);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.22s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
}
.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 16px 8px;
  color: var(--ink-2);
  font-size: 11px;
  letter-spacing: 0.12em;
}
.viewer-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
}
.viewer-body img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 16px;
  object-fit: contain;
  box-shadow: 0 30px 90px -30px #000;
}
.viewer-foot {
  padding: 12px 18px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, rgba(4, 4, 6, 0.7));
}
.viewer-prompt {
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-2);
  margin-bottom: 12px;
  max-height: 88px;
  overflow-y: auto;
  font-family: var(--font-serif);
  letter-spacing: 0.02em;
}
.viewer-meta {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 10px;
  color: var(--ink-4);
  letter-spacing: 0.06em;
}
.viewer-actions {
  display: flex;
  gap: 8px;
}
.viewer-actions .btn {
  height: 42px;
  flex: 1;
  font-size: 12.5px;
}

/* ---------------- settings ---------------- */
.settings-scroll {
  padding: 0 18px 122px;
}
.setting-group {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(var(--haze-rgb), 0.03), rgba(var(--haze-rgb), 0.01));
  overflow: hidden;
  margin-bottom: 14px;
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(var(--haze-rgb), 0.05);
  min-height: 54px;
  text-align: left;
  width: 100%;
  transition: background 0.16s ease;
}
.setting-row:last-child {
  border-bottom: 0;
}
button.setting-row:active {
  background: rgba(var(--haze-rgb), 0.04);
}
.setting-row .s-ico {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.03);
  color: var(--ink-2);
}
.setting-row .s-ico svg {
  width: 15px;
  height: 15px;
}
.setting-row .s-main {
  flex: 1;
  min-width: 0;
}
.setting-row .s-main strong {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.setting-row .s-main span {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}
.setting-row .s-val {
  font-size: 11.5px;
  color: var(--ink-3);
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setting-row .chev {
  width: 14px;
  height: 14px;
  color: var(--ink-4);
  flex: none;
}
.setting-row.danger {
  color: #e29a9a;
}
.setting-row.danger .s-ico {
  color: #e29a9a;
  border-color: rgba(224, 106, 106, 0.2);
  background: rgba(224, 106, 106, 0.07);
}
.provider-card {
  padding: 15px 16px;
  border-bottom: 1px solid rgba(var(--haze-rgb), 0.05);
}
.provider-card:last-child {
  border-bottom: 0;
}
.provider-card .pc-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.provider-card .pc-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  flex: none;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 15px;
  color: #f0d8c8;
  background: linear-gradient(150deg, rgba(226, 100, 63, 0.22), rgba(226, 100, 63, 0.05));
  border: 1px solid rgba(226, 100, 63, 0.24);
}
.provider-card .pc-info {
  flex: 1;
  min-width: 0;
}
.provider-card .pc-info h4 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.provider-card .chev {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--ink-4);
}
.provider-card .pc-info p {
  margin: 2px 0 0;
  font-size: 10.5px;
  color: var(--ink-4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font-mono);
}
.provider-card .pc-models {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-left: 2px;
}
.pc-tag {
  font-size: 9.5px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 999px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.pc-tag.chat::before {
  content: "◍ ";
  color: rgba(116, 195, 160, 0.7);
}
.pc-tag.image::before {
  content: "▣ ";
  color: rgba(226, 100, 63, 0.75);
}
.pc-actions {
  display: flex;
  gap: 6px;
  margin-top: 0;
}
.add-provider-row {
  padding: 13px 16px;
}
.about-text {
  padding: 2px 4px 26px;
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--ink-4);
}
.about-text strong {
  color: var(--ink-3);
  font-weight: 500;
}
.about-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 26px 0 12px;
  color: var(--ink-4);
  font-size: 10.5px;
  letter-spacing: 0.18em;
}
.about-brand .mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--gold);
  border: 1px solid rgba(var(--haze-rgb), 0.09);
  background: rgba(var(--haze-rgb), 0.03);
}

/* provider editor */
.editor {
  padding: 2px 2px 10px;
}
.editor .editor-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 16px;
}
.editor .editor-title h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.editor .editor-title .icon-btn {
  border: 0;
  background: transparent;
}
.preset-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 14px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 26px), transparent 100%);
}
.preset-row::-webkit-scrollbar {
  display: none;
}
.preset-chip {
  flex: none;
  height: 27px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.025);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.03em;
}
.preset-chip:active {
  color: var(--acc-bright);
  border-color: var(--acc-line);
}
.fetch-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 2px 0 12px;
}
.fetch-status {
  flex: 1;
  font-size: 10.5px;
  color: var(--ink-4);
  line-height: 1.5;
}
.fetch-status.ok {
  color: var(--ok);
}
.fetch-status.err {
  color: #e0a0a0;
}
.model-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.model-row {
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.model-row .mr-check {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 5px;
  border: 1px solid rgba(var(--haze-rgb), 0.2);
  display: grid;
  place-items: center;
  color: #25120b;
  background: transparent;
}
.model-row .mr-check svg {
  width: 12px;
  height: 12px;
  opacity: 0;
}
.model-row.on .mr-check {
  background: var(--acc);
  border-color: var(--acc);
}
.model-row.on .mr-check svg {
  opacity: 1;
}
.model-row .mr-name {
  flex: 1;
  min-width: 100px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-row .mr-kind {
  display: flex;
  gap: 3px;
}
.kind-btn {
  height: 23px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 9.5px;
  color: var(--ink-4);
  background: rgba(var(--haze-rgb), 0.03);
  letter-spacing: 0.04em;
}
.kind-btn.on {
  color: #f1c1ae;
  background: rgba(226, 100, 63, 0.13);
  border-color: rgba(226, 100, 63, 0.33);
}
.model-row .mr-mode {
  height: 23px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.03);
  color: var(--ink-3);
  font-size: 9.5px;
  padding: 0 6px;
}
.manual-add {
  display: flex;
  gap: 6px;
}
.manual-add .input {
  height: 38px;
  padding: 8px 11px;
  font-size: 12px;
}
.manual-add .btn {
  height: 38px;
  flex: none;
}
.empty-hint {
  padding: 16px 4px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-4);
  line-height: 1.8;
}

/* ---------------- sheets & modals ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 3, 5, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.22s ease;
}
.sheet {
  width: min(100%, var(--app-w));
  max-height: 88dvh;
  overflow-y: auto;
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: #111116;
  border-top: 1px solid rgba(var(--haze-rgb), 0.11);
  box-shadow: 0 -30px 90px -30px #000;
  animation: sheetUp 0.32s var(--ease);
  scrollbar-width: thin;
}
.sheet.tall {
  max-height: 94dvh;
}
@keyframes sheetUp {
  from {
    transform: translateY(60px);
    opacity: 0.5;
  }
}
.sheet-grab {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: rgba(var(--haze-rgb), 0.16);
  margin: 4px auto 14px;
}
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.sheet-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.sheet-head p {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--ink-4);
  line-height: 1.6;
}
.sheet-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.sheet-actions .btn {
  flex: 1;
}
.sheet-close {
  flex: none;
}

/* model picker */
.pick-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 2px -6px;
}
.pick-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 10px;
  border-radius: 12px;
  text-align: left;
  transition: background 0.15s ease;
  width: 100%;
  color: var(--ink-2);
}
.pick-row:active {
  background: rgba(var(--haze-rgb), 0.05);
}
.pick-row .pick-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-size: 13px;
  color: #e9d3c6;
  background: linear-gradient(150deg, rgba(var(--haze-rgb), 0.08), rgba(var(--haze-rgb), 0.02));
  border: 1px solid var(--line);
}
.pick-row .pick-info {
  flex: 1;
  min-width: 0;
}
.pick-row .pick-info strong {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-row .pick-info span {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--ink-4);
}
.pick-row .pick-check {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  flex: none;
  display: grid;
  place-items: center;
  color: #25120b;
}
.pick-row .pick-check svg {
  width: 10px;
  height: 10px;
  opacity: 0;
}
.pick-row.on .pick-check {
  background: var(--acc);
  border-color: var(--acc);
}
.pick-row.on .pick-check svg {
  opacity: 1;
}
.sheet-note {
  margin: 12px 0 2px;
  font-size: 11px;
  color: var(--ink-4);
  line-height: 1.7;
  text-align: center;
}
.sheet-note a {
  color: var(--gold);
  text-decoration: none;
}

/* dialog */
.dialog-scrim {
  align-items: center;
  padding: 24px;
}
.dialog {
  width: min(100%, 340px);
  border-radius: 22px;
  background: #141419;
  border: 1px solid rgba(var(--haze-rgb), 0.1);
  padding: 22px;
  animation: dialogIn 0.25s var(--ease);
  box-shadow: 0 30px 100px -30px #000;
}
@keyframes dialogIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
}
.dialog h3 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.dialog p {
  margin: 0 0 18px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-3);
}
.dialog .textarea {
  margin-bottom: 16px;
  min-height: 90px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
}
.dialog-actions .btn {
  flex: 1;
  height: 42px;
  font-size: 13px;
}

/* toasts */
.toast-root {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(96px + env(safe-area-inset-bottom));
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: min(86%, 340px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(26, 26, 32, 0.94);
  border: 1px solid rgba(var(--haze-rgb), 0.12);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  box-shadow: 0 16px 40px -16px #000;
  backdrop-filter: blur(12px);
  animation: toastIn 0.25s var(--ease);
  text-align: center;
}
.toast.ok {
  color: #b7e3cf;
  border-color: rgba(116, 195, 160, 0.3);
}
.toast.err {
  color: #f0c0c0;
  border-color: rgba(224, 106, 106, 0.32);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

/* loader */
.loading-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.loading-line .spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--haze-rgb), 0.18);
  border-top-color: var(--ink-2);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ---------------- appearance setting ---------------- */
.theme-card {
  padding: 14px 16px 15px;
}
.theme-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.theme-head .s-ico {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.03);
  color: var(--ink-2);
}
.theme-head .s-ico svg {
  width: 15px;
  height: 15px;
}
.theme-head .s-main {
  flex: 1;
  min-width: 0;
}
.theme-head .s-main strong {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
}
.theme-head .s-main span {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--ink-4);
}
.theme-seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 12px;
  padding: 3px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(var(--haze-rgb), 0.035);
}
.theme-seg button {
  height: 33px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.theme-seg button svg {
  width: 14px;
  height: 14px;
}
.theme-seg button.on {
  background: var(--surface-3);
  color: var(--ink);
  box-shadow: 0 3px 10px -6px #000, inset 0 1px 0 rgba(var(--haze-rgb), 0.06);
}

/* ---------------- light theme ---------------- */
:root[data-theme="light"] {
  --haze-rgb: 43, 36, 26;
  --bg-rgb: 248, 244, 236;
  --bg: #f7f3eb;
  --bg-deep: #ece6da;
  --surface: #fffdf8;
  --surface-2: #f8f4ea;
  --surface-3: #efe8db;
  --line: rgba(var(--haze-rgb), 0.1);
  --line-strong: rgba(var(--haze-rgb), 0.18);
  --ink: #2b261f;
  --ink-2: #5d564b;
  --ink-3: #857b6b;
  --ink-4: #a79c8b;
  --acc: #c9542f;
  --acc-bright: #d65f36;
  --acc-soft: rgba(201, 84, 47, 0.1);
  --acc-line: rgba(201, 84, 47, 0.34);
  --gold: #9a743f;
  --ok: #2f8a68;
  --danger: #b64848;
  --page-veil-top: rgba(248, 244, 236, 0.62);
  --page-veil-bottom: rgba(248, 244, 236, 0.88);
  --reader-veil-top: rgba(248, 244, 236, 0.8);
  --reader-veil-bottom: rgba(248, 244, 236, 0.93);
  color-scheme: light;
}

[data-theme="light"] body {
  background: var(--bg-deep);
}
[data-theme="light"] .ambient {
  background:
    radial-gradient(90% 60% at 82% -12%, rgba(201, 84, 47, 0.11), transparent 62%),
    radial-gradient(70% 50% at -10% 108%, rgba(104, 124, 174, 0.07), transparent 60%),
    radial-gradient(50% 40% at 50% 50%, rgba(255, 255, 255, 0.45), transparent 70%),
    #f4efe5;
}
[data-theme="light"] .ambient::after {
  opacity: 0.028;
  mix-blend-mode: multiply;
}
[data-theme="light"] .app {
  background:
    radial-gradient(120% 55% at 78% -8%, rgba(201, 84, 47, 0.07), transparent 55%),
    linear-gradient(180deg, #fbf8f2 0%, #f7f3ea 55%, #f3eee4 100%);
}
@media (min-width: 560px) {
  [data-theme="light"] .app {
    border-left-color: rgba(43, 36, 26, 0.08);
    border-right-color: rgba(43, 36, 26, 0.08);
    box-shadow: 0 30px 120px -40px rgba(70, 55, 35, 0.4);
  }
}
[data-theme="light"] .tabbar {
  background: rgba(255, 252, 246, 0.82);
  border-color: rgba(43, 36, 26, 0.1);
  box-shadow: 0 18px 50px -24px rgba(70, 55, 35, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}
[data-theme="light"] .select {
  color-scheme: light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23857b6b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}
[data-theme="light"] .brand-mark,
[data-theme="light"] .chat-empty .seal-big {
  color: #f6f0e4;
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 18px 44px -26px rgba(50, 38, 24, 0.55);
}
[data-theme="light"] .empty .glyph {
  color: #d8b98c;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 16px 40px -24px rgba(50, 38, 24, 0.5);
}
[data-theme="light"] .brand-mark::after {
  border-color: rgba(226, 100, 63, 0.34);
}
[data-theme="light"] .conv-avatar {
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
[data-theme="light"] .btn-primary {
  box-shadow: 0 12px 30px -14px rgba(201, 84, 47, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
[data-theme="light"] .send-btn {
  box-shadow: 0 6px 18px -8px rgba(201, 84, 47, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}
[data-theme="light"] .send-btn.stop {
  color: #a84322;
}
[data-theme="light"] .chip.on,
[data-theme="light"] .chapter-strip .chap.on,
[data-theme="light"] .ratio-chip.on,
[data-theme="light"] .kind-btn.on {
  color: #a84322;
}
[data-theme="light"] .msg.assistant .seal {
  color: #a84322;
}
[data-theme="light"] .msg.user .bubble {
  color: #5a2b19;
  border-color: rgba(201, 84, 47, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
[data-theme="light"] .msg.assistant .md {
  color: #332e26;
}
[data-theme="light"] .md h1,
[data-theme="light"] .md h2,
[data-theme="light"] .md h3,
[data-theme="light"] .md h4 {
  color: #2b261f;
}
[data-theme="light"] .md strong {
  color: #201b15;
}
[data-theme="light"] .md em {
  color: #5d4a34;
}
[data-theme="light"] .md code {
  color: #8a5426;
  border-color: rgba(var(--haze-rgb), 0.08);
}
[data-theme="light"] .md .code-block {
  background: #f3ede2;
}
[data-theme="light"] .md pre code {
  color: #3d362c;
}
[data-theme="light"] .notice {
  color: #a85636;
}
[data-theme="light"] .msg-error {
  color: #a83e3e;
}
[data-theme="light"] .composer {
  background: #fffdf9;
  border-color: rgba(43, 36, 26, 0.14);
  box-shadow: 0 14px 44px -26px rgba(70, 55, 35, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
[data-theme="light"] .story-card {
  background: #fffdf8;
  border-color: rgba(var(--haze-rgb), 0.09);
}
[data-theme="light"] .story-cover h3 {
  color: #fbf5e9;
}
[data-theme="light"] .story-cover p {
  color: rgba(255, 255, 255, 0.55);
}
[data-theme="light"] .story-cover::after {
  border-color: rgba(255, 255, 255, 0.13);
}
[data-theme="light"] .story-genre {
  color: rgba(255, 255, 255, 0.66);
  border-color: rgba(255, 255, 255, 0.22);
}
[data-theme="light"] .chapter-title {
  color: #2b261f;
}
[data-theme="light"] .story-text,
[data-theme="light"] .story-text em {
  color: #373027;
}
[data-theme="light"] .char-card {
  background: rgba(var(--haze-rgb), 0.03);
}
[data-theme="light"] .setting-group {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.5));
}
[data-theme="light"] .setting-row,
[data-theme="light"] .provider-card {
  border-bottom-color: rgba(43, 36, 26, 0.06);
}
[data-theme="light"] .setting-row.danger,
[data-theme="light"] .fetch-status.err,
[data-theme="light"] .char-head .del:active {
  color: var(--danger);
}
[data-theme="light"] .setting-row.danger .s-ico {
  color: var(--danger);
  border-color: rgba(182, 72, 72, 0.2);
  background: rgba(182, 72, 72, 0.07);
}
[data-theme="light"] .provider-card .pc-mark {
  color: #a84322;
}
[data-theme="light"] .studio-preview {
  border-color: rgba(var(--haze-rgb), 0.08);
  background:
    radial-gradient(90% 90% at 30% 20%, rgba(201, 84, 47, 0.1), transparent 60%),
    radial-gradient(80% 80% at 80% 90%, rgba(104, 124, 174, 0.09), transparent 60%),
    #f2ece1;
}
[data-theme="light"] .studio-loading {
  background:
    linear-gradient(110deg, rgba(var(--haze-rgb), 0.03) 20%, rgba(201, 84, 47, 0.08) 40%, rgba(var(--haze-rgb), 0.03) 60%),
    #f5f0e6;
}
[data-theme="light"] .gallery-item {
  background: #f0eadf;
}
[data-theme="light"] .prompt-box {
  background: rgba(var(--haze-rgb), 0.035);
}
[data-theme="light"] .studio-preview .preview-actions .icon-btn {
  border-color: rgba(255, 255, 255, 0.18);
}
[data-theme="light"] .model-row {
  background: rgba(var(--haze-rgb), 0.03);
}
[data-theme="light"] .overlay {
  background: rgba(35, 28, 20, 0.34);
}
[data-theme="light"] .sheet {
  background: #fffcf7;
  border-top-color: rgba(43, 36, 26, 0.12);
  box-shadow: 0 -30px 90px -40px rgba(70, 55, 35, 0.45);
}
[data-theme="light"] .dialog {
  background: #fffdf9;
  border-color: rgba(43, 36, 26, 0.12);
  box-shadow: 0 30px 100px -40px rgba(70, 55, 35, 0.5);
}
[data-theme="light"] .pick-row .pick-avatar {
  color: var(--ink-2);
}
[data-theme="light"] .toast {
  background: rgba(255, 252, 246, 0.96);
  border-color: rgba(43, 36, 26, 0.12);
  box-shadow: 0 16px 40px -16px rgba(70, 55, 35, 0.4);
}
[data-theme="light"] .toast.ok {
  color: #1f6f52;
  border-color: rgba(47, 138, 104, 0.28);
}
[data-theme="light"] .toast.err {
  color: #a53a3a;
  border-color: rgba(182, 72, 72, 0.28);
}
[data-theme="light"] .loading-line .spinner {
  border-color: rgba(var(--haze-rgb), 0.18);
  border-top-color: var(--ink-2);
}

/* responsive tweaks */
@media (max-width: 360px) {
  .scroll,
  .settings-scroll {
    padding-left: 15px;
    padding-right: 15px;
  }
  .app-header {
    padding-left: 16px;
    padding-right: 16px;
  }
  .brand h1 {
    font-size: 19px;
  }
  .story-cover h3 {
    font-size: 22px;
  }
  .gallery {
    gap: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .chat-scroll,
  .story-scroll {
    scroll-behavior: auto;
  }
}
