/* ==========================================================
   智慧的余裕 — 水墨清新 · 双栏布局
   ========================================================== */

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

:root {
  --ink: #2c3e50;
  --ink-light: #5a7a8a;
  --ink-lighter: #8eaab5;
  --ink-faint: #b5cbd4;
  --accent: #3a8a7c;
  --accent-light: #5bb5a3;
  --accent-dark: #2d6e63;
  --warm: #c4623a;
  --paper: #f8f9f6;
  --paper-warm: #f4f2ec;
  --white: #ffffff;
  --border: #dfe8e4;
  --border-light: #eaf0ed;

  --shadow: 0 2px 8px rgba(44,62,80,0.05);
  --shadow-hover: 0 6px 20px rgba(44,62,80,0.08);
  --radius: 6px;
  --sidebar-w: 320px;
  --font-title: "ZCOOL XiaoWei", "Noto Serif SC", "Source Han Serif SC", serif;
  --font-cn: "Noto Serif SC", "Source Han Serif SC", "SimSun", serif;
  --font-body: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.8;
  min-height: 100vh;
}

a { color: var(--accent-dark); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent); }

/* ===== Header — 水墨山水 ===== */
.site-header {
  text-align: center;
  position: relative;
  overflow: hidden;
  background: #e8efe9;
}

.site-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 360'%3E%3Cdefs%3E%3ClinearGradient id='sky' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23dce8e0'/%3E%3Cstop offset='100%25' stop-color='%23e8efe9'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect fill='url(%23sky)' width='1200' height='360'/%3E%3Cpath d='M0,300 Q150,190 300,240 Q400,210 500,230 Q650,160 800,220 Q900,190 1000,210 Q1100,180 1200,240 L1200,360 L0,360Z' fill='%23c5d5cb' opacity='0.4'/%3E%3Cpath d='M0,320 Q100,250 250,280 Q350,240 500,270 Q600,230 750,260 Q850,230 950,250 Q1050,220 1200,260 L1200,360 L0,360Z' fill='%23a8bfad' opacity='0.35'/%3E%3Cpath d='M0,340 Q200,285 400,310 Q500,290 650,320 Q800,295 950,310 Q1050,300 1200,320 L1200,360 L0,360Z' fill='%238aa894' opacity='0.25'/%3E%3Cellipse cx='300' cy='260' rx='250' ry='28' fill='white' opacity='0.3'/%3E%3Cellipse cx='800' cy='280' rx='200' ry='22' fill='white' opacity='0.25'/%3E%3Cellipse cx='550' cy='240' rx='150' ry='18' fill='white' opacity='0.2'/%3E%3C/svg%3E") center / cover no-repeat;
  z-index: 0;
}

.header-ornament {
  height: 3px;
  background: linear-gradient(90deg, transparent 10%, var(--accent) 40%, var(--accent-dark) 60%, transparent 90%);
  opacity: 0.4;
  position: relative;
  z-index: 1;
}

.header-inner {
  padding: 2.5rem 1.5rem 2.2rem;
  position: relative;
  z-index: 1;
}

.site-header h1 {
  font-family: var(--font-title);
  font-size: 2.6rem;
  font-weight: 400;
  letter-spacing: 0.35em;
  margin-bottom: 0.5rem;
  color: var(--ink);
  text-shadow: 0 1px 6px rgba(255,255,255,0.6);
}

.header-rule {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.header-rule span {
  display: block;
  width: 50px;
  height: 1px;
  background: var(--accent);
  opacity: 0.5;
  position: relative;
}

.header-rule span::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  width: 5px;
  height: 5px;
  background: var(--accent);
  opacity: 0.7;
}

.site-header .subtitle {
  font-family: var(--font-cn);
  font-size: 0.92rem;
  color: var(--ink-light);
  letter-spacing: 0.2em;
}

.site-header .blog-quote {
  margin-top: 0.7rem;
  font-family: var(--font-cn);
  font-size: 0.78rem;
  color: var(--ink-lighter);
  letter-spacing: 0.08em;
}

/* ===== Two-column layout ===== */
.page-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: calc(100vh - 200px);
}

/* ===== Main column ===== */
.main-col {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 4rem;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--white);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar-section {
  padding: 1rem 1rem 0;
}

.sidebar-section:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

/* Search & Filter */
.sidebar-search {
  margin-bottom: 0.6rem;
}

.sidebar-search input {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: var(--paper);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.sidebar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(58,138,124,0.1);
}

.sidebar-search input::placeholder { color: var(--ink-faint); }

.sidebar-filters select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink-light);
  outline: none;
  cursor: pointer;
}

.sidebar-filters select:focus { border-color: var(--accent); }

/* Sidebar heading */
.sidebar-heading {
  font-family: var(--font-cn);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  padding: 0.8rem 0 0.5rem;
  border-bottom: 1px solid var(--border-light);
  letter-spacing: 0.05em;
}

.sidebar-count {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--ink-faint);
}

/* Scrollable article list */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 2rem;
}

/* Custom scrollbar */
.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-track { background: transparent; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.sidebar-list::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* Year divider in sidebar */
.sidebar-year {
  font-family: var(--font-title);
  font-size: 0.9rem;
  color: var(--ink-lighter);
  padding: 0.8rem 0.5rem 0.3rem;
  letter-spacing: 0.1em;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

/* Sidebar article item */
.sidebar-item {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background .15s;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}

.sidebar-item:hover {
  background: var(--paper);
}

.sidebar-item.active {
  background: rgba(58,138,124,0.06);
  border-left: 3px solid var(--accent);
  padding-left: calc(0.5rem - 3px);
}

.sidebar-item-date {
  font-size: 0.72rem;
  color: var(--ink-faint);
  white-space: nowrap;
  min-width: 2.8rem;
  padding-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

.sidebar-item-body { flex: 1; min-width: 0; }

.sidebar-item-title {
  font-family: var(--font-cn);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
  margin-bottom: 0.15rem;
}

.sidebar-item.active .sidebar-item-title { color: var(--accent-dark); }

.sidebar-item-excerpt {
  font-size: 0.73rem;
  color: var(--ink-lighter);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

/* ===== Post (main area) ===== */
.post-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
}

.post-ornament {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.4rem 0;
}

.post-ornament::before,
.post-ornament::after {
  content: '';
  flex: 1;
  max-width: 80px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.post-header h2 {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 400;
  margin: 0.3rem 0;
  line-height: 1.5;
  color: var(--ink);
  letter-spacing: 0.08em;
}

.post-header .post-meta {
  font-size: 0.83rem;
  color: var(--ink-lighter);
  font-family: var(--font-cn);
  letter-spacing: 0.08em;
}

.post-content {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 2.5rem 2.5rem;
  font-family: var(--font-cn);
  font-size: 1.05rem;
  line-height: 2.1;
  color: var(--ink);
  border-top: 2px solid var(--accent);
}

.post-content p {
  margin-bottom: 1.2em;
  text-indent: 2em;
}

.post-content p:first-child {
  text-indent: 0;
  font-size: 1.06em;
  color: var(--ink-light);
}

.post-image {
  text-align: center;
  margin: 2em 0;
}

.post-image img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(44,62,80,0.08);
}

.post-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  font-family: var(--font-cn);
}

.post-nav a { display: flex; align-items: center; gap: 0.3rem; }
.post-nav .disabled { color: var(--ink-faint); pointer-events: none; }

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--ink-faint);
  font-size: 0.9rem;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--paper-warm);
  border-top: 1px solid var(--border);
}

.footer-ornament {
  width: 30px;
  height: 2px;
  background: var(--accent);
  margin: 0 auto 0.8rem;
  opacity: 0.4;
  border-radius: 1px;
}

.footer-name {
  font-family: var(--font-cn);
  font-size: 0.85rem;
  color: var(--ink-light);
  letter-spacing: 0.15em;
  margin-bottom: 0.2rem;
}

.footer-sub {
  font-size: 0.73rem;
  color: var(--ink-lighter);
}

/* ===== Mobile sidebar toggle ===== */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 2rem;
  padding: 0.6rem 1.2rem;
  font-size: 0.85rem;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(44,62,80,0.2);
  transition: background .2s;
}

.sidebar-toggle:hover { background: var(--accent-dark); }
.toggle-icon { font-size: 1rem; }

/* ===== Responsive ===== */

/* Tablet */
@media (max-width: 1100px) {
  .sidebar { width: 280px; }
  .main-col { padding: 1.5rem 2rem 3rem; }
}

/* Mobile */
@media (max-width: 900px) {
  .page-layout {
    flex-direction: column;
  }

  .main-col {
    padding: 1.5rem 1.2rem 3rem;
  }

  .post-content {
    padding: 1.5rem 1.2rem;
    font-size: 1rem;
  }

  .post-header h2 { font-size: 1.5rem; }

  .post-nav {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
    font-size: 0.82rem;
  }

  /* Sidebar becomes a slide-over panel */
  .sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 360px;
    height: 100vh;
    z-index: 300;
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 20px rgba(0,0,0,0.1);
    transition: right .3s ease;
  }

  .sidebar.open {
    right: 0;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
  }

  .site-header h1 { font-size: 2rem; letter-spacing: 0.2em; }
  .header-inner { padding: 2rem 1rem 1.5rem; }
}

@media (max-width: 480px) {
  .site-header h1 { font-size: 1.6rem; letter-spacing: 0.15em; }
  .main-col { padding: 1rem 0.8rem 2.5rem; }
  .post-content { padding: 1.2rem 1rem; }
}

/* ===== Auth in header ===== */
.header-auth {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 0.8rem;
  z-index: 2;
}

.header-auth a {
  color: var(--ink-lighter);
  transition: color .2s;
}

.header-auth a:hover { color: var(--accent); }
.auth-label { color: var(--ink-lighter); margin-right: 0.5rem; font-size: 0.78rem; }

.hidden { display: none !important; }

/* ===== Admin action bar ===== */
.admin-bar {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.admin-btn {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all .2s;
  background: var(--white);
  color: var(--ink-light);
}

.admin-btn:hover { border-color: var(--accent); color: var(--accent-dark); }

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

.btn-new { background: var(--white); color: var(--accent-dark); border-color: var(--accent); }
.btn-new:hover { background: rgba(58,138,124,0.06); }

.btn-del { color: #b54a3a; border-color: #dcc; }
.btn-del:hover { background: #fdf5f4; border-color: #b54a3a; }

.btn-cancel { background: var(--paper); color: var(--ink-light); }
.btn-small { font-size: 0.75rem; padding: 0.25rem 0.6rem; cursor: pointer; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(44,62,80,0.35);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: var(--white);
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 12px 40px rgba(44,62,80,0.15);
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-sm { max-width: 380px; }
.modal-lg { max-width: 720px; }

.modal-box h3 {
  font-family: var(--font-cn);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 1.2rem;
  letter-spacing: 0.05em;
}

.modal-field { margin-bottom: 0.8rem; }

.modal-field label {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.82rem;
  color: var(--ink-light);
  margin-bottom: 0.25rem;
}

.modal-field input[type="text"],
.modal-field input[type="password"],
.modal-field input[type="date"] {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .2s;
}

.modal-field input:focus { border-color: var(--accent); }

.modal-field textarea {
  width: 100%;
  min-height: 350px;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-body);
  line-height: 1.8;
  resize: vertical;
  outline: none;
  transition: border-color .2s;
}

.modal-field textarea:focus { border-color: var(--accent); }

.modal-row { display: flex; gap: 0.8rem; }
.modal-row .modal-field { flex: 1; }

.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.modal-error {
  font-size: 0.82rem;
  color: #b54a3a;
  margin-top: 0.3rem;
}

.modal-success {
  font-size: 0.82rem;
  color: var(--accent-dark);
}

.char-count { font-size: 0.75rem; color: var(--ink-faint); text-align: right; margin-top: 0.2rem; }

.upload-inline { cursor: pointer; }
.upload-status { font-size: 0.75rem; color: var(--ink-faint); }

/* ===== Editor Toolbar ===== */
.editor-toolbar + textarea {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
}

.editor-toolbar button {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--ink-light);
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-toolbar button:hover {
  background: var(--white);
  border-color: var(--border);
  color: var(--accent-dark);
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 0.3rem;
}

.emoji-popup {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 0.5rem;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.15rem;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  width: max-content;
  max-width: 340px;
}

.emoji-item {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 4px;
  font-size: 1.1rem;
  transition: background .1s;
}

.emoji-item:hover {
  background: var(--paper);
}

/* ===== Rendered content styles ===== */
.post-content h3 {
  font-family: var(--font-title);
  font-size: 1.3rem;
  margin: 1.5em 0 0.8em;
  color: var(--ink);
  text-indent: 0;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5em 1em;
  margin: 1em 0;
  color: var(--ink-light);
  font-style: italic;
  background: rgba(58,138,124,0.03);
  border-radius: 0 var(--radius) var(--radius) 0;
  text-indent: 0;
}

.post-content ul {
  margin: 1em 0;
  padding-left: 2em;
  text-indent: 0;
}

.post-content li {
  margin-bottom: 0.4em;
  line-height: 1.8;
}

.post-content strong { font-weight: 700; }
.post-content em { font-style: italic; }

/* ===== Comment Section ===== */
.comment-section {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.comment-heading {
  font-family: var(--font-cn);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
}

.comment-item {
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border-light);
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.3rem;
}

.comment-author {
  font-family: var(--font-cn);
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink);
}

.comment-time {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.comment-delete {
  font-size: 0.72rem;
  color: var(--warm) !important;
  margin-left: auto;
}

.comment-text {
  font-family: var(--font-cn);
  font-size: 0.92rem;
  color: var(--ink-light);
  line-height: 1.7;
}

.comment-empty {
  text-align: center;
  padding: 1.5rem;
  color: var(--ink-faint);
  font-size: 0.85rem;
}

.comment-form {
  margin-top: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.comment-form input,
.comment-form textarea {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .2s;
}

.comment-form input:focus,
.comment-form textarea:focus {
  border-color: var(--accent);
}

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

.comment-form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.comment-char-hint {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* ===== Drafts Section ===== */
.sidebar-heading-draft {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.sidebar-heading-draft:hover { color: var(--accent-dark); }

.draft-toggle {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-left: auto;
}

.drafts-list {
  max-height: 200px;
  overflow-y: auto;
  border-bottom: 1px solid var(--border-light);
}

.draft-item {
  background: rgba(196, 98, 58, 0.03);
}

.draft-item .sidebar-item-title::before {
  content: '草稿 ';
  font-size: 0.7rem;
  color: var(--warm);
  font-weight: 400;
}

/* Editor action buttons */
.editor-actions {
  flex-wrap: wrap;
}

.editor-actions .btn-del {
  margin-left: auto;
}

/* ===== Print ===== */
@media print {
  .sidebar, .sidebar-toggle, .post-nav { display: none; }
  .site-header::before { display: none; }
  .page-layout { display: block; }
  .post-content { border: none; padding: 0; }
}
