:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --side: #ecebe5;
  --card: #ffffff;
  --text: #1b1d1c;
  --muted: #63675f;
  --border: #dedcd3;
  --accent: #1f6f5c;
  --accent-soft: rgba(31, 111, 92, 0.12);
  --accent-text: #ffffff;
  --code-bg: #efeee8;
  --danger: #b3412e;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121413;
    --side: #171a19;
    --card: #1b1e1d;
    --text: #eceee9;
    --muted: #a0a59d;
    --border: #2e3330;
    --accent: #4cb898;
    --accent-soft: rgba(76, 184, 152, 0.16);
    --accent-text: #0d1a16;
    --code-bg: #232826;
    --danger: #ec7a64;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- layout: index left, page right ---------- */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--side);
  border-right: 1px solid var(--border);
  padding: 22px 14px 16px;
  display: flex; flex-direction: column;
}
.brand { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; color: inherit; text-decoration: none; padding: 0 8px; }
.tagline { margin: 0 0 16px; padding: 0 8px; color: var(--muted); font-size: 0.85rem; }

.index { flex: 1; }
.index > summary { list-style: none; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 0 8px 6px; cursor: default; }
.index > summary::-webkit-details-marker { display: none; }
.days, .pages { list-style: none; margin: 0; padding: 0; }

.day > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: 0.92rem;
  list-style: none;
}
.day > summary::-webkit-details-marker { display: none; }
.day > summary::before { content: "▸"; color: var(--muted); font-size: 0.75rem; width: 10px; transition: transform 0.15s; }
.day[open] > summary::before { transform: rotate(90deg); }
.day > summary:hover { background: var(--accent-soft); }
.d-date { flex: 1; }
.d-count { color: var(--muted); font-weight: 500; font-size: 0.8rem; }
.badge { font-size: 0.68rem; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-text); }

.pages { margin: 2px 0 6px 18px; border-left: 1px solid var(--border); }
.pages a {
  display: block; padding: 6px 10px; margin-left: -1px;
  border-left: 2px solid transparent;
  color: inherit; text-decoration: none; font-size: 0.9rem; line-height: 1.35;
}
.pages a:hover { background: var(--accent-soft); }
.pages a[aria-current="page"] { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.p-title { display: block; }
.p-meta { display: block; font-size: 0.75rem; color: var(--muted); font-weight: 400; margin-top: 2px; }

.side-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 14px 8px 0; margin-top: 12px; border-top: 1px solid var(--border); }
.all-tools { margin-left: auto; font-size: 0.82rem; color: var(--muted); text-decoration: none; }
.all-tools:hover { color: var(--accent); }

main { padding: 40px 48px 64px; max-width: 860px; width: 100%; outline: none; }

/* ---------- page ---------- */
.post-head { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.post-date { margin: 0 0 4px; color: var(--muted); font-size: 0.9rem; }
.post-head h1 { font-size: 2.1rem; line-height: 1.2; margin: 0; letter-spacing: -0.02em; }
.post-summary { margin: 8px 0 0; color: var(--muted); font-size: 1.05rem; }
.post-summary:empty { display: none; }
.pager { display: flex; justify-content: space-between; margin-top: 14px; font-size: 0.85rem; }
.pager-link { color: var(--accent); text-decoration: none; }
.pager-link:hover { text-decoration: underline; }
#older { margin-left: auto; }

.prose { margin-bottom: 32px; }
.prose h2 { font-size: 1.4rem; margin: 2em 0 0.5em; letter-spacing: -0.01em; }
.prose h3 { font-size: 1.15rem; margin: 1.6em 0 0.4em; }
.prose h4, .prose h5 { font-size: 1rem; margin: 1.4em 0 0.4em; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose li + li { margin-top: 0.25em; }
.prose a { color: var(--accent); }
.prose img { max-width: 100%; border-radius: 8px; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.prose blockquote { margin: 0 0 1em; padding: 10px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { font: 0.88em/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 5px; }
.prose pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; margin: 0 0 1em; }
.prose pre code { background: none; padding: 0; font-size: 0.85rem; line-height: 1.45; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--code-bg); font-weight: 600; }
.muted { color: var(--muted); }

/* ---------- checklist + comments ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.card h2 { font-size: 0.78rem; margin: 0 0 10px; color: var(--muted); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.progress { font-size: 0.85rem; color: var(--muted); }

.checklist, .comments { list-style: none; margin: 0 0 12px; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.checklist li + li { border-top: 1px solid var(--border); }
.checklist input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); margin: 0; }
.checklist label { flex: 1; min-width: 0; overflow-wrap: anywhere; cursor: pointer; }
.checklist li.done label { text-decoration: line-through; color: var(--muted); }
.checklist li.empty, .comments:empty { color: var(--muted); }

.comments li { padding: 10px 0; }
.comments li + li { border-top: 1px solid var(--border); }
.c-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: var(--muted); }
.c-text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

input, textarea {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.add-row { display: flex; gap: 8px; }
.comment-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }
.hint { font-size: 0.78rem; color: var(--muted); }

.btn {
  font: inherit; font-weight: 600;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; white-space: nowrap;
}
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); font-weight: 500; }
.btn.small { padding: 5px 10px; font-size: 0.82rem; }
.btn:focus-visible, .pages a:focus-visible, .day > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.del { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.del:hover { color: var(--danger); background: var(--accent-soft); }
.file { position: relative; overflow: hidden; }
.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; }

.local-note { font-size: 0.82rem; color: var(--muted); margin: 20px 0 0; }
.warn { color: var(--danger); font-size: 0.85rem; }
[hidden] { display: none !important; }

/* ---------- phones / narrow windows: index collapses above the page ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 16px 16px 12px; }
  .brand, .tagline, .index > summary { padding-left: 0; padding-right: 0; }
  .tagline { margin-bottom: 10px; }
  .index > summary {
    cursor: pointer; list-style: none;
    font-size: 0.9rem; text-transform: none; letter-spacing: 0; color: var(--text);
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card);
  }
  .index > summary::after { content: " ▾"; color: var(--muted); }
  .index[open] > summary { margin-bottom: 8px; }
  .side-foot { padding: 12px 0 0; }
  main { padding: 24px 16px 48px; }
  .post-head h1 { font-size: 1.6rem; }
  .card { padding: 14px; }
  .hint { display: none; }
}
