:root {
  --paper: #f4f1ea;
  --paper-deep: #ede8de;
  --panel: #fffdf8;
  --ink: #201e1b;
  --ink-soft: #4a463f;
  --muted: #6f685c;
  --line: #e5dfd3;
  --line-soft: #eee9df;
  --accent: #c1492d;
  --accent-deep: #a2351d;
  --accent-soft: #f7e9e3;
  --weibo: #e25b3f;
  --baidu: #3568d4;
  --zhihu: #1f7fd4;
  --ok: #3a7d5d;
  --warn: #b7791f;
  --shadow-sm: 0 1px 2px rgba(42, 36, 27, 0.05);
  --shadow-md: 0 10px 30px rgba(42, 36, 27, 0.08);
  --radius: 14px;
  --ui-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --serif-font: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--ui-font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, #fbf7ef 0%, rgba(251, 247, 239, 0) 60%),
    radial-gradient(900px 500px at -10% 110%, #efe9dd 0%, rgba(239, 233, 221, 0) 55%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

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

::selection {
  background: #f0cec3;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(193, 73, 45, 0.45);
  outline-offset: 2px;
}

.search-box input:focus-visible,
.login-card input:focus-visible,
.field input:focus-visible,
.field textarea:focus-visible {
  outline: none;
}

body.has-modal {
  overflow: hidden;
}

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

/* ---------- Top bar ---------- */
.topbar {
  height: 72px;
  flex: 0 0 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.82);
  backdrop-filter: saturate(150%) blur(10px);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, #cf5a3c, #a2351d);
  color: #fff8f2;
  display: grid;
  place-items: center;
  font-family: var(--serif-font);
  font-size: 20px;
  box-shadow: 0 6px 14px rgba(178, 62, 34, 0.28);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.02em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fffdf8;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}

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

.status-pill.is-ok {
  border-color: #cfe3d8;
  background: #f2f8f4;
  color: var(--ok);
}

.status-pill.is-ok .status-dot {
  background: #3a9d6c;
  box-shadow: 0 0 0 3px rgba(58, 157, 108, 0.14);
}

.status-pill.is-warn {
  border-color: #eadfc4;
  background: #fbf6ea;
  color: var(--warn);
}

.status-pill.is-warn .status-dot {
  background: #d19a35;
}

.status-pill.is-loading .status-dot {
  animation: pulse 1.2s ease-in-out infinite;
}

.icon-btn,
.ghost-btn,
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 9px;
  font-size: 13px;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
  white-space: nowrap;
}

.icon-btn {
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink-soft);
}

.icon-btn:hover {
  border-color: #d6cebe;
  background: #fff;
}

.icon-btn.is-spinning svg {
  animation: spin 0.9s linear infinite;
}

.primary-btn {
  height: 36px;
  padding: 0 16px;
  border: 1px solid #a2351d;
  background: linear-gradient(180deg, #cb5537, #b23e22);
  color: #fff9f5;
  box-shadow: 0 4px 12px rgba(178, 62, 34, 0.2);
}

.primary-btn:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.primary-btn:active {
  transform: translateY(0);
}

.ghost-btn {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink-soft);
}

.ghost-btn:hover {
  border-color: #d6cebe;
  background: #fff;
}

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, 388px) minmax(0, 1fr);
}

.source-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.9), rgba(250, 247, 240, 0.75));
}

/* ---------- Source tabs ---------- */
.source-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 14px 16px 10px;
}

.source-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  transition: all 0.18s ease;
}

.source-tab:hover {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
}

.source-tab.is-active {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.source-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dot-weibo {
  background: var(--weibo);
}

.dot-baidu {
  background: var(--baidu);
}

.dot-zhihu {
  background: var(--zhihu);
}

.source-tab .count {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.source-tab.is-active .count {
  color: var(--accent);
}

/* ---------- List tools ---------- */
.list-tools {
  padding: 0 16px 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.search-box:focus-within {
  border-color: #cfc5b4;
  box-shadow: 0 0 0 3px rgba(193, 73, 45, 0.08);
  background: #fff;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink);
}

.search-box input::placeholder {
  color: #aaa397;
}

.update-line {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---------- Hot list ---------- */
.hot-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 10px 18px;
  scroll-behavior: smooth;
}

.hot-list::-webkit-scrollbar,
.article-panel::-webkit-scrollbar {
  width: 8px;
}

.hot-list::-webkit-scrollbar-thumb,
.article-panel::-webkit-scrollbar-thumb {
  background: #d9d2c5;
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.hot-item {
  width: 100%;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  padding: 11px 10px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  color: inherit;
  transition: background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.hot-item + .hot-item {
  margin-top: 2px;
}

.hot-item:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--line-soft);
}

.hot-item.is-active {
  background: #fff;
  border-color: #e2d6c8;
  box-shadow: 0 4px 16px rgba(60, 48, 34, 0.07);
}

.rank {
  padding-top: 1px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #b3aca0;
  text-align: center;
  font-family: "Georgia", var(--ui-font);
}

.rank.is-top-1 {
  color: var(--accent);
}

.rank.is-top-2 {
  color: #d9772f;
}

.rank.is-top-3 {
  color: #c39a3a;
}

.item-main {
  min-width: 0;
}

.item-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  letter-spacing: 0.005em;
}

.hot-item.is-active .item-title {
  color: var(--accent-deep);
  font-weight: 600;
}

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

.item-meta .tag {
  display: inline-flex;
  align-items: center;
  height: 17px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: #b24a30;
  font-size: 10px;
  line-height: 1;
}

.item-meta .tag.is-top {
  background: #eef1fa;
  color: #4762a8;
}

.thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--paper-deep);
  flex: 0 0 auto;
  margin-top: 2px;
}

.list-message {
  padding: 40px 24px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.9;
}

.list-message .retry-link {
  display: inline-block;
  margin-top: 8px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 12.5px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* skeleton */
.skeleton-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 9px;
  padding: 13px 10px;
}

.sk-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #eee8dd 25%, #f7f2e9 37%, #eee8dd 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
}

.sk-bar.short {
  width: 42%;
  margin-top: 7px;
  height: 10px;
}

/* ---------- Article panel ---------- */
.article-panel {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  position: relative;
}

.article-panel::before {
  content: "";
  position: fixed;
  inset: 72px 0 0 388px;
  pointer-events: none;
  background-image: radial-gradient(rgba(92, 78, 58, 0.045) 0.7px, transparent 0.7px);
  background-size: 5px 5px;
  opacity: 0.7;
}

/* ---------- Empty state ---------- */
.empty-state {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px;
  text-align: center;
}

.empty-orbit {
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  margin-bottom: 26px;
}

.empty-orbit::before,
.empty-orbit::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  border: 1px solid #ddd3c3;
}

.empty-orbit::before {
  inset: 0;
  animation: spin 26s linear infinite;
  border-style: dashed;
}

.empty-orbit::after {
  inset: 18px;
  border-color: #e7ddcd;
}

.empty-glyph {
  position: relative;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(150deg, #fffdf8, #f3eadb);
  border: 1px solid #e4d9c7;
  box-shadow: 0 14px 30px rgba(74, 58, 38, 0.1);
  font-family: var(--serif-font);
  font-size: 30px;
  color: var(--accent);
}

.empty-state h2 {
  margin: 0 0 12px;
  font-family: var(--serif-font);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.empty-state p {
  margin: 0;
  max-width: 420px;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--muted);
}

.empty-steps {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 30px;
  font-size: 11.5px;
  color: #a39b8d;
  letter-spacing: 0.04em;
}

.empty-steps i {
  width: 26px;
  height: 1px;
  background: #d8cfbf;
}

.empty-tip {
  margin: 16px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.empty-tip kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #fffdf8;
  font-family: var(--ui-font);
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

.empty-tip .sep {
  margin: 0 8px;
  color: #c3baab;
}

/* ---------- Workspace ---------- */
.workspace {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 34px 46px 90px;
}

.is-hidden {
  display: none !important;
}

.topic-bar {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.topic-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 11px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 10.5px;
  letter-spacing: 0.04em;
}

.rank-text {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mode-chip {
  display: none;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 5px;
  background: #eef3ec;
  color: #4f7458;
  font-size: 10.5px;
}

.mode-chip.is-visible {
  display: inline-flex;
}

.topic-bar h2 {
  margin: 0;
  font-family: var(--serif-font);
  font-size: 23px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  font-weight: 700;
}

.topic-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}

.topic-sub a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(193, 73, 45, 0.3);
  padding-bottom: 1px;
}

.topic-sub a:hover {
  border-bottom-color: var(--accent);
}

/* ---------- Toolbar ---------- */
.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 0;
  flex-wrap: wrap;
}

.style-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.style-select select {
  height: 34px;
  padding: 0 30px 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b857a' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E")
    no-repeat right 11px center;
  appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink-soft);
  outline: none;
  cursor: pointer;
}

.style-select select:focus {
  border-color: #cfc5b4;
  box-shadow: 0 0 0 3px rgba(193, 73, 45, 0.08);
}

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

.font-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f2ea;
}

.font-control button {
  height: 28px;
  min-width: 30px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  transition: all 0.16s ease;
}

.font-control button:hover {
  color: var(--ink);
}

.font-control button.is-active {
  background: #fff;
  color: var(--accent-deep);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.workspace.is-font-sm .article-content {
  font-size: 15.5px;
}

.workspace.is-font-lg .article-content {
  font-size: 18.5px;
}

/* ---------- Notice / loading / error ---------- */
.notice {
  padding: 10px 14px;
  margin-bottom: 16px;
  border: 1px solid #ecdfc2;
  border-radius: 9px;
  background: #fbf6ea;
  color: #8a6a25;
  font-size: 12px;
  line-height: 1.8;
}

.error-bar {
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid #eccfc8;
  border-radius: 9px;
  background: #fbf0ed;
  color: #a53c26;
  font-size: 12.5px;
  line-height: 1.8;
}

.loading-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px 14px;
  font-size: 12px;
  color: var(--muted);
}

.loading-bar span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

/* ---------- Article ---------- */
.article-content {
  min-height: 120px;
  padding: 14px 0 8px;
  font-size: 16.5px;
  line-height: 1.95;
  color: #302d29;
  letter-spacing: 0.015em;
  word-break: break-word;
}

.article-content:empty {
  display: none;
}

.article-content h1 {
  margin: 4px 0 30px;
  font-family: var(--serif-font);
  font-size: 29px;
  line-height: 1.5;
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #1b1916;
}

.article-content h2 {
  position: relative;
  margin: 38px 0 17px;
  padding-left: 13px;
  font-size: 19.5px;
  line-height: 1.55;
  font-weight: 700;
  color: #262320;
}

.article-content h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.22em;
  bottom: 0.22em;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.article-content h3 {
  margin: 28px 0 12px;
  font-size: 17px;
  font-weight: 700;
}

.article-content p {
  margin: 0 0 19px;
}

.article-content blockquote {
  margin: 0 0 24px;
  padding: 15px 18px;
  border-left: 3px solid #d9a58f;
  border-radius: 0 8px 8px 0;
  background: #f8f3ea;
  color: #5c554a;
  font-size: 15px;
  line-height: 1.9;
}

.article-content blockquote p {
  margin: 0;
}

.article-content strong {
  color: #9c3a22;
  font-weight: 700;
}

.article-content em {
  font-style: normal;
  background: linear-gradient(transparent 62%, #f4dccf 62%);
}

.article-content ul,
.article-content ol {
  margin: 0 0 20px;
  padding-left: 1.35em;
}

.article-content li {
  margin-bottom: 8px;
}

.article-content li::marker {
  color: var(--accent);
}

.article-content hr {
  border: 0;
  height: 1px;
  margin: 32px auto;
  width: 46px;
  background: #d8cfbf;
}

.article-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(193, 73, 45, 0.35);
}

.typing-caret {
  display: inline-block;
  width: 2px;
  height: 1.02em;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}

/* ---------- Actions ---------- */
.article-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 40px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.word-count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.tool-fields {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.icon-only {
  width: 34px;
  padding: 0;
}

#personaBtn #personaLabel {
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtle-btn {
  height: 30px;
  padding: 0 10px;
  border: 1px dashed #d8cfbf;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  transition: all 0.18s ease;
}

.subtle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  background: rgba(40, 33, 25, 0.34);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.16s ease both;
}

.modal {
  width: min(760px, 100%);
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
  border: 1px solid #e2d8c9;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(40, 30, 18, 0.24);
  animation: modalIn 0.2s ease both;
  overflow: hidden;
}

.persona-modal {
  width: min(800px, 100%);
}

.settings-modal {
  width: min(680px, 100%);
}

.publish-modal {
  width: min(860px, 100%);
}

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

.modal-head h2 {
  margin: 0;
  font-family: var(--serif-font);
  font-size: 21px;
  letter-spacing: 0.02em;
}

.modal-head p {
  margin: 5px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

.modal-close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.modal-close:hover {
  background: var(--paper-deep);
  color: var(--ink);
}

.modal-body {
  padding: 20px 26px;
  overflow-y: auto;
  min-height: 0;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 26px;
  border-top: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #fffdf8, #faf6ee);
}

.modal-foot .primary-btn,
.modal-foot .ghost-btn {
  height: 34px;
}

.foot-hint {
  margin-right: auto;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
}

.foot-hint.is-error {
  color: #a53c26;
}

.foot-hint.is-ok {
  color: var(--ok);
}

.danger-link {
  border: 0;
  background: none;
  color: #b4482f;
  font-size: 12px;
  padding: 6px 0;
  margin-right: auto;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.danger-link:hover {
  color: #8f2f18;
}

/* fields */
.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.field input,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

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

.field input:focus,
.field textarea:focus {
  border-color: #cfc5b4;
  box-shadow: 0 0 0 3px rgba(193, 73, 45, 0.08);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #b3aa9c;
}

.field-hint {
  margin: 2px 0 0;
  font-size: 11.5px;
  line-height: 1.8;
  color: var(--muted);
}

.field-hint b {
  color: var(--ink-soft);
  font-weight: 600;
}

.seg {
  display: inline-flex;
  padding: 3px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f6f2ea;
}

.seg button {
  height: 30px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  transition: all 0.16s ease;
}

.seg button.is-active {
  background: #fff;
  color: var(--accent-deep);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

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

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

.mode-options {
  display: flex;
  gap: 20px;
  margin: 4px 0 10px;
}

/* persona */
.persona-body {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
  padding-bottom: 8px;
}

.persona-list-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 18px;
  border-right: 1px solid var(--line-soft);
}

.persona-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 400px;
}

.persona-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  color: var(--ink-soft);
  transition: all 0.16s ease;
}

.persona-item:hover {
  background: #faf6ee;
}

.persona-item.is-active {
  background: #fff;
  border-color: #e2d6c8;
  box-shadow: var(--shadow-sm);
}

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

.persona-item span {
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.persona-item .current-mark {
  color: var(--accent);
  font-size: 10px;
}

.persona-add {
  width: 100%;
  height: 32px;
  font-size: 12px;
}

.persona-form {
  min-width: 0;
}

/* settings */
.settings-panel .field {
  margin-bottom: 13px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 12px;
}

.inline-actions .ghost-btn {
  height: 32px;
  font-size: 12px;
}

.test-result {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  word-break: break-word;
}

.test-result.is-ok {
  color: var(--ok);
}

.test-result.is-error {
  color: #a53c26;
}

.mcp-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0 10px;
}

.mcp-tool {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fffefb;
  font-size: 11.5px;
  color: var(--muted);
}

.mcp-tool b {
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
}

.mcp-tool b:hover {
  color: var(--accent);
}

/* publish */
.publish-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
}

.publish-cover img {
  width: 100%;
  aspect-ratio: 900 / 383;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper-deep);
  object-fit: cover;
}

.cover-meta {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

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

.publish-cover .cover-actions {
  justify-content: center;
  margin-top: 10px;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink-soft);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.upload-btn:hover {
  border-color: #d6cebe;
  background: #fff;
}

.publish-result {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fffefb;
  font-size: 12.5px;
  line-height: 1.8;
}

.publish-result.is-ok {
  border-color: #cfe3d8;
  background: #f4faf6;
  color: #2f6b4e;
}

.publish-result.is-error {
  border-color: #eccfc8;
  background: #fbf0ed;
  color: #a53c26;
}

.publish-result h4 {
  margin: 0 0 8px;
  font-size: 13px;
}

.publish-result ol {
  margin: 0;
  padding-left: 18px;
}

.publish-result li {
  margin-bottom: 4px;
}

.publish-result .step-detail {
  color: var(--muted);
  font-size: 11.5px;
  word-break: break-all;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- Login ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(700px 400px at 70% 20%, rgba(255, 250, 242, 0.9), rgba(244, 241, 234, 0.88)),
    rgba(236, 231, 221, 0.9);
  backdrop-filter: blur(8px);
}

.login-card {
  width: min(380px, 100%);
  padding: 38px 34px 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(58, 44, 27, 0.16);
  text-align: center;
}

.login-lock {
  width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid #e4d9c7;
  background: linear-gradient(150deg, #fffdf8, #f3eadb);
  color: var(--accent);
}

.login-card h2 {
  margin: 0 0 8px;
  font-family: var(--serif-font);
  font-size: 22px;
  letter-spacing: 0.02em;
}

.login-card p {
  margin: 0 0 22px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
}

.login-card input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.login-card input:focus {
  border-color: #cfc5b4;
  box-shadow: 0 0 0 3px rgba(193, 73, 45, 0.1);
}

.login-card .primary-btn {
  width: 100%;
  height: 42px;
  margin-top: 14px;
  font-size: 14px;
}

.login-error {
  min-height: 18px;
  margin-top: 12px;
  font-size: 12px;
  color: #b23e22;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 18px);
  max-width: min(560px, calc(100vw - 40px));
  padding: 11px 20px;
  border-radius: 10px;
  background: rgba(32, 30, 27, 0.92);
  color: #fff8f2;
  font-size: 12.5px;
  line-height: 1.6;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 100;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

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

.toast.is-error {
  background: rgba(150, 46, 26, 0.95);
}

/* ---------- Animations ---------- */
@keyframes shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

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

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hot-list.is-enter .hot-item {
  animation: fadeUp 0.25s ease both;
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .topbar {
    position: sticky;
    top: 0;
    height: 64px;
    flex-basis: 64px;
    padding: 0 16px;
    box-shadow: 0 1px 0 rgba(42, 36, 27, 0.04);
  }

  .brand-text p {
    display: none;
  }

  .status-pill {
    max-width: 148px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .status-text {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .icon-btn span {
    display: none;
  }

  .icon-btn {
    padding: 0 10px;
    min-height: 40px;
  }

  .icon-only {
    min-width: 40px;
  }

  .source-tab {
    height: 42px;
  }

  .ghost-btn,
  .primary-btn {
    min-height: 40px;
  }

  .layout {
    display: block;
  }

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

  .hot-list {
    max-height: 42vh;
    padding-bottom: 10px;
  }

  .article-panel {
    overflow: visible;
  }

  .article-panel::before {
    display: none;
  }

  .empty-state {
    min-height: 52vh;
  }

  .workspace {
    padding: 26px 20px 160px;
    scroll-margin-top: 76px;
  }

  .article-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    margin: 0;
    padding: 9px 16px calc(9px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
    border-top: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: saturate(150%) blur(10px);
    box-shadow: 0 -8px 26px rgba(42, 36, 27, 0.08);
  }

  .article-actions .primary-btn {
    flex: 1 1 100%;
  }

  .article-actions .ghost-btn {
    flex: 1 1 0;
    height: 38px;
    padding: 0 6px;
    font-size: 11.5px;
  }

  .article-actions .word-count {
    display: none;
  }

  .toast {
    bottom: calc(128px + env(safe-area-inset-bottom, 0px));
  }

  .topic-bar h2 {
    font-size: 21px;
  }

  .article-content {
    font-size: 16px;
  }

  .article-content h1 {
    font-size: 25px;
  }

  .tool-fields {
    gap: 10px;
  }

  .persona-body {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .persona-list-pane {
    border-right: 0;
    padding-right: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line-soft);
  }

  .persona-list {
    flex-direction: row;
    overflow-x: auto;
    max-height: none;
    padding-bottom: 2px;
  }

  .persona-item {
    min-width: 150px;
  }

  .publish-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .publish-cover {
    order: -1;
  }

  .modal-overlay {
    padding: 12px;
  }

  .modal {
    max-height: 92vh;
  }

  .modal-head,
  .modal-body,
  .modal-foot {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 620px) {
  .topbar {
    gap: 10px;
    padding: 0 12px;
  }

  .topbar-right {
    gap: 6px;
  }

  #llmStatus {
    display: none;
  }

  #personaBtn #personaLabel {
    display: none;
  }

  .modal-foot {
    flex-wrap: wrap;
  }

  .modal-foot .foot-hint,
  .modal-foot .danger-link {
    width: 100%;
    margin-right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
