:root {
  color-scheme: light dark;
  --page: #f7f9f5;
  --surface: #fff;
  --text: #202b24;
  --muted: #56665c;
  --line: #dbe4db;
  --accent: #295f47;
  --accent-bg: #eaf1e8;
  --button: #295c46;
  --button-text: #fff;
  --warning: #924522;
  --warning-bg: #fff2e8;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #151d19; --surface: #1e2822; --text: #edf3ec; --muted: #b5c4b8;
    --line: #36463c; --accent: #add8b9; --accent-bg: #2a3d30; --button: #b1d4b5;
    --button-text: #18281f; --warning: #f4bb9e; --warning-bg: #422e25;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--text); font: 1rem/1.6 var(--sans); }
h1, h2, p { margin: 0; }
a { color: var(--accent); text-underline-offset: .22em; }
button, input, textarea, select { font: inherit; }
button, select, summary { cursor: pointer; }
:is(input, button, select, textarea, a, summary):focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
input, textarea, select { color: var(--text); }
button:disabled { opacity: .56; cursor: default; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-inner { width: min(1200px, calc(100% - 56px)); margin-inline: auto; }
.topbar-inner { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.identity { display: inline-flex; gap: 12px; align-items: center; text-decoration: none; color: var(--text); font-size: 1.16rem; font-weight: 750; line-height: 1.22; }
.identity small { display: block; color: var(--muted); font-size: .8rem; font-weight: 500; margin-top: 3px; }
.identity-icon { width: 41px; height: 41px; display: grid; place-items: center; color: var(--accent); background: var(--accent-bg); border-radius: 11px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.top-actions a { text-decoration: none; }
.demo-label { color: var(--muted); font-size: .88rem; }
.login-page { min-height: 100svh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(100%, 400px); padding: clamp(20px, 5vw, 32px); border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.login-card h1 { margin: 15px 0 19px; font-size: 1.5rem; }
.login-card form { display: grid; gap: 12px; }
.login-card .primary { margin-top: 4px; }
.login-card input { font-size: 1rem; }
.login-hint { color: var(--muted); font-size: .87rem; }
.workspace { width: min(1200px, calc(100% - 56px)); margin: 30px auto 62px; display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: clamp(14px, 2vw, 24px); align-items: start; }
.workspace[data-editing="true"] { grid-template-columns: 9rem minmax(245px, 310px) minmax(0, 1fr); }
.workspace[data-editing="false"] .editor { display: none; }
.primary, .secondary, .danger, .text-button { min-height: 40px; padding: 7px 13px; border-radius: 8px; font-size: .9rem; font-weight: 650; white-space: nowrap; }
.primary { border: 1px solid transparent; color: var(--button-text); background: var(--button); }
.primary:not(:disabled):hover { filter: brightness(1.13); }
.secondary { border: 1px solid var(--line); color: var(--text); background: var(--surface); }
.secondary:not(:disabled):hover, .text-button:hover { background: var(--accent-bg); color: var(--accent); }
.danger { border: 1px solid var(--line); color: var(--warning); background: var(--warning-bg); }
.text-button { display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--accent); cursor: pointer; }
.sidebar { position: sticky; top: 20px; display: grid; gap: 16px; }
.create-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.sidebar .create-actions { display: grid; }
.create-actions .primary { border-color: var(--line); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.create-actions .primary:hover { filter: none; background: color-mix(in srgb, var(--accent) 19%, var(--surface)); }
.views { display: grid; gap: 5px; }
.views button { padding: 7px 12px; min-height: 43px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); text-align: start; white-space: nowrap; font-size: .94rem; }
.views button:hover, .views button[aria-current="page"] { color: var(--accent); background: var(--accent-bg); }
.views button[aria-current="page"] { font-weight: 720; }
.exports { color: var(--muted); font-size: .94rem; }
.exports summary { color: var(--text); font-weight: 650; }
.exports a { display: block; margin-top: 9px; }
.restore-file { display: block; margin-top: 9px; cursor: pointer; color: var(--accent); text-decoration: underline; }
.restore-file input { width: 100%; font-size: .85rem; margin-top: 4px; }
.exports p { margin-top: 7px; overflow-wrap: anywhere; }
.collection { min-width: 0; padding: clamp(14px, 2.4vw, 24px); border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.workspace[data-editing="false"] .collection { width: min(100%, 850px); justify-self: center; }
.collection-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 15px; }
:is(.collection-head, .site-panel) h1 { font-size: clamp(1.5rem, 3vw, 1.9rem); line-height: 1.22; }
.collection-head p { margin-top: 5px; color: var(--muted); font-size: .9rem; }
.article-filters { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 13px; }
.article-statuses { display: flex; flex-wrap: wrap; gap: 4px; }
.article-filters button { min-height: 40px; padding: 4px 12px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-size: .9rem; }
.article-filters button[aria-pressed="true"] { border-bottom-color: var(--accent); color: var(--accent); font-weight: 700; }
.article-filters .category-manager { margin-left: auto; color: var(--accent); }
.filters { display: grid; gap: 8px; align-items: end; }
.filters:has(#category-filter-label:not([hidden])) { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.compact-label { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: .87rem; }
.compact-label :is(input, select), #template { width: 100%; min-width: 0; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: var(--surface); font-size: .94rem; }
.compact-label select, #template { appearance: none; padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-repeat: no-repeat; background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; }
.review-filter { margin-top: 14px; }
.week-actions, .dates { display: flex; flex-wrap: wrap; gap: 7px; }
.week-actions { margin-bottom: 10px; }
.dates label { flex: 1; }
.records { margin-top: 17px; display: grid; gap: 7px; }
.date-heading { margin: 6px 0 1px; font-size: .88rem; font-weight: 650; color: var(--muted); }
.record-item { display: flex; align-items: flex-start; gap: 6px; min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.record-item[data-active="true"] { border-color: var(--accent); background: var(--accent-bg); }
.record { width: 100%; padding: 11px; border: 0; border-radius: 11px; text-align: left; color: var(--text); background: transparent; min-width: 0; }
.record:hover { background: var(--accent-bg); }
.record strong { display: block; line-height: 1.4; font-size: .99rem; overflow-wrap: anywhere; }
.record span, .record small { display: block; font-size: .86rem; color: var(--muted); overflow-wrap: anywhere; }
.record .record-excerpt { margin-top: 3px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.record small { margin-top: 5px; font-size: .8rem; font-weight: 550; }
.record-item input { width: 1.12rem; height: 1.12rem; flex: 0 0 auto; margin: 14px 0 0 11px; accent-color: var(--accent); }
.row-delete { flex: 0 0 auto; align-self: center; margin-right: 4px; }
.published-title { overflow-wrap: anywhere; }
.empty { padding: 18px 0; color: var(--muted); }
.more { margin-top: 12px; width: 100%; }
.selection { padding: 13px; margin-top: 14px; border-radius: 10px; background: var(--accent-bg); }
.selection h2 { font-size: 1rem; }
.selection ol { padding-left: 21px; margin: 6px 0 12px; }
.selection li { padding-top: 5px; font-size: .9rem; overflow-wrap: anywhere; }
.selection li button { margin-left: 5px; padding-inline: 8px; min-height: 34px; }
.selection p { margin: 8px 0 12px; color: var(--muted); font-size: .88rem; }

.editor { min-width: 0; background: var(--surface); padding: clamp(16px, 2vw, 28px); border: 1px solid var(--line); border-radius: 17px; }
.editor-head { min-height: 27px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; }
.editor-kind { color: var(--accent); font-size: .9rem; font-weight: 750; }
.save-status, .public-state { color: var(--muted); font-size: .87rem; overflow-wrap: anywhere; }
.editor-actions { display: grid; gap: 8px; padding: 9px 0 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.editor-actions:has(#visibility[hidden]) { display: none; }
.editor-actions:has(#visibility:not([hidden])) { position: sticky; top: 0; z-index: 1; }
.visibility { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 12px; }
.visibility a { font-size: .87rem; }
.public-state[data-live="true"] { color: var(--accent); font-weight: 700; }
.title-label input { width: 100%; padding: 9px 0; margin: 7px 0 14px; background: transparent; border: 0; border-bottom: 1px solid var(--line); font-size: clamp(1.45rem, 3vw, 2.15rem); font-weight: 700; }
.title-label input::placeholder { color: var(--muted); opacity: .77; }
.editor-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.span-two { grid-column: span 2; }
.summary { margin-bottom: 8px; }
.check-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; }
.check-label input { accent-color: var(--accent); width: 1rem; height: 1rem; }
.format-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 3px 10px; margin-top: 17px; background: var(--page); border: 1px solid var(--line); border-radius: 9px 9px 0 0; padding: 4px 7px; }
.format-tabs, .editor-tools, .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.format-tabs button { border: 0; border-radius: 6px; min-height: 37px; padding: 4px 8px; background: transparent; color: var(--muted); font-size: .88rem; }
.format-tabs button[aria-pressed="true"] { font-weight: 700; color: var(--accent); background: var(--accent-bg); }
.editor-tools #template { width: auto; min-height: 37px; font-size: .88rem; }
.file-button { position: relative; padding-inline: 8px; }
.file-button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
#body, .preview { display: block; width: 100%; min-height: 290px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 9px 9px; background: var(--surface); padding: 13px; }
#body { font-family: var(--mono); font-size: 1rem; line-height: 1.72; resize: vertical; }
.button-row { gap: 8px; }
.editor-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.back { min-height: 35px; }
.notice { border-radius: 8px; padding: 10px; margin-top: 10px; color: var(--warning); background: var(--warning-bg); font-size: .88rem; }
.notice p { margin-bottom: 6px; }
.notice button { margin: 2px 4px 2px 0; }
.editor-error { margin-top: 8px; color: var(--warning); font-size: .9rem; }

.prose { font-size: 1rem; line-height: 1.8; overflow-wrap: anywhere; }
.prose > * + * { margin-block-start: .7em; }
.prose :is(h1, h2, h3, h4) { line-height: 1.35; }
.prose img { display: block; max-width: 100%; border-radius: 6px; }
.prose :is(pre, table, eqn) { max-width: 100%; overflow: auto; }
.prose pre { padding: 9px; background: var(--accent-bg); border-radius: 6px; }
.prose :is(code, pre) { font-family: var(--mono); }
.prose .hljs-keyword, .prose .hljs-title { color: var(--accent); font-weight: 700; }
.prose .hljs-number, .prose .hljs-string { color: var(--warning); }
.prose blockquote { border-left: 2px solid var(--line); padding-left: .75em; margin-left: 0; color: var(--muted); }
dialog { max-height: min(86vh, 820px); width: min(720px, calc(100% - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 15px; color: var(--text); background: var(--surface); }
dialog::backdrop { background: #131e19a0; }
.dialog-inner { padding: clamp(16px, 4vw, 24px); }
.dialog-inner > p { margin: 8px 0 15px; color: var(--muted); overflow-wrap: anywhere; white-space: pre-line; }
.dialog-preview { border: 1px solid var(--line); padding: 12px; max-height: 48vh; overflow: auto; border-radius: 8px; margin-bottom: 14px; }
#category-dialog { width: min(500px, calc(100% - 30px)); }
.site-panel { grid-column: 2 / -1; width: min(100%, 920px); justify-self: center; min-width: 0; display: grid; gap: 16px; }
.site-card { min-width: 0; padding: clamp(15px, 2.5vw, 24px); border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.site-card h2 { font-size: 1.15rem; }
.traffic-card h2 { margin-bottom: 8px; }
.visitor-names { font-size: .94rem; overflow-wrap: anywhere; margin-block: 3px 7px; }
.traffic-table { width: 100%; margin-block: 9px 12px; border-collapse: collapse; font-size: .9rem; }
.traffic-table th, .traffic-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: start; overflow-wrap: anywhere; }
.traffic-table :is(th, td):not(:first-child) { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.metrics { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 8px; margin: 14px 0 9px; }
.metrics > div { min-width: 0; border-radius: 9px; padding: 11px 13px; background: var(--page); }
.metrics dt, .comment-meta time { color: var(--muted); font-size: .87rem; }
.metrics dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.site-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 15px; margin-top: 15px; }
.site-form textarea { width: 100%; min-width: 0; resize: vertical; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; background: var(--page); font-size: 1rem; }
.site-form-actions { grid-column: 1 / -1; padding-top: 12px; border-top: 1px solid var(--line); }
.cover-controls { display: grid; gap: 8px; min-width: 0; }
.cover-preview { position: relative; display: grid; place-items: center; width: 100%; min-width: 0; aspect-ratio: 2.7 / 1; min-height: 105px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: radial-gradient(ellipse at center, var(--surface), var(--accent-bg)); }
.cover-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-preview span { z-index: 1; align-self: end; justify-self: start; margin: 7px; padding: 3px 7px; border-radius: 5px; background: var(--surface); color: var(--muted); font-size: .8rem; }
.cover-controls .file-button { display: inline-flex; align-items: center; overflow: hidden; }
.cover-crop-frame { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--page); }
.cover-crop-frame canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: grab; }
.cover-crop-frame canvas:active { cursor: grabbing; }
.cover-crop-frame::after { content: ""; position: absolute; inset: 0 24%; border-inline: 1px dashed #fff; filter: drop-shadow(1px 0 1px #162019); pointer-events: none; }
.cover-crop-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; margin-block: 14px 16px; }
.cover-crop-controls label { display: grid; gap: 3px; color: var(--muted); font-size: .88rem; }
.cover-crop-controls input { width: 100%; min-width: 0; min-height: 26px; margin: 0; accent-color: var(--accent); }
.comment-meta { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; }
.comment-statuses button[aria-pressed="true"] { color: var(--accent); background: var(--accent-bg); }
.comment-list { list-style: none; padding: 0; margin: 8px 0 0; }
.comment-list li { padding: 12px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.comment-list p { margin: 5px 0 9px; white-space: pre-wrap; }
.comment-list .comment-source { margin-block: 4px; color: var(--muted); font-size: .86rem; }
#comment-status:not(:empty) { margin-top: 10px; }
.site-hint, #site-status { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.tag-dialog-head, .tag-form, .tag-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tag-form { margin-top: 15px; align-items: end; }
.tag-form label { flex: 1; }
.tag-list { list-style: none; padding: 0; margin: 14px 0 0; }
.tag-list li { border-top: 1px solid var(--line); padding: 6px 0; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace[data-editing="true"] { grid-template-columns: minmax(245px, 310px) minmax(0, 1fr); }
  .sidebar, .site-panel { grid-column: 1 / -1; }
  .sidebar { position: static; gap: 8px; }
  .sidebar .create-actions, .views { display: flex; flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .topbar-inner, .workspace { width: calc(100% - 28px); }
  .topbar-inner { min-height: 64px; }
  .identity { white-space: nowrap; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; gap: 0 4px; }
  .top-actions .text-button { padding-inline: 6px; }
  .workspace, .workspace[data-editing="true"] { grid-template-columns: minmax(0, 1fr); margin-top: 17px; }
  .views { justify-content: space-between; }
  .views button { padding-inline: 6px; font-size: .88rem; }
  .workspace[data-editing="true"] :is(.collection, .create-actions) { display: none; }
  .editor-head { justify-content: flex-start; }
  .save-status { margin-left: auto; }
  .editor-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor { padding: 13px; border-radius: 12px; }
  #body, .preview { height: 265px; min-height: 200px; }
  .compact-label :is(input, select), #template { font-size: 1rem; }
  .site-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  .views { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .views button { text-align: center; }
  .cover-crop-controls { grid-template-columns: minmax(0, 1fr); gap: 5px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics > div:first-child { grid-column: 1 / -1; }
}
