:root {
  --bg: #f5f4f1;
  --panel: #ffffff;
  --ink: #16150f;
  --muted: #6b675d;
  --line: #e2ded4;
  --accent: #1a5c3a;
  --accent-ink: #ffffff;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 16px; height: 16px; border-radius: 4px; background: var(--accent); display: inline-block; }
.wordmark { font-weight: 700; letter-spacing: -0.01em; font-size: 18px; }
.project-chip { font-size: 12px; color: var(--muted); background: var(--bg); padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line); }
.token-area { display: flex; gap: 8px; }
.token-area input { width: 200px; }

input, select, button, textarea { font-family: var(--font); font-size: 14px; }
input, select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
button {
  padding: 9px 16px; border: none; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  cursor: pointer; font-weight: 600;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }

main { max-width: 1080px; margin: 0 auto; padding: 24px 22px 60px; }

.capture-row { display: flex; gap: 8px; }
.capture-row #captureInput { flex: 1; }
.msg { min-height: 18px; font-size: 13px; margin-top: 8px; color: var(--muted); }
.msg.ok { color: var(--accent); }
.msg.err { color: #a3341f; }

.search { margin: 20px 0 8px; }
.search input { width: 100%; padding: 12px 14px; font-size: 16px; }

.columns { display: grid; grid-template-columns: 1fr 260px; gap: 26px; margin-top: 18px; }
@media (max-width: 760px) { .columns { grid-template-columns: 1fr; } }

.col-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.col-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0; font-weight: 700; }
.count { font-size: 12px; color: var(--muted); }

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: border-color .12s;
}
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 600; }
.card .card-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.card .snip { margin-top: 8px; font-size: 13px; color: #48453d; }
.tag { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; font-size: 11px; color: var(--muted); }
.score { color: var(--accent); font-weight: 600; }

.themes { display: flex; flex-direction: column; gap: 6px; }
.theme-item {
  display: flex; justify-content: space-between; align-items: center; padding: 8px 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.theme-item .n { color: var(--muted); font-size: 12px; }

.modal { position: fixed; inset: 0; background: rgba(20,19,15,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow: auto; z-index: 50; }
.modal.hidden { display: none; }
.modal-card { background: var(--panel); border-radius: 12px; max-width: 760px; width: 100%; padding: 28px 30px; position: relative; }
.close { position: absolute; top: 14px; right: 14px; background: transparent; color: var(--muted); font-size: 22px; padding: 4px 10px; }
.close:hover { color: var(--ink); filter: none; }
.doc-meta { font-size: 12px; color: var(--muted); margin: 6px 0 14px; display: flex; gap: 10px; flex-wrap: wrap; }
.doc-summary { background: var(--bg); border-radius: 8px; padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.doc-text { white-space: pre-wrap; font-family: var(--font); font-size: 14px; line-height: 1.6; color: #33302a; max-height: 55vh; overflow: auto; margin: 0; }
.empty { color: var(--muted); font-size: 14px; padding: 24px 0; }
