:root { --ink: #192421; --muted: #6b7571; --bg: #f2f3ef; --surface: #fff; --line: #dce1dd; --pine: #123f3b; --accent: #dc543b; --sidebar: #f7f9f7; }
* { box-sizing: border-box; letter-spacing: 0; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif; line-height: 1.55; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
.admin-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: 236px; padding: 20px 14px; border-right: 1px solid #d9e1dd; display: flex; flex-direction: column; color: #42534e; background: var(--sidebar); }
.admin-brand { height: 48px; padding: 0 10px; display: flex; align-items: center; gap: 11px; color: #18332e; font-weight: 750; text-decoration: none; }
.admin-brand img { width: 34px; height: 34px; }
.sidebar-close, .sidebar-backdrop { display: none; }
.admin-sidebar nav { margin-top: 28px; display: grid; gap: 4px; }
.admin-sidebar nav a, .sidebar-bottom > a, .sidebar-bottom button { width: 100%; min-height: 42px; padding: 9px 12px; display: flex; align-items: center; gap: 11px; border: 0; border-radius: 4px; color: #50615c; background: transparent; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; }
.admin-sidebar nav a span, .sidebar-bottom span { width: 20px; text-align: center; color: #668078; font-size: 18px; }
.admin-sidebar nav a:hover, .admin-sidebar nav a.active, .sidebar-bottom a:hover, .sidebar-bottom button:hover { color: #163e38; background: #e6eeea; }
.admin-sidebar nav a.active { box-shadow: inset 3px 0 var(--accent); font-weight: 700; }
.sidebar-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid #d9e1dd; display: grid; gap: 3px; }
.sidebar-bottom form { margin: 0; }
.admin-main { min-height: 100vh; margin-left: 236px; }
.admin-topbar { position: sticky; top: 0; z-index: 25; height: 64px; padding: 0 34px; display: flex; align-items: center; justify-content: flex-end; gap: 18px; border-bottom: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12px; }
.admin-topbar > div { display: flex; align-items: center; gap: 7px; }
.admin-topbar strong { color: var(--ink); font-size: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #2f9c62; }
.admin-content { width: min(1240px, calc(100% - 64px)); margin: 0 auto; padding: 42px 0 70px; }
.page-heading { min-height: 86px; margin-bottom: 28px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-heading > div:first-child > span { color: var(--accent); font: 750 11px ui-monospace, SFMono-Regular, Consolas, monospace; }
.page-heading h1 { margin: 3px 0 2px; font-size: 31px; line-height: 1.2; }
.page-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.button { display: inline-flex; min-height: 40px; padding: 8px 15px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 4px; font-weight: 700; font-size: 13px; text-decoration: none; cursor: pointer; }
.button.primary { color: white; background: var(--pine); }
.button.primary:hover { background: #0a302d; }
.button.secondary { color: var(--pine); border-color: #b9c8c3; background: white; }
.button.danger { color: white; background: #b33c2d; }
.button.danger:hover { background: #922f24; }
.button.small { min-height: 34px; padding: 5px 11px; }
.button.full { width: 100%; }
.heading-actions { display: flex; gap: 9px; }
.panel { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.panel-heading { min-height: 58px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 16px; }
.panel-heading a, .panel-heading span { color: var(--muted); font-size: 12px; }
.stats-grid { margin-bottom: 26px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stats-grid a { min-height: 145px; padding: 22px; border: 1px solid var(--line); border-radius: 6px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; text-decoration: none; background: white; }
.stats-grid a:hover { border-color: #95aaa4; }
.stats-grid span { color: var(--muted); font-size: 13px; }
.stats-grid strong { grid-row: 2; align-self: end; font: 650 46px/1 Georgia, serif; }
.stats-grid small { color: #749087; font: 700 10px ui-monospace, monospace; }
.compact-list a { min-height: 68px; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); text-decoration: none; }
.compact-list a:last-child { border-bottom: 0; }
.compact-list a:hover { background: #f8faf8; }
.compact-list a > span { display: flex; flex-direction: column; gap: 3px; }
.compact-list a > span:last-child { align-items: flex-end; }
.compact-list strong { font-size: 14px; }
.compact-list small, .compact-list time { color: var(--muted); font-size: 11px; }
.status { display: inline-block; width: fit-content; padding: 3px 7px; border-radius: 3px; font-style: normal; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status-published { color: #176d46; background: #dcefe4; }
.status-draft { color: #775d25; background: #f2e8cf; }
.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 850px; border-collapse: collapse; font-size: 13px; }
th { padding: 13px 16px; color: var(--muted); background: #f7f8f6; text-align: left; font-size: 11px; }
td { padding: 15px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fafbf9; }
.table-title { display: block; max-width: 340px; font-weight: 700; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td small { display: block; max-width: 280px; color: #89928f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.align-right { text-align: right; }
.actions { white-space: nowrap; }
.actions > * { display: inline-block; margin-left: 10px; }
.actions a, .actions button, .danger-link { padding: 0; border: 0; background: none; color: #48635c; font-size: 12px; text-decoration: none; cursor: pointer; }
.actions .danger-link, .danger-link { color: #b33c2d; }
.admin-pagination { min-height: 62px; padding: 12px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: flex-end; gap: 10px; color: var(--muted); font-size: 12px; }
.admin-pagination .page-link { width: 68px; flex: 0 0 68px; }
.admin-pagination .page-indicator { min-width: 36px; text-align: center; white-space: nowrap; }
.admin-pagination .disabled { color: #9da5a2; border-color: #e1e5e2; background: #f7f8f6; cursor: default; }
.empty-admin { padding: 60px 22px; color: var(--muted); text-align: center; }
.empty-admin a { color: var(--pine); }

.editor-meta { margin-bottom: 18px; padding: 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 18px; }
.editor-meta label, .stack-form label { color: #4c5a56; font-size: 12px; font-weight: 700; }
input[type="text"], input[type="password"], input[type="number"], textarea, select { width: 100%; margin-top: 5px; padding: 9px 10px; border: 1px solid #cbd3cf; border-radius: 4px; color: var(--ink); background: white; }
input:focus, textarea:focus, select:focus { border-color: #56847b; outline: 2px solid #d8e8e3; }
textarea { resize: vertical; }
.editor-options { min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: end; }
.checkbox-label { display: flex; align-items: center; gap: 8px; align-self: end; min-height: 40px; }
.checkbox-label input { width: 17px; height: 17px; accent-color: var(--pine); }
.editor-workspace { overflow: hidden; }
.editor-toolbar { min-height: 50px; padding: 8px 12px; display: flex; align-items: center; gap: 5px; border-bottom: 1px solid var(--line); background: #f7f8f6; }
.editor-toolbar button { width: 34px; height: 32px; border: 1px solid #cbd4d0; border-radius: 3px; color: #334742; background: white; cursor: pointer; }
.editor-toolbar button:hover { border-color: #719088; background: #edf3f0; }
#editor-status { margin-left: auto; color: var(--muted); font-size: 11px; }
.editor-grid { min-height: 590px; display: grid; grid-template-columns: 1fr 1fr; }
.editor-pane, .preview-pane { min-width: 0; position: relative; }
.editor-pane { border-right: 1px solid var(--line); }
.pane-label { height: 30px; padding: 8px 12px 0; color: #89948f; background: #fbfcfb; font: 700 10px ui-monospace, monospace; }
.editor-pane textarea { width: 100%; height: 560px; margin: 0; padding: 16px 18px; border: 0; border-radius: 0; resize: none; color: #24312e; background: #fbfcfb; font: 14px/1.75 ui-monospace, SFMono-Regular, Consolas, monospace; }
.editor-pane textarea:focus { outline: none; }
.preview-pane { height: 590px; overflow-y: auto; }
.preview-pane .markdown-body { padding: 14px 24px 40px; font-size: 15px; line-height: 1.8; overflow-wrap: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { line-height: 1.35; }
.markdown-body h1 { font-size: 29px; }
.markdown-body h2 { margin-top: 1.7em; padding-bottom: 7px; border-bottom: 1px solid var(--line); font-size: 24px; }
.markdown-body h3 { font-size: 19px; }
.markdown-body img { max-width: 100%; height: auto; }
.markdown-body pre { max-width: 100%; padding: 16px; overflow-x: auto; border-left: 3px solid #458d81; border-radius: 4px; color: #dce7e3; background: #14211f; }
.markdown-body code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.markdown-body :not(pre) > code { padding: 2px 4px; color: #ad3d2c; background: #edf1ee; }
.markdown-body blockquote { margin-left: 0; padding-left: 15px; border-left: 4px solid var(--accent); color: var(--muted); }
.markdown-body table { width: 100%; display: block; overflow-x: auto; border-collapse: collapse; }
.markdown-body th, .markdown-body td { padding: 7px 9px; border: 1px solid var(--line); text-align: left; }
.markdown-body .toc { padding: 15px 18px; border: 1px solid var(--line); border-radius: 4px; background: #f1f3f0; }
.markdown-body .toc::before { content: "目录"; font-weight: 700; }
.top-error { margin: -16px 0 18px; }

.form-panel .stack-form { padding: 20px; }
.stack-form { display: grid; gap: 17px; }
.tabs { margin-bottom: 18px; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 15px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; text-decoration: none; }
.tabs a.active { border-color: var(--accent); color: var(--ink); font-weight: 700; }
.comment-admin-list { display: grid; gap: 13px; }
.comment-admin-list article { padding: 18px 20px; }
.comment-admin-list header, .comment-admin-list footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.comment-admin-list header > div { display: flex; gap: 10px; }
.comment-admin-list header span, .comment-admin-list time { color: var(--muted); font-size: 11px; }
.comment-admin-list p { margin: 14px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-admin-list footer { padding-top: 12px; border-top: 1px solid var(--line); }
.comment-admin-list footer > a { max-width: 60%; color: #386158; font-size: 12px; }
.comment-admin-list footer > div { display: flex; gap: 12px; }
.comment-admin-list footer form { margin: 0; }
.comment-admin-list footer button { padding: 0; border: 0; color: #3f625a; background: transparent; font-size: 12px; cursor: pointer; }
.settings-panel { max-width: 700px; padding: 24px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.link-create-panel { margin-bottom: 22px; padding: 20px; }
.link-create-form { display: grid; grid-template-columns: minmax(140px, .4fr) minmax(240px, 1fr) minmax(140px, .35fr) auto; align-items: end; gap: 16px; }
.link-create-form label, .link-edit-form label { min-width: 0; color: #4c5a56; font-size: 12px; font-weight: 700; }
.link-create-form .button { min-width: 96px; }
.link-field-error { margin: 10px 0 0; }
.link-list-panel { overflow: hidden; }
.link-list { display: grid; }
.link-item { min-width: 0; min-height: 82px; padding: 12px 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 14px; border-bottom: 1px solid var(--line); background: white; }
.link-item:last-child { border-bottom: 0; }
.link-item.dragging { opacity: .55; background: #eef3f0; }
.link-item-actions { display: flex; align-items: center; gap: 6px; }
.link-item-actions form { margin: 0; }
.drag-handle, .link-move-buttons button { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border: 1px solid #c8d2ce; border-radius: 4px; color: #50635d; background: #f7f9f7; cursor: pointer; }
.drag-handle { font-size: 19px; cursor: grab; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.link-move-buttons { display: grid; grid-template-columns: repeat(2, 28px); gap: 4px; }
.link-move-buttons button { width: 28px; }
.drag-handle:hover, .link-move-buttons button:hover { color: var(--pine); border-color: #8fa49d; background: #e6eeea; }
.link-edit-form { min-width: 0; display: grid; grid-template-columns: minmax(110px, .4fr) minmax(220px, 1fr) minmax(130px, .4fr); align-items: end; gap: 12px; }
.link-edit-form label span { display: block; }
.link-edit-form input, .link-edit-form select { min-width: 0; }
.link-order-status { min-height: 35px; margin: 0; padding: 9px 16px; border-top: 1px solid var(--line); color: var(--muted); background: #fafbf9; font-size: 11px; }
.field-error { margin: -8px 0 0; color: #b8392a; font-size: 12px; }
.flash-stack { margin: 0 0 20px; display: grid; gap: 8px; }
.flash { padding: 11px 14px; border-left: 4px solid #4b8275; border-radius: 3px; background: #dfebe6; font-size: 13px; }
.flash-error { border-color: #b53c2c; background: #f5e2de; }
.flash-warning { border-color: #a97522; background: #f3ead7; }
.nav-toggle { display: none; }

.login-page { min-height: 100vh; padding: 36px 20px; display: grid; place-items: center; background: #e9ece8; }
.login-panel { width: min(420px, 100%); padding: 32px; border: 1px solid #cad2ce; border-top: 4px solid var(--pine); border-radius: 6px; background: white; box-shadow: 10px 12px 0 #d7dbd7; }
.login-brand { display: flex; align-items: center; gap: 11px; font-weight: 750; text-decoration: none; }
.login-copy { margin: 38px 0 26px; }
.login-copy > span { color: var(--accent); font: 700 10px ui-monospace, monospace; }
.login-copy h1 { margin: 5px 0 3px; font-size: 29px; }
.login-copy p { margin: 0; color: var(--muted); font-size: 14px; }
.back-link { display: inline-block; margin-top: 24px; color: var(--muted); font-size: 12px; text-decoration: none; }

@media (max-width: 920px) {
  .admin-sidebar { z-index: 50; transform: translateX(-100%); visibility: hidden; pointer-events: none; box-shadow: none; transition: transform .16s ease, visibility 0s linear .16s; }
  .admin-sidebar.open { transform: translateX(0); visibility: visible; pointer-events: auto; box-shadow: 8px 0 24px rgba(12,29,25,.18); transition-delay: 0s; }
  .admin-brand { padding-right: 48px; }
  .sidebar-close { position: absolute; top: 24px; right: 16px; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border: 1px solid #c5d1cc; border-radius: 4px; color: #314942; background: #eef3f0; font-size: 25px; line-height: 1; cursor: pointer; }
  .sidebar-close:hover, .sidebar-close:focus-visible { color: #123f3b; border-color: #8fa49d; background: #e0eae5; outline: none; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 40; width: 100%; height: 100%; padding: 0; border: 0; display: none; background: rgba(12, 24, 21, .42); cursor: default; }
  .admin-page.nav-open .sidebar-backdrop { display: block; }
  .admin-page.nav-open { overflow: hidden; }
  .admin-page.nav-open .nav-toggle { opacity: 0; pointer-events: none; }
  .admin-main { margin-left: 0; }
  .nav-toggle { position: fixed; z-index: 30; top: 15px; left: 16px; width: 36px; height: 34px; display: block; border: 1px solid #cad2ce; border-radius: 4px; color: var(--ink); background: white; cursor: pointer; transition: opacity .12s ease; }
  .admin-topbar { padding: 0 20px 0 64px; }
  .admin-content { width: min(100% - 32px, 1240px); padding-top: 30px; }
  .editor-grid { grid-template-columns: 1fr; }
  .editor-pane { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor-pane textarea, .preview-pane { height: 440px; }
  .editor-grid { min-height: 880px; }
  .link-item { grid-template-columns: 1fr; }
  .link-item-actions { justify-content: flex-end; }
}

@media (max-width: 620px) {
  .admin-content { width: min(100% - 22px, 1240px); }
  .page-heading { min-height: 0; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; }
  .stats-grid a { min-height: 112px; }
  .editor-meta { grid-template-columns: 1fr; }
  .editor-heading .heading-actions { width: 100%; }
  .editor-heading .heading-actions > * { flex: 1; }
  .editor-toolbar { overflow-x: auto; }
  .form-row { grid-template-columns: 1fr; }
  .compact-list a { align-items: flex-start; }
  .compact-list a > span:last-child { min-width: 80px; }
  .comment-admin-list header, .comment-admin-list footer { align-items: flex-start; flex-direction: column; }
  .comment-admin-list footer > a { max-width: 100%; }
  .link-create-form { grid-template-columns: 1fr; }
  .link-create-form .button { width: 100%; }
  .link-item { padding: 14px 12px; }
  .link-edit-form { grid-template-columns: 1fr; }
  .link-item-actions { justify-content: flex-start; overflow-x: auto; }
}
