/* === Novel Game (文游) Module — moku.chat warm earth-tone redesign === */
:root {
  --novel-primary: #8B7355;      /* brown/gold accent */
  --novel-accent: #A88B6D;       /* lighter brown */
  --novel-accent-2: #C9A97A;     /* soft gold */
  --novel-bg: #F5F0E8;           /* cream/beige background */
  --novel-surface: #FFFFFF;      /* white card surface */
  --novel-surface-2: #FAF6EF;    /* lighter cream surface */
  --novel-surface-3: #EFE7D8;    /* deeper cream */
  --novel-text: #5C4033;         /* brown text */
  --novel-text-2: #6F5346;       /* softer brown */
  --novel-muted: #8B7355;        /* brown muted */
  --novel-muted-2: #B09B82;      /* light brown muted */
  --novel-border: rgba(139, 115, 85, 0.16);
  --novel-border-strong: rgba(139, 115, 85, 0.30);
  --novel-danger: #c0392b;
  --novel-success: #6B8E5A;
  --novel-shadow: 0 2px 10px rgba(92, 64, 51, 0.06);
  --novel-shadow-lg: 0 8px 24px rgba(92, 64, 51, 0.10);
  --novel-radius: 12px;
  --novel-radius-lg: 16px;
  --novel-font: 'Noto Sans CJK SC', 'WenQuanYi Micro Hei', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* ===== Novel Game Page ===== */
#novelGamePage {
  padding: 0;
  overflow: hidden;
  display: none;
  flex-direction: column;
  height: calc(100vh - 73px);
  font-family: var(--novel-font);
  color: var(--novel-text);
  background: var(--novel-bg);
}

#novelGamePage.active {
  display: flex;
}

.novel-container {
  flex: 1;
  overflow-y: auto;
  padding: 0 14px 100px;
  background: var(--novel-bg);
}

/* ===== Top Header (main list view) ===== */
.novel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  background: rgba(245, 240, 232, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--novel-border);
}

.novel-header h2 {
  margin: 0;
  font-size: 20px;
  color: var(--novel-text);
}

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

/* ===== Buttons ===== */
.novel-btn {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--novel-primary);
  color: #FFF;
  font-weight: 600;
  border: 0;
  cursor: pointer;
  font-family: var(--novel-font);
  transition: transform 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
  box-shadow: 0 2px 6px rgba(139, 115, 85, 0.25);
}

.novel-btn:active {
  transform: scale(0.97);
}

.novel-btn.secondary {
  background: var(--novel-surface-2);
  color: var(--novel-text);
  border: 1px solid var(--novel-border);
  box-shadow: none;
}

.novel-btn.small {
  padding: 6px 12px;
  font-size: 13px;
}

.novel-btn.block {
  display: block;
  width: 100%;
  text-align: center;
}

/* ===== Main Tabs (剧本库 / 我的存档) ===== */
.novel-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 2px;
  background: var(--novel-bg);
  border-bottom: 1px solid var(--novel-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.novel-tabs button {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--novel-surface);
  color: var(--novel-muted);
  font-weight: 600;
  border: 1px solid var(--novel-border);
  cursor: pointer;
  font-family: var(--novel-font);
  transition: all 0.16s ease;
}

.novel-tabs button.active {
  background: var(--novel-primary);
  color: #FFF;
  border-color: var(--novel-primary);
}

/* ===== Script Cards ===== */
.novel-script-list {
  display: grid;
  gap: 14px;
  padding: 16px 0;
}

.novel-script-card {
  position: relative;
  border-radius: var(--novel-radius-lg);
  overflow: hidden;
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.novel-script-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--novel-shadow-lg);
}

.novel-script-cover {
  height: 132px;
  background-size: cover;
  background-position: center;
  position: relative;
}

.novel-script-cover-mask {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(60, 40, 25, 0.62) 0%, transparent 62%);
}

.novel-script-cover-text {
  position: absolute;
  bottom: 12px;
  left: 14px;
  right: 14px;
  color: #FFF;
  z-index: 1;
}

.novel-script-cover-text .novel-script-cat {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.22);
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 6px;
  backdrop-filter: blur(4px);
}

.novel-script-cover-text h3 {
  margin: 0;
  font-size: 18px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.novel-script-diff {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--novel-text);
  font-size: 11px;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.novel-script-diff.easy { color: #6B8E5A; }
.novel-script-diff.medium { color: #C9A97A; }
.novel-script-diff.hard { color: #c0392b; }

.novel-script-info {
  padding: 13px 14px 15px;
}

.novel-script-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.novel-tag {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--novel-surface-3);
  color: var(--novel-primary);
  font-size: 11px;
  font-weight: 600;
}

.novel-tag.difficulty-easy { background: rgba(107, 142, 90, 0.15); color: #6B8E5A; }
.novel-tag.difficulty-medium { background: rgba(201, 169, 122, 0.20); color: #A07B3C; }
.novel-tag.difficulty-hard { background: rgba(192, 57, 43, 0.13); color: #c0392b; }

.novel-script-desc {
  color: var(--novel-muted);
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 10px;
}

.novel-script-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--novel-primary);
}

/* ===== Save Slots ===== */
.novel-save-list {
  display: grid;
  gap: 12px;
  padding: 16px 0;
}

.novel-save-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
  cursor: pointer;
  transition: transform 0.16s ease;
}

.novel-save-card:active {
  transform: scale(0.99);
}

.novel-save-thumb {
  width: 42px;
  height: 42px;
  border-radius: var(--novel-radius);
  background: linear-gradient(135deg, var(--novel-accent-2), var(--novel-primary));
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.novel-save-info {
  min-width: 0;
}

.novel-save-info h4 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--novel-text);
}

.novel-save-meta {
  color: var(--novel-muted-2);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.novel-save-meta .dot {
  opacity: 0.6;
}

.novel-save-del {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--novel-surface-2);
  border: 1px solid var(--novel-border);
  color: var(--novel-muted);
  font-size: 14px;
  cursor: pointer;
}

.novel-save-actions {
  display: flex;
  gap: 6px;
}

/* ===== Create Character Form ===== */
.novel-form {
  display: grid;
  gap: 12px;
  padding: 14px 0;
}

.novel-form label {
  display: grid;
  gap: 6px;
  color: var(--novel-muted);
  font-size: 13px;
  font-weight: 600;
}

.novel-form input,
.novel-form textarea,
.novel-form select {
  width: 100%;
  border: 1px solid var(--novel-border);
  border-radius: var(--novel-radius);
  padding: 11px 12px;
  outline: none;
  background: var(--novel-surface);
  color: var(--novel-text);
  font: inherit;
}

.novel-form textarea {
  resize: vertical;
  min-height: 80px;
}

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

.novel-stat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
}

.novel-stat-input span {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--novel-text);
}

.novel-stat-input input {
  width: 70px;
  text-align: center;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--novel-border);
}

/* ===== Create Character Section ===== */
.novel-create-section {
  margin-bottom: 16px;
}

.novel-create-section h4 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--novel-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.novel-create-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--novel-muted-2);
}

.novel-fields {
  display: grid;
  gap: 12px;
}

.novel-field {
  display: grid;
  gap: 6px;
}

.novel-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--novel-muted);
}

.novel-field input,
.novel-field textarea {
  width: 100%;
  border: 1px solid var(--novel-border);
  border-radius: var(--novel-radius);
  padding: 10px 12px;
  outline: none;
  background: var(--novel-surface);
  color: var(--novel-text);
  font: inherit;
  font-size: 14px;
}

.novel-field textarea {
  resize: vertical;
  min-height: 60px;
}

.novel-field input:focus,
.novel-field textarea:focus {
  border-color: var(--novel-primary);
  box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.12);
}

.novel-items-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.novel-item-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--novel-surface-3);
  border: 1px solid var(--novel-border);
  color: var(--novel-primary);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.novel-currency {
  margin-top: 8px;
  font-size: 13px;
  color: var(--novel-muted);
}

/* ===== Story Screen Shell ===== */
.novel-story {
  display: none;
  flex-direction: column;
  height: 100%;
  background: var(--novel-bg);
  position: relative;
  font-family: var(--novel-font);
}

.novel-story.active {
  display: flex;
}

/* slim top toolbar */
.novel-story-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(245, 240, 232, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--novel-border);
  flex-shrink: 0;
}

.novel-story-header .novel-story-time,
.novel-story-header .round-badge {
  display: none; /* moved into the character status card */
}

/* ===== Character Status Header Card ===== */
.novel-status-bar {
  display: block !important;
  flex-direction: column !important;
  gap: 0;
  padding: 12px 14px 8px;
  background: var(--novel-bg);
  border-bottom: 1px solid var(--novel-border);
  overflow: visible;
  flex-shrink: 0;
}

.novel-status-bar::-webkit-scrollbar {
  display: none;
}

.novel-status-empty {
  color: var(--novel-muted-2);
  font-size: 13px;
  padding: 8px 0;
}

.novel-status-card {
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  border-radius: var(--novel-radius-lg);
  box-shadow: var(--novel-shadow);
  padding: 14px;
}

.novel-status-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.novel-status-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--novel-accent-2), var(--novel-primary));
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(139, 115, 85, 0.25);
}

.novel-status-id {
  flex: 1;
  min-width: 0;
}

.novel-status-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--novel-text);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.novel-status-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.novel-tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--novel-surface-3);
  color: var(--novel-primary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.novel-tag-pill.ghost {
  background: transparent;
  border: 1px solid var(--novel-border-strong);
  color: var(--novel-muted);
}

.novel-status-date {
  text-align: right;
  flex-shrink: 0;
}

.novel-status-date-main {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--novel-text);
}

.novel-status-date-sub {
  display: block;
  font-size: 11px;
  color: var(--novel-muted-2);
  margin-top: 2px;
}

.novel-status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--novel-border);
}

.novel-stat-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 10px;
  background: var(--novel-surface-2);
}

.novel-stat-cell-icon {
  font-size: 16px;
  line-height: 1;
}

.novel-stat-cell-label {
  font-size: 10px;
  color: var(--novel-muted);
  font-weight: 600;
}

.novel-stat-cell-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--novel-text);
}

/* ===== Story Scroll ===== */
.novel-story-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 120px;
  -webkit-overflow-scrolling: touch;
}

.novel-story-content {
  line-height: 1.8;
  font-size: 15px;
  color: var(--novel-text);
  word-break: break-word;
}

/* ===== Narrative Cards ===== */
.novel-card {
  margin-bottom: 12px;
  border-radius: var(--novel-radius-lg);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
  overflow: hidden;
}

.novel-card-header {
  padding: 10px 14px 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--novel-primary);
  background: var(--novel-surface-2);
  border-bottom: 1px solid var(--novel-border);
}

.novel-card-body {
  padding: 12px 14px 14px;
}

.novel-card-narrative {
  background: var(--novel-surface-2);
  border-color: var(--novel-border);
  box-shadow: none;
}

.novel-card-hint {
  background: var(--novel-surface-2);
  border: 1px dashed var(--novel-border-strong);
  box-shadow: none;
}

.novel-card-recap {
  background: var(--novel-surface);
  border-color: var(--novel-border);
}

.novel-card-recap .novel-card-header {
  background: var(--novel-surface-2);
  color: var(--novel-accent);
}

/* ===== Narrative Paragraphs ===== */
.novel-para {
  margin: 0 0 8px;
  line-height: 1.85;
  font-size: 15px;
  color: var(--novel-text);
}

.novel-para:last-child {
  margin-bottom: 0;
}

.novel-para-muted {
  color: var(--novel-muted-2);
  font-style: italic;
  font-size: 13px;
}

.novel-recap-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--novel-accent);
  margin-bottom: 8px;
  padding-left: 2px;
}

.novel-sub-h {
  margin: 10px 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--novel-text);
}

.novel-list {
  margin: 6px 0;
  padding-left: 20px;
  color: var(--novel-text-2);
}

.novel-list li {
  margin-bottom: 4px;
  line-height: 1.7;
}

.novel-dialogue {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 8px 0;
  padding: 8px 12px;
  border-left: 3px solid var(--novel-accent);
  background: var(--novel-surface-2);
  border-radius: 0 10px 10px 0;
}

.novel-dialogue-anon {
  border-left-color: var(--novel-muted-2);
}

.novel-speaker {
  font-size: 13px;
  font-weight: 700;
  color: var(--novel-primary);
}

.novel-quote {
  font-size: 14px;
  color: var(--novel-text);
}

/* ===== Stat Change Badges ===== */
.novel-card-stat-changes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--novel-border);
}

.novel-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.novel-stat-badge.positive {
  background: rgba(107, 142, 90, 0.16);
  color: #5A7A4A;
}

.novel-stat-badge.negative {
  background: rgba(192, 57, 43, 0.14);
  color: #c0392b;
}

/* ===== Story Tab Content ===== */
.novel-story-tab {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.novel-narrative {
  background: var(--novel-surface-2);
  border: 1px solid var(--novel-border);
  border-radius: var(--novel-radius-lg);
  padding: 4px;
}

.novel-narrative .novel-card {
  margin-bottom: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.novel-narrative .novel-card-header {
  background: transparent;
  border-bottom: 1px solid var(--novel-border);
}

.novel-choices {
  display: grid;
  gap: 10px;
}

.novel-choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--novel-radius-lg);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
  color: var(--novel-text);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  font-family: var(--novel-font);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.novel-choice-btn:active {
  transform: scale(0.99);
  border-color: var(--novel-primary);
}

.novel-choice-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--novel-surface-3);
  color: var(--novel-primary);
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.novel-choice-text {
  flex: 1;
  line-height: 1.4;
}

.novel-choice-edit {
  color: var(--novel-muted-2);
  font-size: 16px;
  flex-shrink: 0;
}

.novel-custom-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--novel-radius-lg);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
}

.novel-custom-input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--novel-text);
  padding: 4px 0;
}

.novel-custom-input::placeholder {
  color: var(--novel-muted-2);
}

.novel-custom-send {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--novel-primary);
  color: #FFF;
  border: 0;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== Action Panel → 7-tab bottom nav ===== */
.novel-action-panel {
  position: fixed;
  right: calc((100vw - min(100vw, 430px)) / 2);
  bottom: calc(58px + var(--safe-bottom));
  left: calc((100vw - min(100vw, 430px)) / 2);
  width: min(100vw, 430px);
  padding: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--novel-border);
  backdrop-filter: blur(18px);
  box-shadow: 0 -4px 16px rgba(92, 64, 51, 0.06);
  z-index: 25;
}

/* legacy action controls (choices now live in the story content) */
.novel-action-panel .novel-actions,
.novel-action-panel .novel-custom-action {
  display: none !important;
}

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

.novel-action-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  color: var(--novel-text);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.novel-action-idx {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--novel-surface-3);
  color: var(--novel-primary);
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.novel-action-label {
  flex: 1;
}

/* ===== 7-Tab Bottom Navigation ===== */
.novel-tabbar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 6px 4px calc(6px + var(--safe-bottom, 0px));
  background: transparent;
}

.novel-tabbar-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--novel-font);
  border-radius: 10px;
  transition: background 0.16s ease;
}

.novel-tabbar-icon {
  font-size: 19px;
  line-height: 1;
  filter: grayscale(0.35);
  opacity: 0.7;
  transition: filter 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.novel-tabbar-label {
  font-size: 10px;
  color: var(--novel-muted);
  font-weight: 600;
}

.novel-tabbar-btn.active {
  background: var(--novel-surface-3);
}

.novel-tabbar-btn.active .novel-tabbar-icon {
  filter: none;
  opacity: 1;
  transform: translateY(-1px);
}

.novel-tabbar-btn.active .novel-tabbar-label {
  color: var(--novel-primary);
  font-weight: 700;
}

.novel-tabbar-badge {
  position: absolute;
  top: 2px;
  right: 50%;
  transform: translateX(14px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e95656;
  color: #FFF;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--novel-surface);
}

/* ===== Tab Section (shared) ===== */
.novel-tab-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.novel-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 2px;
  font-size: 15px;
  font-weight: 700;
  color: var(--novel-text);
}

.novel-section-icon {
  font-size: 16px;
}

/* ===== Connections Tab ===== */
.novel-npc-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--novel-radius-lg);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
}

.novel-npc-avatar {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  border: 2px dashed var(--novel-border-strong);
  background: var(--novel-surface-2);
  flex-shrink: 0;
}

.novel-npc-main {
  flex: 1;
  min-width: 0;
}

.novel-npc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.novel-npc-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--novel-text);
}

.novel-npc-aff {
  font-size: 13px;
  color: var(--novel-accent-2);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.novel-npc-desc {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--novel-text-2);
  line-height: 1.55;
}

.novel-npc-quote {
  margin: 0;
  font-size: 12px;
  color: var(--novel-muted);
  font-style: italic;
  line-height: 1.5;
}

/* ===== Phone Tab (simulated home screen) ===== */
.novel-phone-home {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.novel-phone-clock {
  text-align: center;
  padding: 20px 0 8px;
}

.novel-phone-clock-time {
  font-size: 54px;
  font-weight: 200;
  color: var(--novel-text);
  line-height: 1;
  letter-spacing: 2px;
}

.novel-phone-clock-date {
  margin-top: 8px;
  font-size: 13px;
  color: var(--novel-muted);
}

.novel-phone-widgets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.novel-phone-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
}

.novel-phone-widget-icon {
  font-size: 22px;
}

.novel-phone-widget div {
  display: flex;
  flex-direction: column;
}

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

.novel-phone-widget span {
  font-size: 11px;
  color: var(--novel-muted-2);
}

.novel-phone-appgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 8px;
  padding: 8px 4px 4px;
}

.novel-phone-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--novel-font);
}

.novel-phone-icon-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--novel-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--novel-shadow);
}

.novel-phone-icon-name {
  font-size: 11px;
  color: var(--novel-muted);
}

/* ===== Attributes Tab ===== */
.novel-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 14px;
  border-radius: var(--novel-radius-lg);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
}

.novel-profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--novel-accent-2), var(--novel-primary));
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(139, 115, 85, 0.3);
}

.novel-profile-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--novel-text);
}

.novel-attr-group {
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  border-radius: var(--novel-radius-lg);
  box-shadow: var(--novel-shadow);
  padding: 12px 14px;
}

.novel-attr-group-title {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--novel-primary);
}

.novel-attr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--novel-border);
  cursor: pointer;
}

.novel-attr-row:last-child {
  border-bottom: 0;
}

.novel-attr-label {
  font-size: 14px;
  color: var(--novel-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.novel-attr-value {
  font-size: 14px;
  color: var(--novel-text);
  text-align: right;
  flex: 1;
  min-width: 0;
}

.novel-attr-placeholder {
  color: var(--novel-muted-2);
  font-size: 13px;
}

.novel-attr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.novel-attr-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface-2);
  cursor: pointer;
}

.novel-attr-cell-icon {
  font-size: 18px;
}

.novel-attr-cell-label {
  font-size: 11px;
  color: var(--novel-muted);
  font-weight: 600;
}

.novel-attr-cell-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--novel-text);
}

/* ===== Events Tab ===== */
.novel-event-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: var(--novel-radius-lg);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
}

.novel-event-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--novel-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.novel-event-body {
  flex: 1;
  min-width: 0;
}

.novel-event-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.novel-event-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--novel-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.novel-event-round {
  font-size: 11px;
  color: var(--novel-primary);
  background: var(--novel-surface-3);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  flex-shrink: 0;
}

.novel-event-preview {
  margin: 0;
  font-size: 13px;
  color: var(--novel-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== Assets Tab ===== */
.novel-goals {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.novel-goal {
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  border-radius: var(--novel-radius);
  box-shadow: var(--novel-shadow);
  padding: 12px 14px;
}

.novel-goal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--novel-text);
}

.novel-goal-head span:last-child {
  color: var(--novel-primary);
  font-weight: 800;
}

.novel-goal-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--novel-surface-3);
  overflow: hidden;
}

.novel-goal-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--novel-accent-2), var(--novel-primary));
  transition: width 0.4s ease;
}

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

.novel-asset-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  box-shadow: var(--novel-shadow);
}

.novel-asset-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--novel-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.novel-asset-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.novel-asset-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--novel-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.novel-asset-source {
  font-size: 11px;
  color: var(--novel-muted-2);
}

/* ===== Settings Tab ===== */
.novel-settings-actions {
  display: flex;
  gap: 10px;
}

.novel-settings-actions .novel-btn {
  flex: 1;
  text-align: center;
}

.novel-save-block {
  background: var(--novel-surface);
  border: 1px solid var(--novel-border);
  border-radius: var(--novel-radius-lg);
  box-shadow: var(--novel-shadow);
  padding: 14px;
}

.novel-save-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--novel-text);
}

.novel-save-block-time {
  font-size: 12px;
  font-weight: 400;
  color: var(--novel-muted-2);
}

.novel-save-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--novel-border);
  cursor: pointer;
}

.novel-save-slot:last-child {
  border-bottom: 0;
}

.novel-save-slot-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.novel-save-slot-info strong {
  font-size: 14px;
  color: var(--novel-text);
}

.novel-save-slot-info span {
  font-size: 12px;
  color: var(--novel-muted-2);
}

.novel-save-slot-go {
  font-size: 12px;
  font-weight: 600;
  color: var(--novel-primary);
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--novel-surface-3);
  flex-shrink: 0;
}

/* ===== Form Extras ===== */
.novel-form-desc {
  padding: 10px 14px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface-2);
  border: 1px solid var(--novel-border);
  font-size: 13px;
  line-height: 1.6;
  color: var(--novel-muted);
  margin-bottom: 4px;
}

.novel-form-items {
  padding: 10px 14px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface-2);
  border: 1px solid var(--novel-border);
  font-size: 13px;
  color: var(--novel-muted);
}

.novel-form-items strong {
  color: var(--novel-text);
}

/* ===== Loading ===== */
.novel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--novel-muted);
  gap: 12px;
}

.novel-loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--novel-surface-3);
  border-top-color: var(--novel-primary);
  border-radius: 50%;
  animation: novel-spin 0.8s linear infinite;
}

.novel-modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px;
  color: var(--novel-muted);
}

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

/* ===== Empty State ===== */
.novel-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--novel-muted);
}

.novel-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.7;
}

.novel-empty-text {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--novel-text);
}

.novel-empty-sub {
  margin: 0;
  font-size: 13px;
  color: var(--novel-muted-2);
}

/* ===== Modal ===== */
.novel-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(60, 40, 25, 0.45);
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.novel-modal-overlay.active {
  display: flex;
}

.novel-modal {
  width: min(92vw, 390px);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--novel-surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--novel-shadow-lg);
  font-family: var(--novel-font);
}

.novel-modal h3 {
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--novel-text);
}

.novel-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.novel-modal-error {
  text-align: center;
  padding: 20px;
  color: var(--novel-muted);
}

/* ===== Create Character Hero ===== */
.novel-create {
  font-family: var(--novel-font);
}

.novel-create-hero {
  position: relative;
  border-radius: var(--novel-radius-lg);
  padding: 18px 16px;
  color: #FFF;
  margin-bottom: 14px;
  background: linear-gradient(135deg, var(--novel-accent-2), var(--novel-primary));
  overflow: hidden;
}

.novel-create-cat {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.22);
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.novel-create-hero h3 {
  margin: 0;
  font-size: 20px;
}

.novel-create-diff {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--novel-text);
  font-size: 11px;
  font-weight: 700;
}

.novel-create-world {
  padding: 12px 14px;
  border-radius: var(--novel-radius);
  background: var(--novel-surface-2);
  border: 1px solid var(--novel-border);
  margin-bottom: 14px;
}

.novel-world-era {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
}

.novel-world-era-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--novel-primary);
  background: var(--novel-surface-3);
  padding: 2px 8px;
  border-radius: 999px;
}

.novel-world-setting {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--novel-text-2);
  line-height: 1.6;
}

.novel-world-rules {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--novel-muted);
  line-height: 1.7;
}

/* ===== Responsive ===== */
@media (max-width: 380px) {
  .novel-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .novel-status-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .novel-attr-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .novel-assets {
    grid-template-columns: 1fr;
  }
  .novel-tabbar-label {
    font-size: 9px;
  }
}

/* === 游戏内手机面板 (legacy overlay, recolored) === */
.novel-phone-panel {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: linear-gradient(180deg, #EFE3D0 0%, #F5F0E8 50%, #FFFFFF 100%);
  flex-direction: column;
  overflow-y: auto;
  animation: novelPhoneSlideIn 0.3s ease;
}
.novel-phone-panel.active {
  display: flex;
}
@keyframes novelPhoneSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.novel-phone-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}
.novel-phone-back {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--novel-surface-3);
  border: none;
  font-size: 18px;
  color: var(--novel-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.novel-phone-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--novel-text);
}
.novel-phone-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--novel-muted);
  background: var(--novel-surface-2);
  padding: 4px 10px;
  border-radius: 12px;
}

.novel-phone-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  margin: 0 16px;
  background: rgba(255,255,255,0.85);
  border-radius: var(--novel-radius-lg);
  box-shadow: var(--novel-shadow);
}
.novel-phone-status-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--novel-accent-2), var(--novel-primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  font-weight: 600;
}
.novel-phone-status-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.novel-phone-status-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--novel-text);
}
.novel-phone-status-realm {
  font-size: 12px;
  color: var(--novel-primary);
  background: var(--novel-surface-3);
  padding: 1px 8px;
  border-radius: 8px;
}
.novel-phone-status-bars {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.novel-phone-status-bar {
  font-size: 12px;
  color: var(--novel-muted);
}

.novel-phone-apps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 20px 16px;
}
.novel-phone-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: var(--novel-radius);
  background: rgba(255,255,255,0.6);
  border: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
}
.novel-phone-app:active {
  transform: scale(0.95);
}
.novel-phone-app.active {
  background: var(--novel-surface-3);
}
.novel-phone-app-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.novel-phone-app-name {
  font-size: 11px;
  color: var(--novel-muted);
  font-weight: 500;
}
.novel-phone-app-notification {
  position: absolute;
  top: 4px; right: 12px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #e95656;
  color: white;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

/* 分类筛选和搜索 */
.novel-cat-bar { display:flex; gap:8px; padding:8px 12px; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.novel-cat-bar::-webkit-scrollbar { display:none; }
.novel-cat-chip { flex-shrink:0; padding:4px 12px; border-radius:999px; font-size:13px; border:1px solid var(--novel-border); background:var(--novel-surface); color:var(--novel-muted); cursor:pointer; transition:all .2s; }
.novel-cat-chip.active { background:var(--novel-primary); color:#fff; border-color:var(--novel-primary); }
.novel-search-wrap { padding:0 12px 8px; }
.novel-search-input { width:100%; padding:8px 12px; border-radius:8px; border:1px solid var(--novel-border); background:var(--novel-surface); color:var(--novel-text); font-size:14px; outline:none; box-sizing:border-box; }
.novel-search-input:focus { border-color:var(--novel-primary); }

/* 重新生成按钮 */
/* === 规格书新增：属性检定面板 === */
.novel-attribute-check {
  margin: var(--novel-gap) 0;
  border-radius: var(--novel-radius);
  overflow: hidden;
  border: 1.5px solid;
}
.novel-attribute-check.novel-check-success {
  border-color: #4caf50;
  background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
}
.novel-attribute-check.novel-check-fail {
  border-color: #f44336;
  background: linear-gradient(135deg, #ffebee 0%, #fce4ec 100%);
}
.novel-check-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.95rem;
}
.novel-check-success .novel-check-header { background: rgba(76,175,80,0.12); color: #2e7d32; }
.novel-check-fail .novel-check-header { background: rgba(244,67,54,0.12); color: #c62828; }
.novel-check-icon { font-size: 1.2rem; }
.novel-check-body { padding: 10px 14px; }
.novel-check-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.88rem;
  color: var(--novel-text);
}
.novel-check-row span:first-child { color: var(--novel-text-secondary, #8d6e63); }
.novel-check-threshold { font-weight: 600; color: #e65100; }
.novel-check-value { font-weight: 600; }
.novel-check-result {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.novel-check-success .novel-check-result { background: rgba(76,175,80,0.08); }
.novel-check-fail .novel-check-result { background: rgba(244,67,54,0.08); }

/* === 规格书新增：结局横幅 === */
.novel-ending-banner {
  margin: var(--novel-gap) 0;
  padding: 24px 16px;
  text-align: center;
  border-radius: var(--novel-radius-lg);
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #e8d5b7;
}
.novel-ending-stars {
  font-size: 1.2rem;
  letter-spacing: 8px;
  color: #ffd700;
  margin: 8px 0;
}
.novel-ending-title {
  font-size: 0.85rem;
  letter-spacing: 4px;
  color: #b8a88a;
  margin: 4px 0;
}
.novel-ending-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffd700;
  margin: 12px 0;
  text-shadow: 0 0 12px rgba(255,215,0,0.3);
}
.novel-ending-narrative {
  font-size: 0.88rem;
  line-height: 1.7;
  color: #c8b89a;
  margin-top: 12px;
  text-align: left;
  padding: 0 8px;
}

/* === 规格书新增：状态变化摘要 === */
.novel-changes-summary {
  margin: var(--novel-gap) 0;
  padding: 10px 14px;
  border-radius: var(--novel-radius);
  background: rgba(139,115,85,0.06);
  border: 1px dashed rgba(139,115,85,0.2);
}
.novel-changes-label {
  font-size: 0.78rem;
  color: var(--novel-text-secondary, #8d6e63);
  display: block;
  margin-bottom: 6px;
}
.novel-changes-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.novel-regen-btn { display:inline-block; padding:6px 16px; border:1px dashed var(--novel-muted-2); border-radius:8px; background:transparent; color:var(--novel-muted); font-size:13px; cursor:pointer; opacity:.7; transition:all .2s; margin-top:8px; }
.novel-regen-btn:hover { opacity:1; border-color:var(--novel-primary); color:var(--novel-primary); }
.novel-regen-btn:disabled { opacity:.3; cursor:not-allowed; }
