/* ————— Second Brain — parchment & ink ————— */

:root {
  --bg: #f6f1e6;
  --bg-deep: #efe8d8;
  --surface: #fdfaf2;
  --surface-2: #f3edde;
  --ink: #251f15;
  --ink-soft: #4d4536;
  --muted: #857a66;
  --faint: #a89d88;
  --line: #e2d8c2;
  --line-strong: #cfc2a6;
  --accent: #9c3d1c;
  --accent-soft: #9c3d1c1a;
  --gold: #b07c22;
  --shadow: 0 1px 2px #2a220f0a, 0 8px 32px #2a220f14;
  --shadow-lg: 0 4px 12px #2a220f14, 0 24px 64px #2a220f29;

  --c-concept: #22766c;
  --c-entity: #a86f14;
  --c-source: #43648f;
  --c-briefing: #82467a;
  --c-raw: #8a8172;
  --c-page: #6d6353;

  --sans: 'IBM Plex Sans', ui-sans-serif, sans-serif;
  --serif: 'Newsreader', Georgia, serif;
  --display: 'Fraunces', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #16120b;
  --bg-deep: #100d08;
  --surface: #1f1a11;
  --surface-2: #262013;
  --ink: #eae1cd;
  --ink-soft: #c9bda2;
  --muted: #94886f;
  --faint: #6e644f;
  --line: #2f2818;
  --line-strong: #453a22;
  --accent: #d97f4a;
  --accent-soft: #d97f4a21;
  --gold: #c99b45;
  --shadow: 0 1px 2px #00000033, 0 8px 32px #00000052;
  --shadow-lg: 0 4px 12px #00000059, 0 24px 64px #00000080;

  --c-concept: #58b3a7;
  --c-entity: #d4a04a;
  --c-source: #7d9fce;
  --c-briefing: #bd7bb2;
  --c-raw: #9a8f7c;
  --c-page: #a29680;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  height: 100%;
  overflow: hidden;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* paper grain */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none; z-index: 999;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.45 0 0 0 0 0.35 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app { display: flex; height: 100vh; }

::selection { background: var(--accent-soft); }

/* ————— sidebar ————— */

#sidebar {
  width: 288px; flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--bg-deep), var(--bg));
  border-right: 1px solid var(--line);
  padding: 22px 18px 14px;
  display: flex; flex-direction: column; gap: 18px;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}

.brand {
  display: flex; align-items: baseline; gap: 10px;
  cursor: pointer; user-select: none;
  padding: 2px 6px;
}
.brand-glyph {
  color: var(--accent); font-size: 15px;
  animation: glyphIn .8s cubic-bezier(.2,1.4,.4,1);
}
.brand-name {
  font-family: var(--display); font-weight: 700;
  font-size: 21px; letter-spacing: .01em;
}
@keyframes glyphIn { from { transform: rotate(-120deg) scale(0); } }

#search-trigger {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted); font-family: var(--sans); font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
#search-trigger:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
#search-trigger kbd { margin-left: auto; }

kbd {
  font-family: var(--mono); font-size: 10.5px;
  padding: 2px 6px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted);
}

.main-nav { display: flex; flex-direction: column; gap: 1px; }
.main-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--ink-soft); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.main-nav a:hover { background: var(--surface-2); }
.main-nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav-ico { width: 16px; text-align: center; font-size: 13px; opacity: .8; }

/* note tree */
#note-tree { display: flex; flex-direction: column; gap: 16px; }
.tree-section {}
.tree-head {
  display: flex; align-items: center; gap: 7px;
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  padding: 0 10px 6px;
  cursor: pointer; user-select: none;
}
.tree-head .dot { width: 7px; height: 7px; border-radius: 50%; }
.tree-head .cnt { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.tree-items { display: flex; flex-direction: column; }
.tree-section.collapsed .tree-items { display: none; }
.tree-items a {
  display: block; padding: 4.5px 10px 4.5px 24px;
  color: var(--ink-soft); text-decoration: none;
  font-size: 13px; border-radius: 7px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-left: 2px solid transparent;
  transition: background .12s;
}
.tree-items a:hover { background: var(--surface-2); }
.tree-items a.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

/* tags */
#tag-cloud { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 4px; }
.tag {
  font-family: var(--mono); font-size: 11px;
  padding: 2.5px 9px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); text-decoration: none;
  transition: all .12s;
  cursor: pointer;
}
.tag:hover, .tag.active { border-color: var(--accent); color: var(--accent); }

.sidebar-foot {
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
#theme-toggle {
  display: flex; align-items: center; gap: 7px;
  background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 11px; cursor: pointer;
  color: var(--muted); font-family: var(--sans); font-size: 12px;
  transition: all .15s;
}
#theme-toggle:hover { border-color: var(--line-strong); color: var(--ink-soft); }
#vault-stat { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }

/* ————— main ————— */

#main {
  flex: 1; height: 100%; overflow-y: auto;
  position: relative;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
#content { min-height: 100%; }

#hamburger { display: none; }
#sidebar-scrim { display: none; }

.view { animation: viewIn .35s cubic-bezier(.2,.8,.3,1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } }

/* ————— home ————— */

.home { max-width: 880px; margin: 0 auto; padding: 64px 48px 80px; }

.home-eyebrow {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--accent);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 12px;
}
.home-eyebrow::after { content: ''; height: 1px; width: 64px; background: var(--accent); opacity: .4; }

.home h1 {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(34px, 5vw, 52px); line-height: 1.08;
  letter-spacing: -.015em;
  margin-bottom: 18px;
}
.home h1 em { font-style: italic; color: var(--accent); }

.home-sub {
  font-family: var(--serif); font-size: 18px; line-height: 1.6;
  color: var(--ink-soft); max-width: 560px;
  margin-bottom: 40px;
}

.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; margin-bottom: 52px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px 14px;
  position: relative; overflow: hidden;
  transition: transform .18s, box-shadow .18s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--tc, var(--accent));
  opacity: .75;
}
.stat-num { font-family: var(--display); font-weight: 700; font-size: 30px; line-height: 1; }
.stat-lbl { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }

.home h2.sect {
  font-family: var(--display); font-weight: 600; font-size: 22px;
  margin: 44px 0 18px;
  display: flex; align-items: baseline; gap: 12px;
}
.home h2.sect .rule { flex: 1; height: 1px; background: var(--line); }

.note-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.note-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px;
  text-decoration: none; color: var(--ink);
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative;
}
.note-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.note-card .nc-type {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--tc, var(--muted));
  display: flex; align-items: center; gap: 6px;
}
.note-card .nc-type::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--tc, var(--muted)); }
.note-card .nc-title { font-family: var(--display); font-weight: 600; font-size: 16.5px; line-height: 1.25; }
.note-card .nc-excerpt {
  font-family: var(--serif); font-size: 13.5px; line-height: 1.5; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.note-card .nc-meta { margin-top: auto; font-family: var(--mono); font-size: 10.5px; color: var(--faint); }

/* activity feed */
.feed { display: flex; flex-direction: column; }
.feed-item {
  display: grid; grid-template-columns: 96px 74px 1fr; gap: 16px;
  padding: 13px 4px; border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.feed-date { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.feed-kind {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; text-align: center;
  border: 1px solid var(--line); color: var(--muted);
  justify-self: start;
}
.feed-kind.ingest { color: var(--c-concept); border-color: var(--c-concept); }
.feed-kind.query { color: var(--c-source); border-color: var(--c-source); }
.feed-kind.update, .feed-kind.lint { color: var(--gold); border-color: var(--gold); }
.feed-title { font-size: 14px; font-weight: 500; }
.feed-detail { grid-column: 3; font-family: var(--serif); font-size: 13.5px; color: var(--muted); line-height: 1.5; margin-top: 2px; }

/* ————— note view ————— */

.note-page { max-width: 760px; margin: 0 auto; padding: 56px 48px 120px; }

.crumbs {
  font-family: var(--mono); font-size: 11.5px; color: var(--faint);
  margin-bottom: 26px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.crumbs a { color: var(--faint); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .5; }

.note-head { margin-bottom: 12px; }
.note-type-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--tc, var(--muted));
  margin-bottom: 14px;
}
.note-type-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--tc, var(--muted)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc, var(--muted)) 18%, transparent); }

.note-page h1.note-title {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(30px, 4.4vw, 42px); line-height: 1.12; letter-spacing: -.015em;
  margin-bottom: 16px;
}

.note-meta-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  padding-bottom: 22px; margin-bottom: 34px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
}
.note-meta-row .tag { font-size: 10.5px; }

/* markdown body */
.md {
  font-family: var(--serif);
  font-size: 17.5px; line-height: 1.72;
  color: var(--ink);
}
.md > * + * { margin-top: 1.1em; }
.md h1, .md h2, .md h3, .md h4 {
  font-family: var(--display); font-weight: 600; line-height: 1.25;
  letter-spacing: -.01em;
  margin-top: 1.9em;
}
.md h1 { font-size: 28px; } .md h2 { font-size: 23px; } .md h3 { font-size: 19px; } .md h4 { font-size: 16.5px; }
.md h2 { padding-bottom: .35em; border-bottom: 1px solid var(--line); }
.md a { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); transition: border-color .12s; }
.md a:hover { border-bottom-color: var(--accent); }
.md a.wikilink { font-family: var(--sans); font-size: .92em; font-weight: 500; background: var(--accent-soft); padding: 1px 6px 2px; border-radius: 6px; border-bottom: none; }
.md a.wikilink:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.md a.wikilink.broken { background: var(--surface-2); color: var(--muted); cursor: default; }
.md a.wikilink::before { content: '⌗ '; font-size: .85em; opacity: .65; }
.md strong { font-weight: 600; }
.md em { font-style: italic; }
.md ul, .md ol { padding-left: 1.5em; }
.md li + li { margin-top: .35em; }
.md li::marker { color: var(--accent); }
.md blockquote {
  border-left: 3px solid var(--gold);
  padding: .3em 0 .3em 1.2em;
  color: var(--ink-soft); font-style: italic;
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 7%, transparent), transparent);
  border-radius: 0 8px 8px 0;
}
.md code {
  font-family: var(--mono); font-size: .82em;
  background: var(--surface-2); border: 1px solid var(--line);
  padding: .12em .38em; border-radius: 5px;
}
.md pre {
  background: var(--bg-deep); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px; line-height: 1.6;
}
.md pre code { background: none; border: none; padding: 0; font-size: inherit; }
.md table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 13.5px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); font-weight: 600; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
.md tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.md img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.md hr { border: none; text-align: center; margin: 2.4em 0; }
.md hr::after { content: '❧'; color: var(--gold); font-size: 18px; }

/* backlinks */
.backlinks { margin-top: 72px; }
.backlinks h3 {
  font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.backlinks h3::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.backlink-list { display: grid; gap: 10px; }
.backlink-item {
  display: block; padding: 13px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.backlink-item:hover { border-color: var(--line-strong); transform: translateX(3px); }
.backlink-item .bl-title { font-family: var(--display); font-weight: 600; font-size: 15px; }
.backlink-item .bl-excerpt { font-family: var(--serif); font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* ————— graph view ————— */

.graph-wrap { position: absolute; inset: 0; overflow: hidden; }
#graph-canvas { position: absolute; inset: 0; cursor: grab; }
#graph-canvas.dragging { cursor: grabbing; }
.graph-legend {
  position: absolute; left: 24px; bottom: 20px;
  display: flex; flex-direction: column; gap: 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
}
.graph-legend .lg-row { display: flex; align-items: center; gap: 9px; }
.graph-legend .lg-dot { width: 9px; height: 9px; border-radius: 50%; }
.graph-title {
  position: absolute; top: 26px; left: 50%; transform: translateX(-50%);
  font-family: var(--display); font-weight: 600; font-size: 20px;
  color: var(--ink); opacity: .85; pointer-events: none;
}
.graph-hint {
  position: absolute; right: 24px; bottom: 20px;
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
}

/* ————— palette ————— */

#palette-overlay[hidden], #preview-pop[hidden] { display: none; }
#palette-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: color-mix(in srgb, var(--bg-deep) 55%, transparent);
  backdrop-filter: blur(4px);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 14vh;
}
#palette {
  width: min(620px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: palIn .18s cubic-bezier(.2,1.2,.4,1);
}
@keyframes palIn { from { opacity: 0; transform: translateY(-12px) scale(.98); } }
#palette-input {
  width: 100%; padding: 17px 20px;
  background: none; border: none; outline: none;
  font-family: var(--serif); font-size: 18px; color: var(--ink);
  border-bottom: 1px solid var(--line);
}
#palette-input::placeholder { color: var(--faint); }
#palette-results { max-height: 46vh; overflow-y: auto; padding: 8px; }
.pal-item {
  display: block; padding: 10px 14px; border-radius: 10px;
  text-decoration: none; color: var(--ink); cursor: pointer;
}
.pal-item.sel { background: var(--accent-soft); }
.pal-item .pi-top { display: flex; align-items: center; gap: 9px; }
.pal-item .pi-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pal-item .pi-title { font-weight: 500; font-size: 14px; }
.pal-item .pi-type { margin-left: auto; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--faint); }
.pal-item .pi-snippet { font-family: var(--serif); font-size: 12.5px; color: var(--muted); margin: 4px 0 0 16px; line-height: 1.45; }
.pal-item .pi-snippet mark { background: color-mix(in srgb, var(--gold) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.pal-empty { padding: 26px; text-align: center; font-family: var(--serif); font-style: italic; color: var(--muted); }
.palette-hints {
  padding: 9px 16px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  display: flex; gap: 14px;
}

/* ————— hover preview ————— */

#preview-pop {
  position: fixed; z-index: 900;
  width: 340px; max-height: 300px; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 16px 18px;
  animation: palIn .15s ease-out;
  pointer-events: none;
}
#preview-pop .pv-type { font-family: var(--mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--tc, var(--muted)); margin-bottom: 6px; }
#preview-pop .pv-title { font-family: var(--display); font-weight: 600; font-size: 16px; margin-bottom: 6px; }
#preview-pop .pv-body { font-family: var(--serif); font-size: 13px; line-height: 1.55; color: var(--ink-soft); }
#preview-pop::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 60px;
  background: linear-gradient(transparent, var(--surface));
}

/* ————— search / tag views ————— */

.list-page { max-width: 760px; margin: 0 auto; padding: 56px 48px 100px; }
.list-page h1 { font-family: var(--display); font-weight: 600; font-size: 32px; margin-bottom: 8px; }
.list-page .lp-sub { font-family: var(--serif); color: var(--muted); font-size: 15px; margin-bottom: 32px; }

/* ————— loading ————— */

.loading {
  display: flex; align-items: center; justify-content: center;
  height: 60vh; color: var(--faint);
  font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .4; } }

/* ————— login & setup ————— */

#login-screen, #setup-screen {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
#login-screen[hidden], #setup-screen[hidden], #app[hidden], #capture-overlay[hidden] { display: none; }
.login-card {
  width: min(400px, 100%);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 44px 40px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: palIn .3s cubic-bezier(.2,1.2,.4,1);
}
.login-glyph { color: var(--accent); font-size: 26px; margin-bottom: 14px; animation: glyphIn .8s cubic-bezier(.2,1.4,.4,1); }
.login-card h1 { font-family: var(--display); font-weight: 700; font-size: 28px; margin-bottom: 6px; }
.login-sub { font-family: var(--serif); font-style: italic; color: var(--muted); margin-bottom: 26px; }
#login-form { display: flex; gap: 8px; }
#login-form input {
  flex: 1; padding: 11px 14px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px;
  font-family: var(--mono); font-size: 14px; color: var(--ink);
  outline: none; letter-spacing: .08em;
}
#login-form input:focus { border-color: var(--accent); }
#login-form button, .btn-primary {
  padding: 11px 20px;
  background: var(--accent); color: var(--surface);
  border: none; border-radius: 10px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
#login-form button:hover, .btn-primary:hover { filter: brightness(1.12); }
#login-form button:active, .btn-primary:active { transform: scale(.98); }
#login-error { margin-top: 14px; color: var(--accent); font-size: 13px; min-height: 18px; }
.setup-card { text-align: left; width: min(560px, 100%); }
.setup-card h1, .setup-card .login-glyph, .setup-card .login-sub { text-align: center; }
.setup-steps { font-size: 13.5px; line-height: 1.7; color: var(--ink-soft); }
.setup-steps ol { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.setup-steps code { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; }
.setup-steps a { color: var(--accent); }

/* ————— capture button ————— */

#capture-btn {
  width: 100%; padding: 10px 14px;
  background: var(--accent); color: var(--surface);
  border: none; border-radius: 10px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600; letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
  transition: filter .15s, transform .1s;
}
#capture-btn:hover { filter: brightness(1.12); }
#capture-btn:active { transform: scale(.98); }

#logout-btn {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 9px; cursor: pointer; color: var(--muted); font-size: 12px;
}
#logout-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ————— capture modal ————— */

#capture-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: color-mix(in srgb, var(--bg-deep) 55%, transparent);
  backdrop-filter: blur(4px);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 9vh;
}
#capture-modal {
  width: min(640px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 14px 18px 18px;
  animation: palIn .18s cubic-bezier(.2,1.2,.4,1);
}
.cap-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 16px; }
.cap-tab {
  background: none; border: 1px solid transparent; border-radius: 8px;
  padding: 7px 13px; cursor: pointer;
  font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--muted);
}
.cap-tab:hover { background: var(--surface-2); }
.cap-tab.active { background: var(--accent-soft); color: var(--accent); }
.cap-close { margin-left: auto; background: none; border: none; color: var(--faint); cursor: pointer; font-size: 15px; padding: 6px 10px; }
.cap-close:hover { color: var(--accent); }

.cap-pane { display: flex; flex-direction: column; gap: 10px; }
.cap-pane[hidden] { display: none; }
.cap-pane input[type=text], .cap-pane input[type=url], .cap-pane select, .cap-pane textarea, .ed-title, #ed-tags, #ed-type {
  padding: 10px 13px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 9px;
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  outline: none; width: 100%;
}
.cap-pane input:focus, .cap-pane textarea:focus, .ed-title:focus, .ed-content:focus, #ed-tags:focus { border-color: var(--accent); }
#cap-title, .ed-title { font-family: var(--display); font-weight: 600; font-size: 18px; }
.cap-row { display: flex; gap: 10px; }
.cap-row select { width: 160px; flex-shrink: 0; }
#cap-content {
  min-height: 220px; resize: vertical;
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
}
.cap-actions { display: flex; align-items: center; gap: 14px; }
.cap-hint { font-family: var(--serif); font-size: 14px; color: var(--muted); font-style: italic; }
#cap-status { font-size: 12.5px; margin-top: 10px; min-height: 16px; font-family: var(--mono); }
#cap-status.ok { color: var(--c-concept); }
#cap-status.err { color: var(--accent); }

#drop-zone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 2px dashed var(--line-strong); border-radius: 12px;
  padding: 38px 20px; cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
}
#drop-zone:hover, #drop-zone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dz-icon { font-size: 26px; color: var(--accent); }
.dz-label { font-weight: 500; font-size: 14px; }
.dz-sub { font-family: var(--mono); font-size: 11px; color: var(--faint); }

/* ————— note actions & editor ————— */

.crumb-actions { margin-left: auto; display: flex; gap: 8px; }
.mini-btn {
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px;
  padding: 4px 11px; cursor: pointer;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  transition: all .12s;
}
.mini-btn:hover { border-color: var(--line-strong); color: var(--ink-soft); }
.mini-btn.danger:hover { border-color: var(--accent); color: var(--accent); }

.editor-page { display: flex; flex-direction: column; gap: 12px; }
.ed-title { font-size: 26px !important; }
.ed-content {
  width: 100%; min-height: 340px; resize: vertical;
  padding: 16px 18px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 12px;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.65; color: var(--ink);
  outline: none;
}
#ed-status { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ————— responsive ————— */

@media (max-width: 860px) {
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 500;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.2,.8,.3,1);
    box-shadow: none;
    width: 300px;
  }
  body.sidebar-open #sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
  body.sidebar-open #sidebar-scrim {
    display: block; position: fixed; inset: 0; z-index: 400;
    background: #00000045;
  }
  #hamburger {
    display: flex; flex-direction: column; gap: 4px; justify-content: center;
    position: fixed; top: 14px; left: 14px; z-index: 300;
    width: 40px; height: 40px; align-items: center;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    cursor: pointer;
  }
  #hamburger span { width: 16px; height: 1.5px; background: var(--ink-soft); border-radius: 2px; }
  .home, .note-page, .list-page { padding-left: 24px; padding-right: 24px; padding-top: 72px; }
  .feed-item { grid-template-columns: 80px 1fr; }
  .feed-kind { display: none; }
  .feed-detail { grid-column: 2; }
}
