﻿@font-face {
  font-family: "Pop Gothic";
  src: url("./assets/fonts/PopGothicCjkTc-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Pop Gothic";
  src: url("./assets/fonts/PopGothicCjkTc-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Xiaolai Mono";
  src: url("./assets/fonts/XiaolaiMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #02030b;
  --bg-soft: #111b3d;
  --panel: rgba(5, 9, 24, 0.72);
  --panel-border: rgba(151, 188, 255, 0.18);
  --text: #f8fbff;
  --muted: #a9badf;
  --accent: #ff4fc8;
  --accent-2: #4d8dff;
  --danger: #ff5d73;
  --ok: #22c55e;
  --cursor: url("./assets/mini.cur") 0 0, auto;
  --cursor-pointer: url("./assets/mini.cur") 0 0, pointer;
  --app-mobile-viewport-height: 100dvh;
  --chat-input-height: 76px;
}

* {
  box-sizing: border-box;
}

* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  width: 0;
  height: 0;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: transparent;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: 19px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: #02030b;
  cursor: var(--cursor);
  overflow-x: hidden;
}

body.is-modal-scroll-locked {
  overflow: hidden;
  overscroll-behavior: none;
}

html[lang="zh-Hans"] .hero h1,
html[lang="zh-Hans"] h2,
html[lang="zh-Hans"] .role-card h3,
html[lang="zh-Hans"] .role-picker-cover,
html[lang="zh-Hans"] .role-picker-card h4,
html[lang="zh-Hans"] .session-picker-card h4,
html[lang="zh-Hans"] .markdown-body h1,
html[lang="zh-Hans"] .markdown-body h2,
html[lang="zh-Hans"] .markdown-body h3,
html[lang="zh-Hans"] .markdown-body h4,
html[lang="zh-Hans"] .markdown-body h5,
html[lang="zh-Hans"] .markdown-body h6 {
  font-family: "Xiaolai Mono", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

html[lang="zh-Hans"] body,
html[lang="zh-Hans"] input,
html[lang="zh-Hans"] textarea,
html[lang="zh-Hans"] select,
html[lang="zh-Hans"] button,
html[lang="zh-Hans"] label,
html[lang="zh-Hans"] summary {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 45%, rgba(24, 80, 255, 0.17), transparent 34%),
    radial-gradient(circle at 35% 60%, rgba(26, 63, 207, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(2, 3, 11, 0.18), rgba(2, 3, 11, 0.82));
}

body.has-custom-background::before {
  background:
    radial-gradient(circle at 50% 45%, rgba(24, 80, 255, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(2, 3, 11, 0.4), rgba(2, 3, 11, 0.82)),
    var(--web-background-image);
  background-position: center, center, center;
  background-size: auto, auto, cover;
  background-repeat: no-repeat;
}

#background-canvas,
#spark-canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  cursor: var(--cursor);
}

#background-canvas[hidden],
#spark-canvas[hidden],
#mouse-follower[hidden],
html.effects-disabled #background-canvas,
html.effects-disabled #spark-canvas,
html.effects-disabled #mouse-follower {
  display: none;
}

#background-canvas {
  z-index: 1;
}

#spark-canvas {
  z-index: 3;
}

.click-ripple {
  position: fixed;
  z-index: 3;
  width: 92px;
  height: 92px;
  border-radius: 999px;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.35);
  opacity: 0.9;
  background:
    radial-gradient(circle, rgba(255, 238, 252, 0.95) 0 8%, rgba(255, 79, 200, 0.72) 9% 20%, rgba(77, 141, 255, 0.34) 21% 42%, transparent 58%);
  animation: clickRipple 420ms ease-out forwards;
  will-change: transform, opacity;
}

#mouse-follower {
  --follower-size: clamp(14px, 2vw, 24px);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 4;
  width: var(--follower-size);
  height: var(--follower-size);
  object-fit: contain;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) rotate(0deg);
  transform-origin: 50% 50%;
  transition: opacity 180ms ease;
  will-change: transform, opacity;
}

#mouse-follower.is-visible {
  opacity: 1;
}

html.is-mac-desktop #mouse-follower {
  display: none;
}

.bg-shape {
  display: none;
}

.bg-shape.one {
  width: 320px;
  height: 320px;
  background: #ff9f1a;
  top: -60px;
  left: -40px;
}

.bg-shape.two {
  width: 280px;
  height: 280px;
  background: #2ec4b6;
  right: -50px;
  top: 40%;
  animation-delay: 1.2s;
}

.layout {
  position: relative;
  z-index: 2;
  width: min(86vw, 1340px);
  margin: 0 auto;
  padding: 20px;
  display: grid;
  gap: 16px;
  grid-template-columns: 360px 1fr;
}

.hero {
  grid-column: 1 / -1;
  background:
    linear-gradient(120deg, rgba(255, 79, 200, 0.18), rgba(77, 141, 255, 0.18)),
    rgba(5, 9, 24, 0.62);
  border: 1px solid rgba(255, 214, 242, 0.18);
  border-radius: 20px;
  padding: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 26px rgba(77, 141, 255, 0.18), inset 0 0 22px rgba(255, 79, 200, 0.06);
}

.hero h1 {
  margin: 0;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: clamp(39px, 5vw, 73px);
  letter-spacing: 0;
  color: #ffd6f2;
  text-shadow:
    0 0 4px #fff,
    0 0 10px #ff4fc8,
    0 0 20px #ff2dbd,
    0 0 40px #ff149f,
    0 0 80px #ff149f;
  animation: neonPulse 4s ease-in-out infinite;
}

.hero p {
  margin: 10px 0 14px;
  color: var(--muted);
}

.hero-guide {
  margin: 0 0 12px;
  font-size: 18px;
  color: #d6e1ff;
}

.mobile-info-toggle {
  display: none;
}

.mobile-info-drawer {
  display: contents;
}

.mobile-nav {
  display: none;
  gap: 10px;
}

.mobile-nav button {
  min-height: 44px;
}

.status-pill {
  display: inline-block;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 18px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.08);
}

.status-pill.started {
  background: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.7);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 42px rgba(0, 0, 0, 0.34), inset 0 0 20px rgba(77, 141, 255, 0.04);
}

html.is-mac-desktop .hero,
html.is-mac-desktop .panel {
  backdrop-filter: none;
}

.sidebar {
  padding: 16px;
}

.chat-panel {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: calc(100dvh - 40px);
  overflow: hidden;
  background: rgba(7, 5, 18, 0.88);
  border-color: rgba(108, 98, 150, 0.35);
}

.chat-primary,
.chat-secondary {
  display: grid;
  gap: 12px;
}

.chat-primary {
  height: min(136dvh, 1520px);
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
}

h2 {
  margin: 4px 0 10px;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: 22px;
}

.stack {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 18px;
  color: var(--muted);
}

.form-hint {
  margin: 0;
  font-size: 17px;
  color: var(--muted);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

[data-novelai-v5-unsupported][hidden] {
  display: none !important;
}

input,
textarea,
select,
button {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  font-size: 19px;
  padding: 10px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: rgba(5, 10, 18, 0.55);
}

textarea {
  resize: vertical;
}

button {
  cursor: var(--cursor-pointer);
  background: linear-gradient(120deg, var(--accent), #ff9ee2);
  border: 0;
  color: #21051a;
  font-weight: 700;
  transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: saturate(1.12);
}

button.secondary {
  background: linear-gradient(120deg, var(--accent-2), #86c6ff);
  color: #041a34;
}

button.muted {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.button-link {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  border-radius: 10px;
  background: linear-gradient(120deg, var(--accent), #ff9ee2);
  color: #21051a;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.button-link.secondary {
  background: linear-gradient(120deg, var(--accent-2), #86c6ff);
  color: #041a34;
}

a,
summary,
select,
input,
textarea,
label,
button {
  cursor: var(--cursor-pointer);
}

.actions-block {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-switch-btn {
  min-height: 42px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: var(--text);
}

.mode-switch-btn.active {
  background: linear-gradient(120deg, var(--accent), #ffb347);
  color: #1a1408;
  border-color: transparent;
}

.style-preview {
  margin: 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
}

.card-list {
  display: grid;
  gap: 8px;
}

.custom-section-list {
  display: grid;
  gap: 10px;
}

.custom-section-card {
  display: grid;
  gap: 10px;
}

.opening-dialogue-editor h4 {
  margin: 0;
}

.opening-dialogue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.opening-dialogue-header button {
  width: auto;
  min-width: 48px;
  padding-inline: 14px;
}

.opening-dialogue-tabs {
  display: flex;
  align-items: end;
  gap: 4px;
  min-height: 44px;
  padding: 2px 2px 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-gutter: auto;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.opening-dialogue-tab {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom-color: transparent;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.05);
}

.opening-dialogue-tab.active {
  background: rgba(255, 209, 246, 0.14);
  border-color: rgba(255, 209, 246, 0.38);
  border-bottom-color: transparent;
}

.opening-dialogue-tab-label,
.opening-dialogue-tab-close {
  width: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  transform: none;
  filter: none;
}

.opening-dialogue-tab-label:hover,
.opening-dialogue-tab-close:hover {
  transform: none;
  filter: none;
}

.opening-dialogue-tab-label {
  max-width: 170px;
  min-width: 78px;
  padding: 9px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.opening-dialogue-tab-close {
  min-width: 34px;
  padding: 9px 10px 9px 0;
  color: var(--muted);
}

.opening-dialogue-tab-close:hover {
  color: #ffbadf;
}

.mode-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content max-content;
  gap: 10px;
  align-items: end;
}

.mode-editor-row button {
  width: auto;
  min-width: 112px;
}

.prompt-mode-transfer-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compression-profile-panel {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.compression-profile-actions {
  grid-template-columns: minmax(0, 1fr) max-content max-content max-content;
}

.compression-profile-grid,
.compression-trigger-grid,
.compression-trigger-action-grid,
.compression-append-term-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  min-width: 18px;
}

.compression-trigger-grid textarea,
.compression-trigger-action-grid textarea,
.compression-append-term-grid textarea {
  min-height: 78px;
  resize: vertical;
}

.compression-image-settings {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255, 209, 246, 0.22);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 209, 246, 0.06);
}

.compression-image-settings[hidden] {
  display: none;
}

.compression-image-settings small {
  color: var(--muted);
  line-height: 1.4;
}

.compression-image-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.compression-image-settings-grid label:last-child {
  grid-column: 1 / -1;
}

.compression-trigger-action-list,
.compression-append-term-list {
  max-height: min(42vh, 360px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  contain: layout paint style;
  padding-right: 4px;
}

.compression-trigger-action-card summary,
.compression-append-term-card summary {
  align-items: center;
}

.compression-model-card {
  align-content: start;
}

.compression-model-list {
  max-height: min(52vh, 440px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  contain: layout paint style;
  padding-right: 4px;
}

.compression-trigger-action-card,
.compression-append-term-card,
.compression-model-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}

.compression-model-card textarea.compression-model-rules {
  min-height: auto;
  height: calc(1.45em * 5 + 22px);
  max-height: calc(1.45em * 5 + 22px);
  overflow-y: auto;
  resize: vertical;
  line-height: 1.45;
}

.time-tracking-section {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.time-tracking-section h4 {
  margin: 0;
}

.time-tracking-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.time-tracking-date-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.time-tracking-grid textarea {
  min-height: 120px;
  resize: vertical;
}

.role-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  overflow-wrap: anywhere;
}

.role-card summary {
  cursor: pointer;
  list-style: none;
}

.role-card summary::-webkit-details-marker {
  display: none;
}

.role-card h3 {
  margin: 0;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: 20px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.role-card p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cover-editor {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.cover-editor-actions {
  display: grid;
  gap: 8px;
}

.cover-preview {
  min-height: 112px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.cover-preview img {
  width: 100%;
  height: 100%;
  min-height: 112px;
  object-fit: cover;
}

.cover-crop-dialog {
  width: min(980px, 96vw);
}

.cover-crop-shell {
  display: grid;
  gap: 14px;
}

.cover-crop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(240px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.cover-crop-pane {
  display: grid;
  gap: 8px;
}

.cover-crop-stage {
  position: relative;
  width: 100%;
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.05) 25%, transparent 25%),
    rgba(4, 8, 20, 0.8);
  background-size: 18px 18px;
}

.cover-crop-stage img {
  max-width: 100%;
  max-height: 58vh;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.cover-crop-box {
  position: absolute;
  border: 2px solid #ff2f57;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.34);
  cursor: move;
  touch-action: none;
}

.cover-crop-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: #22c55e;
  border: 1px solid rgba(255, 255, 255, 0.8);
  cursor: nwse-resize;
}

.cover-crop-preview {
  width: 100%;
  max-height: 360px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  object-fit: contain;
}

.desktop-role-picker-btn {
  display: block;
}

.desktop-session-picker-btn {
  display: block;
}

@media (min-width: 981px) {
  .role-card-inline-list,
  .session-inline-list {
    display: none;
  }
}

.role-picker-dialog,
.session-picker-dialog {
  width: min(1180px, 94vw);
  max-height: min(92vh, 980px);
}

.role-picker-shell,
.session-picker-shell {
  gap: 14px;
}

.role-picker-header,
.role-picker-pagination {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.role-picker-pagination {
  grid-template-columns: 160px 1fr 160px;
  text-align: center;
}

.role-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.session-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.session-picker-content {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.52fr);
  gap: 14px;
  align-items: stretch;
}

.role-picker-card {
  height: 430px;
  display: grid;
  grid-template-rows: 155px auto minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(255, 79, 200, 0.08), rgba(77, 141, 255, 0.06)),
    rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.03);
}

.role-picker-card.active {
  border-color: rgba(255, 79, 200, 0.65);
  box-shadow: 0 0 22px rgba(255, 79, 200, 0.16), inset 0 0 18px rgba(255, 255, 255, 0.04);
}

.role-picker-cover {
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: #ffd6f2;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: 26px;
  text-shadow: 0 0 12px rgba(255, 79, 200, 0.72);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 79, 200, 0.28), transparent 38%),
    radial-gradient(circle at 70% 70%, rgba(77, 141, 255, 0.28), transparent 40%),
    rgba(6, 12, 30, 0.88);
}

.role-picker-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.role-picker-card h4 {
  margin: 0;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: 22px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-picker-intro,
.role-picker-content {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.role-picker-intro::-webkit-scrollbar,
.role-picker-content::-webkit-scrollbar {
  display: none;
}

.role-picker-intro {
  font-size: 17px;
}

.role-picker-content {
  font-size: 18px;
}

.role-picker-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.role-picker-actions button:first-child {
  grid-column: 1 / -1;
}

.session-picker-card {
  height: 300px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 10%, rgba(77, 141, 255, 0.14), transparent 34%),
    linear-gradient(160deg, rgba(255, 79, 200, 0.08), rgba(77, 141, 255, 0.06)),
    rgba(255, 255, 255, 0.04);
}

.session-picker-card.active {
  border-color: rgba(77, 141, 255, 0.72);
  box-shadow: 0 0 22px rgba(77, 141, 255, 0.16), inset 0 0 18px rgba(255, 255, 255, 0.04);
}

.session-picker-card.previewing {
  border-color: rgba(255, 214, 242, 0.72);
  box-shadow: 0 0 22px rgba(255, 79, 200, 0.16), inset 0 0 18px rgba(255, 255, 255, 0.04);
}

.session-picker-card h4 {
  margin: 0;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: 23px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-picker-role,
.session-picker-meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  word-break: break-word;
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.session-picker-role::-webkit-scrollbar,
.session-picker-meta::-webkit-scrollbar {
  display: none;
}

.session-picker-role {
  font-size: 19px;
  color: #dbe8ff;
}

.session-picker-meta {
  font-size: 17px;
}

.session-picker-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.session-picker-actions button:first-child {
  grid-column: 1 / -1;
}

.session-preview-panel {
  min-height: 300px;
  max-height: min(65vh, 690px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background:
    radial-gradient(circle at 22% 8%, rgba(255, 79, 200, 0.14), transparent 34%),
    linear-gradient(160deg, rgba(77, 141, 255, 0.08), rgba(255, 79, 200, 0.06)),
    rgba(255, 255, 255, 0.04);
}

.session-preview-panel > header {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.session-preview-panel > header strong {
  overflow: hidden;
  color: #f8fbff;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-preview-panel > header span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.session-preview-messages {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 12px;
  overscroll-behavior: contain;
}

.session-preview-message {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(4, 7, 19, 0.34);
}

.session-preview-message.user {
  border-color: rgba(77, 141, 255, 0.2);
}

.session-preview-message.assistant {
  border-color: rgba(255, 79, 200, 0.2);
}

.session-preview-message-header {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}

.session-preview-message-header strong {
  min-width: 0;
  overflow: hidden;
  color: #f8fbff;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-preview-message-header span {
  flex: none;
  color: #8fa5cf;
  font-size: 12px;
}

.session-preview-message-body {
  max-height: 220px;
  overflow: auto;
  color: #dbe8ff;
  font-size: 14px;
  line-height: 1.55;
}

.inline-actions {
  display: flex;
  gap: 8px;
}

.inline-actions button {
  flex: 1;
}

.discord-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 76px;
  padding: 12px 24px;
  border-bottom: 1px solid rgba(158, 148, 205, 0.18);
  background: rgba(5, 3, 14, 0.92);
}

.discord-chat-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.chat-header-avatar .discord-avatar {
  width: 46px;
  height: 46px;
}

.chat-header-text {
  min-width: 0;
}

.chat-header-text h2 {
  margin: 0;
  max-width: 44vw;
  color: #ebe8ff;
  font-size: 26px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-text p {
  margin: 4px 0 0;
  color: #a9a3c8;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.discord-chat-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 42px;
  height: 42px;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  color: #c9c4e8;
  font-size: 20px;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.messages {
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  border: 0;
  border-radius: 0;
  padding: 14px 0 22px;
  background: rgba(7, 5, 18, 0.72);
}

.discord-empty {
  margin: 28px;
  color: #9f98c2;
  font-size: 20px;
}

.discord-date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 28px 16px;
  color: #b9b3d8;
  font-weight: 800;
  font-size: 18px;
}

.discord-date-divider::before,
.discord-date-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(174, 165, 214, 0.24);
}

.compression-notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 79, 200, 0.38);
  border-radius: 12px;
  background:
    linear-gradient(120deg, rgba(255, 79, 200, 0.16), rgba(77, 141, 255, 0.12)),
    rgba(5, 10, 18, 0.5);
  color: #ffd6f2;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 0 10px rgba(255, 79, 200, 0.6);
}

.auto-time-warning-notice {
  margin: 14px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 194, 97, 0.45);
  border-radius: 10px;
  background: rgba(44, 33, 12, 0.62);
  color: #ffe2aa;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.message {
  position: relative;
}

.discord-message {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 4px 18px 12px 24px;
  border-radius: 0;
  contain: layout style;
}

.discord-message:hover {
  background: rgba(255, 255, 255, 0.045);
}

.discord-avatar {
  width: 48px;
  height: 48px;
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.28), transparent 38%),
    linear-gradient(145deg, rgba(88, 101, 242, 0.9), rgba(255, 122, 201, 0.72));
  color: #fff;
  font-weight: 900;
  font-size: 18px;
}

.discord-avatar img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discord-avatar.has-image img {
  display: block;
}

.discord-avatar.has-image span {
  display: none;
}

.discord-message-body {
  min-width: 0;
}

.discord-message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 28px;
  flex-wrap: wrap;
}

.discord-message-author {
  color: #eeeaff;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
}

.discord-message-badge {
  max-width: min(42vw, 240px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(150, 145, 174, 0.32);
  color: #e8e5ff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

.discord-message-time,
.discord-message-edited {
  color: #aaa4c7;
  font-size: 16px;
  font-weight: 700;
}

.message-content {
  padding: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 24px;
  line-height: 1.55;
  word-break: break-word;
  border-top: 0;
}

.message-feedback-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  margin-top: 6px;
}

.message-feedback-button {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(187, 180, 220, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  color: #eeeaff;
  font-size: 18px;
}

.message-feedback-button:hover,
.message-feedback-button.active {
  border-color: rgba(255, 122, 201, 0.56);
  background: rgba(255, 122, 201, 0.16);
}

.message-feedback-state {
  color: #b9b3d8;
  font-size: 15px;
  font-weight: 700;
}

.message-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 320px));
  gap: 10px;
  margin-top: 8px;
}

.message-image-link {
  display: block;
  max-width: 320px;
  overflow: hidden;
  border: 1px solid rgba(183, 159, 255, 0.34);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
}

.message-image-link img {
  display: block;
  width: 100%;
  height: auto;
}

.discord-message-menu {
  position: relative;
  align-self: start;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.discord-message:hover .discord-message-menu,
.discord-message-menu[open] {
  opacity: 1;
}

.discord-message-menu > summary {
  width: 42px;
  height: 36px;
  display: grid;
  place-items: center;
  list-style: none;
  cursor: pointer;
  border-radius: 9px;
  color: #d6d2ef;
  background: rgba(47, 42, 64, 0.9);
  font-size: 24px;
}

.discord-message-menu > summary::-webkit-details-marker {
  display: none;
}

.discord-message-menu-list {
  position: absolute;
  right: 0;
  top: 40px;
  z-index: 5;
  width: 180px;
  padding: 8px;
  border: 1px solid rgba(187, 180, 220, 0.18);
  border-radius: 10px;
  background: #292638;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.38);
}

.discord-message-menu-list button {
  width: 100%;
  min-height: 36px;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  color: #eeeaff;
  font-size: 16px;
  text-align: left;
}

.discord-message-menu-list button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.markdown-body {
  white-space: normal;
}

.markdown-body p,
.message-reasoning-content p {
  margin: 0 0 0.75em;
}

.markdown-body p:last-child,
.message-reasoning-content p:last-child {
  margin-bottom: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 0.6em 0 0.35em;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  line-height: 1.25;
  color: #ffd6f2;
  text-shadow: 0 0 10px rgba(255, 79, 200, 0.35);
}

.markdown-body h1 { font-size: 1.35em; }
.markdown-body h2 { font-size: 1.25em; }
.markdown-body h3 { font-size: 1.15em; }

.markdown-body ul,
.markdown-body ol,
.message-reasoning-content ul,
.message-reasoning-content ol {
  margin: 0.4em 0 0.85em;
  padding-left: 1.4em;
}

.markdown-body li,
.message-reasoning-content li {
  margin: 0.18em 0;
}

.markdown-body blockquote,
.message-reasoning-content blockquote {
  margin: 0.6em 0;
  padding: 0.55em 0.8em;
  border-left: 3px solid rgba(255, 79, 200, 0.72);
  border-radius: 0 10px 10px 0;
  background: rgba(255, 79, 200, 0.08);
  color: #f3e8ff;
}

.markdown-body code,
.message-reasoning-content code {
  padding: 0.08em 0.32em;
  border-radius: 6px;
  background: rgba(5, 10, 18, 0.72);
  color: #bfece6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.markdown-body pre,
.message-reasoning-content pre {
  margin: 0.65em 0;
  padding: 0.85em;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(5, 10, 18, 0.76);
}

.markdown-body pre code,
.message-reasoning-content pre code {
  padding: 0;
  background: transparent;
  white-space: pre;
}

.markdown-body a,
.message-reasoning-content a {
  color: #86c6ff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.discord-message-content.streaming-reasoning .markdown-body {
  color: #aaa4c7;
  font-style: italic;
}

.markdown-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.65em 0;
  border-radius: 8px;
}

.markdown-body table {
  width: 100%;
  margin: 0.75em 0;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
}

.markdown-body th,
.markdown-body td {
  padding: 0.45em 0.6em;
  border: 1px solid rgba(255, 255, 255, 0.16);
  vertical-align: top;
}

.markdown-body th {
  background: rgba(255, 255, 255, 0.08);
  color: #ffd6f2;
}

.markdown-body hr {
  margin: 0.85em 0;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.markdown-body details {
  margin: 0.7em 0;
  padding: 0.55em 0.75em;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.markdown-body summary {
  cursor: pointer;
  font-weight: 800;
}

.markdown-body div,
.markdown-body section,
.markdown-body article,
.markdown-body aside,
.markdown-body figure {
  max-width: 100%;
}

.message-reasoning {
  margin: 0 12px 10px;
  border: 1px solid rgba(46, 196, 182, 0.2);
  border-radius: 10px;
  background: rgba(46, 196, 182, 0.06);
}

.message-reasoning summary {
  cursor: pointer;
  padding: 8px 10px;
  font-size: 17px;
  color: #bfece6;
  list-style: none;
}

.message-reasoning summary::-webkit-details-marker {
  display: none;
}

.message-reasoning-content {
  padding: 0 10px 10px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  word-break: break-word;
  font-size: 23px;
  line-height: 1.6;
  color: #dffaf7;
}

.ai-log-box {
  margin-top: 12px;
}

.ai-log-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  max-height: min(70dvh, 560px);
  overflow: auto;
  overscroll-behavior: contain;
}

.ai-log-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.ai-log-cost-total {
  border: 1px solid rgba(191, 236, 230, 0.22);
  border-radius: 10px;
  padding: 9px 10px;
  background: rgba(62, 186, 168, 0.08);
  color: #dffaf7;
  font-size: 17px;
  font-weight: 800;
}

.ai-log-item summary {
  cursor: pointer;
  list-style: none;
}

.ai-log-item summary::-webkit-details-marker {
  display: none;
}

.ai-log-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 18px;
  color: #d6e1ff;
}

.ai-log-usage {
  color: #bfece6;
  font-size: 17px;
  margin-left: auto;
}

.ai-log-status {
  color: var(--muted);
  font-size: 17px;
}

.ai-log-status.error {
  color: #ffb0bc;
}

.ai-log-status.skipped {
  color: #ffe0ab;
}

.ai-log-body {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.ai-log-body label {
  font-size: 17px;
}

.ai-log-block {
  margin: 4px 0 0;
  min-height: 110px;
  max-height: 320px;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(5, 10, 18, 0.55);
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
}

.ai-log-block.reasoning {
  border-color: rgba(46, 196, 182, 0.35);
  background: rgba(46, 196, 182, 0.08);
}

.ai-log-block.cost {
  border-color: rgba(191, 236, 230, 0.24);
  background: rgba(23, 76, 68, 0.34);
  color: #dffaf7;
}

.meta-box {
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.meta-box summary {
  cursor: pointer;
  font-weight: 700;
}

.meta-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.chat-input {
  position: relative;
  margin: 0 18px 18px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  border: 1px solid rgba(134, 124, 194, 0.2);
  border-radius: 14px;
  background: #181331;
}

.chat-input textarea {
  height: 48px;
  min-height: 48px;
  max-height: 168px;
  padding: 9px 4px;
  border: 0;
  background: transparent;
  color: #eeeaff;
  resize: none;
  overflow-y: hidden;
  line-height: 1.45;
  box-shadow: none;
}

.chat-input.has-command-composer textarea {
  display: none;
}

.chat-command-composer {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 0;
}

.chat-command-composer[hidden] {
  display: none;
}

.chat-command-composer-command {
  flex: 0 0 auto;
  padding: 7px 10px;
  border-radius: 8px;
  background: #312a55;
  color: #fffaff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.chat-command-param {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid rgba(190, 181, 244, 0.18);
  border-radius: 8px;
  background: #211b3e;
}

.chat-command-param.active {
  border-color: rgba(220, 214, 255, 0.72);
  box-shadow: 0 0 0 1px rgba(220, 214, 255, 0.18);
}

.chat-command-param-number,
.chat-command-param-message_number {
  flex: 0 0 142px;
}

.chat-command-param-message,
.chat-command-param-feedback,
.chat-command-param-content,
.chat-command-param-name,
.chat-command-param-id {
  flex: 1 1 240px;
}

.chat-command-param-label {
  flex: 0 0 auto;
  color: #c9c2e9;
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
}

.chat-command-param-input {
  width: 100%;
  min-width: 42px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fffaff;
  font-size: 18px;
  line-height: 1.2;
  outline: 0;
}

.chat-command-param-input::placeholder {
  color: #8f88ae;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.chat-input button {
  width: auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 16px;
}

.chat-plus-button {
  width: 52px;
  height: 46px;
  padding: 0;
  border-radius: 11px;
  color: #d7d1f5;
  background: #312c4e;
  font-size: 33px;
  line-height: 1;
}

.chat-plus-button:hover,
.chat-plus-button[aria-expanded="true"] {
  background: #3c355d;
  transform: none;
  filter: none;
}

.chat-command-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 9px);
  z-index: 12;
  display: grid;
  gap: 4px;
  max-height: min(42dvh, 320px);
  overflow: auto;
  padding: 5px;
  border: 1px solid rgba(151, 143, 210, 0.55);
  border-radius: 17px;
  background: #171328;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(255, 255, 255, 0.035);
}

.chat-command-menu[hidden] {
  display: none;
}

.chat-command-menu.is-command-form {
  gap: 7px;
  padding: 6px;
}

.chat-command-item {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #eeeaff;
  text-align: left;
}

.chat-command-menu.is-filtered .chat-command-item {
  grid-template-columns: 56px minmax(0, 1fr);
}

.chat-command-item:hover,
.chat-command-item.active {
  background: #312a55;
  border-color: rgba(202, 194, 255, 0.28);
  transform: none;
  filter: none;
}

.chat-command-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: #484260;
  color: #f4eaff;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.chat-command-body {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.chat-command-title {
  overflow: hidden;
  color: #f3efff;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-command-name {
  color: #fffaff;
}

.chat-command-title-text {
  color: #f0ecff;
}

.chat-command-description {
  overflow: hidden;
  color: #c4bedc;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.28;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-command-hint {
  align-self: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: #4b4566;
  color: #eeeaff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.chat-command-empty {
  padding: 16px;
  color: #b8b0d8;
  text-align: center;
}

.chat-command-form-header {
  min-height: 56px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid rgba(202, 194, 255, 0.28);
  border-radius: 12px;
  background: #312a55;
}

.chat-command-field-help-list {
  display: grid;
  gap: 5px;
}

.chat-command-field-help {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 38px;
  padding: 7px 10px;
  border-radius: 10px;
  color: #c9c2e9;
}

.chat-command-field-help.active {
  background: rgba(126, 115, 185, 0.28);
  color: #fffaff;
}

.chat-command-field-help-name {
  font-size: 16px;
  font-weight: 900;
}

.chat-command-field-help-text {
  min-width: 0;
  overflow: hidden;
  color: #c4bedc;
  font-size: 15px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog {
  width: min(720px, 92vw);
  max-height: min(90vh, 920px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  color: var(--text);
  background: #111c31;
  padding: 14px;
  overflow: auto;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog h3 {
  margin: 0;
}

.prompt-viewer-dialog {
  width: min(1040px, 90vw);
  overflow: hidden;
}

.prompt-viewer-dialog > form {
  max-height: calc(min(90vh, 920px) - 28px);
  overflow: auto;
  overscroll-behavior: contain;
  scroll-behavior: auto;
  padding-right: 6px;
}

.novelai-dialog {
  width: min(1480px, 96vw);
  padding: 0;
  background: #11101f;
}

.novelai-page-body {
  min-height: 100vh;
  overflow-y: auto;
  background:
    radial-gradient(circle at 12% 8%, rgba(77, 141, 255, 0.18), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(255, 79, 200, 0.12), transparent 24%),
    #050412;
}

.novelai-page-shell {
  width: min(1500px, calc(100vw - 32px));
  min-height: 100vh;
  display: grid;
  gap: 14px;
  margin: 0 auto;
  padding: 18px 0 28px;
}

.novelai-page-header {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
}

.novelai-page-header h1 {
  margin: 2px 0 4px;
  color: #f8fbff;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: 34px;
  line-height: 1.1;
}

.novelai-page-shell .novelai-shell {
  min-width: 0;
}

.novelai-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(5, 4, 18, 0.72);
  pointer-events: none;
}

.novelai-drop-overlay > div {
  max-width: min(520px, 88vw);
  padding: 22px 24px;
  border: 2px dashed rgba(134, 198, 255, 0.72);
  border-radius: 16px;
  background: rgba(17, 16, 31, 0.94);
  color: #f8fbff;
  font-size: 22px;
  font-weight: 900;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.36);
}

body.is-novelai-drop-active .novelai-drop-overlay {
  display: grid;
}

body.novelai-studio-body {
  height: 100vh;
  overflow: hidden;
  background: #111329;
}

.novelai-studio-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 450px minmax(0, 1fr) 140px;
  background: #111329;
  color: #fffdf5;
}

.novelai-studio-sidebar,
.novelai-history-rail {
  min-width: 0;
  min-height: 0;
  background: #17182f;
}

.novelai-studio-sidebar {
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.novelai-studio-brand {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px 48px;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.novelai-back-link,
.novelai-square-button {
  width: 48px;
  min-height: 54px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #f8f4c0;
  font-size: 30px;
  text-decoration: none;
}

.novelai-square-button {
  min-height: 42px;
  color: #ffffff;
  font-size: 24px;
}

.novelai-anlas-pill {
  min-width: 116px;
  max-width: 100%;
  padding: 9px 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 0;
  border-radius: 3px 0 0 3px;
  background: #1e2039;
  color: #fffad2;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.novelai-anlas-group {
  justify-self: center;
  max-width: 100%;
  display: inline-flex;
  min-width: 0;
  align-items: stretch;
}

.novelai-anlas-plus {
  width: 46px;
  min-height: 38px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.08);
  border-radius: 0 3px 3px 0;
  background: #252743;
  color: #ffffff;
  font-size: 24px;
  font-weight: 900;
}

.novelai-sidebar-form {
  min-height: 0;
  display: grid;
  gap: 20px;
  align-content: start;
  padding: 34px 20px 0;
  overflow: auto;
}

.novelai-model-card,
.novelai-prompt-card,
.novelai-compact-settings,
.novelai-extra-box {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  background: #111329;
}

.novelai-model-card {
  padding: 18px 20px;
  display: grid;
  gap: 7px;
}

.novelai-model-card label {
  color: #f8f8ff;
  font-size: 16px;
  font-weight: 900;
}

.novelai-model-description {
  margin: 0;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.35;
}

.novelai-model-card select,
.novelai-prompt-card textarea,
.novelai-compact-settings input,
.novelai-compact-settings select,
.novelai-extra-box input,
.novelai-extra-box select,
.novelai-extra-box textarea {
  border-color: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  background: #101126;
}

.novelai-model-card select {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 16px;
  font-weight: 900;
}

.novelai-prompt-card {
  padding: 18px 14px 12px;
}

.novelai-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
}

.novelai-card-title strong {
  min-width: 0;
  flex: 1 1 auto;
}

.novelai-card-icon-button {
  width: 30px;
  min-height: 30px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #ffffff;
  font-size: 17px;
}

.novelai-prompt-card textarea {
  min-height: 168px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fffdf5;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.62;
  resize: vertical;
}

.novelai-prompt-meter {
  height: 4px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.novelai-prompt-meter span {
  display: block;
  width: 30%;
  height: 100%;
  background: #d9dbe8;
}

.novelai-compact-settings {
  padding: 0;
}

.novelai-compact-settings > summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 16px;
  list-style: none;
  cursor: pointer;
}

.novelai-compact-settings > summary::-webkit-details-marker,
.novelai-extra-box > summary::-webkit-details-marker {
  display: none;
}

.novelai-compact-settings > summary span {
  min-width: 0;
  color: #cfd4ff;
  font-size: 13px;
  line-height: 1.35;
}

.novelai-compact-settings > summary b {
  display: block;
  overflow: hidden;
  color: #ffffff;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.novelai-compact-settings .novelai-control-grid {
  padding: 0 14px 14px;
}

.novelai-sidebar-form .novelai-control-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.novelai-sidebar-form label {
  color: #cfd4ff;
  font-size: 14px;
}

.novelai-toggle-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.novelai-toggle-grid label {
  border-radius: 3px;
  background: #111329;
  color: #e7e9ff;
  font-size: 14px;
}

.novelai-extra-box {
  padding: 12px 14px;
}

.novelai-extra-box > summary {
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
}

.novelai-small-preview {
  border-radius: 3px;
  background: #0f1024;
}

.novelai-generate-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0 -20px;
  padding: 16px 20px 18px;
  background: linear-gradient(180deg, rgba(23, 24, 47, 0), #17182f 28%);
}

.novelai-cost-preview {
  min-height: 34px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: #cfd4ff;
  font-size: 14px;
}

#novelAiGenerateBtn {
  min-height: 44px;
  border-radius: 3px;
  background: #fffcc5;
  color: #06071a;
  font-size: 15px;
  font-weight: 950;
}

.novelai-canvas-workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 74px minmax(0, 1fr) 54px;
  background: #111329;
}

.novelai-tool-strip {
  justify-self: center;
  align-self: start;
  display: flex;
  gap: 1px;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #1a1b31;
}

.novelai-tool-strip button {
  width: 46px;
  min-height: 42px;
  padding: 0;
  border-radius: 0;
  background: #1a1b31;
  color: #ffffff;
  font-size: 18px;
}

.novelai-tool-strip button:nth-child(3) {
  width: 60px;
  font-size: 14px;
  font-weight: 900;
}

.novelai-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 22px 28px;
  overflow: hidden;
}

.novelai-output-grid {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.novelai-output-grid .novelai-empty-card {
  width: min(760px, 88%);
  min-height: 360px;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.025);
  color: #9ea4d1;
  font-size: 20px;
}

.novelai-output-grid .novelai-image-card {
  width: min(100%, 1100px);
  max-height: 100%;
  display: grid;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.novelai-output-grid .novelai-image-preview {
  width: 100%;
  max-height: calc(100vh - 190px);
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  aspect-ratio: auto;
}

.novelai-output-grid .novelai-image-preview img {
  width: 100%;
  max-height: calc(100vh - 210px);
  object-fit: contain;
}

.novelai-output-grid .novelai-image-meta,
.novelai-output-grid .novelai-image-actions {
  width: min(100%, 480px);
  justify-self: center;
}

.novelai-stage-footer {
  align-self: end;
  justify-self: center;
  min-width: min(100%, 760px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 12px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 850;
}

.novelai-stage-footer > span,
.novelai-stage-footer > div {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: #1a1b31;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

.novelai-history-rail {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 28px 10px 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.novelai-history-rail header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
  font-size: 14px;
}

.novelai-history-rail header button {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 3px;
  background: transparent;
  color: #ffffff;
}

.novelai-rail-title {
  color: #9ea4d1;
  font-size: 13px;
  font-weight: 900;
}

.novelai-history-actions {
  display: grid;
  gap: 8px;
  justify-items: center;
  color: rgba(255, 255, 255, 0.42);
}

.novelai-history-actions button {
  width: 100%;
  min-height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.42);
  font-size: 12px;
  font-weight: 800;
}

.novelai-history-strip {
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.novelai-history-strip .novelai-empty-card {
  min-height: 86px;
  padding: 8px;
  border-radius: 3px;
  font-size: 12px;
}

.novelai-history-strip .novelai-image-card {
  gap: 4px;
  padding: 0;
  border-radius: 2px;
  background: transparent;
}

.novelai-history-strip .novelai-image-preview {
  border-radius: 2px;
}

.novelai-history-strip .novelai-image-meta,
.novelai-history-strip .novelai-image-actions {
  display: none;
}

.novelai-dialog > form {
  padding: 14px;
}

.novelai-shell {
  display: grid;
  gap: 14px;
}

.novelai-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: #11101f;
}

.novelai-header-actions {
  flex: 0 0 auto;
}

.novelai-layout {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.novelai-settings,
.novelai-results,
.novelai-output-section,
.novelai-extra-box {
  min-width: 0;
}

.novelai-settings {
  align-self: start;
}

.novelai-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #ffd6f2;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: 21px;
  font-weight: 800;
}

.novelai-title-row button {
  width: auto;
  min-width: 84px;
  padding: 8px 12px;
  font-size: 16px;
}

.novelai-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.novelai-toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.novelai-toggle-grid label {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.novelai-toggle-grid input {
  width: auto;
}

.novelai-image-pick-row {
  display: grid;
  grid-template-columns: 136px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.novelai-small-preview {
  width: 136px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: rgba(5, 10, 18, 0.48);
  color: var(--muted);
  text-align: center;
  font-size: 15px;
}

.novelai-small-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.novelai-character-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.novelai-character-card {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.novelai-character-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.novelai-character-header button {
  width: auto;
  min-width: 72px;
  padding: 7px 10px;
  font-size: 16px;
}

.novelai-generate-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 152px;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  background: linear-gradient(180deg, rgba(17, 16, 31, 0), #11101f 30%);
}

.novelai-cost-preview {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(191, 236, 230, 0.2);
  border-radius: 10px;
  background: rgba(23, 76, 68, 0.22);
  color: #dffaf7;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.35;
}

.novelai-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  min-height: 120px;
}

.novelai-image-card,
.novelai-empty-card {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.novelai-empty-card {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.novelai-image-card {
  display: grid;
  gap: 9px;
  padding: 9px;
}

.novelai-image-preview {
  width: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(5, 10, 18, 0.55);
}

.novelai-image-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.novelai-image-meta {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.novelai-image-meta strong,
.novelai-image-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.novelai-image-meta strong {
  color: #f8fbff;
  font-size: 16px;
}

.novelai-image-meta span {
  color: var(--muted);
  font-size: 14px;
}

.novelai-image-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.novelai-image-actions button {
  min-height: 36px;
  padding: 7px 8px;
  font-size: 15px;
}

body.novelai-studio-body .novelai-generate-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 46px;
  gap: 8px;
  align-items: stretch;
  margin: 0 -20px;
  padding: 16px 20px 18px;
  background: linear-gradient(180deg, rgba(23, 24, 47, 0), #17182f 28%);
}

body.novelai-studio-body .novelai-generate-side-button,
body.novelai-studio-body #novelAiGenerateBtn {
  min-height: 44px;
  border-radius: 3px;
}

body.novelai-studio-body .novelai-generate-side-button {
  width: 46px;
  padding: 0;
  background: #252743;
  color: #ffffff;
  font-size: 18px;
}

body.novelai-studio-body #novelAiGenerateBtn {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 0 10px 0 18px;
  background: #fffcc5;
  color: #06071a;
  font-size: 15px;
  font-weight: 950;
}

body.novelai-studio-body #novelAiGenerateBtn span:first-child {
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.novelai-studio-body .novelai-cost-preview {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 0;
  border-radius: 3px;
  background: #15162c;
  color: #fffcc5;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

body.novelai-studio-body .novelai-toggle-grid label {
  border-radius: 3px;
  background: #111329;
  color: #e7e9ff;
  font-size: 14px;
}

body.novelai-studio-body .novelai-small-preview {
  border-radius: 3px;
  background: #0f1024;
}

.env-settings-fields {
  display: grid;
  gap: 14px;
}

.env-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.env-section h4 {
  margin: 0;
  color: #ffd6f2;
  font-size: 20px;
}

.env-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.env-field {
  min-width: 0;
}

.env-field-wide {
  grid-column: 1 / -1;
}

.env-image-field {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: center;
}

.env-image-field .env-field-title,
.env-image-field .env-field-key,
.env-image-field .env-field-help {
  grid-column: 1 / -1;
}

.env-image-preview {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.env-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.env-image-actions {
  display: grid;
  gap: 8px;
  align-content: center;
  justify-items: start;
}

.env-image-actions button {
  width: auto;
  min-width: 118px;
}

.env-field-title {
  color: var(--text);
  font-weight: 700;
}

.env-field-key {
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 2px 6px;
  border-radius: 6px;
  color: #b9cdfb;
  background: rgba(77, 141, 255, 0.12);
  font-size: 14px;
}

.env-field-help {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.env-test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-api-processing-keys {
  display: grid;
  gap: 8px;
}

.chat-api-processing-key-list {
  margin: 0;
}

.env-test-status {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

.env-test-status.testing {
  color: #f8d777;
}

.env-test-status.success {
  color: #86efac;
}

.env-test-status.error {
  color: #ff9faf;
}

.env-extra-box {
  margin-top: 0;
}

.env-extra-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.env-extra-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.env-extra-row button {
  width: auto;
  min-width: 76px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.prompt-stack {
  grid-template-columns: 1fr;
}

.prompt-grid textarea {
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.55;
}

.prompt-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
}

.dialog-actions button {
  touch-action: manipulation;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.92);
  color: #04200f;
  font-weight: 700;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: rgba(255, 93, 115, 0.95);
  color: #2f020a;
}

@keyframes neonPulse {
  0%,
  100% {
    opacity: 0.94;
    filter: brightness(1);
  }

  45% {
    opacity: 1;
    filter: brightness(1.28);
  }

  52% {
    opacity: 0.82;
    filter: brightness(0.92);
  }

  58% {
    opacity: 1;
    filter: brightness(1.38);
  }
}

@keyframes clickRipple {
  to {
    transform: translate(-50%, -50%) scale(1.7);
    opacity: 0;
  }
}

@media (max-width: 980px) {
  html,
  body {
    min-height: var(--app-mobile-viewport-height, 100dvh);
  }

  body[data-mobile-page="chat"] {
    height: var(--app-mobile-viewport-height, 100dvh);
    overflow: hidden;
  }

  body[data-mobile-page="controls"] {
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .env-grid,
  .env-extra-row {
    grid-template-columns: 1fr;
  }

  .env-extra-row button {
    width: 100%;
  }

  .env-image-field {
    grid-template-columns: 1fr;
  }

  .env-image-actions {
    justify-items: stretch;
  }

  .env-image-actions button {
    width: 100%;
  }

  .novelai-dialog {
    width: 100vw;
    max-width: 100vw;
    max-height: var(--app-mobile-viewport-height, 100dvh);
    border-radius: 0;
  }

  .novelai-page-shell {
    width: 100vw;
    padding: 0 0 16px;
  }

  .novelai-page-header {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  body.novelai-studio-body {
    height: auto;
    overflow-y: auto;
  }

  .novelai-studio-shell {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
  }

  .novelai-studio-sidebar {
    grid-template-rows: auto auto;
    border-right: 0;
  }

  .novelai-sidebar-form {
    padding: 16px 12px 0;
    overflow: visible;
  }

  .novelai-canvas-workspace {
    min-height: 74vh;
    grid-template-rows: auto minmax(420px, 1fr) auto;
  }

  .novelai-tool-strip {
    max-width: calc(100vw - 20px);
    overflow-x: auto;
  }

  .novelai-stage {
    padding: 12px;
  }

  .novelai-stage-footer {
    min-width: 0;
    width: calc(100vw - 20px);
    margin-bottom: 12px;
  }

  .novelai-history-rail {
    grid-template-rows: auto auto auto auto auto;
    max-height: none;
    border-left: 0;
    padding: 14px 12px 18px;
  }

  .novelai-history-strip {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    max-height: 240px;
  }

  .novelai-dialog > form {
    max-height: calc(var(--app-mobile-viewport-height, 100dvh) - 2px);
    padding: 10px;
  }

  .novelai-page-shell .novelai-shell {
    padding: 10px;
  }

  .novelai-header {
    align-items: stretch;
    flex-direction: column;
  }

  .novelai-header-actions,
  .novelai-generate-bar,
  .novelai-layout,
  .novelai-control-grid,
  .novelai-toggle-grid,
  .novelai-image-pick-row {
    grid-template-columns: 1fr;
  }

  .novelai-image-grid {
    grid-template-columns: repeat(auto-fill, minmax(154px, 1fr));
  }

  .novelai-small-preview {
    width: 100%;
    max-width: 220px;
  }

  .novelai-image-actions {
    grid-template-columns: 1fr;
  }

  .layout {
    width: 100vw;
    max-width: none;
    margin: 0;
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
    overflow-x: clip;
  }

  .layout > *,
  .sidebar,
  .chat-panel,
  .chat-primary,
  .chat-secondary,
  .mobile-chat-page,
  .mobile-controls-page {
    min-width: 0;
    max-width: 100vw;
  }

  .panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .mobile-info-toggle {
    display: inline-flex;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 6;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 999px;
    background: rgba(15, 26, 43, 0.94);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  }

  .mobile-info-drawer {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    transform: translateY(calc(-100% - 24px));
    transition: transform 0.2s ease;
    pointer-events: none;
  }

  body[data-mobile-info-open="true"] .mobile-info-drawer {
    transform: translateY(0);
    pointer-events: auto;
  }

  .mobile-info-drawer .hero {
    margin: 0;
    padding: 58px 14px 12px;
    border: 0;
    border-radius: 0 0 18px 18px;
    background: linear-gradient(160deg, rgba(28, 44, 76, 0.97), rgba(14, 24, 43, 0.98));
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
    padding: 10px 14px 14px;
    background: rgba(15, 26, 43, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
  }

  .discord-chat-header {
    padding-left: 64px;
  }

  body[data-mobile-page="chat"] .mobile-controls-page {
    display: none;
  }

  body[data-mobile-page="controls"] .mobile-chat-page {
    display: none;
  }

  .chat-panel {
    min-height: var(--app-mobile-viewport-height, 100dvh);
    order: -1;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  body[data-mobile-page="chat"] .chat-panel {
    height: var(--app-mobile-viewport-height, 100dvh);
    max-height: var(--app-mobile-viewport-height, 100dvh);
  }

  body[data-mobile-page="controls"] .chat-panel {
    min-height: auto;
    order: -2;
  }

  .chat-primary {
    height: var(--app-mobile-viewport-height, 100dvh);
    max-height: var(--app-mobile-viewport-height, 100dvh);
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 0;
  }

  .sidebar,
  .chat-secondary {
    width: 100%;
    padding: 16px 0 20px;
    overflow-x: clip;
  }

  .desktop-role-picker-btn {
    display: none;
  }

  .desktop-session-picker-btn {
    display: none;
  }

  .sidebar > *,
  .chat-secondary > * {
    width: min(calc(100% - 24px), 720px);
    max-width: calc(100vw - 24px);
    margin-left: auto;
    margin-right: auto;
  }

  .sidebar .stack,
  .sidebar .actions-block,
  .sidebar .card-list,
  .chat-secondary .ai-log-list {
    min-width: 0;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar .stack > *,
  .sidebar .actions-block > *,
  .sidebar .card-list > *,
  .chat-secondary .ai-log-list > *,
  .role-card > *,
  .inline-actions > * {
    min-width: 0;
    max-width: 100%;
  }

  .sidebar input,
  .sidebar textarea,
  .sidebar select,
  .sidebar button,
  .role-card,
  .inline-actions {
    max-width: 100%;
  }

  .chat-secondary {
    align-content: start;
  }

  .chat-secondary .ai-log-box {
    min-height: 64px;
    margin-top: 0;
  }

  .chat-secondary .ai-log-box > summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .compression-profile-grid,
  .compression-trigger-grid,
  .compression-trigger-action-grid,
  .compression-image-settings-grid,
  .compression-append-term-grid,
  .compression-profile-actions {
    grid-template-columns: 1fr;
  }

  .cover-editor {
    grid-template-columns: 1fr;
  }

  .cover-crop-layout {
    grid-template-columns: 1fr;
  }

  .cover-crop-stage {
    min-height: 280px;
  }

  .session-picker-content,
  .role-picker-grid,
  .session-picker-grid,
  .role-picker-pagination {
    grid-template-columns: 1fr;
  }

  .session-preview-panel {
    max-height: none;
  }

  .role-picker-card {
    height: auto;
    min-height: 0;
  }

  .session-picker-card {
    height: auto;
    min-height: 0;
  }

  .role-picker-intro,
  .role-picker-content {
    max-height: none;
  }

  .inline-actions,
  .dialog-actions {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  body {
    background: linear-gradient(180deg, #0f1a2b 0%, #101d33 100%);
  }

  .mobile-info-drawer .hero h1 {
    font-size: 29px;
  }

  .sidebar,
  .chat-panel {
    padding: 0;
  }

  .messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 10px 0 calc(var(--chat-input-height, 76px) + env(safe-area-inset-bottom, 0px) + 12px);
    border: 0;
    border-radius: 0;
    background: #070512;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .discord-chat-header {
    flex: 0 0 auto;
    min-height: 64px;
    padding: 10px 14px 10px 64px;
  }

  .chat-header-text h2 {
    max-width: 52vw;
    font-size: 22px;
  }

  .discord-message {
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 4px 8px 12px 12px;
  }

  .discord-avatar {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }

  .discord-message-author {
    font-size: 20px;
  }

  .message-content {
    font-size: 21px;
  }

  .message {
    max-width: 100%;
    margin-bottom: 12px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    overflow: visible;
  }

  .message.user {
    margin-left: auto;
    background: linear-gradient(145deg, rgba(46, 196, 182, 0.22), rgba(46, 196, 182, 0.1));
    border-color: rgba(46, 196, 182, 0.28);
  }

  .message.assistant {
    margin-right: auto;
    background: linear-gradient(145deg, rgba(255, 159, 26, 0.18), rgba(255, 159, 26, 0.08));
    border-color: rgba(255, 159, 26, 0.24);
  }

  .message-summary {
    padding: 0;
  }

  .message-summary .meta,
  .message-summary .message-preview {
    display: none;
  }

  .message-content {
    padding: 12px 10px;
    border-top: 0;
    font-size: 25px;
    line-height: 1.7;
  }

  .message-reasoning {
    margin: 0 10px 10px;
    border-radius: 14px;
  }

  .chat-primary {
    height: var(--app-mobile-viewport-height, 100dvh);
    max-height: var(--app-mobile-viewport-height, 100dvh);
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    gap: 0;
    overflow: hidden;
  }

  .ai-log-list {
    max-height: min(58dvh, 520px);
    overflow: auto;
  }

  .ai-log-box {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .chat-input {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 7;
    width: 100%;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    justify-items: stretch;
    gap: 8px;
    margin: 0;
    padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 0;
    background: #15102d;
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.24);
    transform: translateZ(0);
  }

  .chat-command-menu {
    left: 8px;
    right: 8px;
    bottom: calc(100% + 8px);
    max-height: min(40dvh, 300px);
  }

  .chat-command-item {
    min-height: 58px;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    padding: 8px;
  }

  .chat-command-menu.is-filtered .chat-command-item,
  .chat-command-form-header {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .chat-command-title {
    font-size: 17px;
  }

  .chat-command-description {
    font-size: 14px;
  }

  .chat-command-composer {
    min-height: 46px;
    gap: 5px;
  }

  .chat-command-composer-command {
    padding: 6px 8px;
    font-size: 16px;
  }

  .chat-command-param {
    min-height: 36px;
    gap: 4px;
    padding: 5px 7px;
  }

  .chat-command-param-number,
  .chat-command-param-message_number {
    flex-basis: 112px;
  }

  .chat-command-param-message,
  .chat-command-param-feedback,
  .chat-command-param-content,
  .chat-command-param-name,
  .chat-command-param-id {
    flex-basis: 150px;
  }

  .chat-command-param-label {
    font-size: 13px;
  }

  .chat-command-param-input {
    font-size: 16px;
  }

  .chat-command-field-help {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .chat-input textarea {
    display: block;
    width: 100%;
    margin: 0;
    height: 46px;
    min-height: 46px;
    max-height: 132px;
    font-size: 19px;
  }

  .chat-actions {
    width: auto;
    margin: 0;
    min-width: 0;
  }

  .chat-input button,
  .actions-block button,
  .inline-actions button {
    min-height: 46px;
  }

  .chat-input button {
    width: auto;
    min-width: 58px;
    height: 46px;
    padding: 0 12px;
    border-radius: 12px;
  }

  .chat-plus-button {
    width: 44px;
    min-width: 44px;
    padding: 0;
  }

  .dialog {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    overflow: hidden;
  }

  .dialog > form {
    height: 100%;
    max-height: 100%;
    overflow: auto;
    padding: 14px 12px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
  }

  .dialog-actions {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 4px -12px 0;
    padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 12px);
    background: linear-gradient(180deg, rgba(17, 28, 49, 0.88), #111c31 34%);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 -14px 28px rgba(0, 0, 0, 0.24);
  }

  .dialog-actions button {
    min-height: 48px;
  }

  .prompt-viewer-dialog textarea {
    min-height: 180px;
  }

  .mode-editor-row {
    grid-template-columns: 1fr;
  }

  .time-tracking-grid {
    grid-template-columns: 1fr;
  }

  .mode-editor-row button {
    width: 100%;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(16px);
  }
}

body.novelai-bright-body {
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: #fff4fb !important;
  color: #3c2b4f;
}

body.novelai-bright-body::before,
body.novelai-bright-body.has-custom-background::before {
  content: none;
  display: none;
  background: none;
}

body.novelai-bright-body #background-canvas,
body.novelai-bright-body #spark-canvas,
body.novelai-bright-body #mouse-follower {
  display: none !important;
}

body.novelai-bright-body button,
body.novelai-bright-body input,
body.novelai-bright-body select,
body.novelai-bright-body textarea {
  font-family: inherit;
}

.nai-bright-shell {
  height: 100vh;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr) minmax(190px, 240px);
  gap: 14px;
  padding: 14px;
}

.nai-left-panel,
.nai-preview-panel,
.nai-history-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid rgba(216, 148, 232, 0.38);
  border-radius: 18px;
  background: #fffafe;
  box-shadow: 0 18px 48px rgba(180, 117, 206, 0.18);
}

.nai-left-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.nai-panel-header,
.nai-preview-panel > header,
.nai-history-panel > header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid rgba(216, 148, 232, 0.26);
}

.nai-panel-header > div {
  min-width: 0;
}

.nai-panel-header h1 {
  margin: 0;
  color: #472957;
  font-size: 24px;
  line-height: 1.1;
}

.nai-title-ciallo {
  color: #866c98;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 20px;
  font-weight: 800;
}

.nai-preview-panel h2 {
  margin: 0;
  color: #472957;
  font-size: 24px;
  line-height: 1.1;
}

.nai-panel-header p,
.nai-preview-panel p,
.nai-history-panel span {
  margin: 4px 0 0;
  color: #866c98;
  font-size: 13px;
  font-weight: 700;
}

.nai-panel-header #novelAiStatus.is-token-ready {
  color: #15803d;
}

.nai-panel-header #novelAiStatus.is-token-missing {
  color: #dc2626;
}

.nai-panel-header .nai-credit-line {
  display: grid;
  gap: 2px;
  margin: 7px 0 0;
  max-width: 520px;
  color: #9b7baa;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
}

.nai-credit-line a {
  display: inline-block;
  color: #d774c3;
  font-family: "Pop Gothic", "Noto Sans TC", "PingFang TC", sans-serif;
  font-weight: 900;
  text-decoration: none;
  text-shadow:
    0 0 1px rgba(255, 255, 255, 0.75),
    0 0 4px rgba(255, 79, 200, 0.42),
    0 0 9px rgba(255, 45, 189, 0.32);
  animation: neonPulse 4s ease-in-out infinite;
}

.nai-credit-line a:hover,
.nai-credit-line a:focus-visible {
  color: #f0a3dd;
  text-decoration: none;
}

.nai-icon-button {
  width: 42px;
  min-height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(211, 148, 232, 0.38);
  border-radius: 14px;
  background: #fff;
  color: #9a4ec4;
  font-size: 24px;
  font-weight: 900;
  text-decoration: none;
}

.nai-icon-button {
  margin-left: auto;
  padding: 0;
  font-size: 18px;
}

.nai-settings-form {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.nai-control-scroll,
.nai-history-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.nai-control-scroll {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 14px 12px 4px;
}

.nai-card {
  min-width: 0;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(224, 161, 238, 0.36);
  border-radius: 16px;
  background: #ffffff;
}

.nai-card-title,
.nai-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.nai-card-title strong {
  color: #553068;
  font-size: 18px;
}

.nai-card-title span,
.nai-card-hint,
.nai-empty-inline {
  color: #9277a4;
  font-size: 13px;
  line-height: 1.45;
}

.nai-empty-inline {
  margin: 0;
  padding: 12px;
  border: 1px dashed rgba(210, 148, 230, 0.48);
  border-radius: 12px;
  background: rgba(255, 248, 254, 0.78);
  text-align: center;
}

.nai-card textarea,
.nai-card select,
.nai-card input[type="text"],
.nai-card input[type="password"],
.nai-card input[type="number"] {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(206, 151, 229, 0.42);
  border-radius: 12px;
  background: #fff;
  color: #3f2a50;
  font-size: 15px;
}

.nai-token-card input[type="password"] {
  font-family: "Xiaolai Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.nai-token-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nai-token-actions .nai-switch {
  margin: 0;
}

.nai-card textarea {
  resize: vertical;
  line-height: 1.55;
}

.nai-prompt-highlight-wrap {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

.nai-prompt-highlight {
  position: absolute;
  inset: 0;
  z-index: 0;
  box-sizing: border-box;
  overflow: hidden;
  border-color: transparent;
  border-style: solid;
  border-radius: 12px;
  background: #fff;
  color: transparent;
  pointer-events: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.nai-card .nai-prompt-highlight-wrap textarea {
  position: relative;
  z-index: 1;
  background: transparent;
  caret-color: #3f2a50;
}

.nai-duplicate-token {
  border-radius: 5px;
  background: rgba(255, 216, 75, 0.72);
  box-shadow: 0 0 0 1px rgba(239, 68, 106, 0.38), 0 0 0 4px rgba(255, 216, 75, 0.22);
  color: transparent;
}

.nai-card textarea.has-duplicate-prompts {
  border-color: rgba(239, 68, 106, 0.82);
  box-shadow: 0 0 0 3px rgba(239, 68, 106, 0.16);
}

.nai-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #6d4b82;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.nai-switch input {
  width: auto;
}

.nai-switch-field {
  min-height: 40px;
  justify-content: flex-start;
  padding: 10px 12px;
  border: 1px solid rgba(218, 154, 235, 0.58);
  border-radius: 12px;
  background: #fff;
}

.nai-character-list,
.nai-reference-list,
.nai-fixed-prompt-list,
.nai-random-prompt-list {
  display: grid;
  gap: 10px;
}

.nai-character-card,
.nai-fixed-prompt-card,
.nai-random-prompt-card {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(214, 150, 232, 0.34);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
}

.nai-character-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.nai-character-header > div {
  display: inline-flex;
  gap: 5px;
}

.nai-random-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nai-random-prompt-header button:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nai-character-header button,
.nai-random-prompt-header button,
.nai-title-row button,
.nai-metadata-card button,
.nai-reference-item button,
.novelai-image-actions button {
  width: auto;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13px;
}

.nai-position-button {
  width: fit-content;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #f7e6ff;
  color: #763d94;
  font-weight: 900;
}

.nai-position-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.nai-position-grid[hidden] {
  display: none;
}

.nai-position-grid button {
  min-height: 34px;
  padding: 0;
  border-radius: 10px;
  background: #fff;
  color: #7c5a91;
}

.nai-position-grid button.active {
  background: linear-gradient(135deg, #ff8fd6, #9cc6ff);
  color: #fff;
}

.nai-random-prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.nai-random-weight-toggle {
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid rgba(218, 154, 235, 0.58);
  border-radius: 12px;
  background: #fff;
}

.nai-random-prompt-grid input:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.nai-random-bias-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.nai-random-bias-row input {
  grid-column: 1 / -1;
}

.nai-random-bias-row b {
  color: #7d45a0;
  font-size: 13px;
}

.nai-random-prompt-entry {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(218, 154, 235, 0.36);
  border-radius: 12px;
  background: rgba(255, 247, 254, 0.74);
}

.nai-reference-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 58px auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 14px;
  background: #ffffff;
}

.nai-reference-item img {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
}

.nai-reference-item span {
  overflow: hidden;
  color: #5d436f;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nai-reference-controls {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 244, 253, 0.82);
}

.nai-danger-button {
  border-color: rgba(235, 104, 161, 0.5);
  background: #fff0f6;
  color: #bd286d;
  font-weight: 900;
}

.nai-danger-button:hover {
  background: #ffddec;
}

.nai-reference-range {
  display: grid;
  grid-template-columns: minmax(118px, 1fr) minmax(92px, 1.2fr) 64px;
  gap: 8px;
  align-items: center;
  color: #5b3a6c;
  font-size: 12px;
  font-weight: 800;
}

.nai-reference-range input[type="range"],
.nai-range-row input[type="range"],
.nai-random-bias-row input[type="range"] {
  --range-progress: 0%;
  width: 100%;
  height: 28px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: var(--cursor-pointer);
}

.nai-reference-range input[type="range"]::-webkit-slider-runnable-track,
.nai-range-row input[type="range"]::-webkit-slider-runnable-track,
.nai-random-bias-row input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border: 1px solid rgba(137, 111, 150, 0.46);
  border-radius: 999px;
  background: linear-gradient(90deg, #d35bc6 0 var(--range-progress), #f5f2f7 var(--range-progress) 100%);
}

.nai-reference-range input[type="range"]::-webkit-slider-thumb,
.nai-range-row input[type="range"]::-webkit-slider-thumb,
.nai-random-bias-row input[type="range"]::-webkit-slider-thumb {
  width: 26px;
  height: 26px;
  margin-top: -9px;
  border: 0;
  border-radius: 999px;
  background: #d35bc6;
  box-shadow: 0 4px 10px rgba(168, 64, 160, 0.24);
  appearance: none;
  -webkit-appearance: none;
}

.nai-reference-range input[type="range"]::-moz-range-track,
.nai-range-row input[type="range"]::-moz-range-track,
.nai-random-bias-row input[type="range"]::-moz-range-track {
  height: 10px;
  border: 1px solid rgba(137, 111, 150, 0.46);
  border-radius: 999px;
  background: #f5f2f7;
}

.nai-reference-range input[type="range"]::-moz-range-progress,
.nai-range-row input[type="range"]::-moz-range-progress,
.nai-random-bias-row input[type="range"]::-moz-range-progress {
  height: 10px;
  border-radius: 999px;
  background: #d35bc6;
}

.nai-reference-range input[type="range"]::-moz-range-thumb,
.nai-range-row input[type="range"]::-moz-range-thumb,
.nai-random-bias-row input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 999px;
  background: #d35bc6;
  box-shadow: 0 4px 10px rgba(168, 64, 160, 0.24);
}

.nai-reference-number {
  width: 100%;
  min-height: 32px;
  padding: 4px 6px;
  border: 1px solid rgba(218, 154, 235, 0.58);
  border-radius: 10px;
  background: #fff;
  color: #6f3d8a;
  font: 800 13px/1 "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  text-align: center;
}

.nai-range-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(100px, 1.2fr) 48px;
  gap: 10px;
  align-items: center;
  color: #5b3a6c;
  font-size: 13px;
  font-weight: 800;
}

.nai-range-row b {
  color: #9a4ec4;
  text-align: right;
}

.nai-image-drop-card {
  position: relative;
  width: 100%;
  min-height: 168px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(199, 127, 226, 0.56);
  border-radius: 16px;
  background: #fff9fe;
  color: #8d68a2;
  font-weight: 900;
  cursor: pointer;
}

.nai-image-drop-card:focus-visible {
  outline: 3px solid rgba(95, 145, 246, 0.42);
  outline-offset: 2px;
}

.nai-image-drop-card.has-image {
  min-height: 220px;
}

.nai-image-drop-card img {
  width: 100%;
  height: 100%;
  max-height: 260px;
  display: block;
  object-fit: contain;
}

.nai-base-image-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid rgba(105, 58, 126, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #5b326f;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(70, 43, 82, 0.16);
}

.nai-base-image-remove:hover {
  transform: translateY(-1px);
  background: rgba(255, 246, 253, 0.96);
}

.nai-size-custom,
.nai-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.nai-ai-settings summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}

.nai-ai-settings summary::-webkit-details-marker {
  display: none;
}

.nai-ai-settings summary > span {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  color: #8e6aa2;
  font-size: 12px;
}

.nai-ai-settings summary em {
  overflow: hidden;
  color: #583269;
  font-style: normal;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nai-generate-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid rgba(216, 148, 232, 0.26);
  background: #fffafe;
}

.nai-generate-size {
  min-width: 0;
  display: grid;
  gap: 3px;
  color: #7b5c8f;
  font-size: 13px;
  font-weight: 800;
}

.nai-generate-actions {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(124px, 140px) minmax(130px, 1fr) minmax(120px, 1fr);
  gap: 8px;
  align-items: center;
}

.nai-generate-bar strong {
  color: #c83ab5;
  font-size: 16px;
}

.nai-loop-count-label {
  min-width: 124px;
  display: grid;
  grid-template-columns: max-content minmax(58px, 72px);
  gap: 8px;
  align-items: center;
  color: #7b5c8f;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.nai-loop-count-label input {
  min-width: 58px;
  width: 100%;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid #e7b7f2;
  border-radius: 12px;
  background: #fff;
  color: #3b164f;
  font-weight: 900;
}

#novelAiLoopGenerateBtn,
#novelAiGenerateBtn {
  min-height: 48px;
  border-radius: 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 950;
}

#novelAiLoopGenerateBtn {
  background: linear-gradient(135deg, #9d70ff, #5ea2ff);
  box-shadow: 0 12px 24px rgba(91, 109, 219, 0.22);
}

#novelAiGenerateBtn {
  background: linear-gradient(135deg, #ff7ecf, #8bb9ff);
  font-size: 17px;
  box-shadow: 0 12px 24px rgba(208, 84, 185, 0.24);
}

.nai-preview-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.nai-preview-panel > header {
  justify-content: space-between;
}

.nai-main-output {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.7) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.7) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.7) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.7) 75%),
    #f6eefb;
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}

.nai-main-output .novelai-empty-card {
  width: min(560px, 90%);
  min-height: 360px;
  border: 2px dashed rgba(196, 136, 224, 0.48);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.7);
  color: #9a77ad;
  font-size: 22px;
  font-weight: 900;
}

.nai-main-output .novelai-image-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.nai-main-output .novelai-image-preview {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  padding: 12px 12px 92px;
  aspect-ratio: auto;
  border: 0;
  background: transparent;
}

.nai-main-output .novelai-image-preview img {
  width: auto !important;
  height: auto !important;
  max-width: 100%;
  max-height: calc(100vh - 245px);
  display: block;
  object-fit: contain;
  object-position: center center;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(94, 52, 120, 0.18);
}

.nai-main-output .novelai-image-meta,
.nai-main-output .novelai-image-actions {
  position: absolute;
  z-index: 2;
  bottom: 12px;
}

.nai-main-output .novelai-image-meta {
  left: 12px;
  max-width: min(58%, 520px);
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 14px;
  border: 1px solid rgba(136, 87, 190, 0.42);
  background: rgba(255, 253, 255, 0.96);
  color: #331446;
  box-shadow: 0 12px 28px rgba(94, 52, 120, 0.16);
}

.nai-main-output .novelai-image-meta strong,
.nai-main-output .novelai-image-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nai-main-output .novelai-image-meta strong {
  color: #2b0d3e;
}

.nai-main-output .novelai-image-meta span {
  color: #6b3a87;
}

.nai-main-output .novelai-image-actions {
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: 1fr;
  justify-content: stretch;
  gap: 5px;
  width: 78px;
  max-width: 78px;
}

.nai-main-output .novelai-image-actions button {
  width: 100%;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid rgba(45, 107, 190, 0.36);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  box-shadow: 0 6px 14px rgba(73, 100, 180, 0.12);
}

.nai-main-output .novelai-image-actions .nai-restore-action {
  border: 1px solid rgba(194, 90, 141, 0.72);
  background: linear-gradient(120deg, #fff7fb, #ffd2e8);
  color: #8e1649;
  box-shadow: 0 10px 22px rgba(194, 90, 141, 0.18);
}

.nai-main-output .novelai-image-actions .nai-content-action {
  border: 1px solid rgba(136, 87, 190, 0.5);
  background: linear-gradient(120deg, #fffaff, #eadbff);
  color: #5b2574;
}

.nai-history-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.nai-history-panel > header {
  align-items: flex-start;
}

.nai-history-panel strong {
  color: #553068;
  font-size: 19px;
}

.nai-history-list {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 12px;
}

.nai-history-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(214, 150, 232, 0.34);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.nai-history-item.active {
  border-color: rgba(142, 80, 205, 0.72);
  background: linear-gradient(120deg, #fffaff, #f1e4ff);
  box-shadow: 0 12px 28px rgba(121, 75, 173, 0.18);
}

.nai-history-item.active > button:first-child {
  box-shadow: 0 0 0 3px rgba(142, 80, 205, 0.24);
}

.nai-history-item > button:first-child {
  width: 72px;
  min-height: 72px;
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
}

.nai-history-item img {
  width: 72px;
  height: 72px;
  display: block;
  object-fit: cover;
}

.nai-history-item strong,
.nai-history-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nai-history-item strong {
  color: #573269;
  font-size: 13px;
}

.nai-history-item span {
  color: #9b7bad;
  font-size: 12px;
}

.nai-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(255, 239, 252, 0.72);
  pointer-events: none;
}

.nai-drop-overlay > div {
  max-width: min(520px, 88vw);
  padding: 24px 28px;
  border: 2px dashed rgba(196, 93, 210, 0.72);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  color: #7a3b91;
  font-size: 24px;
  font-weight: 950;
  text-align: center;
  box-shadow: 0 20px 60px rgba(157, 83, 185, 0.24);
}

body.is-novelai-drop-active .nai-drop-overlay {
  display: grid;
}

.nai-drop-choice-dialog,
.nai-download-dialog {
  width: min(520px, calc(100vw - 28px));
  max-width: calc(100vw - 28px);
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(216, 148, 232, 0.42);
  border-radius: 22px;
  background: #fffaff;
  color: #4b2c5d;
  box-shadow: 0 24px 80px rgba(101, 42, 130, 0.28);
}

.nai-drop-choice-dialog::backdrop,
.nai-download-dialog::backdrop {
  background: transparent;
}

.nai-drop-choice-dialog form,
.nai-download-dialog form {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 18px;
}

.nai-drop-choice-dialog h3,
.nai-drop-choice-dialog p,
.nai-download-dialog h3,
.nai-download-dialog p {
  min-width: 0;
  margin: 0;
}

.nai-drop-choice-text {
  display: grid;
  gap: 3px;
  color: #56336b;
  font-size: 16px;
  line-height: 1.35;
}

.nai-drop-choice-name {
  min-width: 0;
  max-width: 100%;
  display: block;
  overflow: hidden;
  color: #7a4b95;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nai-drop-choice-preview {
  min-height: 160px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 18px;
  background: #f7ecff;
}

.nai-drop-choice-preview img {
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.nai-drop-choice-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.nai-drop-choice-actions button {
  min-width: 0;
  min-height: 44px;
  overflow: hidden;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nai-drop-choice-actions [data-drop-action="cancel"] {
  grid-column: 1 / -1;
  border: 2px solid rgba(196, 64, 124, 0.55);
  background: #ffffff;
  color: #b91c5c;
  font-weight: 950;
}

.nai-drop-choice-actions [data-drop-action="cancel"]:hover {
  background: #ffe8f2;
}

.nai-download-actions {
  display: grid;
  gap: 8px;
}

.nai-download-actions button {
  min-height: 46px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 900;
}

.nai-content-dialog {
  width: min(820px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid rgba(216, 148, 232, 0.42);
  border-radius: 22px;
  background: #fffaff;
  color: #3f2350;
  box-shadow: 0 24px 80px rgba(101, 42, 130, 0.28);
}

.nai-content-dialog::backdrop {
  background: rgba(64, 23, 80, 0.26);
}

.nai-content-dialog form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.nai-content-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nai-content-dialog h3 {
  margin: 0;
  color: #4d2364;
}

.nai-content-dialog textarea {
  width: 100%;
  min-height: min(58vh, 560px);
  resize: vertical;
  border: 1px solid rgba(206, 151, 229, 0.52);
  border-radius: 14px;
  background: #fff;
  color: #2f1f3c;
  font: 14px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.nai-image-viewer-dialog {
  width: min(96vw, 1680px);
  height: min(94vh, 1120px);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 22px;
  background: #120d18;
  color: #fff8ff;
  box-shadow: 0 28px 90px rgba(17, 10, 22, 0.54);
}

.nai-image-viewer-dialog::backdrop {
  background: rgba(22, 7, 29, 0.72);
}

.nai-image-viewer-dialog form {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.nai-image-viewer-dialog .nai-content-dialog-header {
  color: #fff8ff;
}

.nai-image-viewer-dialog h3 {
  min-width: 0;
  overflow: hidden;
  margin: 0;
  color: #fff8ff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nai-image-viewer-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  border-radius: 16px;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.08) 75%),
    #0c0811;
  background-size: 30px 30px;
  background-position: 0 0, 0 15px, 15px -15px, -15px 0;
}

.nai-image-viewer-stage.is-dragging {
  cursor: grabbing;
}

.nai-image-viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
  border-radius: 10px;
  transform-origin: center center;
  transition: transform 80ms ease-out;
  will-change: transform;
  pointer-events: none;
}

.nai-image-viewer-stage.is-dragging img {
  transition: none;
}

@media (max-width: 980px) {
  body.novelai-bright-body {
    height: auto;
    overflow: auto;
  }

  .nai-bright-shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }

  .nai-left-panel,
  .nai-preview-panel,
  .nai-history-panel {
    min-height: auto;
  }

  .nai-settings-form,
  .nai-preview-panel,
  .nai-history-panel {
    min-height: 0;
  }

  .nai-control-scroll,
  .nai-history-list {
    overflow: visible;
  }

  .nai-main-output {
    min-height: 70vh;
  }
}

@media (max-width: 640px) {
  .nai-bright-shell {
    gap: 10px;
    padding: 10px;
  }

  .nai-character-header,
  .nai-reference-item,
  .nai-generate-bar,
  .nai-generate-actions,
  .nai-range-row,
  .nai-size-custom,
  .nai-field-grid,
  .nai-random-prompt-grid {
    grid-template-columns: 1fr;
  }

  .nai-drop-choice-actions {
    grid-template-columns: 1fr;
  }

  .nai-main-output .novelai-image-preview {
    padding: 12px 12px 92px;
  }

  .nai-main-output .novelai-image-actions {
    right: 12px;
    bottom: 12px;
    width: 78px;
    max-width: 78px;
  }
}
