@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&family=Noto+Serif+SC:wght@500;600;700&display=swap");

:root {
  --bg: #f4efe6;
  --bg-soft: #deedf0;
  --ink: #122234;
  --muted: #425365;
  --card: rgba(255, 255, 255, 0.88);
  --card-border: rgba(18, 34, 52, 0.1);
  --accent: #0f6073;
  --accent-strong: #0b4a59;
  --accent-soft: #d9edf2;
  --warn: #a03828;
  --ok: #1f7a4e;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(18, 34, 52, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 14% 14%, #ffefc2 0%, transparent 36%),
    radial-gradient(circle at 92% 2%, #d6f6f0 0%, transparent 46%),
    linear-gradient(150deg, var(--bg), var(--bg-soft));
}

.background-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(44px);
  opacity: 0.52;
  z-index: 0;
  pointer-events: none;
}

.orb-a {
  width: 220px;
  height: 220px;
  background: #f7c56f;
  top: -80px;
  right: 6%;
}

.orb-b {
  width: 280px;
  height: 280px;
  background: #7bc1d2;
  left: -120px;
  bottom: 18%;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(244, 239, 230, 0.86);
  border-bottom: 1px solid rgba(18, 34, 52, 0.08);
  padding: 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
}

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

.nav-links a,
.nav-future {
  border: 1px solid #adc0cc;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  color: #244052;
  background: rgba(255, 255, 255, 0.65);
}

.nav-links a.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.nav-future {
  color: #627280;
  border-style: dashed;
}

.page-shell {
  position: relative;
  z-index: 1;
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px 18px 34px;
  display: grid;
  gap: 18px;
}

.writer-shell {
  padding-right: 18px;
  margin-left: max(12px, calc((100vw - 1220px) / 2 - 150px));
  margin-right: auto;
}

.writer-shell > :not(.action-dock):not(.dock-log-panel) {
  position: relative;
  z-index: 14;
}

.hero {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  animation: fade-up 320ms ease-out;
}

.hero h1 {
  margin: 6px 0 10px;
  font-family: "Noto Serif SC", serif;
  font-size: clamp(28px, 3.7vw, 40px);
  line-height: 1.12;
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

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

.output-grid {
  display: grid;
  grid-template-columns: 1.65fr 0.85fr;
  gap: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.outline-card .hint {
  margin: 0 0 10px;
  line-height: 1.6;
}

.kb-coverage-box {
  border: 1px solid #d8e1e8;
  border-radius: 12px;
  background: #f8fbfe;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.coverage-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.coverage-badge {
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
}

.coverage-badge.good {
  background: #e6f7ed;
  color: #1a6a3d;
}

.coverage-badge.warn {
  background: #fff1db;
  color: #8b4d05;
}

.coverage-stats {
  font-size: 12px;
  color: #4b6373;
}

.coverage-note {
  margin: 8px 0 6px;
  font-size: 13px;
  color: #2f4959;
  line-height: 1.5;
}

.coverage-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  color: #466074;
  display: grid;
  gap: 4px;
}

.coverage-list li {
  display: grid;
  gap: 2px;
}

.global-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
}

.outline-panel {
  border: 1px solid #d6e0e7;
  border-radius: 12px;
  background: #fff;
  padding: 14px;
  min-height: 120px;
}

.outline-item {
  border: 1px solid #cfdce6;
  border-radius: 12px;
  background: #f8fbfe;
  padding: 12px 12px 10px;
}

.outline-item + .outline-item {
  margin-top: 14px;
}

.outline-index {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #dceff5;
  color: #0d5062;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  margin-top: 1px;
}

.outline-title-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.outline-title-row h3 {
  margin: 0;
  font-size: 16px;
}

.outline-field {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: #4d6374;
  font-weight: 600;
}

.outline-editor-input,
.outline-editor-textarea {
  border: 1px solid #c9d6df;
  border-radius: 10px;
  background: #fff;
  color: #1b3345;
  font: inherit;
  padding: 8px 10px;
}

.outline-editor-textarea {
  resize: vertical;
  min-height: 66px;
}

.outline-foot {
  display: flex;
  justify-content: flex-end;
}

.outline-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #2d4f62;
  font-weight: 600;
}

.outline-delete-btn {
  white-space: nowrap;
  padding: 8px 10px;
}

.outline-tools {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #cfdae3;
  display: flex;
  justify-content: flex-end;
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  animation: fade-up 360ms ease-out;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 20px;
  font-family: "Noto Serif SC", serif;
}

.card h3 {
  margin: 14px 0 8px;
  font-size: 15px;
}

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

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

.field-hint {
  margin: -2px 0 4px;
  border: 1px solid #cfe0e8;
  border-radius: 10px;
  background: #f6fafc;
  color: #335062;
  font-size: 12px;
  line-height: 1.6;
  padding: 8px 10px;
}

.form-grid input,
.form-grid textarea,
.form-grid select,
.plain-input,
.plain-textarea {
  width: 100%;
  border: 1px solid #c6d1da;
  border-radius: 12px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  transition: border-color 170ms ease-out, box-shadow 170ms ease-out;
}

.plain-textarea {
  min-height: 90px;
  resize: vertical;
}

.project-pick-row {
  display: flex;
  gap: 8px;
}

.project-pick-row select {
  flex: 1;
}

.span-2 {
  grid-column: 1 / -1;
}

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

.action-dock {
  position: fixed;
  top: 96px;
  right: 18px;
  width: 260px;
  z-index: 30;
  border: 1px solid rgba(18, 34, 52, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 28px rgba(18, 34, 52, 0.18);
  backdrop-filter: blur(8px);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.dock-title {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #4f6475;
  font-weight: 700;
}

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

button.dock-btn {
  width: 100%;
  text-align: left;
  border-radius: 12px;
  padding: 10px 11px;
  font-size: 13px;
}

.dock-btn.dock-current {
  border: 1px solid #0d5b6c;
  box-shadow: 0 0 0 3px rgba(15, 96, 115, 0.2);
}

.dock-hint {
  margin: 0;
  font-size: 12px;
  color: #516879;
  line-height: 1.5;
}

.dock-log-panel {
  position: fixed;
  top: 296px;
  right: 18px;
  width: 348px;
  z-index: 8;
  border: 1px solid rgba(18, 34, 52, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 14px 28px rgba(18, 34, 52, 0.16);
  backdrop-filter: blur(8px);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.dock-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dock-log-head h2 {
  margin: 0;
  font-size: 16px;
  font-family: "Noto Serif SC", serif;
}

.dock-log-list {
  margin: 0;
  max-height: 380px;
  min-height: 180px;
  overflow: auto;
  padding-left: 16px;
}

button {
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  padding: 9px 13px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 170ms ease-out, transform 170ms ease-out;
}

button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

button.ghost {
  background: transparent;
  border: 1px solid #9fb2be;
  color: var(--ink);
}

button.ghost:hover {
  background: #f2f7fa;
}

button.warn {
  background: #8f3a2a;
}

button.warn:hover {
  background: #7a2f20;
}

button:disabled {
  opacity: 0.66;
  cursor: not-allowed;
  transform: none;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 96, 115, 0.2);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed #c9d4dc;
  padding: 8px 0;
  gap: 8px;
}

.status-label {
  color: var(--muted);
  font-size: 14px;
}

.status-card-end .log-list {
  max-height: 320px;
}

.badge {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge.idle,
.badge.draft,
.badge.planning,
.badge.retrieving,
.badge.writing,
.badge.polishing {
  background: #e8f0f4;
  color: #295061;
}

.badge.completed {
  background: #e5f5ec;
  color: var(--ok);
}

.badge.failed {
  background: #fdebe8;
  color: var(--warn);
}

.log-list {
  margin: 0;
  padding-left: 16px;
  max-height: 250px;
  overflow: auto;
  display: grid;
  gap: 7px;
  color: #22374a;
}

.log-list li {
  font-size: 13px;
  line-height: 1.45;
}

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

.preview-tabs {
  display: flex;
  gap: 8px;
  margin: 10px 0 12px;
}

.tab-btn {
  background: #edf4f7;
  color: #1f3b4d;
  border: 1px solid #c5d5df;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
}

.tab-btn:hover {
  background: #dceaf1;
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#copyHint,
#sourceMeta {
  font-size: 12px;
  color: var(--muted);
}

#articlePreview,
#markdownPreview,
.source-panel {
  margin: 0;
  background: #fff;
  border: 1px solid #d6e0e7;
  border-radius: 12px;
  padding: 14px;
  min-height: 280px;
  max-height: 660px;
  overflow: auto;
}

#articlePreview,
#markdownPreview {
  line-height: 1.6;
  color: #1a2c3e;
}

#articlePreview {
  font-size: 15px;
  line-height: 1.8;
}

#articlePreview h1,
#articlePreview h2,
#articlePreview h3 {
  font-family: "Noto Serif SC", serif;
  margin: 1.1em 0 0.5em;
  line-height: 1.3;
}

#articlePreview h1 {
  font-size: 28px;
}

#articlePreview h2 {
  font-size: 22px;
}

#articlePreview h3 {
  font-size: 18px;
}

#articlePreview p {
  margin: 0 0 0.9em;
}

#articlePreview ul {
  margin: 0 0 1em;
  padding-left: 1.2em;
}

#articlePreview li {
  margin-bottom: 0.34em;
}

#articlePreview blockquote {
  margin: 0 0 1em;
  padding: 8px 12px;
  border-left: 4px solid #7ea8ba;
  background: #f3f9fc;
  color: #365263;
}

#articlePreview hr {
  border: none;
  border-top: 1px dashed #c4d3dd;
  margin: 1.2em 0;
}

#articlePreview code,
#markdownPreview code,
.mono {
  padding: 1px 4px;
  border-radius: 6px;
  background: #f1f5f8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

#markdownPreview {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.source-card h2 {
  font-size: 17px;
}

.source-panel {
  font-size: 12px;
  line-height: 1.5;
}

.source-block + .source-block {
  border-top: 1px dashed #cad6de;
  padding-top: 10px;
  margin-top: 10px;
}

.source-block h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.source-block ul {
  margin: 0;
  padding-left: 16px;
  display: grid;
  gap: 7px;
}

.source-block li span {
  color: #4d6273;
}

.source-empty {
  margin: 0;
  color: #607588;
}

.source-empty.small {
  font-size: 12px;
}

.hint {
  color: #5b7082;
  font-size: 13px;
}

.subtle {
  color: #607386;
  font-size: 12px;
}

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

.history-item {
  border: 1px solid #cfdae2;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.history-item h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #506376;
  margin-bottom: 8px;
}

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

.history-pagination {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed #d2dde6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.history-page-info {
  min-width: 80px;
  text-align: center;
  color: #41586b;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #d3dee6;
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #edf2f6;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #4f6274;
}

.empty-box {
  border: 1px dashed #bfd0da;
  border-radius: 12px;
  padding: 16px;
  color: #607688;
  background: rgba(255, 255, 255, 0.72);
}

.error-box {
  margin: 0;
  background: #fff1ee;
  color: #8d2d1d;
  border: 1px solid #f6c7bd;
  border-radius: 12px;
  padding: 10px 12px;
}

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

@media (max-width: 1080px) {
  .writer-shell {
    padding-bottom: 108px;
    margin-left: auto;
    margin-right: auto;
  }

  .action-dock {
    top: auto;
    left: 50%;
    right: auto;
    bottom: 12px;
    transform: translateX(-50%);
    width: min(720px, calc(100% - 20px));
    grid-template-columns: 1fr;
  }

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

  button.dock-btn {
    text-align: center;
    font-size: 12px;
    padding: 9px 8px;
  }

  .panel-grid,
  .output-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .dock-log-panel {
    position: static;
    width: auto;
    top: auto;
    right: auto;
    order: 8;
    box-shadow: var(--shadow);
    margin-bottom: 6px;
  }

  .dock-log-list {
    max-height: 180px;
  }
}

@media (max-width: 760px) {
  .top-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-shell {
    padding: 14px 12px 22px;
  }

  .writer-shell {
    padding-bottom: 118px;
    margin-left: auto;
    margin-right: auto;
  }

  .hero,
  .card {
    padding: 14px;
    border-radius: 14px;
  }

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

  .actions,
  .project-pick-row,
  .history-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .history-pagination {
    justify-content: space-between;
  }

  .dock-hint {
    display: none;
  }

  .dock-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
