/* 全站视觉基调：克制、清晰、适合反复阅读和维护内容。 */
:root {
  --bg: #f7f8f4;
  --surface: #ffffff;
  --surface-2: #eef4ef;
  --text: #1d2522;
  --muted: #68736e;
  --line: #d8ded8;
  --primary: #087f7a;
  --primary-dark: #05615d;
  --accent: #b5543f;
  --warn: #a16207;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(22, 39, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 127, 122, 0.14);
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 248, 244, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-shell {
  max-width: 1180px;
  margin: 0 auto;
  min-height: 68px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand,
.nav-links,
.nav-links a,
.primary-button,
.secondary-button,
.ghost-button,
.icon-button,
.meta-line span {
  display: inline-flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
}

.nav-links {
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a,
.ghost-button {
  gap: 7px;
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 11px;
  color: var(--muted);
  border: 1px solid transparent;
  background: transparent;
}

.nav-links a.active,
.nav-links a:hover,
.ghost-button:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line);
}

.inline-form {
  margin: 0;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 34px auto 72px;
}

.narrow-page,
.auth-page {
  width: min(560px, calc(100% - 32px));
}

.auth-page {
  width: min(960px, calc(100% - 32px));
}

.page-heading,
.article-title-row,
.result-heading,
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.page-heading {
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.18;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.22rem;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.icon-button {
  cursor: pointer;
  border: 0;
}

.primary-button,
.secondary-button,
.danger-button {
  gap: 8px;
  min-height: 42px;
  justify-content: center;
  border-radius: 8px;
  padding: 10px 15px;
  font-weight: 750;
}

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

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
}

.secondary-button:hover {
  border-color: var(--primary);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  color: #fff;
  background: var(--danger);
}

.danger-button:hover {
  background: #8f1d14;
}

.small-button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

.heading-actions,
.table-actions,
.role-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.icon-link {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  color: var(--primary);
  background: var(--surface-2);
}

.icon-button:hover,
.icon-link:hover {
  background: #dcebe5;
}

.flash {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 0;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.flash-success {
  border-color: rgba(8, 127, 122, 0.35);
  color: var(--primary-dark);
}

.flash-error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.flash-warn {
  border-color: rgba(161, 98, 7, 0.35);
  color: var(--warn);
}

.post-list {
  display: grid;
  gap: 14px;
}

.post-card,
.auth-panel,
.tool-panel,
.content-section,
.article-shell,
.side-panel,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.post-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
}

.post-card h2 {
  margin: 6px 0 8px;
}

.post-card h2 a:hover {
  color: var(--primary);
}

.excerpt,
.muted {
  color: var(--muted);
}

.excerpt {
  margin: 0;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.meta-line span {
  gap: 6px;
}

.auth-panel,
.tool-panel,
.content-section,
.article-shell,
.empty-state {
  padding: 24px;
}

.auth-panel-wide {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(320px, 1.2fr);
  gap: 24px;
  align-items: stretch;
}

.auth-intro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 100%;
  border-radius: 8px;
  padding: 22px;
  background: var(--surface-2);
}

.auth-intro h1,
.auth-intro p {
  margin: 0;
}

.auth-intro p {
  color: var(--muted);
}

.auth-form-area {
  min-width: 0;
}

.form-title {
  margin-bottom: 18px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

.divider-top {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.compact-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.form-switch {
  margin: 16px 0 0;
  color: var(--muted);
}

.form-switch a {
  color: var(--primary);
  font-weight: 750;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  min-height: 40px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.segment.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 750;
}

.hidden {
  display: none !important;
}

.editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.editor-main,
.editor-side {
  display: grid;
  gap: 16px;
}

.editor-main {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.side-panel {
  padding: 16px;
}

.file-drop {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
}

.file-drop input {
  width: auto;
  max-width: 100%;
}

.snippet-list {
  display: grid;
  gap: 12px;
}

.snippet-editor {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: #f8faf8;
  border: 1px solid var(--line);
}

.preview-panel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.article-page {
  display: grid;
  gap: 18px;
}

.article-header {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.article-title-row h1 {
  max-width: 880px;
}

.markdown-body {
  font-size: 1rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin-top: 1.35em;
  margin-bottom: 0.5em;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol {
  margin: 0.75em 0;
}

.markdown-body a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.markdown-body table,
.stats-table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-body th,
.markdown-body td,
.stats-table th,
.stats-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.markdown-body pre,
.code-block pre {
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f6f8fa;
}

.markdown-body code,
.code-block code {
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.92rem;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.attachment-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.attachment-item:hover {
  border-color: var(--primary);
}

.attachment-item img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
}

.attachment-item small {
  color: var(--muted);
}

.file-icon {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--primary);
}

.code-block {
  margin: 0 0 16px;
}

.code-block figcaption {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stats-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: center;
}

.chart-wrap {
  min-height: 280px;
  display: grid;
  place-items: center;
}

.tool-panel {
  margin-bottom: 18px;
}

.inline-tool-form,
.stats-form {
  display: grid;
  gap: 14px;
  align-items: end;
}

.inline-tool-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.stats-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.allowed-roots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.allowed-roots code {
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.file-table-wrap {
  overflow: auto;
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.admin-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 9px 12px;
}

.admin-tabs a.active,
.admin-tabs a:hover {
  color: var(--text);
  border-color: var(--primary);
  background: var(--surface-2);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.admin-stats article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.admin-stats span {
  display: block;
  color: var(--muted);
  font-weight: 650;
}

.admin-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 2rem;
  line-height: 1;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.admin-table th:last-child,
.admin-table td:last-child {
  min-width: 180px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.86rem;
  font-weight: 750;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--primary-dark);
  background: #dcebe5;
}

.muted-pill {
  color: var(--muted);
}

.text-link {
  color: var(--primary);
  font-weight: 750;
}

.text-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.block-muted {
  display: block;
  color: var(--muted);
}

.role-form select {
  min-width: 112px;
  width: auto;
}

svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

@media (max-width: 860px) {
  .nav-shell,
  .page-heading,
  .article-title-row,
  .result-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .editor-shell,
  .stats-section,
  .inline-tool-form,
  .stats-form,
  .auth-panel-wide,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-wrap {
    min-height: 220px;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 22px, 1180px);
    margin-top: 22px;
  }

  .nav-shell {
    padding: 12px;
  }

  h1 {
    font-size: 1.65rem;
  }

  .post-card,
  .auth-panel,
  .tool-panel,
  .content-section,
  .article-shell,
  .empty-state {
    padding: 16px;
  }

  .post-card {
    align-items: flex-start;
  }

  .admin-stats {
    grid-template-columns: 1fr;
  }
}
