:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1f2933; --muted: #6b7280; --line: #e5e7eb;
  --accent: #1d4ed8; --accent-ink: #ffffff; --accent-soft: #e8eefc;
  --inbox: #b45309; --inbox-bg: #fef3c7; --ready: #1d4ed8; --ready-bg: #dbeafe; --read: #047857; --read-bg: #d1fae5;
  --danger: #b91c1c; --code: #f1f3f5;
  --reader-size: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --panel: #1a1f25; --text: #e5e7eb; --muted: #9aa3ad; --line: #2b323a;
    --accent: #6c9cff; --accent-ink: #0b1220; --accent-soft: #1d2a44;
    --inbox: #fbbf24; --inbox-bg: #3b2f12; --ready: #93b4ff; --ready-bg: #1d2a44; --read: #6ee7b7; --read-bg: #12332a;
    --danger: #f87171; --code: #232a31;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 780px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.inline { display: inline; margin: 0; }

/* header */
.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.top-in { display: flex; align-items: center; gap: 12px; min-height: 56px; }
@media (max-width: 420px) { .top .brand { font-size: 0; gap: 0; } .top .brand .logo { font-size: 13px; } .top .nav a { padding: 6px 8px; } }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 17px; }
.brand:hover { text-decoration: none; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-size: 13px; letter-spacing: .5px; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.nav a:hover { text-decoration: none; color: var(--text); }

main.wrap { padding-top: 20px; padding-bottom: 40px; min-height: 60vh; }
.page-title { font-size: 24px; margin: 4px 0 16px; }
.sec { font-size: 18px; margin: 28px 0 12px; }
.flash { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--read-bg); color: var(--read); }

/* hero */
.hero { padding: 20px 0 4px; }
.hero h1 { font-size: 26px; line-height: 1.35; margin: 0 0 8px; }
.hero-links { display: flex; gap: 10px; flex-wrap: wrap; }

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; gap: 4px; justify-content: center;
  min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-size: 15px; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: 14px; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 42px;
}
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { line-height: 1.6; resize: vertical; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.form label.check input { width: 20px; min-height: 20px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; align-items: end; } }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0; }
.narrow { max-width: 480px; }
.error { color: var(--danger); margin: 0; }
.quick-add { display: flex; gap: 8px; margin-bottom: 14px; }
.quick-add input { flex: 1; min-width: 0; }
.search { display: flex; gap: 8px; margin: 0 0 12px; }
.search input { flex: 1; min-width: 0; }

/* tabs & chips */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tab { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--accent); border-color: var(--accent); }
.tab:hover { text-decoration: none; color: var(--text); }
.tab small { font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip small { opacity: .75; }
.chip:hover { text-decoration: none; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
.card h2 { font-size: 17px; margin: 0 0 6px; }
.card-title { margin: 0 0 4px; font-size: 17px; line-height: 1.45; word-break: break-word; }
.card-title a { color: var(--text); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin: 0; font-size: 13px; color: var(--muted); }
.excerpt { margin: 6px 0 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 6px; font-weight: 600; }
.s-inbox { color: var(--inbox); background: var(--inbox-bg); }
.s-ready { color: var(--ready); background: var(--ready-bg); }
.s-read { color: var(--read); background: var(--read-bg); }
.vis { display: inline-flex; align-items: center; gap: 3px; }
.empty-line { padding: 24px 0; text-align: center; }
.empty { text-align: center; padding: 48px 0; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 16px 0; }

/* reader */
.reader { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 22px; position: relative; }
.reader h1 { font-size: 23px; line-height: 1.4; margin: 0 0 8px; padding-right: 92px; word-break: break-word; }
.reader-tools { position: absolute; top: 14px; right: 14px; display: flex; gap: 6px; }
.reader-tools .btn { min-width: 38px; padding: 4px 8px; }
.reader .md { font-size: var(--reader-size); line-height: 1.8; }
.reader-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.note { margin-top: 22px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); }
.note h2 { font-size: 16px; margin: 0 0 4px; }
.note .md { font-size: calc(var(--reader-size) - 1px); }
.md { word-break: break-word; }
.md h1, .md h2, .md h3 { line-height: 1.4; margin: 1.3em 0 .5em; }
.md h1 { font-size: 1.3em; } .md h2 { font-size: 1.18em; } .md h3 { font-size: 1.06em; }
.md p, .md ul, .md ol, .md blockquote, .md pre, .md table { margin: .7em 0; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: .25em 0; }
.md blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; color: var(--muted); }
.md code { background: var(--code); border-radius: 5px; padding: 1px 5px; font-size: .9em; }
.md pre { background: var(--code); padding: 12px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md img { max-width: 100%; height: auto; border-radius: 8px; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; }
.md hr { border: 0; border-top: 1px solid var(--line); }
.preview { border: 1px dashed var(--line); border-radius: 10px; padding: 4px 14px; background: var(--panel); }

/* edit page */
.steps { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; margin-bottom: 18px; }
.steps p { margin: 8px 0; }
.steps textarea { font-size: 14px; color: var(--muted); }
.danger-zone { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

/* projects */
.projects { display: grid; gap: 14px; }
.proj { display: grid; gap: 14px; grid-template-columns: 1fr; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; scroll-margin-top: 72px; }
.proj img { width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; }
.proj h2 { font-size: 18px; margin: 0 0 6px; }
.proj p { margin: 4px 0; }
@media (min-width: 640px) { .proj:has(img) { grid-template-columns: 200px 1fr; } .proj img { height: 130px; } }
.proj-mini { display: flex; flex-wrap: wrap; gap: 8px; }
.proj-chip { padding: 6px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); font-size: 14px; }

/* footer */
.foot { border-top: 1px solid var(--line); background: var(--panel); padding: 18px 0 calc(18px + env(safe-area-inset-bottom)); text-align: center; font-size: 14px; }
.foot p { margin: 4px 0; }
.foot a { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }

/* likes */
.likes { display: inline-flex; align-items: center; gap: 3px; color: #e11d48; }
.share-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 26px 0 4px; }
.share-bar .like-btn { padding: 8px 16px; }
.like-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 22px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: inherit; font-size: 15px; cursor: pointer;
  transition: transform .12s ease, color .12s ease, border-color .12s ease;
}
.like-btn:hover { color: #e11d48; border-color: #e11d48; }
.like-btn.on { color: #e11d48; border-color: #e11d48; background: color-mix(in srgb, #e11d48 10%, var(--panel)); }
.like-btn:active { transform: scale(.94); }
.like-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* share image sheet */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .65); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.sheet-panel { width: min(440px, 100%); background: var(--panel); border-radius: 16px; padding: 14px; text-align: center; }
.sheet-panel p { margin: 4px 0 10px; }
.sheet-panel img { width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); display: block; -webkit-touch-callout: default; }
.sheet-panel .row { justify-content: center; margin-top: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: rgba(17, 20, 24, .9); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 15px; pointer-events: none; }

/* multi-user */
.author { font-weight: 600; color: var(--text); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.user-actions input { width: 140px; min-height: 34px; padding: 4px 10px; }
.tag-role { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.tag-off { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--inbox-bg); color: var(--inbox); }
.profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
@media (max-width: 640px) {
  .table.users thead { display: none; }
  .table.users tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table.users td { display: block; border: 0; padding: 3px 0; }
  .user-actions input { flex: 1; min-width: 0; }
}

/* 随手记 */
.place { display: inline-flex; align-items: center; gap: 2px; }
.me-links { margin: -6px 0 12px; }
.note-text { margin: 8px 0; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.note-text a { color: var(--text); }
.pgrid { display: grid; gap: 4px; margin: 10px 0; }
.pgrid a { display: block; overflow: hidden; border-radius: 8px; background: var(--code); }
.pgrid img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pgrid.g1 a { max-width: 100%; }
.pgrid.g1 img { height: auto; max-height: 70vh; object-fit: contain; }
.pgrid.g2 { grid-template-columns: repeat(2, 1fr); max-width: 520px; }
.pgrid.g3 { grid-template-columns: repeat(3, 1fr); max-width: 560px; }
.pgrid.g2 a, .pgrid.g3 a { aspect-ratio: 1; }
.note-card .pgrid.g1 img { max-height: 420px; width: auto; max-width: 100%; }
.note-reader .md { margin-top: 12px; }
.note-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 640px) { .note-strip { grid-template-columns: repeat(6, 1fr); } }
.note-tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--accent-soft); display: block; }
.note-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-text { display: block; padding: 8px; font-size: 13px; color: var(--text); }
.tile-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: 12px; color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, .55)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-tile:hover { text-decoration: none; }

/* photo picker */
.photo-pick { display: grid; gap: 10px; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.thumbs:empty { display: none; }
@media (min-width: 640px) { .thumbs { grid-template-columns: repeat(5, 1fr); } }
.thumb { position: relative; margin: 0; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--code); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb[data-state="busy"] img, .thumb[data-state="error"] img { opacity: .45; }
.t-status { position: absolute; left: 4px; right: 4px; bottom: 4px; font-size: 12px; line-height: 1.3; color: #fff;
  background: rgba(0, 0, 0, .55); border-radius: 6px; padding: 2px 4px; text-align: center; }
.t-status:empty { display: none; }
.thumb[data-state="error"] .t-status { background: rgba(185, 28, 28, .85); cursor: pointer; }
.t-btn { position: absolute; top: 4px; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55);
  color: #fff; font-size: 18px; line-height: 28px; padding: 0; cursor: pointer; }
.t-del { right: 4px; }
.t-left { left: 4px; }
.t-right { left: 36px; }
.add-photo { position: relative; justify-self: start; }
.add-photo input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; min-height: 0; }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .92); display: grid; place-items: center; touch-action: pan-y; }
.lightbox img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.lb-btn { position: absolute; border: 0; background: rgba(255, 255, 255, .15); color: #fff; width: 44px; height: 44px; border-radius: 50%;
  font-size: 26px; line-height: 44px; padding: 0; cursor: pointer; }
.lb-prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 10px; top: 50%; transform: translateY(-50%); }
.lb-close { right: 12px; top: calc(12px + env(safe-area-inset-top)); }
.lb-count { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: #ddd; font-size: 14px; }
.form label.add-photo { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-size: 15px; }
