:root {
  --page-bg: var(--bg-body, #f6f7fc);
  --page-card: var(--bg-card, #fff);
  --page-text: var(--text-main, #202235);
  --page-muted: var(--text-sub, #74798c);
  --page-line: var(--border-light, #e7e9f3);
  --page-accent: var(--primary, #7470da);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--page-bg);
  color: var(--page-text);
  font:
    15px/1.7 system-ui,
    "Microsoft YaHei",
    sans-serif;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: 0.6;
}
a {
  color: inherit;
  text-decoration: none;
}
.work-page {
  width: min(100%, 1250px);
  margin: auto;
  padding: 24px 22px 100px;
}
.work-header {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  margin-bottom: 20px;
}
.work-header h1 {
  font-size: 21px;
  margin: 0;
  flex: 1;
}
.work-header button,
.work-header a {
  border: 0;
  background: var(--page-card);
  border-radius: 14px;
  padding: 8px 12px;
}
.work-hero {
  border-radius: 24px;
  background: linear-gradient(115deg, #655fce, #a3a7e5);
  padding: 30px;
  color: #fff;
  margin-bottom: 24px;
}
.work-hero h2 {
  margin: 0 0 6px;
  font-size: 30px;
}
.work-hero p {
  margin: 0;
  opacity: 0.9;
}
.work-card {
  background: var(--page-card);
  border: 1px solid var(--page-line);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 20px;
}
.work-note {
  font-size: 13px;
  color: var(--page-muted);
  white-space: pre-wrap;
}
.work-error {
  background: #ed65751a;
  color: #b93853;
  padding: 14px;
  border-radius: 12px;
  white-space: pre-wrap;
}
.work-primary {
  background: var(--page-accent);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 10px 18px;
}
.work-secondary {
  background: var(--page-card);
  border: 1px solid var(--page-line);
  border-radius: 12px;
  padding: 9px 16px;
}
.work-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 20px 0;
}
.work-tabs button {
  flex: 1;
  white-space: nowrap;
  border: 1px solid var(--page-line);
  background: var(--page-card);
  padding: 10px 14px;
  border-radius: 12px;
}
.work-tabs button[aria-selected="true"] {
  color: #fff;
  background: var(--page-accent);
  border-color: transparent;
}
.work-field {
  display: grid;
  gap: 6px;
  margin: 16px 0;
}
.work-field input,
.work-field textarea,
.work-field select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--page-line);
  background: var(--page-bg);
  border-radius: 12px;
  padding: 12px;
  outline-color: var(--page-accent);
}
.work-field textarea {
  min-height: 150px;
  resize: vertical;
}
.work-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}
.work-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.novel-tile {
  min-width: 0;
  background: var(--page-card);
  border: 1px solid var(--page-line);
  border-radius: 18px;
  overflow: hidden;
  position: relative;
}
.novel-open {
  display: block;
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  padding: 14px;
  cursor: pointer;
}
.novel-cover {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 10px;
  background: linear-gradient(135deg, #c8c6ee, #e9e9f5);
  display: grid;
  place-items: center;
  color: #716dba;
  font:
    64px Georgia,
    serif;
}
.novel-tile h3 {
  margin: 12px 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.novel-tile p {
  font-size: 12px;
  color: var(--page-muted);
  margin: 0;
}
.novel-tile .novel-options {
  position: absolute;
  right: 18px;
  top: 18px;
  border: 0;
  border-radius: 12px;
  background: #ffffffdf;
  color: #333;
  padding: 4px 12px;
}
.work-dialog {
  position: fixed;
  inset: 0;
  background: #11152c73;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 16px;
}
.work-dialog[hidden],
[hidden] {
  display: none !important;
}
.work-dialog > section {
  width: min(100%, 600px);
  max-height: 90dvh;
  overflow: auto;
  background: var(--page-card);
  border-radius: 22px;
  padding: 24px;
}
.work-dialog h2 {
  margin: 0 0 12px;
}
.work-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4000;
  max-width: 90%;
  padding: 10px 18px;
  border-radius: 14px;
  color: #fff;
  background: #29283ee8;
  pointer-events: none;
  white-space: pre-wrap;
}
.rank-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 8px;
  border-bottom: 1px solid var(--page-line);
  min-width: 0;
}
.rank-place {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  text-align: center;
  border-radius: 12px;
  background: #8b7ce71a;
  color: var(--page-accent);
  font-weight: 800;
  line-height: 36px;
}
.rank-copy {
  min-width: 0;
  flex: 1;
}
.rank-copy strong {
  display: block;
  word-break: break-word;
}
.rank-value {
  text-align: right;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}
.rank-value small {
  display: block;
  font-size: 11px;
  color: var(--page-muted);
  font-weight: 400;
}
.rank-bars {
  height: 5px;
  background: #8e93af1c;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 10px;
}
.rank-bars i {
  height: 100%;
  display: block;
  background: #9385d5;
  border-radius: 8px;
}
.novel-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--page-card);
  border-top: 1px solid var(--page-line);
  display: flex;
  justify-content: space-around;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
}
.novel-nav button {
  border: 0;
  background: transparent;
  color: var(--page-muted);
  padding: 8px 16px;
}
.novel-nav button.active {
  color: var(--page-accent);
  font-weight: 700;
}
.novel-editor {
  width: min(100%, 1040px);
  margin: auto;
  padding: 14px 22px 40px;
}
.novel-paper {
  display: block;
  width: 100%;
  min-height: 65dvh;
  border: 0;
  resize: vertical;
  outline: none;
  background: var(--page-card);
  padding: 26px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 2;
  font-family: Georgia, "Songti SC", "SimSun", serif;
  font-size: 18px;
}
.novel-sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: min(86vw, 340px);
  background: var(--page-card);
  padding: 24px;
  z-index: 3100;
  overflow: auto;
  box-shadow: -8px 0 40px #2222;
}
.novel-sidebar button {
  display: block;
  width: 100%;
  border: 0;
  padding: 12px;
  background: transparent;
  text-align: left;
  border-radius: 10px;
}
.novel-sidebar button.active {
  background: #8d7adb1a;
  color: var(--page-accent);
}
.novel-backdrop {
  position: fixed;
  inset: 0;
  background: #1116;
  z-index: 3050;
}
.character-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 12px;
}
.character-row input,
.character-row textarea {
  grid-column: 1;
}
.character-row button {
  grid-column: 2;
  grid-row: 1/3;
  align-self: center;
  border: 0;
  background: none;
  color: #c45c73;
}
.novel-live {
  white-space: pre-wrap;
  line-height: 2;
  overflow-wrap: anywhere;
}
.work-empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--page-muted);
}
@media (min-width: 800px) {
  .work-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .novel-world {
    padding-left: 150px;
  }
  .novel-nav {
    right: auto;
    top: 0;
    bottom: 0;
    width: 145px;
    flex-direction: column;
    justify-content: center;
    border-top: 0;
    border-right: 1px solid var(--page-line);
    gap: 14px;
  }
  .novel-nav button {
    padding: 18px 10px;
  }
  .work-dialog > section {
    padding: 30px;
  }
  .novel-editor {
    padding-top: 25px;
  }
}
@media (min-width: 1200px) {
  .work-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
@media (max-width: 400px) {
  .work-page,
  .novel-editor {
    padding-left: 14px;
    padding-right: 14px;
  }
  .work-header {
    gap: 6px;
  }
  .work-header h1 {
    font-size: 17px;
  }
  .work-header button,
  .work-header a {
    font-size: 12px;
    padding: 8px;
  }
  .novel-paper {
    padding: 16px;
  }
  .work-grid {
    gap: 12px;
  }
  .work-hero {
    padding: 22px;
  }
  .rank-value {
    font-size: 16px;
  }
}
