﻿:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --surface: #121722;
  --surface-2: #171e2a;
  --line: #2a3443;
  --text: #edf2f8;
  --muted: #a8b3c3;
  --accent: #4ecdc4;
  --accent-2: #ffcb6b;
  --success: #72e1a5;
  --danger: #ff7c7c;
  --focus: rgba(78, 205, 196, 0.26);
  --reader-font-size: 16px;
}

body.theme-light {
  color-scheme: light;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #edf2f5;
  --line: #cfd8df;
  --text: #17202a;
  --muted: #5f6d7a;
  --accent: #167d7f;
  --accent-2: #9a5b00;
  --success: #14784f;
  --danger: #b82929;
  --focus: rgba(22, 125, 127, 0.18);
}

body[data-reader-size="small"] {
  --reader-font-size: 15px;
}

body[data-reader-size="large"] {
  --reader-font-size: 18px;
}

.global-error-toast {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 12000;
  max-width: min(780px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid rgba(255, 207, 148, 0.6);
  border-radius: 8px;
  background: rgba(26, 19, 12, 0.96);
  color: #ffe2bd;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  transform: translateX(-50%);
  line-height: 1.5;
  pointer-events: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.pay-card a {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.pay-card a:hover {
  border-color: #526276;
}

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

button.is-loading {
  cursor: wait;
}

.status.success {
  color: var(--success);
}

.status.error {
  color: var(--danger);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--focus);
}

.hidden {
  display: none !important;
}

.app {
  display: grid;
  grid-template-columns: minmax(360px, 43vw) minmax(420px, 1fr);
  height: 100vh;
}

.app-wide {
  grid-template-columns: 280px minmax(720px, 1fr);
}

.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.topbar > div {
  min-width: 0;
  padding-right: 8px;
}

.topbar h1,
.recharge-dialog h2,
.pay-card h1 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: 0;
}

.topbar h1 {
  margin-bottom: 4px;
  font-size: 20px;
  white-space: nowrap;
}

.topbar p,
.small,
.pay-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.icon-button {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  font-size: 18px;
}

.auth-panel,
.account-panel {
  display: grid;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.profile-entry {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: 14px 20px 0;
  padding: 10px;
  text-align: left;
}

.profile-avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(78, 205, 196, 0.42);
  border-radius: 50%;
  background: rgba(78, 205, 196, 0.14);
  color: var(--text);
  font-weight: 700;
}

.profile-avatar.large {
  width: 74px;
  height: 74px;
  font-size: 26px;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.member-badge {
  display: inline-grid;
  min-width: 40px;
  height: 22px;
  margin-left: 8px;
  padding: 0 8px;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-family: "STXingkai", "KaiTi", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  vertical-align: middle;
  transform: translateY(-1px);
  white-space: nowrap;
}

.member-badge.active {
  color: #fff7c4;
  border-color: rgba(255, 235, 150, 0.98);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 36%),
    linear-gradient(180deg, #fff2a8 0%, #f1c24b 38%, #a86d11 100%);
  box-shadow:
    0 0 0 1px rgba(255, 246, 180, 0.28) inset,
    0 0 18px rgba(255, 215, 92, 0.95),
    0 0 34px rgba(255, 175, 32, 0.45);
  text-shadow:
    0 1px 0 rgba(70, 42, 0, 0.65),
    0 0 7px rgba(255, 252, 210, 0.9);
}

.member-badge.active.annual {
  min-width: 52px;
  color: #fffbe8;
  border-color: rgba(255, 244, 184, 1);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0) 34%),
    linear-gradient(180deg, #fff6bc 0%, #f2d36a 32%, #d28a19 68%, #7a4510 100%);
  box-shadow:
    0 0 0 1px rgba(255, 255, 230, 0.38) inset,
    0 0 22px rgba(255, 223, 96, 1),
    0 0 42px rgba(255, 168, 25, 0.62);
}

.member-badge.inactive {
  color: #d8dce5;
  border-color: rgba(190, 198, 212, 0.36);
  background: linear-gradient(180deg, #777e8d, #313743);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.38);
}

.profile-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.profile-copy strong,
.profile-copy em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy strong {
  display: flex;
  align-items: center;
  min-width: 0;
}

#profileName {
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-copy em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

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

.tabs button {
  height: 34px;
}

.tabs button.active {
  border-color: rgba(78, 205, 196, 0.68);
  background: rgba(78, 205, 196, 0.16);
}

.register-method-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.register-method-tabs button {
  min-height: 36px;
}

.register-method-tabs button.active {
  border-color: rgba(78, 205, 196, 0.68);
  background: rgba(78, 205, 196, 0.16);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form button {
  height: 38px;
  border-color: rgba(78, 205, 196, 0.46);
}

.verify-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

.verify-field button {
  min-height: 38px;
  white-space: nowrap;
}

.account-panel {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.account-panel span,
.account-panel strong {
  display: block;
}

.account-panel span {
  overflow: hidden;
  color: #dce5f0;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-panel strong {
  margin-top: 3px;
  color: #fff;
  font-size: 16px;
}

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

.account-actions button {
  height: 34px;
  padding: 0 11px;
}

.form {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 13px;
  overflow: auto;
  padding: 18px 20px 24px;
}

.pane {
  min-height: 0;
}

.pane h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0;
}

.page-grid {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-columns: minmax(380px, 42%) minmax(420px, 1fr);
  background:
    radial-gradient(circle at 88% 10%, rgba(78, 205, 196, 0.1), transparent 28%),
    linear-gradient(180deg, #111720 0%, #0b0d12 100%);
}

body.theme-light .page-grid,
body.theme-light .output {
  background: linear-gradient(180deg, #f7fafb 0%, #eef3f5 100%);
}

body.theme-light .page-grid > .form,
body.theme-light .workspace {
  background: #ffffff;
}

body.theme-light .pane h2,
body.theme-light .preference-panel h2,
body.theme-light .result h2,
body.theme-light .writer-directory h3,
body.theme-light label,
body.theme-light .account-panel span {
  color: var(--text);
}

body.theme-light textarea[readonly],
body.theme-light .memory-panel,
body.theme-light .characters-panel,
body.theme-light .other-settings-panel,
body.theme-light .task-panel,
body.theme-light .writer-directory {
  background: rgba(23, 32, 42, 0.035);
}

.page-grid > .form {
  border-right: 1px solid var(--line);
  background: #0e121a;
}

.side-nav {
  display: grid;
  gap: 8px;
  padding: 16px 20px;
}

.side-nav button {
  height: 40px;
  text-align: center;
  padding: 0 12px;
}

.side-nav button.active,
.mode-tabs button.active {
  border-color: rgba(78, 205, 196, 0.68);
  background: rgba(78, 205, 196, 0.16);
}

.sidebar-drawer {
  margin: 0 20px 18px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 0 20px 18px;
  display: grid;
  gap: 10px;
}

.sidebar-footer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 38px;
  text-align: center;
  padding: 0 12px;
}

.legal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  font-size: 12px;
}

.icp-link {
  display: block;
  color: rgba(214, 226, 246, 0.72);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  text-decoration: none;
}

.icp-link:hover {
  color: rgba(255, 255, 255, 0.92);
}

.legal-links a {
  color: var(--muted);
  text-decoration: none;
}

.legal-links .link-button {
  display: inline;
  width: auto;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.legal-links a:hover,
.legal-links .link-button:hover {
  color: var(--text);
}

.doc-page {
  overflow: auto;
  padding: 28px;
  background: var(--bg);
}

.doc-shell {
  width: min(840px, 100%);
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.doc-shell h1,
.doc-shell h2 {
  margin: 0 0 12px;
  letter-spacing: 0;
}

.doc-shell h1 {
  font-size: 26px;
}

.doc-shell h2 {
  margin-top: 24px;
  font-size: 18px;
}

.doc-shell p,
.doc-shell li {
  color: var(--muted);
  line-height: 1.8;
}

.doc-shell a {
  color: var(--accent);
}

.sidebar-drawer button {
  width: 100%;
  min-height: 34px;
  margin-top: 10px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.memory-panel,
.rewrite-panel,
.advice-panel,
.writer-config-group {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.writer-config-group,
.memory-panel,
.rewrite-panel,
.advice-panel {
  border-left: 3px solid rgba(229, 201, 143, 0.52);
}

.group-heading {
  display: grid;
  gap: 3px;
}

.group-heading.compact {
  gap: 2px;
}

.group-heading h3 {
  margin: 0;
  color: #ffffff;
  font-size: 15px;
  line-height: 1.35;
}

.group-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.characters-panel,
.other-settings-panel,
.outline-builder-panel,
.outline-overview-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.book-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
}

.book-picker-toggle {
  height: 38px;
}

.book-picker-toggle[title] {
  position: relative;
}

.book-picker-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.book-picker-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.book-picker-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  text-align: left;
}

.book-picker-item strong {
  color: #ffffff;
  font-size: 13px;
}

.book-picker-item span {
  color: var(--muted);
  font-size: 12px;
}

.book-picker-item.active {
  border-color: rgba(78, 205, 196, 0.72);
  background: rgba(78, 205, 196, 0.13);
}

.characters-head,
.character-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.characters-head h3 {
  margin: 0;
  font-size: 14px;
}

.character-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.character-page-jump {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.character-page-jump input {
  width: 54px;
  height: 32px;
  padding: 0 6px;
  text-align: center;
}

.character-page-jump em {
  font-style: normal;
  white-space: nowrap;
}

.characters-head button,
.character-card-head button {
  min-height: 32px;
  padding: 0 10px;
}

.compact-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.compact-select input {
  width: 78px;
  height: 32px;
  padding: 0 8px;
  text-align: center;
}

.outline-builder-panel,
.outline-overview-panel {
  border-color: rgba(229, 201, 143, 0.36);
  background: rgba(229, 201, 143, 0.055);
}

.outline-builder-panel .small,
.outline-overview-panel .small {
  margin: 0;
  line-height: 1.55;
}

.outline-builder-panel > .characters-head,
.outline-overview-panel > .characters-head {
  align-items: flex-start;
}

.outline-builder-panel > .characters-head h3,
.outline-overview-panel > .characters-head h3 {
  min-width: 76px;
  padding-top: 8px;
  font-size: 15px;
}

.outline-builder-panel .character-tools {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) minmax(118px, auto) 96px 96px;
  align-items: center;
  gap: 8px;
}

.outline-step-tools {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
}

.outline-step-tools button {
  min-width: 76px;
  height: 34px;
  padding: 0 12px;
}

.outline-builder-panel .character-tools button {
  min-width: 96px;
  height: 36px;
  padding: 0 12px;
}

.outline-ending-check {
  min-height: 32px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  white-space: nowrap;
}

.outline-extra-field {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
}

.outline-extra-field textarea {
  min-height: 112px;
  line-height: 1.65;
}

.outline-progress {
  padding: 8px 10px;
  border: 1px solid rgba(229, 201, 143, 0.28);
  border-radius: 8px;
  color: var(--text);
  background: rgba(229, 201, 143, 0.08);
  font-size: 12px;
  line-height: 1.55;
}

.outline-box {
  min-height: 190px;
  resize: vertical;
  line-height: 1.75;
}

.outline-overview-box {
  min-height: 240px;
  white-space: pre-wrap;
}

.outline-box[readonly] {
  cursor: default;
  background: rgba(6, 10, 18, 0.7);
}

.save-settings-btn {
  min-height: 38px;
  border-color: rgba(78, 205, 196, 0.62);
  background: rgba(78, 205, 196, 0.16);
}

.character-list,
.other-settings-list {
  display: grid;
  gap: 10px;
}

.character-card,
.other-setting-card {
  display: grid;
  gap: 8px;
}

.other-setting-name {
  height: 38px;
}

.character-card-head strong {
  color: #dce5f0;
  font-size: 13px;
}

.graph-result {
  white-space: normal;
}

.inspiration-guide {
  display: grid;
  align-content: start;
  gap: 16px;
}

.guide-table {
  display: grid;
  gap: 10px;
}

.guide-row {
  display: grid;
  grid-template-columns: minmax(108px, 0.32fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.guide-row strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

.guide-row span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.graph-section {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.graph-section h3 {
  margin: 0;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.35;
}

.graph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.graph-node {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.graph-node strong {
  color: #ffffff;
  font-size: 14px;
}

.graph-node span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.graph-node.core {
  border-color: rgba(78, 205, 196, 0.45);
  background: rgba(78, 205, 196, 0.1);
}

.graph-node.character {
  border-color: rgba(255, 203, 107, 0.34);
}

.graph-node.event {
  border-color: rgba(126, 170, 255, 0.32);
}

.event-flow {
  display: grid;
  gap: 8px;
}

.graph-arrow {
  color: var(--muted);
  text-align: center;
}

.graph-list {
  margin: 0;
  padding-left: 18px;
  color: #dce5f0;
  font-size: 13px;
  line-height: 1.7;
}

.graph-section pre {
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  color: #e7edf6;
  white-space: pre-wrap;
}

.memory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.memory-head h3 {
  margin: 0;
  font-size: 14px;
}

.memory-head button,
#addMemoryBtn {
  min-height: 34px;
  padding: 0 10px;
}

.row {
  display: grid;
  gap: 12px;
}

.row.two {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.preference-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.preference-panel h2 {
  margin: 0;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.35;
  letter-spacing: 0;
}

label {
  display: grid;
  gap: 7px;
  color: #dce5f0;
  font-size: 13px;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

input,
select {
  height: 38px;
  padding: 0 11px;
}

textarea {
  resize: vertical;
  min-height: 82px;
  padding: 10px 11px;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

textarea[readonly] {
  background: rgba(255, 255, 255, 0.045);
  color: #d9e3ee;
}

::placeholder {
  color: #768396;
}

.output {
  display: grid;
  min-width: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
  background:
    radial-gradient(circle at 88% 10%, rgba(78, 205, 196, 0.1), transparent 28%),
    linear-gradient(180deg, #111720 0%, #0b0d12 100%);
}

.writer-output {
  display: flex;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 8px;
}

.writer-output > .actions {
  flex-wrap: nowrap;
}

.actions button {
  min-height: 32px;
  padding: 0 10px;
}

.download-top-btn {
  margin-left: auto;
}

#saveGeneratedBtn {
  border-color: rgba(78, 205, 196, 0.62);
  background: rgba(78, 205, 196, 0.16);
}

.segmented,
.tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented button {
  min-width: 98px;
  height: 38px;
  border-color: rgba(78, 205, 196, 0.42);
}

.segmented button:first-child {
  background: rgba(78, 205, 196, 0.16);
}

.segmented button:last-child {
  background: rgba(255, 203, 107, 0.14);
}

.tools button {
  height: 34px;
  padding: 0 11px;
  color: #d9e3ee;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.result {
  overflow: auto;
  min-height: 520px;
  padding: 30px 38px 64px;
  color: var(--text);
  line-height: 1.82;
  white-space: pre-wrap;
}

.writer-output > #writerResult {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.result h2 {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: 0;
}

.novel-reader h2,
#workContent h2 {
  margin: 4px 0 26px;
  text-align: center;
  font-size: 28px;
}

.novel-body {
  font-size: var(--reader-font-size);
  white-space: pre-wrap;
}

.chapter-title-input {
  width: 100%;
  margin-bottom: 14px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
}

.chapter-body-editor {
  min-height: 56vh;
  font-size: var(--reader-font-size);
  line-height: 1.82;
}

.task-panel,
.writer-directory {
  margin: 14px 20px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  white-space: pre-wrap;
}

.writer-output .task-panel {
  max-height: 132px;
  overflow: auto;
  margin: 10px 16px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.55;
}

.writer-directory {
  display: grid;
  flex: 0 0 auto;
  gap: 8px;
  min-height: 96px;
  max-height: 170px;
  overflow: auto;
}

.directory-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.writer-directory h3 {
  margin: 0 0 2px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.directory-toggle {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.writer-directory.collapsed {
  min-height: auto;
  max-height: none;
  padding: 8px 12px;
  overflow: visible;
}

.writer-directory.collapsed .chapter-item {
  display: none;
}

.writer-directory .chapter-item {
  width: 100%;
  text-align: left;
}

.writer-directory .chapter-item.pending {
  cursor: default;
  opacity: 0.68;
}

.result p {
  margin: 0;
  color: var(--muted);
}

.result.loading {
  color: #cbd6e4;
}

.result.error {
  color: #ffd1cc;
}

.works-page {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(300px, 34%) minmax(420px, 1fr);
  height: 100vh;
}

.creation-page {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(300px, 34%) minmax(420px, 1fr);
  height: 100vh;
}

.works-list,
.work-reader,
.creation-sidebar,
.creation-chat {
  min-width: 0;
  overflow: hidden;
}

.works-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.works-manage {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.works-edit-controls {
  display: grid;
  gap: 6px;
  min-width: 74px;
}

.works-edit-controls button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.creation-sidebar {
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding-bottom: 22px;
}

.member-lock-notice {
  position: relative;
  display: grid;
  gap: 8px;
  margin: 18px 22px 2px;
  padding: 14px 44px 14px 16px;
  border: 1px solid rgba(255, 219, 133, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 225, 145, 0.16), rgba(185, 216, 255, 0.055)),
    rgba(14, 18, 26, 0.92);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.member-lock-notice strong {
  color: #fff1bd;
  font-size: 15px;
}

.member-lock-notice p {
  margin: 0;
  color: #dce5f0;
  font-size: 13px;
  line-height: 1.7;
}

.member-lock-notice > button:not(.notice-close) {
  justify-self: start;
  min-height: 32px;
  padding: 0 14px;
  border-color: rgba(255, 219, 133, 0.50);
  background: rgba(255, 219, 133, 0.14);
  color: #fff1bd;
}

.notice-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #dce5f0;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.creation-page.member-locked .creation-compose textarea,
.creation-page.member-locked #creationContext,
.creation-page.member-locked .creation-tools button,
.creation-page.member-locked #creationUseInspirationBtn,
.creation-page.member-locked #creationImportChapterBtn,
.creation-page.member-locked #creationClearReferenceBtn,
.creation-page.member-locked #creationClearBtn {
  cursor: not-allowed;
  opacity: 0.58;
}

.creation-page.member-locked .creation-compose {
  border-top-color: rgba(255, 219, 133, 0.20);
  background: rgba(7, 10, 17, 0.88);
}

.creation-page.member-locked .creation-compose::before {
  content: "会员未开启，当前仅可预览创作助手。";
  color: #ffe2a3;
  font-size: 13px;
}

.creation-sidebar > label,
.creation-sidebar > button,
.creation-work-panel {
  margin: 0 22px;
}

.creation-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 22px;
}

.creation-tools button,
.creation-sidebar > button {
  min-height: 38px;
  text-align: left;
  padding: 0 12px;
}

.creation-tools button {
  border-color: rgba(185, 216, 255, 0.22);
  background: rgba(255, 255, 255, 0.045);
}

.creation-work-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.creation-work-panel h3 {
  margin: 0;
  color: #ffffff;
  font-size: 14px;
  line-height: 1.35;
}

.creation-work-panel button {
  min-height: 36px;
  padding: 0 12px;
  text-align: left;
}

.creation-chat {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  background:
    radial-gradient(circle at 80% 8%, rgba(185, 216, 255, 0.12), transparent 28%),
    linear-gradient(180deg, #0f1622 0%, #080b12 100%);
}

.creation-messages {
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 24px;
}

.creation-message {
  display: grid;
  gap: 8px;
  max-width: min(760px, 86%);
  padding: 14px 16px;
  border: 1px solid rgba(214, 228, 248, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.creation-message.user {
  justify-self: end;
  border-color: rgba(229, 201, 143, 0.28);
  background: rgba(229, 201, 143, 0.09);
}

.creation-message.assistant {
  justify-self: start;
}

.creation-message.error {
  border-color: rgba(255, 130, 120, 0.34);
  background: rgba(255, 130, 120, 0.08);
}

.creation-message.pending {
  border-color: rgba(229, 201, 143, 0.34);
  background: rgba(229, 201, 143, 0.08);
}

.creation-message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.creation-message-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.creation-message-actions button {
  min-width: auto;
  min-height: 30px;
  padding: 0 10px;
  border-color: rgba(214, 228, 248, 0.18);
  background: rgba(214, 228, 248, 0.08);
}

.creation-message strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
  font-size: 13px;
}

.creation-message p {
  margin: 0;
  color: #dce5f0;
  line-height: 1.78;
  white-space: pre-wrap;
}

.creation-compose {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid rgba(229, 201, 143, 0.26);
  background: linear-gradient(180deg, rgba(20, 28, 42, 0.86), rgba(7, 10, 17, 0.86));
  box-shadow: 0 -10px 34px rgba(0, 0, 0, 0.22);
}

.creation-compose textarea {
  min-height: 106px;
  border-color: rgba(229, 201, 143, 0.34);
  background: rgba(2, 6, 12, 0.76);
  box-shadow: 0 0 0 1px rgba(229, 201, 143, 0.07) inset;
}

.inline-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(229, 201, 143, 0.35);
  border-top-color: #e5c98f;
  border-radius: 999px;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.creation-compose-actions button {
  min-width: 104px;
  min-height: 38px;
  border-color: rgba(185, 216, 255, 0.46);
  background: rgba(185, 216, 255, 0.14);
}

button.danger {
  border-color: rgba(255, 142, 142, 0.58);
  background: rgba(255, 86, 86, 0.16);
  color: #ffd7d7;
}

.works-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: 0;
}

.work-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 16px;
}

.work-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 8px;
  width: 100%;
  padding: 14px;
  cursor: pointer;
  text-align: center;
}

.work-card.active {
  border-color: rgba(78, 205, 196, 0.65);
  background: rgba(78, 205, 196, 0.12);
}

.work-card.selectable {
  padding-top: 38px;
}

.work-card.selected {
  border-color: rgba(255, 203, 107, 0.76);
  background: rgba(255, 203, 107, 0.1);
}

.work-select {
  position: absolute;
  top: 10px;
  left: 10px;
  display: block;
  width: 22px;
  height: 22px;
}

.work-select input {
  width: 22px;
  height: 22px;
  margin: 0;
}

.work-card strong {
  color: #fff;
  font-size: 15px;
}

.work-card button {
  height: 30px;
  padding: 0 8px;
}

.work-cover {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(145deg, rgba(78, 205, 196, 0.18), rgba(255, 203, 107, 0.12));
}

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

.work-cover em {
  color: var(--muted);
  font-style: normal;
}

.work-card span,
.empty-state {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.work-badges {
  min-height: 18px;
  color: #4ecdc4;
  font-size: 11px;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.works-bulk-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: rgba(14, 18, 26, 0.98);
}

.works-bulk-bar span {
  color: #dce5f0;
  font-size: 13px;
}

.works-bulk-bar button {
  min-height: 34px;
  padding: 0 12px;
}

input[name="historyWindow"] {
  text-align: center;
}

.work-reader {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100vh;
}

#workDetail {
  display: grid;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.work-detail-top {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) minmax(220px, 30%);
  gap: 18px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.cover-uploader {
  display: grid;
  position: relative;
  min-height: 210px;
  align-content: center;
  justify-items: center;
  gap: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  cursor: pointer;
  overflow: hidden;
}

.cover-uploader input {
  display: none;
}

.cover-uploader img {
  display: none;
  width: 100%;
  height: 210px;
  object-fit: cover;
}

.work-editor {
  display: grid;
  align-content: start;
  gap: 12px;
}

.work-editor button {
  width: fit-content;
  min-height: 38px;
  padding: 0 14px;
}

.work-catalog {
  display: grid;
  min-height: 0;
  gap: 10px;
}

.work-catalog h3 {
  margin: 0;
  font-size: 15px;
}

.chapter-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.chapter-item {
  min-height: 34px;
  padding: 0 10px;
  text-align: left;
}

.chapter-item.active {
  border-color: rgba(78, 205, 196, 0.65);
  background: rgba(78, 205, 196, 0.12);
}

#workContent {
  min-height: 0;
  overflow: auto;
}

#workContent .chapter-body-editor {
  width: 100%;
  min-height: 52vh;
}

.advice-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.recharge-dialog {
  width: min(460px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.profile-dialog,
.settings-dialog,
.compliance-dialog,
.report-dialog {
  width: min(560px, calc(100vw - 32px));
}

.outline-supplement-dialog {
  width: min(640px, calc(100vw - 32px));
}

.creation-edit-dialog {
  width: min(680px, calc(100vw - 32px));
}

.creation-edit-dialog textarea {
  min-height: 220px;
  line-height: 1.7;
}

.outline-supplement-body {
  display: grid;
  gap: 12px;
  padding: 2px 0 6px;
}

.outline-supplement-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.outline-supplement-list ul {
  margin: 0;
  padding-left: 18px;
}

.outline-supplement-list li {
  margin: 0 0 6px;
  line-height: 1.55;
}

.account-compliance-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.account-security-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(215, 224, 240, 0.14);
  border-radius: 10px;
  background: rgba(8, 14, 24, 0.36);
}

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

.contact-bind-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(215, 224, 240, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.contact-bind-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.contact-bind-head span {
  color: var(--muted);
  font-size: 12px;
}

.contact-bind-card .verify-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.contact-bind-card button.danger {
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(127, 29, 29, 0.28);
}

.contact-bind-card button:disabled {
  cursor: wait;
  opacity: 0.82;
  color: rgba(255, 255, 255, 0.92);
}

.compliance-content {
  display: grid;
  gap: 12px;
}

.compliance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.compliance-grid div {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.compliance-grid span {
  color: var(--muted);
  font-size: 12px;
}

.compliance-grid strong {
  font-size: 14px;
}

.profile-editor-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.9fr);
  gap: 14px;
  align-items: stretch;
}

.avatar-uploader {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 130px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.035);
}

.avatar-uploader input {
  display: none;
}

.avatar-uploader em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.wallet-card {
  display: grid;
  align-content: center;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(78, 205, 196, 0.08);
}

.wallet-card span {
  color: var(--muted);
  font-size: 12px;
}

.wallet-card strong {
  white-space: pre-line;
  line-height: 1.25;
}

.premium-wallet-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #e5c98f;
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.premium-wallet-hint.locked {
  color: #c2cad6;
}

.ledger-panel {
  overflow: hidden;
}

.ledger-panel > button {
  width: fit-content;
  margin: 8px 0 10px;
  padding: 0 12px;
}

.ledger-list {
  min-width: 0;
}

.ledger-columns {
  align-items: start;
}

.ledger-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.ledger-item strong,
.ledger-item span,
.ledger-item small {
  overflow-wrap: anywhere;
}

.ledger-item small {
  color: rgba(235, 241, 255, 0.58);
  font-size: 12px;
}

.ledger-item.income em {
  color: #aaf0c1;
}

.ledger-item.expense em {
  color: #ffd2a6;
}

.ledger-item em {
  text-align: right;
}

.wallet-card strong {
  font-size: 20px;
}

.wallet-card button {
  height: 34px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-line input {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

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

.legal-consent-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(88vh, 760px);
  border: 1px solid rgba(229, 201, 143, 0.36);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.legal-consent-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(5px);
}

.legal-consent-card {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.legal-consent-card h2,
.legal-consent-card h3,
.legal-consent-card p {
  margin: 0;
  letter-spacing: 0;
}

.legal-consent-card h2 {
  font-size: 22px;
}

.legal-consent-scroll {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.legal-consent-scroll h3 {
  font-size: 15px;
}

.legal-consent-scroll p,
.legal-consent-card .small,
.legal-consent-check span {
  color: var(--muted);
  line-height: 1.75;
}

.legal-consent-check {
  align-items: flex-start;
  padding: 12px;
  border: 1px solid rgba(229, 201, 143, 0.32);
  border-radius: 8px;
  background: rgba(229, 201, 143, 0.08);
}

.legal-consent-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legal-consent-links a {
  color: var(--accent);
}

.announcement-dialog {
  width: min(560px, calc(100vw - 30px));
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.announcement-dialog::backdrop {
  background: radial-gradient(circle at 50% 20%, rgba(185, 216, 255, 0.16), rgba(0, 0, 0, 0.76) 58%);
  backdrop-filter: blur(8px);
}

.announcement-card {
  position: relative;
  overflow: hidden;
  padding: 28px 28px 24px;
  border: 1px solid rgba(229, 201, 143, 0.42);
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 0%, rgba(229, 201, 143, 0.18), transparent 36%),
    radial-gradient(circle at 86% 12%, rgba(185, 216, 255, 0.16), transparent 34%),
    linear-gradient(145deg, rgba(12, 18, 30, 0.98), rgba(6, 9, 16, 0.96));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.035) inset;
}

.announcement-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.35) 0 1px, transparent 1.5px),
    linear-gradient(110deg, transparent 0 26%, rgba(229, 201, 143, 0.08) 44%, transparent 64%);
  background-size: 86px 86px, 100% 100%;
  opacity: 0.38;
}

.announcement-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  border-color: rgba(229, 201, 143, 0.35);
  background: rgba(255, 255, 255, 0.06);
  color: #fff7df;
  font-size: 22px;
  line-height: 1;
}

.announcement-kicker,
.announcement-card h2,
.announcement-content,
.announcement-time {
  position: relative;
  z-index: 1;
}

.announcement-kicker {
  display: inline-flex;
  margin-bottom: 12px;
  color: #e5c98f;
  font-size: 13px;
  letter-spacing: 0;
}

.announcement-card h2 {
  margin: 0 38px 14px 0;
  color: #f7fbff;
  font-size: 26px;
  line-height: 1.35;
  text-shadow: 0 0 18px rgba(185, 216, 255, 0.28);
}

.announcement-content {
  display: grid;
  gap: 10px;
  max-height: min(52vh, 420px);
  overflow: auto;
  color: rgba(237, 242, 248, 0.92);
  font-size: 15px;
  line-height: 1.85;
}

.announcement-content p {
  margin: 0;
}

.announcement-time {
  margin: 18px 0 0;
  color: rgba(174, 185, 201, 0.88);
  font-size: 12px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dialog-head h2 {
  font-size: 18px;
}

.dialog-head .icon-button,
.onboarding-close {
  display: inline-grid;
  place-items: center;
  padding: 0;
  line-height: 1;
}

.floating-creation-btn {
  position: fixed;
  right: 22px;
  bottom: 26px;
  z-index: 8000;
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-color: rgba(229, 201, 143, 0.58);
  border-radius: 999px;
  background: radial-gradient(circle at 35% 25%, rgba(255, 241, 189, 0.34), rgba(229, 201, 143, 0.16) 44%, rgba(18, 23, 34, 0.96));
  color: #fff1bd;
  font-size: 24px;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.42), 0 0 24px rgba(229, 201, 143, 0.18);
}

.floating-creation-btn.locked::after {
  content: "🔒";
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgba(229, 201, 143, 0.58);
  border-radius: 999px;
  background: rgba(18, 23, 34, 0.96);
  font-size: 12px;
}

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

.package-group {
  display: grid;
  gap: 8px;
}

.package-group h3 {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.package-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.payment-providers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.payment-providers button {
  height: 38px;
}

.payment-providers button.active {
  border-color: rgba(78, 205, 196, 0.72);
  background: rgba(78, 205, 196, 0.16);
}

.package {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  text-align: left;
}

.package.active {
  border-color: rgba(255, 213, 104, 0.85);
  box-shadow: 0 0 0 2px rgba(255, 213, 104, 0.12);
}

.package strong {
  color: var(--text);
  font-size: 14px;
}

.package span {
  color: var(--muted);
  font-size: 12px;
}

.redeem-guide,
.redeem-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.redeem-guide h3 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
}

.redeem-guide p,
.redeem-guide li span {
  color: var(--muted);
  line-height: 1.7;
}

.redeem-guide ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.redeem-guide li {
  display: grid;
  gap: 3px;
}

.redeem-guide strong,
.redeem-panel label {
  color: var(--text);
  font-weight: 700;
}

.redeem-panel input {
  width: 100%;
  margin-top: 6px;
  font-family: "Courier New", monospace;
  text-transform: uppercase;
}

.redeem-panel button {
  width: 100%;
  margin-top: 10px;
}

#rechargeStatus {
  display: block;
  margin-top: 12px;
  white-space: pre-line;
}

.pay-page {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
}

.pay-card {
  display: grid;
  width: min(520px, 100%);
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pay-card button,
.pay-card a {
  display: inline-grid;
  width: fit-content;
  min-height: 38px;
  align-items: center;
  padding: 0 14px;
}

.pay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pay-qr {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.pay-qr img {
  width: 260px;
  max-width: 100%;
  border-radius: 6px;
  background: #fff;
}

.pay-button.secondary {
  opacity: 0.82;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-check input {
  width: auto;
  height: auto;
}

@media (max-width: 920px) {
  body {
    overflow: auto;
  }

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

  .app-wide,
  .page-grid {
    grid-template-columns: 1fr;
  }

  .creation-page {
    grid-template-columns: 1fr;
    height: auto;
  }

  .workspace {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .page-grid > .form {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .output {
    min-height: 70vh;
  }

  .creation-chat {
    min-height: 70vh;
  }
}

@media (max-width: 620px) {
  .row.two,
  .row.three,
  .account-panel,
  .profile-editor-head {
    grid-template-columns: 1fr;
  }

  .account-actions {
    width: 100%;
  }

  .account-actions button {
    flex: 1;
  }

  .actions,
  .meta,
  .creation-compose-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .creation-tools {
    grid-template-columns: 1fr;
  }

  .segmented button,
  .tools button {
    flex: 1;
  }

  .result {
    padding: 20px 18px 36px;
  }
}

/* Workspace visual polish */
:root {
  --bg: #070a11;
  --surface: #101622;
  --surface-2: #172131;
  --line: rgba(210, 225, 245, 0.14);
  --text: #f1f5fb;
  --muted: #aeb9c9;
  --accent: #b9d8ff;
  --accent-2: #e5c98f;
  --focus: rgba(185, 216, 255, 0.18);
  --panel-glow: rgba(185, 216, 255, 0.08);
}

body {
  background:
    radial-gradient(circle at 18% 18%, rgba(74, 101, 158, 0.20), transparent 28%),
    radial-gradient(circle at 84% 8%, rgba(229, 201, 143, 0.10), transparent 24%),
    linear-gradient(135deg, #05070c 0%, #090d16 42%, #070a11 100%);
}

.app-wide {
  background: rgba(7, 10, 17, 0.88);
}

.workspace {
  border-right-color: rgba(214, 228, 248, 0.13);
  background:
    linear-gradient(180deg, rgba(18, 26, 40, 0.96), rgba(9, 13, 22, 0.98)),
    radial-gradient(circle at 30% 8%, rgba(185, 216, 255, 0.14), transparent 28%);
  box-shadow: 18px 0 50px rgba(0, 0, 0, 0.24);
}

.topbar {
  position: relative;
  z-index: 2;
  padding: 22px 20px 16px;
  border-bottom-color: rgba(214, 228, 248, 0.12);
  background: linear-gradient(180deg, rgba(8, 12, 20, 0.98), rgba(8, 12, 20, 0.88));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.topbar h1 {
  color: #f7fbff;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  font-size: 22px;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 18px rgba(185, 216, 255, 0.26),
    0 2px 10px rgba(0, 0, 0, 0.55);
}

.topbar p,
.small {
  color: #aeb9c9;
}

.icon-button,
.side-nav button,
.sidebar-footer button,
.actions button,
.auth-form button,
.work-card,
.chapter-item,
.package,
.book-picker-item,
.creation-tools button,
.creation-sidebar > button,
.creation-compose-actions button {
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.profile-entry {
  border-color: rgba(185, 216, 255, 0.20);
  background: rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.profile-entry:hover,
.side-nav button:hover,
.sidebar-footer button:hover,
.actions button:hover,
.work-card:hover,
.book-picker-item:hover,
.chapter-item:hover,
.creation-tools button:hover,
.creation-sidebar > button:hover,
.creation-compose-actions button:hover {
  transform: translateY(-1px);
  border-color: rgba(185, 216, 255, 0.46);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.profile-avatar {
  border-color: rgba(185, 216, 255, 0.50);
  background: linear-gradient(145deg, rgba(185, 216, 255, 0.20), rgba(229, 201, 143, 0.10));
}

.side-nav {
  gap: 10px;
  padding-top: 18px;
}

.side-nav button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.035);
  color: #dfe8f7;
  font-weight: 600;
}

.side-nav button.locked {
  color: #c4ccd8;
}

.nav-lock {
  position: absolute;
  right: 12px;
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid rgba(255, 216, 120, 0.42);
  border-radius: 50%;
  background: rgba(255, 216, 120, 0.10);
  color: #ffe09a;
  font-size: 12px;
  box-shadow: 0 0 12px rgba(255, 203, 90, 0.18);
}

.side-nav button.active,
.mode-tabs button.active {
  border-color: rgba(185, 216, 255, 0.56);
  background: linear-gradient(90deg, rgba(185, 216, 255, 0.18), rgba(255, 255, 255, 0.045));
  color: #ffffff;
  box-shadow: inset 3px 0 0 rgba(229, 201, 143, 0.88), 0 12px 26px rgba(0, 0, 0, 0.16);
}

.memory-panel,
.characters-panel,
.other-settings-panel,
.book-picker-panel,
.creation-work-panel,
.task-panel,
.writer-directory,
.preference-panel {
  border-color: rgba(214, 228, 248, 0.15);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.026));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.page-grid,
.output {
  background:
    radial-gradient(circle at 82% 12%, rgba(185, 216, 255, 0.12), transparent 27%),
    radial-gradient(circle at 20% 90%, rgba(229, 201, 143, 0.07), transparent 30%),
    linear-gradient(180deg, #0d131f 0%, #070a11 100%);
}

.page-grid > .form {
  border-right-color: rgba(214, 228, 248, 0.13);
  background:
    linear-gradient(180deg, rgba(13, 19, 31, 0.96), rgba(9, 13, 22, 0.98)),
    radial-gradient(circle at 50% 0%, rgba(185, 216, 255, 0.08), transparent 32%);
}

.form {
  gap: 15px;
  padding: 22px 22px 28px;
}

.pane h2,
.works-head h2 {
  color: #ffffff;
  font-size: 21px;
  text-shadow: 0 0 18px rgba(185, 216, 255, 0.12);
}

label {
  color: #dce6f5;
  font-weight: 600;
}

input,
select,
textarea {
  border-color: rgba(214, 228, 248, 0.16);
  background: rgba(8, 12, 20, 0.76);
  color: #f3f7ff;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(185, 216, 255, 0.32);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(185, 216, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(185, 216, 255, 0.16), 0 0 26px rgba(185, 216, 255, 0.07);
}

button,
.pay-card a {
  border-color: rgba(214, 228, 248, 0.16);
  background: linear-gradient(180deg, rgba(31, 43, 62, 0.92), rgba(18, 26, 40, 0.92));
  color: #eef5ff;
}

button:hover,
.pay-card a:hover {
  border-color: rgba(185, 216, 255, 0.55);
}

.save-settings-btn,
#saveGeneratedBtn,
#completeInspirationBtn,
#writeBtn,
#profileRechargeBtn {
  border-color: rgba(229, 201, 143, 0.48);
  background: linear-gradient(180deg, rgba(229, 201, 143, 0.18), rgba(185, 216, 255, 0.08));
}

.actions {
  padding: 20px 22px 13px;
}

.meta {
  padding: 0 22px 14px;
  border-bottom-color: rgba(214, 228, 248, 0.12);
  color: #aeb9c9;
}

.result {
  margin: 0;
  padding: 28px 34px 48px;
  color: #edf3ff;
}

.result h2,
.graph-section h3,
.writer-directory h3,
.work-catalog h3 {
  color: #ffffff;
}

.novel-reader,
#workContent {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01)),
    radial-gradient(circle at 50% 0%, rgba(185, 216, 255, 0.08), transparent 42%);
}

.novel-reader h2,
#workContent h2 {
  color: #f8fbff;
  text-shadow: 0 0 18px rgba(185, 216, 255, 0.14);
}

.graph-node {
  border-color: rgba(214, 228, 248, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.024));
}

.graph-node.core {
  border-color: rgba(185, 216, 255, 0.44);
  background: rgba(185, 216, 255, 0.10);
}

.graph-node.character {
  border-color: rgba(229, 201, 143, 0.36);
}

.graph-node.event {
  border-color: rgba(150, 174, 234, 0.36);
}

.works-page {
  background:
    radial-gradient(circle at 84% 12%, rgba(185, 216, 255, 0.10), transparent 28%),
    linear-gradient(180deg, #0d131f 0%, #070a11 100%);
}

.works-list {
  border-right: 1px solid rgba(214, 228, 248, 0.13);
  background: rgba(10, 15, 24, 0.82);
}

.works-head {
  border-bottom-color: rgba(214, 228, 248, 0.12);
}

.work-cards {
  gap: 14px;
  padding: 18px;
}

.work-card {
  border-color: rgba(214, 228, 248, 0.13);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.024));
}

.work-card.active {
  border-color: rgba(185, 216, 255, 0.66);
  background: rgba(185, 216, 255, 0.11);
}

.work-cover {
  border-color: rgba(214, 228, 248, 0.15);
  background:
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.18), transparent 30%),
    linear-gradient(145deg, rgba(185, 216, 255, 0.20), rgba(229, 201, 143, 0.10), rgba(30, 40, 62, 0.94));
  box-shadow: inset 0 0 38px rgba(0, 0, 0, 0.18);
}

.work-detail-top {
  border-bottom-color: rgba(214, 228, 248, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

.cover-uploader {
  border-color: rgba(214, 228, 248, 0.18);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.05), rgba(185, 216, 255, 0.06));
}

.chapter-item.active {
  border-color: rgba(185, 216, 255, 0.66);
  background: rgba(185, 216, 255, 0.12);
}

.recharge-dialog {
  border-color: rgba(214, 228, 248, 0.18);
  background: linear-gradient(180deg, rgba(17, 24, 37, 0.98), rgba(10, 15, 24, 0.98));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.46);
}

.wallet-card {
  border-color: rgba(229, 201, 143, 0.24);
  background: linear-gradient(145deg, rgba(229, 201, 143, 0.12), rgba(185, 216, 255, 0.08));
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

::-webkit-scrollbar-thumb {
  border: 2px solid rgba(7, 10, 17, 0.92);
  border-radius: 999px;
  background: rgba(185, 216, 255, 0.26);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(185, 216, 255, 0.40);
}

body.theme-light {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --line: #ced9e6;
  --text: #152033;
  --muted: #627188;
  --accent: #3d6f9e;
  --accent-2: #9a6a1f;
  --focus: rgba(61, 111, 158, 0.18);
}

body[data-workspace-bg="moonlit"] {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #edf3f8;
  --line: rgba(80, 104, 132, 0.20);
  --text: #172033;
  --muted: #637184;
  --accent: #466f9f;
  --accent-2: #a0712a;
  --focus: rgba(70, 111, 159, 0.18);
}

body[data-workspace-bg="moonlit"] {
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.92), transparent 22%),
    radial-gradient(circle at 86% 0%, rgba(165, 193, 224, 0.32), transparent 24%),
    linear-gradient(135deg, #e9eff6 0%, #f7fafc 52%, #e5edf5 100%);
}

body[data-workspace-bg="moonlit"] .workspace,
body[data-workspace-bg="moonlit"] .page-grid > .form,
body[data-workspace-bg="moonlit"] .works-list {
  background: rgba(255, 255, 255, 0.86);
}

body[data-workspace-bg="moonlit"] .topbar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(240, 246, 252, 0.92));
  box-shadow: 0 10px 24px rgba(80, 104, 132, 0.10);
}

body[data-workspace-bg="moonlit"] .page-grid,
body[data-workspace-bg="moonlit"] .output,
body[data-workspace-bg="moonlit"] .works-page {
  background:
    radial-gradient(circle at 84% 12%, rgba(70, 111, 159, 0.10), transparent 28%),
    linear-gradient(180deg, #f8fbfd 0%, #e8eff6 100%);
}

body[data-workspace-bg="moonlit"] .topbar h1,
body[data-workspace-bg="moonlit"] .pane h2,
body[data-workspace-bg="moonlit"] .works-head h2,
body[data-workspace-bg="moonlit"] .result h2 {
  color: #172033;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  text-shadow: none;
}

body[data-workspace-bg="moonlit"] input,
body[data-workspace-bg="moonlit"] select,
body[data-workspace-bg="moonlit"] textarea,
body[data-workspace-bg="moonlit"] button {
  background: rgba(255, 255, 255, 0.78);
  color: #172033;
}

body[data-workspace-bg="ink"] {
  --bg: #030509;
  --surface: #090d14;
  --surface-2: #101723;
  --line: rgba(170, 190, 220, 0.13);
  --text: #eef4ff;
  --muted: #9aa7bb;
  --accent: #d7e6ff;
  --accent-2: #b9985f;
  --focus: rgba(215, 230, 255, 0.16);
}

body[data-workspace-bg="ink"] {
  background:
    radial-gradient(circle at 78% 18%, rgba(90, 118, 180, 0.14), transparent 28%),
    radial-gradient(circle at 22% 86%, rgba(185, 155, 95, 0.08), transparent 30%),
    linear-gradient(135deg, #020305 0%, #060912 58%, #030509 100%);
}

body[data-workspace-bg="ink"] .workspace,
body[data-workspace-bg="ink"] .page-grid > .form,
body[data-workspace-bg="ink"] .works-list {
  background: linear-gradient(180deg, rgba(9, 13, 20, 0.98), rgba(3, 5, 9, 0.99));
}

body[data-workspace-bg="ink"] .topbar {
  background: linear-gradient(180deg, rgba(3, 5, 9, 0.99), rgba(6, 9, 16, 0.94));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
}

body[data-workspace-bg="ink"] .topbar h1 {
  color: #f8fbff;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 20px rgba(215, 230, 255, 0.28),
    0 2px 12px rgba(0, 0, 0, 0.72);
}

body[data-workspace-bg="ink"] .page-grid,
body[data-workspace-bg="ink"] .output,
body[data-workspace-bg="ink"] .works-page {
  background:
    radial-gradient(circle at 80% 8%, rgba(215, 230, 255, 0.08), transparent 30%),
    linear-gradient(180deg, #070b12 0%, #030509 100%);
}

.side-nav button::before {
  display: inline-grid;
  flex: 0 0 22px;
  width: 22px;
  margin-right: 0;
  color: rgba(229, 201, 143, 0.9);
  text-align: center;
}

.sidebar-footer button::before {
  display: inline-grid;
  flex: 0 0 22px;
  width: 22px;
  margin-right: 8px;
  color: rgba(229, 201, 143, 0.9);
  text-align: center;
}

#showInspiration::before {
  content: "✧";
}

#showWriter::before {
  content: "✎";
}

#showWorks::before {
  content: "▣";
}

#showCreation::before {
  content: "✦";
}

#showTasks::before {
  content: "◴";
}

#settingsBtn::before {
  content: "⚙";
}
.work-card::after {
  position: absolute;
  inset: 8px 8px auto auto;
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(229, 201, 143, 0.75));
  content: "";
  opacity: 0.66;
}

.work-card strong {
  line-height: 1.45;
}

.work-cover::before {
  display: block;
  width: 34%;
  height: 1px;
  margin-bottom: 7px;
  background: rgba(255, 255, 255, 0.36);
  content: "";
}

#writerResult,
#workContent {
  font-family: "Microsoft YaHei", "PingFang SC", "Source Han Serif SC", serif;
}

.novel-body,
#workContent p {
  letter-spacing: 0;
}

.chapter-list,
.writer-directory {
  scrollbar-width: thin;
}

.tasks-page {
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  background:
    radial-gradient(circle at 82% 12%, rgba(185, 216, 255, 0.12), transparent 27%),
    linear-gradient(180deg, #0d131f 0%, #070a11 100%);
}

.tasks-panel {
  min-width: 0;
  overflow: hidden;
}

.tasks-list {
  display: grid;
  gap: 12px;
  padding: 18px;
  overflow: auto;
  max-height: calc(100vh - 92px);
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(214, 228, 248, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.024));
}

.task-card strong,
.version-item strong {
  display: block;
  color: #ffffff;
  font-size: 14px;
}

.task-card span,
.task-card small,
.version-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.task-card em {
  color: #e5c98f;
  font-size: 12px;
  font-style: normal;
}

.task-card progress {
  grid-column: 1 / -1;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.task-card progress::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.07);
}

.task-card progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, #b9d8ff, #e5c98f);
}

.planning-panel {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(214, 228, 248, 0.14);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
}

.planning-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  cursor: pointer;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  list-style: none;
}

.planning-panel summary::-webkit-details-marker {
  display: none;
}

.planning-panel summary::after {
  color: rgba(229, 201, 143, 0.9);
  content: "展开";
  font-size: 12px;
  font-weight: 600;
}

.planning-panel[open] summary::after {
  content: "收起";
}

.planning-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 12px 0;
}

.planning-grid textarea {
  min-height: 118px;
}

.versions-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.version-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(214, 228, 248, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.version-item div {
  display: grid;
  gap: 4px;
}

.version-item button {
  width: auto;
  padding: 7px 12px;
}

@media (max-width: 920px) {
  .planning-grid {
    grid-template-columns: 1fr;
  }

  .writer-output > .actions {
    flex-wrap: wrap;
  }

  .download-top-btn {
    margin-left: 0;
  }
}

.preflight-panel,
.quality-panel,
.ledger-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(214, 228, 248, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.preflight-panel strong,
.quality-panel strong {
  color: #f5f8ff;
}

.preflight-panel span,
.quality-panel span,
.ledger-panel span {
  color: rgba(235, 241, 255, 0.74);
  font-size: 0.88rem;
}

.quality-panel ul {
  margin: 0;
  padding-left: 18px;
  color: #ffd8a8;
}

.writer-output .quality-panel {
  gap: 4px;
  margin: 6px 16px;
  padding: 7px 10px;
}

.writer-output .quality-panel strong,
.writer-output .quality-panel span,
.writer-output .quality-panel li {
  font-size: 12px;
  line-height: 1.45;
}

.writer-output .quality-panel ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding-left: 16px;
}

.works-filter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 130px 130px;
  gap: 8px;
  margin-bottom: 12px;
}

.works-filter input,
.works-filter select,
#downloadFormat {
  min-height: 36px;
}

.ledger-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.download-dialog {
  width: min(460px, calc(100vw - 32px));
}

.download-dialog select,
.download-dialog input {
  min-height: 42px;
}

.download-dialog input[readonly] {
  color: var(--muted);
}

.dialog-actions {
  justify-content: flex-end;
  padding: 0;
}

.ledger-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.ledger-columns h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.ledger-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 10px;
  border: 1px solid rgba(214, 228, 248, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.ledger-item div {
  display: grid;
  gap: 3px;
}

.ledger-item em {
  font-style: normal;
  color: #dce7ff;
  white-space: nowrap;
  text-align: right;
}

.wallet-card strong {
  white-space: pre-line;
  line-height: 1.25;
}

.ledger-panel {
  overflow: hidden;
}

.ledger-panel > button {
  width: fit-content;
  margin: 8px 0 10px;
  padding: 0 12px;
}

.ledger-list {
  min-width: 0;
}

.ledger-columns {
  align-items: start;
}

.ledger-item strong,
.ledger-item span,
.ledger-item small {
  overflow-wrap: anywhere;
}

.ledger-item small {
  color: rgba(235, 241, 255, 0.58);
  font-size: 12px;
}

.ledger-item.income em {
  color: #aaf0c1;
}

.ledger-item.expense em {
  color: #ffd2a6;
}

.ledger-item em {
  text-align: right;
}

.onboarding-dialog {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  pointer-events: none;
}

.onboarding-dialog::backdrop {
  background: transparent;
}

.onboarding-card {
  position: fixed;
  z-index: 10000;
  display: grid;
  width: min(380px, calc(100vw - 32px));
  gap: 12px;
  padding: 20px;
  border: 1px solid rgba(229, 201, 143, 0.45);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(20, 28, 42, 0.98), rgba(8, 12, 20, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.52), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  pointer-events: auto;
}

.onboarding-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 34px;
  min-height: 34px;
  border-color: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
}

.onboarding-arrow {
  display: none;
}

.onboarding-step-label {
  width: fit-content;
  padding: 4px 9px;
  border: 1px solid rgba(229, 201, 143, 0.36);
  border-radius: 999px;
  color: #e5c98f;
  font-size: 12px;
  font-weight: 800;
}

.onboarding-card h2 {
  margin: 0;
  padding-right: 38px;
  color: #ffffff;
  font-size: 20px;
}

.onboarding-card p {
  margin: 0;
  color: rgba(237, 242, 248, 0.82);
  font-size: 14px;
  line-height: 1.75;
}

.onboarding-never {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(237, 242, 248, 0.86);
  font-size: 13px;
}

.onboarding-never input {
  width: 16px;
  height: 16px;
}

.onboarding-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.onboarding-actions button {
  min-width: 86px;
}

.onboarding-target {
  position: relative;
  z-index: 9000;
  border-color: rgba(229, 201, 143, 0.92) !important;
  box-shadow: 0 0 0 4px rgba(229, 201, 143, 0.24), 0 0 28px rgba(229, 201, 143, 0.48) !important;
}

.onboarding-spotlight {
  position: fixed;
  z-index: 8999;
  border: 2px solid rgba(229, 201, 143, 0.95);
  border-radius: 10px;
  pointer-events: none;
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0.36),
    0 0 28px rgba(229, 201, 143, 0.56);
}

.onboarding-connector {
  position: fixed;
  z-index: 8998;
  height: 3px;
  border-radius: 999px;
  background: rgba(229, 201, 143, 0.92);
  pointer-events: none;
  transform-origin: 0 50%;
  filter: drop-shadow(0 0 8px rgba(229, 201, 143, 0.68));
}

.onboarding-connector::after {
  position: absolute;
  right: -1px;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid rgba(229, 201, 143, 0.92);
  content: "";
  transform: translateY(-50%);
}

.task-chapters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.task-chapters span {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.task-chapters .done {
  color: #aaf0c1;
}

.task-chapters .running {
  color: #c9dbff;
}

.task-chapters .failed {
  color: #ffb3b3;
}

.safety-note {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 216, 128, 0.24);
  border-radius: 8px;
  background: rgba(255, 216, 128, 0.08);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.7;
}

/* Theme contrast guardrails: keep text readable when users switch workspace backgrounds. */
.topbar h1,
.pane h2,
.result h2,
.graph-section h3,
.writer-directory h3,
.work-catalog h3,
.guide-row strong,
.character-card-head strong,
.task-card strong,
.version-item strong,
.redeem-guide h3,
.redeem-guide strong,
.redeem-panel label,
.profile-copy strong,
.wallet-card strong {
  color: var(--text);
}

.topbar p,
.small,
.meta,
.result p,
.guide-row span,
.redeem-guide p,
.redeem-guide li span,
.task-card span,
.task-card small,
.version-item span,
.ledger-columns h3,
.wallet-card span,
.profile-copy em {
  color: var(--muted);
}

body.theme-light .topbar h1,
body.theme-light .pane h2,
body.theme-light .result h2,
body.theme-light .graph-section h3,
body.theme-light .writer-directory h3,
body.theme-light .work-catalog h3,
body.theme-light .guide-row strong,
body.theme-light .character-card-head strong,
body.theme-light .task-card strong,
body.theme-light .version-item strong,
body.theme-light .redeem-guide h3,
body.theme-light .redeem-guide strong,
body.theme-light .redeem-panel label,
body[data-workspace-bg="moonlit"] .topbar h1,
body[data-workspace-bg="moonlit"] .pane h2,
body[data-workspace-bg="moonlit"] .result h2,
body[data-workspace-bg="moonlit"] .graph-section h3,
body[data-workspace-bg="moonlit"] .writer-directory h3,
body[data-workspace-bg="moonlit"] .work-catalog h3,
body[data-workspace-bg="moonlit"] .guide-row strong,
body[data-workspace-bg="moonlit"] .character-card-head strong,
body[data-workspace-bg="moonlit"] .task-card strong,
body[data-workspace-bg="moonlit"] .version-item strong,
body[data-workspace-bg="moonlit"] .redeem-guide h3,
body[data-workspace-bg="moonlit"] .redeem-guide strong,
body[data-workspace-bg="moonlit"] .redeem-panel label {
  color: #152033;
  text-shadow: none;
}

body.theme-light .topbar p,
body.theme-light .small,
body.theme-light .meta,
body.theme-light .result p,
body.theme-light .guide-row span,
body.theme-light .redeem-guide p,
body.theme-light .redeem-guide li span,
body.theme-light .task-card span,
body.theme-light .task-card small,
body.theme-light .version-item span,
body.theme-light .ledger-columns h3,
body.theme-light .wallet-card span,
body.theme-light .profile-copy em,
body[data-workspace-bg="moonlit"] .topbar p,
body[data-workspace-bg="moonlit"] .small,
body[data-workspace-bg="moonlit"] .meta,
body[data-workspace-bg="moonlit"] .result p,
body[data-workspace-bg="moonlit"] .guide-row span,
body[data-workspace-bg="moonlit"] .redeem-guide p,
body[data-workspace-bg="moonlit"] .redeem-guide li span,
body[data-workspace-bg="moonlit"] .task-card span,
body[data-workspace-bg="moonlit"] .task-card small,
body[data-workspace-bg="moonlit"] .version-item span,
body[data-workspace-bg="moonlit"] .ledger-columns h3,
body[data-workspace-bg="moonlit"] .wallet-card span,
body[data-workspace-bg="moonlit"] .profile-copy em {
  color: #5f6d7a;
}

body[data-workspace-bg="moonlit"] .side-nav button,
body.theme-light .side-nav button,
body[data-workspace-bg="moonlit"] .sidebar-footer button,
body.theme-light .sidebar-footer button {
  color: #152033;
}

body[data-workspace-bg="ink"] .topbar h1,
body[data-workspace-bg="ink"] .pane h2,
body[data-workspace-bg="ink"] .result h2,
body[data-workspace-bg="ink"] .graph-section h3,
body[data-workspace-bg="ink"] .writer-directory h3,
body[data-workspace-bg="ink"] .work-catalog h3,
body[data-workspace-bg="ink"] .guide-row strong,
body[data-workspace-bg="ink"] .redeem-guide h3,
body[data-workspace-bg="ink"] .redeem-guide strong,
body[data-workspace-bg="ink"] .redeem-panel label {
  color: #eef4ff;
}

@media (max-width: 720px) {
  .works-filter {
    grid-template-columns: 1fr;
  }

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

  .ledger-item {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  html,
  body {
    min-height: 100%;
    overflow: auto;
  }

  .app,
  .app-wide,
  .page-grid,
  .works-page,
  .creation-page {
    grid-template-columns: 1fr !important;
    height: auto;
    min-height: 100vh;
  }

  .workspace {
    position: sticky;
    top: 0;
    z-index: 50;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav,
  .sidebar-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-grid > .form,
  .works-list,
  .creation-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .output,
  .work-reader,
  .creation-chat,
  .result {
    min-height: min(520px, 62vh);
  }

  .result {
    padding: 20px 18px 42px;
  }
}

@media (max-width: 720px) {
  .topbar,
  .profile-entry,
  .side-nav,
  .sidebar-footer,
  .pane,
  .output,
  .works-head,
  .work-reader,
  .creation-sidebar,
  .creation-chat {
    padding-left: 14px;
    padding-right: 14px;
  }

  .side-nav,
  .sidebar-footer,
  .row.two,
  .row.three,
  .settings-grid,
  .writer-controls,
  .works-filter,
  .ledger-columns {
    grid-template-columns: 1fr !important;
  }

  .dialog-head,
  .meta,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Floating creation assistant */
.creation-float-head {
  display: none;
}

body.creation-floating-open .creation-page {
  display: contents !important;
}

body.creation-floating-open .creation-sidebar {
  display: none !important;
}

body.creation-floating-open .creation-chat {
  position: fixed !important;
  right: 26px;
  bottom: 92px;
  z-index: 8200;
  display: grid !important;
  width: min(460px, calc(100vw - 32px));
  height: min(680px, calc(100vh - 122px));
  min-height: 0 !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 0 !important;
  border: 1px solid rgba(229, 201, 143, 0.34);
  border-radius: 22px;
  background:
    radial-gradient(circle at 20% 0%, rgba(229, 201, 143, 0.10), transparent 34%),
    linear-gradient(180deg, rgba(18, 24, 36, 0.98), rgba(6, 10, 18, 0.98));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.58), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
}

body.creation-float-dragging {
  user-select: none;
}

body.creation-floating-open .creation-float-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(214, 228, 248, 0.12);
  background: rgba(12, 17, 27, 0.88);
  cursor: grab;
  touch-action: none;
}

body.creation-float-dragging .creation-float-head {
  cursor: grabbing;
}

body.creation-floating-open .creation-float-head > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

body.creation-floating-open .creation-float-head strong {
  color: #ffffff;
  font-size: 16px;
}

body.creation-floating-open .creation-float-head span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.creation-floating-open .creation-messages {
  padding: 16px;
}

body.creation-floating-open .creation-compose {
  padding: 14px 16px 16px;
}

body.creation-floating-open .creation-compose textarea {
  min-height: 92px;
}

body.creation-floating-open .creation-page.member-locked .creation-chat {
  border-color: rgba(229, 201, 143, 0.46);
}

body.creation-floating-open .creation-page.member-locked .creation-float-head::before {
  content: "🔒";
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border: 1px solid rgba(229, 201, 143, 0.5);
  border-radius: 999px;
  color: #e5c98f;
  font-size: 12px;
}

body.creation-floating-open .floating-creation-btn {
  border-color: rgba(255, 241, 189, 0.86);
  box-shadow: 0 0 0 4px rgba(229, 201, 143, 0.16), 0 16px 42px rgba(0, 0, 0, 0.42);
}

.memory-panel,
.rewrite-panel,
.advice-panel,
.writer-config-group {
  border-left-color: rgba(229, 201, 143, 0.72) !important;
}

/* Mobile web adaptation: only active on phone/narrow screens. */
@media (max-width: 760px) {
  html,
  body {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
  }

  body {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }

  .app,
  .app-wide {
    display: block;
    min-width: 0;
    min-height: 100vh;
    height: auto;
  }

  .workspace {
    position: relative;
    top: auto;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: auto;
    padding: 0 14px 20px;
    border-right: 0;
    border-bottom: 1px solid rgba(214, 228, 248, 0.12);
    background: rgba(8, 12, 20, 0.96);
    backdrop-filter: blur(16px);
  }

  .topbar {
    grid-column: 1 / -1;
    padding: 12px 0 2px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  #reloadConfig {
    width: 34px;
    height: 34px;
    min-height: 34px;
    flex-basis: 34px;
  }

  .profile-entry {
    position: relative;
    z-index: 3100;
    grid-template-columns: 38px minmax(0, 1fr);
    width: 100%;
    margin: 0;
    padding: 8px 10px;
  }

  .profile-avatar {
    width: 38px;
    height: 38px;
  }

  .profile-copy strong {
    font-size: 15px;
  }

  .profile-copy em {
    font-size: 12px;
  }

  .auth-panel {
    margin-top: 0;
    padding: 12px 14px;
  }

  .side-nav {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    z-index: 7000;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 6px;
    padding: 7px;
    border: 1px solid rgba(214, 228, 248, 0.16);
    border-radius: 18px;
    background: rgba(9, 13, 22, 0.94);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    backdrop-filter: blur(18px);
  }

  .side-nav button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    min-height: 50px;
    padding: 6px 4px;
    border-radius: 13px;
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
  }

  .side-nav button.active {
    box-shadow: inset 0 -3px 0 rgba(229, 201, 143, 0.88), 0 12px 26px rgba(0, 0, 0, 0.16);
  }

  .side-nav .nav-lock {
    right: 8px;
    top: 7px;
  }

  .side-nav button::before {
    display: block;
    width: 100%;
    margin: 0 auto 3px;
    font-size: 15px;
    text-align: center;
  }

  .side-nav button span {
    justify-content: center;
  }

  .sidebar-footer {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 6px 8px;
    margin: 8px 14px calc(18px + env(safe-area-inset-bottom));
    padding: 10px;
    border: 1px solid rgba(214, 228, 248, 0.14);
    border-radius: 16px;
    background: rgba(9, 13, 22, 0.92);
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.32), 0 0 0 1px rgba(255, 255, 255, 0.035) inset;
    backdrop-filter: blur(18px);
  }

  .sidebar-footer button {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    text-align: center;
    font-size: 13px;
  }

  .legal-links {
    order: 2;
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-content: center;
    gap: 4px;
    padding: 0;
    font-size: 10px;
    line-height: 1.35;
    text-align: center;
  }

  .legal-links a,
  .legal-links .link-button {
    display: block;
    min-height: auto;
    padding: 0;
    font-size: 10px;
    line-height: 1.35;
    text-align: center;
  }

  .sidebar-footer > #showTasks,
  .sidebar-footer > #settingsBtn {
    grid-row: 1;
  }

  .sidebar-footer > #showTasks {
    grid-column: 1;
  }

  .sidebar-footer > #settingsBtn {
    grid-column: 2;
    transform: none;
    width: 100%;
  }

  .sidebar-footer .icp-link {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: 0;
    font-size: 10px;
    line-height: 1.2;
    text-align: center;
  }

  .page-grid,
  .works-page,
  .creation-page {
    display: block;
    min-width: 0;
    min-height: auto;
    height: auto;
  }

  .workspace > * {
    flex: 0 0 auto;
  }

  .pane,
  .form,
  .output,
  .works-list,
  .work-reader,
  .creation-sidebar,
  .creation-chat {
    min-width: 0;
    padding: 18px 16px;
  }

  .page-grid > .form,
  .works-list,
  .creation-sidebar {
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .output,
  .work-reader {
    min-height: 72vh;
  }

  .row.two,
  .row.three,
  .settings-grid,
  .writer-controls,
  .works-filter,
  .ledger-columns,
  .profile-editor-head,
  .book-picker {
    grid-template-columns: 1fr !important;
  }

  .characters-head,
  .memory-head,
  .works-head,
  .main-head,
  .work-reader-head {
    align-items: stretch;
    flex-direction: column;
  }

  .character-tools,
  .worldbook-tools,
  .other-setting-tools,
  .actions,
  .meta,
  .creation-compose-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

  .characters-panel .character-tools button:first-child,
  .other-settings-panel .character-tools button:first-child,
  .worldbook-panel .character-tools button:first-child {
    grid-column: 1;
  }

  .characters-panel .character-tools .character-page-jump,
  .other-settings-panel .character-tools .character-page-jump,
  .worldbook-panel .character-tools .character-page-jump {
    grid-column: 2;
  }

  .characters-panel .character-tools button:nth-of-type(2),
  .other-settings-panel .character-tools button:nth-of-type(2),
  .worldbook-panel .character-tools button:nth-of-type(2) {
    grid-column: 3;
  }

  .characters-panel .character-tools button:last-child,
  .other-settings-panel .character-tools button:last-child,
  .worldbook-panel .character-tools button:last-child {
    grid-column: 1 / -1;
  }

  .characters-panel .character-page-jump,
  .other-settings-panel .character-page-jump,
  .worldbook-panel .character-page-jump {
    justify-content: center;
    min-width: 96px;
  }

  .characters-panel .character-page-jump input,
  .other-settings-panel .character-page-jump input,
  .worldbook-panel .character-page-jump input {
    width: 54px;
    min-width: 54px;
  }

  .outline-builder-panel .character-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

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

  .outline-builder-panel .compact-select,
  .outline-builder-panel .outline-ending-check {
    justify-content: center;
    width: 100%;
  }

  .outline-builder-panel .character-tools button {
    width: 100%;
  }

  .outline-overview-panel .character-page-jump {
    justify-content: center;
    min-width: 112px;
  }

  .outline-overview-panel .character-tools button {
    width: 100%;
  }

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

  button,
  .actions button,
  .auth-form button,
  .creation-compose-actions button {
    min-height: 44px;
  }

  textarea {
    min-height: 118px;
  }

  .character-card textarea,
  .result,
  .novel-reader,
  #writerResult,
  #workContent {
    max-width: 100%;
  }

  .result,
  .novel-reader {
    min-height: 62vh;
    padding: 22px 16px 44px;
  }

  .novel-reader h2,
  #workContent h2 {
    font-size: 22px;
    line-height: 1.55;
  }

  .novel-reader p,
  .novel-body {
    font-size: var(--reader-font-size);
    line-height: 2.05;
  }

  .writer-output > .actions {
    position: sticky;
    top: 74px;
    z-index: 1200;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid rgba(214, 228, 248, 0.12);
    border-radius: 12px;
    background: rgba(9, 13, 22, 0.92);
    backdrop-filter: blur(14px);
  }

  .writer-output > .actions .download-top-btn {
    grid-column: 1 / -1;
  }

  .writer-directory {
    min-height: 118px;
    max-height: 280px;
    overflow: auto;
  }

  .writer-directory.collapsed {
    min-height: auto;
  }

  .chapter-title-input,
  .chapter-body-editor {
    width: 100%;
  }

  .chapter-body-editor,
  #workContent .chapter-body-editor {
    min-height: 58vh;
  }

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

  .work-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
    overflow: visible;
    padding: 18px 10px 10px;
  }

  .work-card {
    min-height: 180px;
    padding: 12px 10px;
  }

  .work-card h3 {
    font-size: 14px;
  }

  .work-catalog {
    max-height: 340px;
  }

  .works-pager {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px 12px 16px;
  }

  .works-pager span {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    white-space: nowrap;
  }

  .works-pager button {
    min-height: 40px;
  }

  .work-reader,
  #workDetail {
    display: block;
    height: auto;
    min-height: 0;
  }

  .work-detail-top {
    grid-template-columns: 1fr !important;
    gap: 16px;
    padding: 18px 14px;
  }

  .cover-uploader {
    width: min(74vw, 260px);
    min-height: 340px;
    justify-self: center;
  }

  .cover-uploader img {
    height: 100%;
    min-height: 340px;
  }

  .work-editor {
    min-width: 0;
  }

  .work-editor button {
    width: 100%;
  }

  .planning-grid {
    grid-template-columns: 1fr !important;
  }

  .work-catalog {
    min-width: 0;
    max-height: none;
  }

  .chapter-list {
    max-height: 320px;
    overflow: auto;
  }

  .chapter-item {
    width: 100%;
    min-height: 42px;
    padding: 8px 12px;
    line-height: 1.45;
    white-space: normal;
  }

  #workContent {
    min-height: 60vh;
    padding: 20px 16px 48px;
  }

  .contact-bind-grid {
    grid-template-columns: 1fr;
  }

  .recharge-dialog,
  .profile-dialog,
  .settings-dialog,
  .compliance-dialog,
  .report-dialog,
  .download-dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 24px);
    padding: 18px 16px;
    border-radius: 16px;
  }

  .dialog-head {
    align-items: center;
    flex-direction: row;
  }

  .package-grid,
  .payment-providers {
    grid-template-columns: 1fr;
  }

  .floating-creation-btn {
    right: 18px;
    bottom: calc(92px + env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
  }
}

@media (max-width: 430px) {
  .side-nav {
    left: 8px;
    right: 8px;
    gap: 4px;
    padding: 6px;
  }

  .side-nav button {
    min-height: 48px;
    font-size: 11px;
  }

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

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

  .writer-output > .actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .work-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body.creation-floating-open .creation-chat {
    left: 10px !important;
    right: 10px !important;
    top: auto !important;
    bottom: calc(86px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    height: min(76vh, 680px) !important;
    border-radius: 20px 20px 18px 18px;
  }

  body.creation-floating-open .creation-float-head {
    cursor: default;
  }

  body.creation-floating-open .creation-messages {
    padding: 14px;
  }

  body.creation-floating-open .creation-message {
    max-width: 100%;
  }

  body.creation-floating-open .creation-message-head {
    align-items: flex-start;
    flex-direction: column;
  }

  body.creation-floating-open .creation-message-actions {
    width: 100%;
  }

  body.creation-floating-open .creation-message-actions button {
    flex: 1;
  }

  body.creation-floating-open .creation-compose {
    padding: 12px 14px 14px;
  }

  body.creation-floating-open .creation-compose textarea {
    min-height: 86px;
    max-height: 28vh;
  }
}
