:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #20242b;
  --ink-soft: #5b6472;
  --muted: #8c94a1;
  --line: #e6e9ee;
  --accent: #2563eb;
  --accent-ink: #1746b3;
  --accent-soft: #eef3ff;
  --ok: #15803d;
  --danger: #d93025;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(29, 42, 68, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 50% -240px, #e4ebff 0%, rgba(244, 245, 247, 0) 70%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.shell {
  width: min(860px, calc(100% - 40px));
  margin: 0 auto;
  padding: 56px 0 64px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

h1 {
  margin: 14px 0 10px;
  font-size: clamp(28px, 4vw, 38px);
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.lead {
  max-width: 660px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.8;
}

.steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.steps span:not(.arrow) {
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}

.arrow {
  color: #b3bac6;
  align-self: center;
}

/* ---------- 前台展示 ---------- */

.article-card {
  margin-top: 26px;
  padding: 26px 28px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.article-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 5px 9px;
  border-radius: 6px;
}

.sync {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.14);
}

.sync.is-offline .sync-dot {
  background: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.14);
  animation: pulse 1.2s infinite;
}

.article-title {
  margin: 0 0 20px;
  padding-bottom: 18px;
  border-bottom: 1px dashed var(--line);
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.article-body {
  color: #2c313a;
}

.article-body .paragraph {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.9;
}

.article-body .paragraph:last-child {
  margin-bottom: 0;
}

.article-body.is-updated .paragraph {
  animation: settle 0.34s ease;
}

.article-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-ink);
  background: var(--accent-soft);
  transition: background 0.15s ease;
}

.btn-ghost:hover {
  background: #e3ecff;
  text-decoration: none;
}

/* ---------- 原始数据 ---------- */

.raw {
  margin-top: 18px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.raw summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-soft);
  list-style: none;
}

.raw summary::-webkit-details-marker {
  display: none;
}

.raw summary::after {
  content: "展开";
  font-size: 12px;
  color: var(--muted);
}

.raw[open] summary::after {
  content: "收起";
}

.raw pre {
  margin: 0 0 16px;
  padding: 14px 16px;
  max-height: 340px;
  overflow: auto;
  border-radius: 10px;
  background: #111827;
  color: #d7e2f7;
  font-size: 12px;
  line-height: 1.65;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.hint {
  margin: 22px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 后台控制 ---------- */

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.notice {
  margin-top: 24px;
  padding: 16px 18px;
  border: 1px solid #d9e4ff;
  border-radius: 12px;
  background: linear-gradient(180deg, #f5f8ff, #eef4ff);
  color: #33415c;
  font-size: 13.5px;
  line-height: 1.75;
}

.notice strong {
  color: var(--accent-ink);
}

.block-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.block-card {
  padding: 18px 20px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(29, 42, 68, 0.04);
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.block-label {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.text-input {
  width: 100%;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.7;
}

.text-input:focus,
.size-input:focus,
.align-select:focus {
  outline: none;
  border-color: #a8c3ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  background: #fff;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  margin-top: 14px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.control-label {
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
}

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

.toggle {
  width: 36px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #4a5361;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  cursor: pointer;
  transition: 0.15s ease;
}

.toggle:hover {
  border-color: #c5d4f5;
  background: #f8faff;
}

.toggle[aria-pressed="true"] {
  border-color: #b9cdfb;
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.toggle-bold {
  font-weight: 800;
}

.toggle-italic {
  font-style: italic;
}

.toggle-underline {
  text-decoration: underline;
}

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

.swatch {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  transition: 0.15s ease;
}

.swatch:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(29, 42, 68, 0.1);
}

.swatch .swatch-dot {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  background: var(--swatch);
}

.swatch.is-none .swatch-dot {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.swatch.is-none .swatch-dot::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 7px;
  width: 1.5px;
  height: 20px;
  background: #c24b4b;
  transform: rotate(45deg);
}

.swatch[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.size-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.size-input {
  width: 92px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.unit {
  font-size: 12px;
  color: var(--muted);
}

.align-select {
  width: 160px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.block-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.btn-primary {
  padding: 9px 16px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.22);
  transition: 0.15s ease;
}

.btn-primary:hover {
  background: var(--accent-ink);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.save-state {
  font-size: 12.5px;
  color: var(--muted);
}

.save-state.is-ok {
  color: var(--ok);
}

.save-state.is-error {
  color: var(--danger);
}

.loading {
  margin: 0;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.loading.is-error {
  color: var(--danger);
}

@keyframes settle {
  from {
    opacity: 0.35;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 32px, 860px);
    padding: 32px 0 44px;
  }

  .admin-head {
    flex-direction: column;
    gap: 14px;
  }

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

  .article-card {
    padding: 20px 18px 16px;
  }

  .article-foot {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

  html {
    scroll-behavior: auto;
  }
}
