:root {
  --page-width: 900px;
  --text: #222;
  --muted: #666;
  --line: #e5e5e5;
  --link: #2457a7;
  --background: #fff;
  --soft-background: #f6f7f8;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.85;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: min(calc(100% - 40px), var(--page-width));
  margin: 0 auto;
}

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

a:hover,
a:focus-visible {
  text-decoration: underline;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-name {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 14px;
}

.site-nav a {
  color: var(--muted);
}

.article {
  padding-top: 72px;
  padding-bottom: 80px;
}

.article-header {
  padding-bottom: 42px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

h1,
h2 {
  color: #111;
  line-height: 1.35;
}

h1 {
  margin: 0 0 20px;
  font-size: clamp(32px, 7vw, 48px);
  letter-spacing: -0.03em;
}

h2 {
  margin: 0 0 18px;
  font-size: clamp(24px, 5vw, 30px);
}

.lead {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.toc {
  margin: 38px 0 12px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.toc strong {
  display: block;
  margin-bottom: 10px;
}

.toc ol {
  margin: 0;
  padding-left: 24px;
  columns: 2;
  column-gap: 48px;
}

.toc li {
  break-inside: avoid;
  margin: 5px 0;
}

section {
  padding: 46px 0;
  border-bottom: 1px solid var(--line);
}

section:last-child {
  border-bottom: 0;
}

p {
  margin: 0 0 18px;
}

p:last-child {
  margin-bottom: 0;
}

ul,
ol {
  padding-left: 24px;
}

li + li {
  margin-top: 6px;
}

figure {
  margin: 28px 0;
}

figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

pre {
  margin: 26px 0;
  padding: 20px;
  overflow-x: auto;
  color: #222;
  background: var(--soft-background);
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 14px/1.7 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  white-space: pre;
  -webkit-overflow-scrolling: touch;
}

code {
  font-family: inherit;
}

table {
  width: 100%;
  margin: 26px 0;
  border-collapse: collapse;
  font-size: 15px;
}

th,
td {
  padding: 12px 14px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--soft-background);
  font-weight: 600;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.footer-inner {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

@media (max-width: 720px) {
  html {
    scroll-padding-top: 64px;
  }

  .wrap {
    width: min(calc(100% - 28px), var(--page-width));
  }

  .header-inner {
    min-height: 56px;
  }

  .site-nav {
    display: none;
  }

  .article {
    padding-top: 48px;
    padding-bottom: 52px;
  }

  .article-header {
    padding-bottom: 32px;
  }

  .lead {
    font-size: 16px;
  }

  .toc {
    margin-top: 30px;
  }

  .toc ol {
    columns: 1;
  }

  section {
    padding: 36px 0;
  }

  pre {
    margin: 22px -2px;
    padding: 16px;
    font-size: 13px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .footer-inner {
    min-height: 100px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}


/* 文章站补充样式 */
.primary-nav,
.night-actions {
  display: flex;
  align-items: center;
  gap: 22px;
}

.night-actions[hidden] {
  display: none !important;
}

.nav-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text) !important;
}

.nav-button-primary {
  border-color: var(--text);
  background: var(--text);
  color: #fff !important;
}

.breadcrumb,
.article-meta,
.article-index small,
.tag-list,
.note,
small {
  color: var(--muted);
}

.breadcrumb {
  margin: 0 0 24px;
  font-size: 14px;
}

.article-meta {
  margin-top: 18px;
  font-size: 14px;
}

.article-index {
  margin: 0;
  padding: 0;
  list-style: none;
}

.article-index li {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.article-index li:first-child {
  padding-top: 0;
}

.article-index li > a {
  font-size: 20px;
  font-weight: 650;
}

.article-index p {
  margin: 5px 0 3px;
}

.section-heading,
.article-nav,
.pagination,
.search-form,
.form-actions,
.admin-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h2 {
  margin: 0;
}

.note {
  margin: 24px 0;
  padding: 16px 18px;
  border-left: 3px solid var(--line);
  background: var(--soft-background);
}

.article-nav {
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.article-nav a:last-child {
  text-align: right;
}

.tag-list a {
  display: inline-block;
  margin-left: 10px;
}

.cover img,
.article-body img {
  max-width: 100%;
  height: auto;
}

.cover {
  margin-top: 36px;
}

.pagination {
  justify-content: center;
  margin-top: 32px;
}

.search-form {
  justify-content: flex-start;
  margin-top: 28px;
}

.search-form input {
  width: min(100%, 520px);
}

.narrow {
  max-width: 680px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}


.narrow-form {
  max-width: 620px;
}

/* 表单与后台 */
input,
textarea,
select,
button {
  font: inherit;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="time"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  margin-top: 7px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cfcfcf;
  border-radius: 4px;
}

textarea {
  resize: vertical;
}

label {
  display: block;
  font-weight: 600;
}

label small {
  display: block;
  margin-top: 5px;
  font-weight: 400;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 8px 15px;
  border: 1px solid #bbb;
  border-radius: 4px;
  color: var(--text);
  background: #fff;
  cursor: pointer;
  text-decoration: none;
}

.button:hover {
  text-decoration: none;
  background: var(--soft-background);
}

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

.button-primary:hover {
  color: #fff;
  background: #000;
}

.button.small {
  min-height: 32px;
  padding: 4px 9px;
  font-size: 13px;
}

.alert {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.alert-success {
  background: #f1f8f2;
}

.alert-error {
  background: #fff3f3;
}

.admin-body {
  background: #fafafa;
}

.admin-wrap {
  width: min(calc(100% - 40px), 1180px);
  margin: 0 auto;
}

.admin-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.admin-header-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}

.admin-nav form,
.actions form {
  display: inline;
  margin: 0;
}

.link-button {
  padding: 0;
  color: var(--link);
  background: none;
  border: 0;
  cursor: pointer;
}

.link-button:hover {
  text-decoration: underline;
}

.link-button.danger {
  color: #a52828;
}

.admin-main {
  padding: 48px 0 80px;
}

.admin-title-row {
  margin-bottom: 30px;
}

.admin-title-row h1 {
  margin-bottom: 0;
  font-size: 34px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 42px;
  background: var(--line);
  border: 1px solid var(--line);
}

.stat-grid div {
  padding: 20px;
  background: #fff;
}

.stat-grid strong,
.stat-grid span {
  display: block;
}

.stat-grid strong {
  font-size: 30px;
}

.stat-grid span {
  color: var(--muted);
  font-size: 13px;
}

.admin-section {
  padding: 28px 0;
}

.admin-form,
.upload-form {
  display: grid;
  gap: 22px;
}

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

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

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

.code-editor {
  min-height: 540px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 14px;
  line-height: 1.65;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.editor-toolbar button {
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 10px;
  margin-bottom: 22px;
}

.filter-form input,
.filter-form select {
  margin-top: 0;
}

.table-scroll {
  overflow-x: auto;
  background: #fff;
}

.actions {
  white-space: nowrap;
}

.actions > * {
  margin-right: 10px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-top: 34px;
}

.media-grid figure {
  min-width: 0;
  margin: 0;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.media-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: var(--soft-background);
}

.media-grid figcaption {
  text-align: left;
}

.media-grid code,
.media-grid small {
  display: block;
  overflow-wrap: anywhere;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-box {
  width: min(100%, 420px);
  display: grid;
  gap: 20px;
  padding: 34px;
  background: #fff;
  border: 1px solid var(--line);
}

.login-box h1 {
  margin: 0;
  font-size: 30px;
}

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

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

  .admin-header-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  .admin-nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }
}

@media (max-width: 720px) {
  .site-nav {
    display: flex;
  }

  .primary-nav {
    display: none;
  }

  .night-actions {
    gap: 8px;
  }

  .nav-button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
  }

  .article-nav,
  .section-heading,
  .admin-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .article-nav a:last-child {
    text-align: left;
  }

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

  .span-2 {
    grid-column: auto;
  }

  .admin-wrap {
    width: min(calc(100% - 24px), 1180px);
  }

  .admin-main {
    padding-top: 32px;
  }

  .media-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .login-box {
    padding: 24px;
  }
}
