
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 10px 0 24px;
  gap: 16px;
  border-right: 0.5px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: width 0.3s ease;
}

.sidebar.is-panel-open {
  width: var(--sidebar-open-w);
}

.sidebar-avatar,
.sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.sidebar-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-strong);
  margin-bottom: 8px;
  margin-left: calc((var(--sidebar-w) - 44px) / 2);
  cursor: pointer;
  flex-shrink: 0;
}

.sidebar-avatar:hover,
.sidebar-avatar.is-active {
  background: rgba(94, 80, 63, 0.14);
  border-color: rgba(94, 80, 63, 0.26);
}

.sidebar-avatar svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.sidebar-avatar.is-authenticated {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.sidebar-avatar-initial {
  line-height: 1;
}

.sidebar-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  margin-left: calc((var(--sidebar-w) - 44px) / 2);
  cursor: pointer;
  color: var(--accent-mid);
}

.sidebar-icon svg {
  width: 18px;
  height: 18px;
}

.sidebar-icon:hover,
.sidebar-icon.is-active {
  background: rgba(94, 80, 63, 0.14);
  color: var(--accent);
}

.sidebar-spacer {
  flex: 1;
  width: 100%;
}

.sidebar-detail-panel {
  position: absolute;
  inset: 0 0 0 var(--sidebar-w);
  padding: 24px;
  border-left: 0.5px solid var(--border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(247, 243, 240, 0.88)),
    var(--bg);
  opacity: 0;
  transform: translateX(-12px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.sidebar.is-panel-open .sidebar-detail-panel {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.sidebar-detail-scroll {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-card-md);
  padding-right: 4px;
}

.sidebar-detail-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-detail-scroll::-webkit-scrollbar-thumb {
  background: rgba(94, 80, 63, 0.12);
  border-radius: 999px;
}

.sidebar-profile-card,
.sidebar-module {
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-sm);
}

.sidebar-profile-card {
  display: flex;
  gap: var(--space-card-sm);
  align-items: flex-start;
  padding: var(--space-card-sm);
}

.sidebar-profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-light);
  border: 1px solid rgba(94, 80, 63, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}

.sidebar-profile-avatar svg {
  width: 20px;
  height: 20px;
}

.sidebar-profile-avatar.has-text {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.sidebar-profile-name {
  font-size: var(--text-body-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.sidebar-profile-note,
.sidebar-module-tip {
  font-size: var(--text-note);
  line-height: var(--leading-body);
  color: var(--text-secondary);
}

.sidebar-profile-email {
  margin-top: 6px;
  font-size: var(--text-note);
  line-height: var(--leading-body);
  color: var(--text-hint);
  word-break: break-all;
}

.sidebar-auth-actions {
  display: grid;
  gap: var(--space-card-sm);
}

.sidebar-auth-link {
  display: inline-flex;
  align-items: center;
  width: 100%;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

.sidebar-module {
  display: grid;
  gap: var(--space-card-sm);
  padding: var(--space-card-sm);
}

.sidebar-module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-card-sm);
}

.sidebar-module-header h3 {
  font-size: var(--text-subtitle);
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-count-badge {
  min-width: 24px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-note);
  font-weight: 600;
}

.favorite-list {
  display: grid;
  gap: var(--space-card-sm);
}

.favorite-story-group {
  display: grid;
  gap: var(--space-card-sm);
}

.favorite-story-title {
  font-size: var(--text-body-sm);
  font-weight: 700;
  line-height: var(--leading-body);
  color: var(--text-primary);
}

.favorite-chapter-list {
  display: grid;
  gap: var(--space-card-sm);
}

.favorite-chapter-group {
  display: grid;
  gap: var(--space-card-sm);
}

.favorite-chapter-header {
  display: flex;
  align-items: center;
}

.favorite-quote-list {
  display: grid;
  gap: var(--space-card-sm);
}

.favorite-empty,
.favorite-item {
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-sm);
}

.favorite-empty {
  padding: var(--space-card-sm);
  color: var(--text-secondary);
  font-size: var(--text-note);
  line-height: var(--leading-body);
}

.favorite-item {
  padding: var(--space-card-sm);
  display: grid;
  gap: var(--space-card-sm);
}

.favorite-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-card-sm);
  font-size: var(--text-note);
  color: var(--text-hint);
}

.favorite-item-meta-main {
  display: flex;
  align-items: center;
  gap: var(--space-card-sm);
  min-width: 0;
}

.favorite-item-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(247, 150, 70, 0.16);
  color: #c9a12a;
  font-weight: 600;
}

.favorite-remove-button {
  border: none;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-secondary);
  border-radius: 999px;
  min-height: 30px;
  min-width: 100px;
  max-width: 300px;
  padding: 0 14px;
  font-size: var(--text-note);
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.favorite-remove-button:hover {
  background: rgba(225, 29, 72, 0.12);
  color: #be123c;
}

.favorite-remove-button:active {
  transform: translateY(1px);
}

.favorite-item-text {
  color: var(--text-primary);
  line-height: var(--leading-body);
  font-size: var(--text-body-sm);
}

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  padding: 0 32px;
  background: var(--bg);
  border-bottom: 0.5px solid var(--border);
  position: relative;
  flex-shrink: 0;
}

.step-tabs {
  display: flex;
  gap: var(--space-card-sm);
}

#top-stage-tabs {
  transform: translateX(-35px);
}

.step-tab,
.chip,
.btn-primary,
.primary-button,
.secondary-button,
.ghost-button,
.tiny-button,
.icon-button,
.relation-badge,
.story-chapter-tab,
.btn-export,
.btn-export-main,
.btn-icon-round {
  transition: all var(--transition);
}

.step-tab {
  flex: 0 0 64px;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: var(--radius-pill);
  font-size: 14px;
  line-height: 1;
  color: var(--text-hint);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  font-weight: 400;
  letter-spacing: 0;
  text-align: center;
}

.step-tab:hover {
  color: var(--text-primary);
}

.step-tab.is-active {
  background: var(--tab-active-bg);
  color: var(--tab-active-text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.neuro-toggle {
  position: absolute;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-light);
  border: 0.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.neuro-toggle:hover {
  background: #ddd4c6;
}

.neuro-toggle.is-busy {
  animation: neuroPulse 1.2s ease-in-out infinite;
}

.neuro-toggle-mark {
  font-family: var(--font-serif);
  font-size: var(--text-note);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: var(--tracking-caps);
}

@keyframes neuroPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: var(--shadow-sm);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 0 6px rgba(166, 144, 118, 0.08);
  }
}

.content-area {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow: hidden;
}

.page-shell {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  overflow: hidden;
  position: relative;
}

.page {
  display: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: var(--bg);
}

.page.is-current {
  display: flex;
}

.scroll-area,
.outline-main,
.prose-main,
.char-editor {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
}

.scroll-area,
.outline-main {
  padding: 48px 60px;
}

.char-editor {
  padding: 44px 48px 32px;
}

.prose-main {
  background: var(--bg);
}

.scroll-area::-webkit-scrollbar,
.outline-main::-webkit-scrollbar,
.char-editor::-webkit-scrollbar,
.prose-main::-webkit-scrollbar,
.llm-activity-log::-webkit-scrollbar {
  width: 4px;
}

.scroll-area::-webkit-scrollbar-track,
.outline-main::-webkit-scrollbar-track,
.char-editor::-webkit-scrollbar-track,
.prose-main::-webkit-scrollbar-track,
.llm-activity-log::-webkit-scrollbar-track {
  background: transparent;
}

.scroll-area::-webkit-scrollbar-thumb,
.outline-main::-webkit-scrollbar-thumb,
.char-editor::-webkit-scrollbar-thumb,
.prose-main::-webkit-scrollbar-thumb,
.llm-activity-log::-webkit-scrollbar-thumb {
  background: rgba(94, 80, 63, 0.12);
  border-radius: 999px;
}

.page-title {
  font-family: var(--font-serif);
  font-size: var(--text-display);
  font-weight: 700;
  line-height: var(--leading-title);
  margin-bottom: 8px;
  letter-spacing: var(--tracking-title);
}

.page-title-line {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.page-title.page-title-line {
  margin-bottom: 0;
}

.page-title-line .page-subtitle {
  display: inline;
}

.page-title-divider {
  color: var(--text-secondary);
  font-size: var(--text-body-lg);
}

.stage-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-card-md);
}

.stage-header-main {
  margin-bottom: 6px;
}

.stage-header-compact {
  margin-bottom: var(--space-card-md);
}

#stage-characters .stage-header-compact {
  margin-bottom: 0;
}

.stage-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-card-sm);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-card-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-card-md);
}

.stage-toolbar .form-hint {
  margin-bottom: 0;
}

#stage-basic .stage-toolbar {
  margin-bottom: 40px;
}

.section-stage-title {
  font-family: var(--font-serif);
  font-size: var(--text-title);
  font-weight: 700;
  line-height: var(--leading-title);
  letter-spacing: var(--tracking-title);
}

.page-subtitle {
  font-size: var(--text-body-lg);
  color: var(--text-secondary);
  margin-bottom: var(--space-card-lg);
}

.page-subtitle-compact {
  margin-bottom: 0;
}

.form-hint {
  font-size: var(--text-note);
  color: var(--text-hint);
  margin-bottom: var(--space-card-md);
}

.form-hint b {
  color: var(--accent);
}

.form-section {
  margin-bottom: var(--space-card-lg);
}

.form-label,
.outline-synopsis-label,
.chapter-label,
.rel-label,
.char-input-label,
.input-label-sm,
.worldview-label,
.outline-stage-range,
.section-kicker,
.story-meta-label {
  letter-spacing: 0.08em;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: var(--space-card-sm);
  font-size: var(--text-note);
  font-weight: 600;
  color: var(--text-secondary);
}

.required-badge,
.inline-required {
  color: var(--accent);
}

.type-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-card-sm);
}

#genre-options.type-chips,
#style-options.type-chips {
  display: contents;
}

.chip {
  min-width: 100px;
  max-width: 300px;
  min-height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 0.5px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: var(--text-body-sm);
  cursor: pointer;
  user-select: none;
  box-shadow: var(--shadow-sm);
}

.chip:hover {
  border-color: var(--accent-mid);
  background: var(--accent-light);
  color: var(--accent);
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fafaf8;
  box-shadow: var(--shadow-md);
}

.custom-chip {
  background: var(--bg-input);
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-card-sm);
}

.custom-chip-input {
  cursor: text;
}

.chip-input,
.input-field,
.textarea-field,
.character-field input,
.character-field textarea,
.stage-range-editor input,
.outline-stage-editor input {
  border: 0.5px solid var(--border);
  outline: none;
  color: var(--text-primary);
  background: var(--bg-card);
  font-family: var(--font-serif);
  transition: all var(--transition);
}

.chip-input {
  width: 120px;
  border: none;
  background: transparent;
  padding: 0;
  font-size: var(--text-body-sm);
}

.input-field,
.character-field input,
.outline-stage-editor input,
.stage-range-editor input {
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  font-size: var(--text-body-sm);
  line-height: var(--leading-body);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.textarea-field,
.character-field textarea {
  width: 100%;
  min-height: 44px;
  padding: 14px 16px;
  font-size: var(--text-body-sm);
  line-height: var(--leading-body);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  resize: vertical;
}

.input-field:focus,
.textarea-field:focus,
.character-field input:focus,
.character-field textarea:focus,
.outline-stage-editor input:focus,
.stage-range-editor input:focus {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: var(--shadow-md);
}

.input-field::placeholder,
.textarea-field::placeholder,
.character-field input::placeholder,
.character-field textarea::placeholder {
  color: var(--text-hint);
}

.worldview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-card-sm);
}

.input-label-sm,
.char-input-label,
.character-field-hint,
.worldview-label {
  font-size: var(--text-note);
  font-weight: 600;
  color: var(--text-hint);
  margin-bottom: 8px;
  letter-spacing: var(--tracking-caps);
}

.metrics-stack {
  width: calc((100% - (2 * var(--space-card-sm))) / 3);
  max-width: none;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-card-sm);
  align-items: end;
}

.metric-input-shell {
  display: flex;
  align-items: center;
  gap: var(--space-card-sm);
  width: 100%;
  max-width: none;
}

.metric-display-shell {
  width: 100%;
  max-width: none;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.metric-display {
  width: 100%;
  display: flex;
  align-items: center;
  color: var(--text-primary);
  font-size: var(--text-body-sm);
}

.input-unit {
  font-size: var(--text-body-sm);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.next-btn,
.stage-actions,
.align-end {
  display: flex;
  justify-content: flex-end;
}

.next-btn {
  margin-top: var(--space-card-md);
}

.btn-primary,
.primary-button,
.secondary-button,
.ghost-button,
.tiny-button,
.btn-secondary,
.btn-export-main,
.btn-export,
.sel-btn {
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.btn-primary,
.primary-button,
.secondary-button,
.ghost-button,
.btn-secondary,
.btn-export-main,
.btn-export,
.sel-btn,
.story-chapter-tab,
.character-tab {
  min-width: 100px;
  max-width: 300px;
  min-height: var(--btn-h-md);
  max-height: 60px;
  font-size: var(--text-body-sm);
  line-height: 1;
}

.btn-primary,
.primary-button,
.btn-export-main {
  min-height: var(--btn-h-lg);
  height: var(--btn-h-lg);
  padding: 0 24px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover,
.primary-button:hover,
.btn-export-main:hover {
  background: var(--accent-hover);
}

.btn-primary svg {
  width: 14px;
  height: 14px;
}

.btn-secondary,
.secondary-button,
.ghost-button,
.tiny-button,
.btn-export,
.btn-icon-round,
.icon-btn,
.relation-badge,
.story-chapter-tab {
  background: var(--bg-card);
  border: 0.5px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary,
.secondary-button,
.ghost-button {
  min-height: var(--btn-h-md);
  height: var(--btn-h-md);
  padding: 0 20px;
  color: var(--text-secondary);
}

.btn-secondary:hover,
.secondary-button:hover,
.ghost-button:hover,
.btn-export:hover,
.btn-icon-round:hover,
.icon-btn:hover,
.story-chapter-tab:hover,
.relation-badge:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.btn-ai {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.tiny-button {
  min-width: 100px;
  max-width: 300px;
  min-height: var(--btn-h-xs);
  height: var(--btn-h-xs);
  max-height: 60px;
  padding: 0 16px;
  font-size: var(--text-note);
}

#go-to-characters,
#generate-story {
  min-height: var(--btn-h-xl);
  height: var(--btn-h-xl);
}

#generate-outline {
  min-height: var(--btn-h-md);
  height: var(--btn-h-md);
  padding: 0 20px;
  font-size: var(--text-body-sm);
}

.btn-ai:hover {
  background: var(--accent-hover);
  color: #ffffff;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.character-page {
  flex: 1;
  min-width: 0;
  display: flex;
  overflow: hidden;
}

.char-editor {
  flex: 1;
  min-width: 0;
}

.character-tabs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.character-tab-row {
  display: flex;
  align-items: flex-end;
  gap: 0;
}

.character-tab-row-overflow {
  flex-wrap: nowrap;
}

.character-tab-row-main {
  margin-bottom: -1px;
}

.character-tabs.has-overflow-row .character-tab-row-overflow {
  justify-content: flex-start;
}

.character-tab {
  position: relative;
  padding: 8px 22px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border: 0.5px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  margin-right: -0.5px;
  z-index: 1;
}

.character-tab.is-active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 500;
  border-bottom-color: var(--bg-card);
  z-index: 5;
}

.character-tab-add {
  color: var(--text-hint);
}

.character-tab-remove {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 15px;
  line-height: 1;
  opacity: 0;
}

.character-tab:hover .character-tab-remove {
  opacity: 1;
}

.character-dossier-card {
  background: var(--bg-card);
  border: 0.5px solid var(--border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 24px;
}

.character-dossier-scroll {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.char-editor.char-compact .character-dossier-scroll {
  grid-template-columns: 1fr;
}

.char-editor.char-compact .character-field.span-full {
  grid-column: auto;
}

.character-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.character-field.span-full {
  grid-column: 1 / -1;
}

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

.relationship-area {
  width: 380px;
  min-width: 220px;
  flex-shrink: 0;
  border-left: 0.5px solid var(--border);
  padding: 47px 20px 24px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.rel-resize-handle,
.neuro-drag-edge {
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  z-index: 12;
}

.rel-resize-handle:hover,
.neuro-drag-edge:hover {
  background: rgba(94, 80, 63, 0.08);
}

.rel-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-bottom: 33px;
}

.rel-label-meta {
  display: block;
  font-size: var(--text-note);
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-hint);
}

.rel-touch-hint {
  display: none;
  text-transform: none;
  letter-spacing: 0;
}

.graph-wrap {
  flex: 1;
  min-height: 260px;
  position: relative;
}

.graph-wrap.is-panning {
  cursor: grabbing;
}

.graph-wrap.is-panning .graph-node {
  cursor: grabbing;
}


.graph-canvas {
  position: relative;
  width: 100%;
  min-height: 440px;
  height: 100%;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(247, 243, 240, 0.2));
}

.graph-svg,
.graph-nodes,
.relation-labels {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.graph-svg {
  width: 100%;
  height: 100%;
}

.graph-node {
  position: absolute;
  width: 116px;
  height: 62px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid;
  background: #fffefb;
  text-align: center;
  cursor: crosshair;
  user-select: none;
}

.graph-node.is-source,
.graph-node.is-target {
  transform: translateY(-1px) scale(1.02);
}

.graph-node-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 500;
}

.relation-badge {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 100px;
  max-width: 188px;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 28px rgba(94, 80, 63, 0.12);
}

.relation-badge-button span {
  display: block;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
}

.relation-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.relation-toolbar > * {
  flex: 1;
}

.relation-save-state {
  align-self: stretch;
  width: 100%;
  box-sizing: border-box;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 0.5px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.relation-save-state.saved {
  border-style: solid;
  color: var(--success);
  background: rgba(79, 125, 97, 0.08);
}

.outline-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.outline-page-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.outline-synopsis-label {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.outline-actions-row {
  --outline-action-gap: 0px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--outline-action-gap);
  margin-left: auto;
}

.outline-icons,
.stage-icon-actions {
  display: flex;
  align-items: center;
}

#outline-tools-anchor {
  align-self: center;
  justify-content: flex-end;
  gap: var(--outline-action-gap);
}

.stage-icon-actions {
  gap: 8px;
}

.icon-btn-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 62px;
  cursor: pointer;
}

.icon-button {
  padding: 0;
}

.icon-btn {
  width: var(--btn-h-sm);
  height: var(--btn-h-sm);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn svg {
  width: 13px;
  height: 13px;
  color: var(--text-secondary);
}

.icon-btn-label {
  font-size: 14px;
  color: var(--text-hint);
}

.outline-result,
.story-result {
  min-height: 240px;
}

#story-result {
  margin-left: 60px;
  margin-right: 60px;
}

.outline-result.empty-state,
.story-result.empty-state {
  display: grid;
  place-items: center;
  padding: 48px 24px;
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.textarea-compact {
  min-height: 104px;
}

.outline-board {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.outline-hero-card,
.outline-summary-card {
  display: grid;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.outline-summary-meta {
  display: grid;
  gap: 12px;
  color: var(--text-secondary);
}

.outline-summary-meta strong {
  color: var(--text-primary);
}

.synopsis-display {
  display: grid;
  align-content: start;
  height: 100%;
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  background: var(--accent-light);
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.outline-title-card span,
.outline-ai-card span {
  font-size: 16px;
  line-height: 1.7;
}

.outline-title-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.outline-title-card,
.outline-ai-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  color: var(--text-secondary);
}

.outline-title-card strong,
.outline-ai-card strong {
  display: block;
  color: var(--text-primary);
}

.outline-count-card {
  min-width: 0;
  background: var(--bg-card);
}

.outline-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.outline-meta-grid > .synopsis-display,
.outline-meta-grid > .outline-ai-card {
  width: 100%;
  max-width: none;
}

.outline-ai-card {
  border: 0.5px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.outline-ai-card span {
  font-size: 16px;
  line-height: 1.75;
}

.arc-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.arc-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.micro-tip {
  color: var(--text-secondary);
  line-height: 1.7;
}

.arc-tracks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.arc-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  height: 100%;
}

.arc-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: 0.04em;
}

.arc-card,
.outline-stage-card,
.chapter-item,
.chapter-plan-card,
.outline-history-entry {
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.arc-card {
  display: grid;
  gap: 16px;
  min-height: 0;
  padding: 14px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  align-content: start;
  flex: 1;
}

.arc-card.generating {
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: var(--shadow-md);
}

.arc-card-copy {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.arc-range-editor {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 40px;
}

.arc-range-input {
  width: 52px;
  padding: 6px 8px;
  font-size: 14px;
  text-align: center;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

.arc-range-input:focus {
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: var(--shadow-md);
}

.arc-range-prefix,
.arc-range-suffix,
.arc-range-divider {
  font-size: 14px;
  color: var(--text-secondary);
}

.arc-range-divider {
  color: var(--text-hint);
  font-weight: 600;
}

.outline-stage-grid,
.outline-chapter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.outline-stage-card,
.chapter-plan-card {
  display: grid;
  gap: 12px;
  min-height: 220px;
  padding: 16px;
  align-content: start;
}

.outline-stage-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.outline-stage-editor {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 12px;
}

.outline-stage-editor label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}

.chapter-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chapter-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.chapter-item {
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-secondary);
  display: grid;
  gap: 4px;
}

.chapter-item b,
.chapter-plan-card strong,
.outline-stage-card strong {
  color: var(--text-primary);
  font-weight: 500;
}

.chapter-item-title {
  display: block;
}

.chapter-item-line {
  white-space: pre-wrap;
}

.inferred-list,
.chapter-plan-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.8;
}

.prose-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.story-reader-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.prose-title-bar,
.story-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 48px;
  border-bottom: 0.5px solid var(--border);
}

.prose-title-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.prose-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0.02em;
}

.section-stage-title,
.outline-synopsis-label > span:first-child,
.prose-title {
  font-family: var(--font-serif);
  font-size: var(--text-title);
  font-weight: 600;
  line-height: var(--leading-title);
  letter-spacing: var(--tracking-title);
  color: var(--nav-ink, var(--accent-hover));
  text-transform: none;
}

#stage-characters .section-stage-title,
.rel-label-title {
  font-family: var(--font-serif);
  font-size: var(--text-note);
  font-weight: 600;
  line-height: var(--leading-body);
  letter-spacing: var(--tracking-caps);
  color: var(--text-secondary);
  text-transform: uppercase;
}

.prose-chapter-sub,
.story-summary {
  color: var(--text-secondary);
}

.prose-actions,
.story-chapter-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.prose-title-bar .prose-actions {
  flex: 1;
  min-width: 0;
  justify-content: flex-end;
}

.prose-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

.btn-icon-round {
  width: var(--btn-h-sm);
  height: var(--btn-h-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.btn-icon-round svg {
  width: 15px;
  height: 15px;
  color: var(--text-secondary);
}

.btn-export-main {
  white-space: nowrap;
}

.btn-export {
  padding: 6px 14px;
}

.story-title-badge {
  padding: 10px 16px;
  border-radius: 18px;
  border: 0.5px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.synopsis-display,
.arc-card-copy,
.status-box {
  max-width: var(--line-length-body);
}

.prose-title-bar-static {
  flex-shrink: 0;
  padding: 48px 60px 0;
  margin-bottom: 0;
  border-bottom: 0;
}

.story-chapter-tab {
  padding: 10px 16px;
  color: var(--text-secondary);
}

.story-chapter-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.prose-scroll-area {
  position: relative;
  padding: 40px 48px;
  padding-bottom: 112px;
  overflow-y: auto;
}

.chapter-block,
.story-chapter-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 48px 56px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  border: 0.5px solid var(--border);
}

.chapter-block-header,
.story-chapter-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 34px;
}

.chapter-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chapter-regenerate-button {
  min-width: var(--btn-h-sm);
}

.chapter-label-en {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.chapter-block-title {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
}

.chapter-content,
.prose-content {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 2;
  color: var(--text-primary);
  user-select: text;
  max-width: none;
  width: 100%;
}

.chapter-content p,
.prose-content p {
  margin: 0 0 1.2em;
  text-indent: 2em;
  break-inside: avoid;
}

#stage-story .chapter-block,
#stage-story .story-chapter-card {
  width: 100%;
  max-width: none;
}

#stage-story .chapter-content,
#stage-story .prose-content {
  max-width: none;
}

body.neuro-panel-open #stage-story .chapter-content,
body.neuro-panel-open #stage-story .prose-content {
  column-count: 1;
  column-gap: 0;
}

@media (min-width: 1320px) {
  body:not(.neuro-panel-open) #stage-story .chapter-content,
  body:not(.neuro-panel-open) #stage-story .prose-content {
    column-count: 2;
    column-gap: 48px;
    column-fill: balance;
  }
}

.chapter-content p.prose-opening-paragraph,
.prose-content p.prose-opening-paragraph {
  text-indent: 2em;
  padding-left: 0;
}

.prose-drop-cap {
  float: none;
  display: inline;
  font-size: inherit;
  line-height: inherit;
  margin-right: 0;
  margin-top: 0;
  font-weight: inherit;
  color: inherit;
}

.prose-opening-rest {
  display: inline;
  padding-top: 0;
}

.story-fragment-user,
.prose-human {
  color: #2b5ea7;
  background: rgba(43, 94, 167, 0.07);
  border-radius: 3px;
  padding: 0 2px;
}

.story-fragment-favorite,
.prose-favorite {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: #e88db2;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-skip-ink: none;
}

.prose-content::selection,
.prose-content *::selection {
  color: #2b5ea7;
  background: rgba(43, 94, 167, 0.07);
}

.story-fragment-ai,
.prose-ai {
  color: var(--text-primary);
}

.chapter-navigation-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 0.5px solid var(--border);
}

.chapter-navigation-row.has-next {
  justify-content: flex-end;
}

.chapter-navigation-row.has-prev.has-next {
  justify-content: space-between;
}

.chapter-nav-button {
  min-width: 104px;
}

.story-fragment-highlight {
  animation: storyHighlight 1.2s ease;
}

@keyframes storyHighlight {
  from {
    box-shadow: 0 0 0 0 rgba(94, 80, 63, 0.2);
  }
  to {
    box-shadow: 0 0 0 12px rgba(94, 80, 63, 0);
  }
}

.story-selection-toolbar {
  position: fixed;
  z-index: 34;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: var(--radius-lg);
  background: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

.sel-btn {
  padding: 5px 11px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
}

.sel-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.sel-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
}

.sel-btn-icon svg {
  width: 15px;
  height: 15px;
}

.sel-btn-icon.is-favorited {
  color: #f2a7c3;
}

.favorite-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 42;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(34, 34, 34, 0.94);
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
}

.page-toast {
  position: fixed;
  top: calc(var(--topbar-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 43;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: 999px;
  border: 0.5px solid rgba(230, 175, 60, 0.46);
  background: rgba(255, 250, 232, 0.98);
  color: #8a5a13;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.neuro-guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 36;
  pointer-events: none;
  user-select: none;
}

.guide-arrow {
  position: fixed;
  overflow: visible;
  z-index: 0;
  filter: drop-shadow(0 3px 5px rgba(61, 45, 31, 0.18));
}

.guide-arrow-path {
  fill: none;
  stroke: rgba(61, 45, 31, 0.92);
  stroke-width: 3px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.guide-arrow-head {
  fill: rgba(61, 45, 31, 0.92);
}

.guide-note {
  --guide-note-size: 250px;
  position: fixed;
  z-index: 1;
  width: var(--guide-note-size);
  height: calc(var(--guide-note-size) - 14px);
  padding: 18px 18px 10px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 246, 202, 0.98), rgba(255, 239, 168, 0.98));
  box-shadow: 0 10px 24px rgba(61, 45, 31, 0.24);
  color: #23180c;
  transform: rotate(var(--guide-note-rotation, 0deg));
}

.guide-note::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px;
  background: rgba(255, 251, 232, 0.95);
}

.guide-note--sm {
  --guide-note-size: 220px;
}

.guide-note--md {
  --guide-note-size: 250px;
}

.guide-note--lg {
  --guide-note-size: 290px;
}

.guide-note-body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-handwrite);
  font-size: clamp(16px, 1.15vw, 20px);
  line-height: 1.56;
  white-space: pre-line;
}

.guide-note-text,
.guide-panel-text {
  white-space: pre-line;
}

.guide-panel-line {
  display: block;
}

.guide-panel-line + .guide-panel-line {
  margin-top: 10px;
}

.guide-panel-line--primary {
  color: #5a452b;
  font-weight: 700;
}

.guide-panel-line--prompt {
  color: #9d6d18;
  font-weight: 700;
}

.guide-typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 2px;
  border-radius: 999px;
  vertical-align: -0.08em;
  background: currentColor;
  animation: blink 0.9s infinite;
}

.neuro-panel {
  width: 0;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 0.5px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
  position: relative;
}

.neuro-panel.is-open,
.neuro-panel.open {
  width: var(--neuro-width);
  padding: 20px 16px 14px;
}

.neuro-panel .neuro-header,
.neuro-panel .neuro-meta,
.neuro-panel .llm-activity-actions,
.neuro-panel .llm-activity-log,
.neuro-panel .neuro-input-row {
  opacity: 0;
  transition: opacity 0.2s ease 0.15s;
  min-width: 0;
}

.neuro-panel.is-open .neuro-header,
.neuro-panel.is-open .neuro-meta,
.neuro-panel.is-open .llm-activity-actions,
.neuro-panel.is-open .llm-activity-log,
.neuro-panel.is-open .neuro-input-row,
.neuro-panel.open .neuro-header,
.neuro-panel.open .neuro-meta,
.neuro-panel.open .llm-activity-actions,
.neuro-panel.open .llm-activity-log,
.neuro-panel.open .neuro-input-row {
  opacity: 1;
}

.neuro-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 0.5px solid var(--border);
}

.neuro-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.neuro-avatar span {
  font-size: 14px;
  font-weight: 600;
  color: #ffffff;
}

.neuro-name {
  font-size: 14px;
  font-weight: 500;
}

#llm-activity-title {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  white-space: nowrap;
  word-break: keep-all;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.neuro-stage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 80px;
  height: var(--btn-h-md);
  padding: 0 12px;
  font-size: 14px;
  background: rgba(94, 80, 63, 0.1);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

.neuro-close {
  margin-left: 4px;
  min-width: 100px;
  min-height: var(--btn-h-md);
  height: var(--btn-h-md);
  padding: 0 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.neuro-meta {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 68px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 0.5px solid var(--border-strong);
  background: #ffffff;
  font-size: 14px;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.status-pill.busy {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.status-pill.paused {
  background: var(--accent-light);
  color: var(--accent);
}

.status-box {
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 0.5px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-secondary);
  line-height: 1.75;
  white-space: pre-line;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 220ms ease, border-color 220ms ease, background 220ms ease;
}

.status-box.is-guide-highlight {
  border-color: rgba(233, 179, 59, 0.65);
  background: linear-gradient(180deg, rgba(255, 251, 232, 0.98), rgba(255, 244, 198, 0.98));
  box-shadow: 0 0 0 3px rgba(247, 212, 128, 0.18), 0 14px 28px rgba(107, 84, 39, 0.14);
}

.status-box.is-guide-highlight .guide-panel-line--primary {
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.status-box.is-guide-prompt-ready .guide-panel-line--prompt {
  animation: guidePromptPulse 1.2s ease-in-out infinite;
}

@keyframes guidePromptPulse {
  0%,
  100% {
    color: #9d6d18;
  }
  50% {
    color: #c48a1c;
  }
}

.llm-activity-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.llm-activity-log,
.neuro-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.llm-activity-log-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
  border: 0.5px solid var(--border);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.llm-activity-log-item.is-success {
  background: rgba(79, 125, 97, 0.08);
}

.llm-activity-log-item.is-error {
  background: rgba(184, 90, 70, 0.08);
}

.llm-activity-log-item.is-waiting,
.llm-activity-log-item.is-stopped {
  background: rgba(166, 144, 118, 0.08);
}

.llm-activity-log-item.is-user {
  margin-left: 28px;
  border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
  background: rgba(94, 80, 63, 0.1);
}

.llm-activity-dot {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.llm-activity-item-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.llm-activity-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.llm-activity-item-time,
.llm-activity-item-detail {
  color: var(--text-secondary);
}

.llm-activity-item-time {
  font-size: 14px;
  flex-shrink: 0;
}

.llm-activity-item-detail {
  line-height: 1.7;
}

.neuro-input-row {
  margin-top: auto;
  padding-top: 12px;
  border-top: 0.5px solid var(--border);
}

.neuro-input-shell {
  width: 100%;
  display: grid;
  gap: 10px;
}

.neuro-input-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.neuro-input-hint {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.neuro-feedback-input {
  min-height: 124px;
  background: rgba(255, 255, 255, 0.92);
}

.neuro-chat-composer {
  display: grid;
  gap: 10px;
}

.neuro-chat-bubble {
  padding: 10px 12px;
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
  border: 0.5px solid var(--border);
  background: #ffffff;
  color: var(--text-secondary);
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
}

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

.neuro-input-placeholder {
  min-height: 40px;
  border-radius: var(--radius-pill);
  border: 0.5px solid var(--border-strong);
  background: #ffffff;
  display: grid;
  place-items: center;
  color: var(--text-hint);
  padding: 0 12px;
  text-align: center;
}

.neuro-input-row.is-feedback-mode .neuro-input-placeholder {
  display: none;
}

.cursor {
  display: inline-block;
  width: 1.5px;
  height: 14px;
  background: var(--text-primary);
  border-radius: 1px;
  animation: blink 0.9s infinite;
  vertical-align: text-bottom;
  margin-left: 2px;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-input) 25%, rgba(220, 215, 208, 0.6) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(34, 34, 34, 0.34);
  z-index: 40;
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border-radius: 28px;
  border: 0.5px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(249, 243, 236, 0.96));
  box-shadow: 0 18px 34px rgba(51, 38, 29, 0.24);
}

.modal-card-compact {
  width: min(420px, 100%);
}

.section-heading,
.action-row,
.outline-history-entry-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.section-kicker {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-hint);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-group + .field-group,
.check-row,
.action-row {
  margin-top: 14px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.check-row input {
  width: auto;
}

.outline-history-list {
  display: grid;
  gap: 14px;
}

.outline-history-entry {
  padding: 18px;
}

.outline-history-entry p {
  margin: 10px 0 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.modal-confirm-actions {
  justify-content: flex-start;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: var(--danger-hover);
}

@media (max-width: 1200px) {
  .scroll-area,
  .outline-main {
    padding: 32px 40px;
  }

  .char-editor {
    padding: 44px 30px 24px;
  }

  .relationship-area {
    padding-top: 47px;
  }

  .prose-title-bar {
    padding: 16px 32px;
  }

  .prose-title-bar-static {
    padding: 32px 40px 0;
  }

  #story-result {
    margin-left: 40px;
    margin-right: 40px;
  }

  .outline-stage-grid,
  .outline-chapter-grid,
  .arc-tracks,
  .worldview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics-stack {
    width: calc((100% - var(--space-card-sm)) / 2);
  }
}

@media (max-width: 1100px) {
  .relationship-area {
    width: 300px;
  }

  .worldview-grid,
  .outline-stage-grid,
  .outline-chapter-grid,
  .arc-tracks,
  .outline-meta-grid,
  .outline-title-row {
    grid-template-columns: 1fr;
  }

  .metrics-stack {
    width: 100%;
  }

  .character-dossier-scroll {
    grid-template-columns: 1fr;
  }

  .character-field.span-full {
    grid-column: auto;
  }
}

@media (max-width: 960px) {
  :root {
    --text-display: 26px;
    --text-title: 22px;
    --text-subtitle: 16px;
    --text-body-lg: 14px;
    --text-body-sm: 13px;
    --text-note: 12px;
    --leading-body: 1.55;
  }

  body {
    overflow: auto;
    font-size: 13px;
  }

  .app {
    min-height: 100vh;
    height: auto;
  }

  .topbar {
    justify-content: flex-start;
    padding: 12px 18px;
    min-height: 62px;
  }

  .step-tabs {
    max-width: calc(100% - 52px);
    overflow-x: auto;
    padding-right: 10px;
  }

  #top-stage-tabs {
    transform: none;
  }

  .content-area,
  .character-page {
    flex-direction: column;
  }

  .stage-header,
  .stage-toolbar,
  .prose-title-bar,
  .story-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .stage-header-actions,
  .stage-icon-actions {
    justify-content: flex-start;
  }

  .prose-actions,
  .prose-action-group {
    justify-content: flex-start;
  }

  .page-shell {
    flex: 1 1 auto;
  }

  .page {
    min-height: calc(100vh - 62px);
  }

  .relationship-area {
    width: 100%;
    border-left: none;
    border-top: 0.5px solid var(--border);
    padding: 24px 18px;
  }

  .rel-touch-hint {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.55;
  }

  .graph-canvas,
  .graph-nodes,
  .relation-labels {
    touch-action: pan-y pinch-zoom;
    overscroll-behavior: contain;
  }

  .graph-node {
    touch-action: none;
    cursor: grab;
    -webkit-tap-highlight-color: transparent;
  }

  .graph-node.is-source,
  .graph-node.is-target {
    cursor: grabbing;
  }

  .relation-hit-path,
  .relation-badge-button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .relation-hit-path {
    stroke-width: 28;
  }

  .rel-label {
    margin-bottom: 12px;
  }

  .rel-resize-handle,
  .neuro-drag-edge {
    display: none;
  }

  .neuro-panel {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    height: min(62vh, 520px);
    width: auto;
    transform: translateY(calc(100% + 20px));
    opacity: 0;
    pointer-events: none;
    border: 0.5px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    transition: transform 260ms ease, opacity 260ms ease;
    padding: 20px 16px 14px;
    z-index: 25;
  }

  .neuro-panel.is-open,
  .neuro-panel.open {
    width: auto;
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .neuro-panel .neuro-header,
  .neuro-panel .neuro-meta,
  .neuro-panel .llm-activity-actions,
  .neuro-panel .llm-activity-log,
  .neuro-panel .neuro-input-row {
    opacity: 1;
  }

  .neuro-guide-overlay {
    display: none !important;
  }

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

  button {
    font-size: 13px;
  }

  .step-tab,
  .chip,
  .form-label,
  .micro-tip,
  .icon-btn-label,
  .outline-synopsis-label,
  .relation-badge,
  .relation-save-state,
  .arc-title,
  .arc-range-prefix,
  .arc-range-suffix,
  .arc-range-divider,
  .outline-stage-editor label,
  .chapter-label,
  .chapter-label-en,
  .story-title-badge,
  .sel-btn,
  .favorite-toast,
  .page-toast,
  .story-action-toast,
  .neuro-avatar span,
  .neuro-name,
  .neuro-stage,
  .status-pill,
  .llm-activity-item-title,
  .llm-activity-item-time,
  .neuro-input-label,
  .neuro-input-hint,
  .section-kicker {
    font-size: 12px;
  }

  .character-tab,
  .graph-node-name,
  .synopsis-display,
  .outline-title-card span,
  .outline-ai-card span,
  .arc-card,
  .chapter-item {
    font-size: 14px;
  }

  .character-tab-remove {
    font-size: 12px;
  }

  .prose-title {
    font-size: 20px;
  }

  .chapter-block-title {
    font-size: 25px;
  }

  .chapter-content,
  .prose-content,
  .story-chapter-content,
  .outline-result {
    font-size: 15px;
    line-height: 1.8;
  }
}

@media (max-width: 720px) {
  .page-toast {
    top: 14px;
  }

  .scroll-area,
  .outline-main {
    padding: 24px 18px;
  }

  .char-editor {
    padding: 24px 18px 18px;
  }

  .prose-title-bar,
  .story-topbar,
  .prose-scroll-area {
    padding-left: 18px;
    padding-right: 18px;
  }

  .prose-title-bar-static {
    padding-top: 24px;
    padding-bottom: 0;
  }

  #story-result {
    margin-left: 18px;
    margin-right: 18px;
  }

  .chapter-block,
  .story-chapter-card {
    padding: 26px 20px;
  }

  .topbar {
    padding-right: 58px;
  }

  .outline-synopsis-label,
  .outline-actions-row,
  .prose-title-bar,
  .story-topbar,
  .story-chapter-header,
  .section-heading,
  .action-row,
  .outline-history-entry-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .outline-icons,
  .story-chapter-tabs {
    flex-wrap: wrap;
  }

  .outline-actions-row {
    align-self: flex-end;
    align-items: center;
  }
}

@media (max-width: 520px) {
  .metrics-row {
    grid-template-columns: 1fr;
  }

  .metric-input-shell,
  .metric-display-shell {
    max-width: 100%;
  }
}
