:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-alt: #fbfbfa;
  --text: #1f2328;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --danger: #dc2626;
  --success: #15803d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 30px rgba(0, 0, 0, 0.05);
  --max-width: 820px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1f26;
    --surface-alt: #161b21;
    --text: #e6e8eb;
    --text-muted: #9aa4b2;
    --border: #2a313a;
    --accent: #6ba4ff;
    --accent-hover: #8ab6ff;
    --accent-soft: rgba(107, 164, 255, 0.12);
    --danger: #f87171;
    --success: #4ade80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
}

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

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

.container {
  width: min(100% - 2.5rem, var(--max-width));
  margin: 0 auto;
}

/* HTML 笔记使用更宽的版心，尽量接近浏览器直接打开的效果 */
.container.main-wide {
  width: calc(100% - 2rem);
  max-width: 1600px;
}

.main {
  flex: 1;
  padding: 2.5rem 0 4rem;
}

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--text-muted);
  font-size: 0.95rem;
}

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

/* Hero */
.hero {
  padding: 1rem 0 2rem;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 1.75rem;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  margin: 0;
  color: var(--text-muted);
}

/* Search */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.search-form input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.search-form input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.clear-search {
  align-self: center;
  font-size: 0.9rem;
  white-space: nowrap;
}

.result-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: -0.75rem 0 1.25rem;
}

/* Post list */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.post-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.post-card-title {
  margin: 0 0 0.5rem;
  font-size: 1.3rem;
  line-height: 1.4;
}

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

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

.post-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.tag {
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.05rem 0.6rem;
  font-size: 0.78rem;
}

.post-summary {
  margin: 0.75rem 0 1rem;
  color: var(--text-muted);
}

.read-more {
  font-size: 0.9rem;
  font-weight: 600;
}

/* Article */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.post-content {
  font-size: 1.02rem;
  line-height: 1.9;
  word-wrap: break-word;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  line-height: 1.4;
  margin: 2rem 0 0.75rem;
}

.post-content h2 {
  font-size: 1.4rem;
}

.post-content h3 {
  font-size: 1.2rem;
}

.post-content p {
  margin: 0 0 1.1rem;
}

.post-content a {
  border-bottom: 1px solid var(--accent-soft);
}

.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
  margin: 0 0 1.1rem;
}

.post-content li {
  margin-bottom: 0.35rem;
}

.post-content blockquote {
  margin: 1.25rem 0;
  padding: 0.5rem 1.25rem;
  border-left: 4px solid var(--accent);
  background: var(--surface-alt);
  color: var(--text-muted);
  border-radius: 0 8px 8px 0;
}

.post-content blockquote p {
  margin: 0.25rem 0;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.post-content code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--accent-soft);
  padding: 0.15em 0.4em;
  border-radius: 6px;
}

.post-content pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem 1.25rem;
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 0.9rem;
}

.post-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

.post-footer-nav {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  font-size: 0.92rem;
}

.pagination .disabled {
  color: var(--text-muted);
  opacity: 0.6;
}

.page-info {
  color: var(--text-muted);
}

/* About & errors */
.about h1 {
  margin-top: 0;
}

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

.error-page {
  text-align: center;
  padding: 4rem 0;
}

.error-code {
  font-size: 4rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0;
  line-height: 1;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.75rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0.2rem 0;
}

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

.copyright {
  margin-top: 0.5rem !important;
}

/* Buttons & forms */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

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

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

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

.btn-block {
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.field input,
.field textarea,
.field select {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 400;
}

.field textarea {
  resize: vertical;
  line-height: 1.7;
}

.field input.mono,
.field textarea.mono,
.mono {
  font-family: var(--mono);
  font-size: 0.9rem;
}

.hint {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.82rem;
}

.field-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.field-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.field-status {
  margin-bottom: 0;
}

.field-status select {
  min-width: 8rem;
}

.form-error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.3);
  border-radius: 9px;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  margin: 0 0 1.1rem;
}

.notice {
  background: rgba(21, 128, 61, 0.1);
  color: var(--success);
  border: 1px solid rgba(21, 128, 61, 0.25);
  border-radius: 9px;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

/* Admin */
.admin-body {
  background: var(--bg);
}

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.admin-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0;
}

.admin-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.admin-user {
  color: var(--text-muted);
}

.admin-main {
  flex: 1;
  padding: 2rem 0 4rem;
  width: min(100% - 2.5rem, 1100px);
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-head h1 {
  margin: 0;
  font-size: 1.5rem;
}

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

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

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

.link-button.danger {
  color: var(--danger);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form {
  padding: 2rem;
}

.login-wrap {
  display: flex;
  justify-content: center;
  padding: 3rem 0;
}

.login-wrap .card {
  width: min(100%, 380px);
}

.login-wrap h1 {
  margin: 0 0 1.5rem;
  font-size: 1.35rem;
}

.login-tip {
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-align: center;
}

.post-form {
  padding: 1.75rem;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th,
.table td {
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-alt);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--surface-alt);
}

.cell-title {
  min-width: 180px;
  max-width: 360px;
}

.cell-title a {
  color: var(--text);
  font-weight: 500;
}

.actions {
  white-space: nowrap;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.badge-green {
  background: rgba(21, 128, 61, 0.12);
  color: var(--success);
}

/* Private notes */
.preview-banner {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px dashed var(--accent);
  border-radius: 9px;
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.notes-head h1 {
  margin: 0;
  font-size: 1.6rem;
}

.note-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.private-gate {
  max-width: 420px;
  margin: 2rem auto;
  text-align: center;
}

.private-gate h1 {
  margin-bottom: 0.5rem;
}

.gate-tip {
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.gate-form {
  text-align: left;
}

.code-card {
  margin-bottom: 1.5rem;
}

.code-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.code-card .hint {
  display: block;
  margin: 0 0 1rem;
}

.code-card .field {
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .container {
    width: min(100% - 1.75rem, var(--max-width));
  }

  .container.main-wide {
    width: calc(100% - 1.5rem);
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .post-card {
    padding: 1.25rem;
  }

  .post-header h1 {
    font-size: 1.55rem;
  }

  .field-row {
    flex-direction: column;
    align-items: stretch;
  }

  .field-actions {
    width: 100%;
  }

  .field-actions .btn {
    flex: 1;
  }

  .form {
    padding: 1.25rem;
  }

  .post-form {
    padding: 1.25rem;
  }
}
