/* ==========================================================================
   墨匣 · Inkcase
   写作系统自定义样式（配合本地 Tailwind 工具类使用）
   ========================================================================== */

:root {
  --paper: #f6f3ec;
  --surface: #fffdf8;
  --ink: #23282a;
  --ink-soft: #565f60;
  --muted: #8a9192;
  --line: #e4dfd3;
  --accent: #2f5d50;
  --accent-soft: #e6efe9;
  --danger: #b4453a;
  --nav-bg: rgba(250, 248, 242, 0.86);
  --scroll-thumb: #d8d2c6;
  --nav-h: 56px;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --editor-size: 18px;
  --editor-line: 1.9;
  --editor-color: #2a2d2c;
  --wallpaper: none;
}

/* 护眼模式：暖黄纸色 */
body.eye-care {
  --paper: #f3e3bf;
  --surface: #faf0d8;
  --ink: #3a3226;
  --ink-soft: #5d5446;
  --muted: #8a7f6b;
  --line: #e2cfaa;
  --accent: #8a6a3f;
  --accent-soft: #efdcb6;
  --nav-bg: rgba(243, 227, 191, 0.9);
  --scroll-thumb: #d8c39c;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.writing {
  overflow: hidden;
}

body.has-wallpaper {
  background-image: linear-gradient(rgba(246, 243, 236, 0.7), rgba(246, 243, 236, 0.7)), var(--wallpaper);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}

body.eye-care.has-wallpaper {
  background-image: linear-gradient(rgba(243, 227, 191, 0.82), rgba(243, 227, 191, 0.82)), var(--wallpaper);
}

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

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

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}

.hidden {
  display: none !important;
}

/* ---------- 顶部导航 ---------- */

.app-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 0 22px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--ink);
  color: #f8f5ee;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0;
}

.brand-mark-lg {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  font-size: 24px;
}

.brand-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0.14em;
  line-height: 1;
}

.brand-name small {
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-links a {
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: background 0.16s, color 0.16s;
}

.nav-links a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-links a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-logout {
  margin: 0;
}

.nav-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: 0.16s;
}

.nav-icon:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

/* ---------- 页面骨架 ---------- */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 38px 28px 80px;
}

.page-narrow {
  max-width: 780px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.page-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.page-sub {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.section-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 18px 40px -32px rgba(30, 36, 34, 0.45);
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s, opacity 0.16s;
}

.btn svg {
  flex: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.07);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--muted);
  color: var(--ink);
}

.btn-danger {
  background: transparent;
  border-color: rgba(180, 69, 58, 0.24);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(180, 69, 58, 0.08);
  border-color: rgba(180, 69, 58, 0.45);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-block {
  width: 100%;
  height: 40px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-icon-only {
  width: 30px;
  padding: 0;
  flex: none;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  flex: none;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: 0.16s;
}

.btn-icon:hover {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

/* ---------- 表单 ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.field-label {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.field-hint {
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.input {
  height: 38px;
}

.input-lg {
  height: 44px;
  font-family: var(--serif);
  font-size: 16px;
}

.textarea {
  line-height: 1.75;
  resize: vertical;
  min-height: 110px;
}

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

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
}

.select {
  height: 38px;
  padding: 0 10px;
  cursor: pointer;
}

.select-sm {
  height: 30px;
  width: auto;
  max-width: 132px;
  padding: 0 6px;
  font-size: 12px;
  background: var(--surface);
}

.form-card {
  padding: 26px 28px 22px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.form-section-title {
  margin: 4px 0 14px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.file-input {
  font-size: 12px;
  color: var(--muted);
  max-width: 100%;
}

.file-input::file-selector-button {
  height: 32px;
  margin-right: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
}

.file-input::file-selector-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 16px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.check-line input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

/* ---------- 提示 ---------- */

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 16px;
}

.alert-error {
  background: #fbece9;
  border-color: #efc8c1;
  color: #8f332b;
}

.alert-ok {
  background: #e8f1ea;
  border-color: #c6ddcd;
  color: #2f5d42;
}

.alert-info {
  background: var(--accent-soft);
  border-color: var(--line);
  color: var(--accent);
}

.flash-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 34px -18px rgba(30, 36, 34, 0.5);
  font-size: 13px;
  color: var(--ink);
  animation: flash-in 0.3s ease, flash-out 0.45s ease 4.4s forwards;
}

.flash-ok svg {
  color: var(--accent);
}

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

@keyframes flash-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes flash-out {
  to { opacity: 0; transform: translate(-50%, -8px); }
}

/* ---------- 空状态 ---------- */

.empty {
  padding: 58px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 4px;
}

.empty-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}

.empty-text {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}

/* ---------- 书架 ---------- */

.novel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.novel-card {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s;
}

.novel-card:hover {
  transform: translateY(-2px);
  border-color: #d8d2c4;
  box-shadow: 0 18px 34px -26px rgba(30, 36, 34, 0.5);
}

.cover {
  position: relative;
  flex: none;
  width: 92px;
  height: 126px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(155deg, #46584f, #1f2b27);
  display: grid;
  place-items: center;
  box-shadow: 0 10px 18px -14px rgba(20, 26, 23, 0.8);
}

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

.cover-char {
  font-family: var(--serif);
  font-size: 30px;
  color: #f3eee1;
  letter-spacing: 0.1em;
}

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

.novel-title {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}

.novel-title a {
  color: var(--ink);
  text-decoration: none;
}

.novel-title a:hover {
  color: var(--accent);
}

.novel-intro {
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.novel-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.meta-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--line);
}

.novel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.cover-edit {
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.cover-preview {
  width: 84px;
  height: 114px;
}

.cover-edit-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- 壁纸管理 ---------- */

.upload-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.upload-card-text {
  flex: 1;
  min-width: 240px;
}

.upload-card-text .field-hint {
  margin: 6px 0 0;
}

.upload-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wall-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.wall-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.wall-card.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.wall-thumb {
  height: 148px;
  background-size: cover;
  background-position: center;
  border-bottom: 1px solid var(--line);
}

.wall-info {
  padding: 11px 14px 6px;
}

.wall-name {
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wall-meta {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.wall-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px 12px;
  margin-top: auto;
}

.current-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.06em;
}

/* ---------- 登录 ---------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: radial-gradient(900px 480px at 18% 0%, var(--accent-soft), transparent 70%),
              radial-gradient(700px 400px at 100% 100%, rgba(196, 185, 160, 0.18), transparent 70%);
}

.auth-card {
  width: 100%;
  max-width: 388px;
  padding: 34px 32px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 70px -40px rgba(25, 32, 29, 0.55);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-title {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0.18em;
  line-height: 1.2;
}

.auth-sub {
  margin-top: 5px;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.auth-rule {
  height: 1px;
  background: var(--line);
  margin: 24px 0 22px;
}

.auth-form .field {
  margin-bottom: 16px;
}

.auth-foot {
  margin: 22px 0 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* ---------- 安装向导 ---------- */

.install-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 36px 20px;
}

.install-card {
  width: 100%;
  max-width: 620px;
  padding: 30px 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 70px -44px rgba(25, 32, 29, 0.55);
}

.install-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.install-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.install-sub {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.install-checks {
  display: grid;
  gap: 6px;
  margin-bottom: 20px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--paper);
  font-size: 12px;
  color: var(--ink-soft);
}

.check-dot {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

.check-row.ok .check-dot {
  background: var(--accent);
}

.check-row.bad .check-dot {
  background: var(--danger);
}

.check-name {
  flex: 1;
}

.check-value {
  font-size: 11px;
  color: var(--muted);
}

.install-form .field {
  margin-bottom: 14px;
}

.install-hint {
  margin: 16px 0 0;
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- 说明卡片 ---------- */

.note-card {
  margin-top: 22px;
  padding: 22px 24px;
}

.note-list {
  margin: 12px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 7px;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--ink-soft);
}

.note-list strong {
  color: var(--ink);
}

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 0.95em;
}

/* ---------- 写作页 ---------- */

.writer {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  height: calc(100vh - var(--nav-h));
}

.outline {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(250, 248, 242, 0.72);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body.eye-care .outline {
  background: rgba(250, 240, 216, 0.82);
}

.outline-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px dashed var(--line);
}

.outline-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.outline-back {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  transition: 0.16s;
}

.outline-back:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.novel-select {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  outline: none;
}

.novel-select:hover {
  border-color: var(--line);
  background: var(--surface);
}

.novel-select:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.outline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.outline-actions .btn:first-child {
  flex: 1;
}

.outline-meta {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.outline-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 8px 24px;
}

.outline-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 9px 8px 9px 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.outline-item:hover {
  background: var(--surface);
}

.outline-item.active {
  background: var(--surface);
  border-color: var(--line);
}

.outline-item.active::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 13px;
  bottom: 13px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.outline-item.dragging {
  opacity: 0.4;
}

.ch-drag {
  flex: none;
  padding-top: 2px;
  color: var(--muted);
  opacity: 0;
  cursor: grab;
  transition: opacity 0.15s;
}

.outline-item:hover .ch-drag {
  opacity: 0.55;
}

.ch-index {
  width: 16px;
  flex: none;
  padding-top: 2px;
  text-align: right;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

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

.ch-title {
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-soft);
  word-break: break-word;
}

.outline-item.active .ch-title {
  color: var(--accent);
  font-weight: 600;
}

.ch-time {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--muted);
}

.ch-delete {
  flex: none;
  padding: 2px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: 0.15s;
}

.outline-item:hover .ch-delete {
  opacity: 0.65;
}

.ch-delete:hover {
  opacity: 1;
  color: var(--danger);
  background: rgba(180, 69, 58, 0.08);
}

.outline-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.85;
  color: var(--muted);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 16px;
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tool-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  transition: 0.16s;
}

.tool-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tool-toggle.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tool-divider {
  width: 1px;
  height: 20px;
  margin: 0 6px;
  background: var(--line);
}

.tool-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tool-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.stepper {
  display: inline-flex;
  align-items: center;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.stepper button {
  width: 26px;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: 0.14s;
}

.stepper button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.stepper span {
  min-width: 32px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  cursor: pointer;
}

input[type="range"] {
  width: 84px;
  height: 30px;
  accent-color: var(--accent);
  background: transparent;
  cursor: pointer;
}

.tool-value {
  width: 26px;
  font-size: 11px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.toolbar-spacer {
  flex: 1;
  min-width: 8px;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.save-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s;
}

.save-status[data-state="dirty"] {
  color: #a5731f;
}

.save-status[data-state="dirty"] .dot {
  background: #c58b2e;
}

.save-status[data-state="saving"] {
  color: var(--accent);
}

.save-status[data-state="saving"] .dot {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.save-status[data-state="saved"] {
  color: #3f7a58;
}

.save-status[data-state="saved"] .dot {
  background: #4a8a66;
}

.save-status[data-state="error"] {
  color: var(--danger);
}

.save-status[data-state="error"] .dot {
  background: var(--danger);
}

.save-status[data-state="loading"] .dot {
  background: var(--muted);
  animation: pulse 1s ease-in-out infinite;
}

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

.workspace-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 20px 70px;
  background: transparent;
}

.paper {
  position: relative;
  max-width: 1115px;
  min-height: 260vh;
  margin: 0 auto;
  padding: 38px 52px 56px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.paper-title {
  width: 100%;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0 0 10px;
  background: transparent;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.02em;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s;
}

.paper-title:focus {
  border-bottom-color: var(--line);
}

.paper-title::placeholder {
  color: var(--muted);
  font-weight: 400;
}

.paper-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0 20px;
  margin-bottom: 22px;
  border-bottom: 1px dashed var(--line);
  font-size: 11px;
  color: var(--muted);
}

.paper-sub-right {
  letter-spacing: 0.02em;
}

.paper-body {
  display: block;
  width: 100%;
  min-height: calc(260vh - 200px);
  padding: 0;
  border: 0;
  background: transparent;
  resize: none;
  overflow: hidden;
  outline: none;
  font-family: var(--serif);
  font-size: var(--editor-size);
  line-height: var(--editor-line);
  color: var(--editor-color);
  letter-spacing: 0.02em;
}

.paper-body::placeholder {
  color: var(--muted);
}

/* ---------- AI 悬浮与弹窗 ---------- */

.ai-fab {
  position: fixed;
  z-index: 55;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(47, 93, 80, 0.65);
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.16s, transform 0.16s;
}

.ai-fab.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(24, 29, 27, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 680px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 40px 90px -40px rgba(18, 24, 21, 0.7);
  animation: modal-in 0.22s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px dashed var(--line);
}

.modal-title {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}

.modal-body {
  padding: 20px 24px 24px;
  overflow-y: auto;
}

.ai-selection {
  max-height: 116px;
  overflow-y: auto;
  margin-bottom: 18px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--paper);
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

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

.ai-mode {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  text-align: left;
  cursor: pointer;
  transition: 0.16s;
}

.ai-mode strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.ai-mode span {
  font-size: 11px;
  color: var(--muted);
}

.ai-mode:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ai-mode:disabled {
  opacity: 0.5;
  cursor: wait;
}

.ai-mode.is-busy {
  border-color: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.ai-loading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 2px 4px;
  font-size: 12.5px;
  color: var(--muted);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.ai-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fbece9;
  color: #8f332b;
  font-size: 12.5px;
  line-height: 1.7;
}

.ai-result {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.ai-result-label {
  margin-bottom: 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.ai-output {
  max-height: 260px;
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  font-family: var(--serif);
  font-size: 14.5px;
  line-height: 1.9;
  white-space: pre-wrap;
  color: var(--ink);
}

.ai-result-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  z-index: 70;
  max-width: 82vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #f7f5ef;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 16px 34px -16px rgba(20, 26, 24, 0.6);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: #8f332b;
}

/* ---------- 响应式（PC 优先，仅做基础降级） ---------- */

@media (max-width: 1100px) {
  .novel-grid {
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  }
}

@media (max-width: 900px) {
  .writer {
    grid-template-columns: 232px minmax(0, 1fr);
  }

  .paper {
    padding: 30px 28px 44px;
  }

  .tool-inline .tool-label {
    display: none;
  }
}

@media (max-width: 720px) {
  .app-nav {
    gap: 12px;
    padding: 0 14px;
  }

  .brand-name small {
    display: none;
  }

  .page {
    padding: 26px 16px 60px;
  }

  .writer {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - var(--nav-h));
  }

  .outline {
    max-height: 42vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace-scroll {
    padding: 16px 12px 40px;
  }

  .paper {
    padding: 26px 20px 36px;
    min-height: 60vh;
  }

  .form-row-2,
  .ai-modes {
    grid-template-columns: 1fr;
  }

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

  .page-title {
    font-size: 24px;
  }
}
