/* ==========================================================================
   EduLearn Blog — 主题样式
   ========================================================================== */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --fg: #1f2328;
  --fg-soft: #3d444d;
  --muted: #6b7280;
  --line: #e7e3db;
  --line-soft: #f0ece4;
  --accent: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.08);
  --danger: #b42318;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 8px 24px -12px rgba(24, 24, 27, 0.12);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1a1d22;
    --fg: #e8e6e3;
    --fg-soft: #c5c9ce;
    --muted: #8b929c;
    --line: #2a2f36;
    --line-soft: #22262c;
    --accent: #4fd1c5;
    --accent-soft: rgba(79, 209, 197, 0.1);
    --danger: #f28b82;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

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

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

img {
  max-width: 100%;
  height: auto;
}

.skip {
  position: absolute;
  left: -999px;
}

.skip:focus {
  left: 12px;
  top: 12px;
  background: var(--surface);
  padding: 8px 14px;
  border-radius: 6px;
  z-index: 100;
}

.wrap {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
}

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

/* ---------- 顶栏 ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.head-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 14.5px;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.nav a:hover {
  color: var(--fg);
  text-decoration: none;
}

.nav a.on {
  color: var(--fg);
  border-bottom-color: var(--accent);
}

.nav a.rss {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
}

/* ---------- 列表 ---------- */
main.wrap {
  padding-top: 44px;
  padding-bottom: 72px;
}

.intro {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line-soft);
}

.intro p {
  margin: 0;
  color: var(--fg-soft);
  font-size: 16.5px;
}

.post-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.post-card {
  padding: 22px 20px 22px 22px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  border-left: 3px solid var(--line);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.post-card:hover {
  background: var(--surface);
  border-color: var(--line-soft);
  border-left-color: var(--accent);
  box-shadow: var(--shadow);
}

.card-date time {
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.card-title {
  margin: 6px 0 8px;
  font-size: 21px;
  line-height: 1.45;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-title a {
  color: var(--fg);
}

.card-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.card-excerpt {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  font-size: 12px;
  color: var(--muted);
  background: var(--accent-soft);
  padding: 2px 9px;
  border-radius: 999px;
}

.chip:hover {
  color: var(--accent);
  text-decoration: none;
}

.empty {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
  font-size: 14.5px;
}

.pager .off {
  color: var(--line);
}

.pager .page-now {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- 文章 ---------- */
.article-head {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line-soft);
}

.article-head h1 {
  margin: 0 0 16px;
  font-size: 34px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.article-meta {
  color: var(--muted);
  font-size: 13.5px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.article-meta .sep {
  opacity: 0.5;
}

.article-tags {
  margin-top: 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.markdown-body {
  font-size: 17px;
  line-height: 1.85;
  color: var(--fg-soft);
  word-wrap: break-word;
}

.markdown-body > *:first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--fg);
  line-height: 1.4;
  margin: 1.9em 0 0.7em;
  letter-spacing: -0.01em;
  font-weight: 650;
}

.markdown-body h1 {
  font-size: 27px;
}

.markdown-body h2 {
  font-size: 23px;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--line-soft);
}

.markdown-body h3 {
  font-size: 19.5px;
}

.markdown-body h4 {
  font-size: 17px;
}

.markdown-body p {
  margin: 0 0 1.2em;
}

.markdown-body ul,
.markdown-body ol {
  margin: 0 0 1.2em;
  padding-left: 1.5em;
}

.markdown-body li {
  margin: 0.35em 0;
}

.markdown-body li::marker {
  color: var(--muted);
}

.markdown-body ol {
  padding-left: 1.35em;
}

.markdown-body li > ul,
.markdown-body li > ol {
  margin: 0.35em 0;
}

.markdown-body blockquote {
  margin: 1.4em 0;
  padding: 4px 20px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.markdown-body code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}

.markdown-body pre {
  margin: 1.4em 0;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  overflow-x: auto;
  line-height: 1.6;
}

.markdown-body pre code {
  background: none;
  color: var(--fg-soft);
  padding: 0;
  font-size: 13.5px;
}

.markdown-body hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.4em 0;
}

.markdown-body img {
  border-radius: 8px;
  margin: 0.4em 0;
}

.markdown-body a {
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.markdown-body a:hover {
  text-decoration: none;
  border-bottom-color: var(--accent);
}

.markdown-body del {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  margin: 1.4em 0;
}

.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 9px 13px;
  text-align: left;
}

.markdown-body th {
  background: var(--line-soft);
  font-weight: 600;
  color: var(--fg);
}

/* ---------- 文章底部导航 ---------- */
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--line-soft);
}

.article-nav a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.article-nav a:hover {
  text-decoration: none;
  border-color: var(--accent);
  background: var(--surface);
}

.article-nav span {
  font-size: 12px;
  color: var(--muted);
}

.article-nav strong {
  font-size: 14.5px;
  color: var(--fg);
  font-weight: 600;
  line-height: 1.5;
}

.nav-next {
  text-align: right;
  align-items: flex-end;
}

.empty-slot {
  visibility: hidden;
}

/* ---------- 归档 / 标签 ---------- */
.page-title {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.01em;
}

.archive-count {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 40px;
}

.archive-year {
  margin-bottom: 36px;
}

.archive-year h2 {
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.archive-year ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.archive-year li {
  display: flex;
  gap: 18px;
  align-items: baseline;
  padding: 7px 0;
}

.archive-year time {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  flex: 0 0 78px;
}

.archive-year a {
  color: var(--fg);
  font-size: 15.5px;
}

.archive-year a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- 404 ---------- */
.notfound {
  text-align: center;
  padding: 80px 0;
}

.notfound h1 {
  font-size: 64px;
  margin: 0 0 8px;
  letter-spacing: -0.03em;
  color: var(--line);
}

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

/* ---------- 页脚 ---------- */
.site-foot {
  border-top: 1px solid var(--line-soft);
  padding: 36px 0 44px;
}

.foot-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 24px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.foot-brand {
  color: var(--fg);
  font-weight: 600;
  font-size: 14px;
}

.foot-icp a,
.foot-note a {
  color: var(--muted);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

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

@media (prefers-color-scheme: dark) {
  .btn.primary {
    color: #0b1214;
  }
}

.btn.primary:hover {
  filter: brightness(1.08);
  color: inherit;
}

/* ==========================================================================
   后台
   ========================================================================== */
.admin-body {
  background: var(--bg);
}

.admin-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.admin-bar-in {
  max-width: 1180px;
  margin: 0 auto;
  height: 58px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.admin-brand {
  font-weight: 650;
  color: var(--fg);
  font-size: 15px;
  white-space: nowrap;
}

.admin-brand span {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
}

.admin-nav {
  display: flex;
  gap: 22px;
  font-size: 14px;
  flex: 1;
}

.admin-nav a {
  color: var(--muted);
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.admin-nav a.on,
.admin-nav a:hover {
  color: var(--fg);
  text-decoration: none;
  border-bottom-color: var(--accent);
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13.5px;
  color: var(--muted);
}

.admin-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.admin-head h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--line-soft);
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.cell-title a {
  font-weight: 600;
  color: var(--fg);
  font-size: 15px;
}

.cell-title a:hover {
  color: var(--accent);
  text-decoration: none;
}

.cell-slug {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.cell-date,
.cell-views {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-ops {
  white-space: nowrap;
  display: flex;
  gap: 12px;
  align-items: center;
}

.cell-ops a,
.cell-ops button {
  font-size: 13px;
}

.cell-empty {
  text-align: center;
  color: var(--muted);
  padding: 56px 0 !important;
}

.badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge.live {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge.draft {
  background: var(--line-soft);
  color: var(--muted);
}

.inline-form {
  display: inline;
  margin: 0;
}

.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}

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

.linklike.danger {
  color: var(--danger);
}

/* ---------- 编辑器 ---------- */
.editor-top {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.editor-title {
  flex: 1;
  height: 48px;
  padding: 0 16px;
  font-size: 19px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
}

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

.editor-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.editor-fields label,
.settings-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.editor-fields input,
.settings-form input,
.settings-form textarea {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
}

.editor .full,
.settings-form .full {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 12.5px;
  color: var(--muted);
}

.editor .full input {
  height: 38px;
}

.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 62vh;
}

.pane {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--muted);
  background: var(--line-soft);
}

.pane-head .hint {
  font-size: 11.5px;
  opacity: 0.85;
}

.editor-text {
  flex: 1;
  width: 100%;
  min-height: 56vh;
  border: 0;
  outline: none;
  resize: none;
  padding: 18px;
  background: transparent;
  color: var(--fg);
  font-size: 14.5px;
  line-height: 1.8;
  font-family: var(--mono);
}

.editor-text.small {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.preview {
  flex: 1;
  padding: 18px 22px;
  overflow-y: auto;
  max-height: 72vh;
  font-size: 15.5px;
}

.preview .muted {
  font-size: 13.5px;
}

.editor-bottom {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.save-hint {
  color: var(--accent);
}

/* ---------- 设置 ---------- */
.settings-form {
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-actions {
  margin-top: 8px;
}

.alert {
  max-width: 760px;
  margin-bottom: 20px;
  padding: 11px 15px;
  border-radius: 8px;
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  font-size: 14px;
}

.alert.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- 登录 ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.login-card h1 {
  margin: 10px 0 22px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.login-card input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-size: 14.5px;
  font-family: inherit;
}

.login-card .btn {
  height: 42px;
  margin-top: 4px;
}

.login-hint {
  margin: 20px 0 0;
  font-size: 13px;
  text-align: center;
}

input:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 0;
  border-color: var(--accent);
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .editor-split {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .editor-text {
    min-height: 46vh;
  }

  .preview {
    max-height: none;
    min-height: 200px;
  }

  .admin-table {
    font-size: 13px;
  }

  .cell-views,
  .admin-table th:nth-child(4) {
    display: none;
  }
}

@media (max-width: 640px) {
  .head-inner {
    height: 56px;
    padding: 0 18px;
  }

  .wrap {
    padding: 0 18px;
  }

  main.wrap {
    padding-top: 30px;
  }

  .nav {
    gap: 12px;
    font-size: 13px;
  }

  .article-head h1 {
    font-size: 26px;
  }

  .markdown-body {
    font-size: 16.5px;
  }

  .post-card {
    padding: 18px 14px 18px 16px;
  }

  .card-title {
    font-size: 18.5px;
  }

  .article-nav {
    grid-template-columns: 1fr;
  }

  .editor-top {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-fields {
    grid-template-columns: 1fr;
  }

  .admin-bar-in {
    padding: 0 16px;
    gap: 14px;
  }

  .admin-user a[target] {
    display: none;
  }
}

/* 窄屏：标题与导航分两行，避免横向溢出 */
@media (max-width: 600px) {
  .head-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 18px 8px;
    row-gap: 2px;
  }

  .brand {
    width: 100%;
    font-size: 16px;
  }

  .nav {
    width: 100%;
    justify-content: flex-start;
    gap: 18px;
  }

  .nav a {
    padding-bottom: 2px;
  }
}
