:root {
    --ink: #202521;
    --muted: #6f766f;
    --paper: #f4f3ed;
    --surface: #fffef9;
    --line: #d5d8cf;
    --green: #286a57;
    --green-soft: #dcebe3;
    --coral: #d9664a;
    --yellow: #f2c866;
    --danger: #b83b35;
    --shadow: 0 12px 36px rgba(31, 42, 35, .08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.65 Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font: 700 11px/1.2 Consolas, monospace; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; background: var(--green); color: white; font: 700 28px/1 serif; border-radius: 4px; }
.brand-mark.small { width: 36px; height: 36px; font-size: 18px; }
.topbar { position: sticky; z-index: 40; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 10px max(24px, calc((100vw - 1240px)/2)); border-bottom: 1px solid var(--ink); background: rgba(244, 243, 237, .94); backdrop-filter: blur(12px); }
.wordmark { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.wordmark strong, .wordmark small { display: block; }
.wordmark strong { font-size: 17px; line-height: 1.15; }
.wordmark small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-actions form { display: contents; }
.user-name { margin-right: 8px; color: var(--muted); font-size: 12px; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; background: transparent; text-decoration: none; cursor: pointer; border-radius: 4px; }
.icon-button:hover, .icon-button:focus-visible { background: var(--green-soft); outline: none; }
.app-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 70px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; padding: 0 0 28px; border-bottom: 1px solid var(--ink); }
.page-heading h1 { max-width: 720px; margin: 0; font: 600 42px/1.15 Georgia, "Songti SC", serif; }
.record-total { display: flex; align-items: baseline; gap: 9px; }
.record-total strong { font: 600 34px/1 Consolas, monospace; color: var(--coral); }
.record-total span { color: var(--muted); font-size: 12px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 42px; padding-top: 34px; }
.timeline-column, .side-column { min-width: 0; }
.side-column { position: sticky; top: 92px; align-self: start; }
.composer, .entries, .side-section { background: var(--surface); border: 1px solid var(--ink); box-shadow: var(--shadow); }
.composer { margin-bottom: 34px; }
.section-head, .side-title { display: flex; align-items: center; justify-content: space-between; }
.section-head { min-height: 59px; padding: 12px 18px; border-bottom: 1px solid var(--ink); }
.section-head > div { display: flex; align-items: center; gap: 12px; }
.section-head h2, .side-title h2 { margin: 0; font-size: 14px; }
.section-index { color: var(--coral); font: 700 11px Consolas, monospace; }
.text-button { color: var(--green); font-size: 12px; text-decoration: none; }
#entryForm { padding: 18px; }
.editor-wrap { position: relative; }
textarea { display: block; width: 100%; min-height: 150px; resize: vertical; padding: 15px; border: 1px solid var(--line); background: #fafaf6; color: var(--ink); outline: none; font: 14px/1.75 Consolas, "Microsoft YaHei", monospace; border-radius: 4px; }
textarea:focus, input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(40, 106, 87, .1); outline: none; }
.composer-tools { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 15px; }
.tool-group { display: flex; align-items: center; gap: 4px; }
.tool-button { display: inline-flex; min-height: 36px; align-items: center; gap: 7px; padding: 0 10px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 4px; }
.tool-button:hover { background: var(--green-soft); color: var(--ink); }
.emoji-wrap { position: relative; }
.emoji-picker { position: absolute; z-index: 15; left: 0; top: 42px; display: grid; width: 276px; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 8px; border: 1px solid var(--ink); background: white; box-shadow: var(--shadow); }
.emoji-picker[hidden] { display: none; }
.emoji-picker button { display: grid; place-items: center; height: 38px; padding: 0; border: 0; background: transparent; font-size: 20px; cursor: pointer; border-radius: 3px; }
.emoji-picker button:hover { background: var(--green-soft); }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px; padding: 0 17px; border: 1px solid var(--ink); background: white; color: var(--ink); cursor: pointer; text-decoration: none; border-radius: 4px; }
.button.primary { background: var(--green); color: white; border-color: var(--green); }
.button.primary:hover { background: #1f5748; }
.button.full { width: 100%; }
.preview { margin-top: 12px; padding: 14px; border: 1px dashed var(--green); background: var(--green-soft); }
.file-preview { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.file-preview:empty { display: none; }
.file-thumb { position: relative; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); background: #eee; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-thumb button { position: absolute; top: 4px; right: 4px; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; background: rgba(32,37,33,.78); color: white; cursor: pointer; border-radius: 50%; }
.entries { box-shadow: none; }
.day-group { padding: 0 18px 24px; }
.day-label { display: flex; align-items: baseline; gap: 9px; padding: 22px 0 10px; color: var(--muted); }
.day-label strong { color: var(--ink); font-size: 13px; }
.day-label span { font-size: 11px; }
.entry { position: relative; padding: 17px 17px 15px 25px; border: 1px solid var(--line); border-left: 3px solid var(--line); background: white; }
.entry + .entry { margin-top: 10px; }
.entry.pinned { border-left-color: var(--coral); }
.entry header { position: relative; display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.entry-time { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.entry-time time { color: var(--ink); font: 700 12px Consolas, monospace; }
.entry-time .bi-pin-angle-fill { color: var(--coral); }
.entry-menu { position: absolute; z-index: 10; top: 36px; right: 0; display: none; min-width: 118px; padding: 5px; border: 1px solid var(--ink); background: white; box-shadow: var(--shadow); }
.entry-menu.open { display: block; }
.entry-menu form { margin: 0; }
.entry-menu a, .entry-menu button { display: flex; width: 100%; min-height: 34px; align-items: center; gap: 8px; padding: 0 9px; border: 0; background: transparent; text-decoration: none; cursor: pointer; border-radius: 3px; }
.entry-menu a:hover, .entry-menu button:hover { background: var(--green-soft); }
.entry-menu .danger-text { color: var(--danger); }
.entry-content { color: #343b36; overflow-wrap: anywhere; }
.entry-content > :first-child, .preview > :first-child { margin-top: 0; }
.entry-content > :last-child, .preview > :last-child { margin-bottom: 0; }
.entry footer { margin-top: 10px; color: var(--muted); font-size: 10px; }
.markdown-body h1, .markdown-body h2, .markdown-body h3 { margin: 16px 0 8px; font-family: Georgia, "Songti SC", serif; }
.markdown-body h1 { font-size: 22px; } .markdown-body h2 { font-size: 19px; } .markdown-body h3 { font-size: 16px; }
.markdown-body p { margin: 0 0 9px; }
.markdown-body blockquote { margin: 12px 0; padding: 7px 12px; border-left: 3px solid var(--coral); background: #f7eee9; color: #5f514c; }
.markdown-body pre { overflow-x: auto; padding: 12px; background: var(--ink); color: #f4f3ed; border-radius: 4px; }
.markdown-body code { padding: 2px 5px; background: #e8e9e2; font-family: Consolas, monospace; border-radius: 3px; }
.markdown-body pre code { padding: 0; background: none; }
.markdown-body img { max-width: 100%; }
.markdown-body a { color: var(--green); }
.image-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.image-button { min-width: 0; aspect-ratio: 1; overflow: hidden; padding: 0; border: 0; background: #eee; cursor: zoom-in; }
.image-button img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.image-button:hover img { transform: scale(1.025); }
.empty-state { padding: 64px 20px; text-align: center; color: var(--muted); }
.empty-state i { color: var(--line); font-size: 42px; }
.empty-state h3 { margin: 10px 0 3px; color: var(--ink); font: 600 18px Georgia, serif; }
.empty-state p { margin: 0; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-top: 1px solid var(--line); }
.pagination a { display: inline-flex; align-items: center; gap: 7px; color: var(--green); text-decoration: none; }
.pagination span { color: var(--muted); font: 12px Consolas, monospace; }
.side-section { padding: 17px; box-shadow: none; }
.side-section + .side-section { margin-top: 13px; }
.side-title { margin-bottom: 14px; }
.side-title > div { display: flex; }
.side-title .icon-button { width: 28px; height: 28px; }
.month-title { display: block; margin-bottom: 10px; color: var(--coral); font: 600 20px Consolas, monospace; }
.weekdays, .days { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekdays span { padding: 3px 0 7px; color: var(--muted); font-size: 10px; text-align: center; }
.days a, .days > span { position: relative; display: grid; place-items: center; aspect-ratio: 1; color: var(--ink); text-decoration: none; font: 12px Consolas, monospace; }
.days a.disabled { pointer-events: none; color: #aaa; }
.days a.has-entry span { display: grid; place-items: center; width: 27px; height: 27px; background: var(--green-soft); border-radius: 50%; }
.days a:hover span, .days a.active span { background: var(--green); color: white; }
.days a.today span { outline: 1px solid var(--coral); outline-offset: 1px; }
.days small { position: absolute; right: 0; bottom: 0; color: var(--coral); font-size: 8px; }
.search-form { display: grid; grid-template-columns: 1fr 36px; border-bottom: 1px solid var(--ink); }
.search-form input { min-width: 0; height: 38px; padding: 0 3px; border: 0; background: transparent; }
.markdown-help dl { margin: 0; }
.markdown-help dl div { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); }
.markdown-help dt { font: 11px Consolas, monospace; }
.markdown-help dd { margin: 0; color: var(--muted); font-size: 11px; }
.filter-notice, .alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding: 10px 13px; border: 1px solid #a8c7b9; background: var(--green-soft); color: #204f42; border-radius: 4px; }
.filter-notice a { color: var(--green); }
.alert.danger, .alert.danger-text { border-color: #e3aaa5; background: #f8e6e4; color: var(--danger); }
.auth-page, .lock-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--paper); }
.auth-card, .lock-panel { width: min(420px, 100%); padding: 34px; border: 1px solid var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.auth-card .brand-mark, .lock-panel .brand-mark { margin-bottom: 22px; }
.auth-card h1, .lock-panel h1 { margin: 0 0 5px; font: 600 30px Georgia, "Songti SC", serif; }
.stack { display: grid; gap: 14px; margin-top: 24px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 4px; }
.auth-card .alert, .lock-panel .alert { margin: 18px 0 0; }
.subtle-link { display: block; margin-top: 18px; color: var(--muted); font-size: 12px; text-align: center; }
.lock-page { min-height: calc(100vh - 64px); }
.lightbox { position: fixed; z-index: 100; inset: 0; display: grid; grid-template-rows: auto 1fr; padding: 18px; background: rgba(15,18,16,.94); }
.lightbox[hidden] { display: none; }
.lightbox-bar { display: flex; align-items: center; justify-content: center; gap: 8px; color: white; }
.lightbox-bar .icon-button:hover { background: rgba(255,255,255,.12); }
.lightbox-stage { display: grid; place-items: center; overflow: hidden; }
.lightbox-stage img { max-width: 90vw; max-height: 82vh; cursor: grab; user-select: none; transform-origin: center; }

@media (max-width: 900px) {
    .app-shell { width: min(100% - 28px, 720px); padding-top: 26px; }
    .layout { grid-template-columns: 1fr; gap: 20px; }
    .side-column { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
    .side-section + .side-section { margin-top: 0; }
    .calendar-section { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    .topbar { padding: 9px 14px; }
    .user-name { display: none; }
    .app-shell { width: 100%; padding: 24px 14px 50px; }
    .page-heading { align-items: start; }
    .page-heading h1 { font-size: 30px; }
    .record-total { display: block; text-align: right; }
    .record-total strong, .record-total span { display: block; }
    .layout { padding-top: 22px; }
    .composer-tools { align-items: flex-end; }
    .tool-button { width: 38px; padding: 0; justify-content: center; }
    .tool-button span { display: none; }
    .file-preview { grid-template-columns: repeat(3, 1fr); }
    .day-group { padding: 0 10px 18px; }
    .entry { padding: 15px; }
    .entry-menu { position: fixed; top: auto; right: 14px; bottom: 14px; left: 14px; min-width: 0; }
    .entry-menu a, .entry-menu button { min-height: 46px; }
    .side-column { display: block; }
    .side-section + .side-section { margin-top: 13px; }
    .markdown-help { display: none; }
    .image-grid { grid-template-columns: repeat(2, 1fr); }
    .auth-card, .lock-panel { padding: 27px 22px; }
}
