:root {
  --bg: #f6f6f3; --surface: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e3e2dc;
  --accent: #2f5bd3; --accent-ink: #fff; --bad: #b3261e; --warn-bg: #fff4e0; --warn: #7a4b00;
  --pill: #efeee9; --code: #f3f2ee; --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --surface: #1d1d1b; --text: #ecebe6; --muted: #9c9b95; --line: #2f2f2c;
    --accent: #7c9cff; --accent-ink: #0e1220; --bad: #ff8a80; --warn-bg: #3a2c12; --warn: #ffd28a;
    --pill: #2a2a27; --code: #232321; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.warn { background: var(--warn-bg); color: var(--warn); padding: 8px 12px; border-radius: 8px; }

.top { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { font-weight: 650; font-size: 17px; }
.brand .muted { font-weight: 400; margin-left: 6px; font-size: 14px; }
.sync { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sync form { margin: 0; }

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--surface); }
.tabs button { background: none; color: var(--muted); border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 12px; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.tab > .grid2 { margin-bottom: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 6px; flex: 0 0 auto; color: var(--text); margin: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button { font: inherit; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:disabled { opacity: .6; cursor: progress; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.sm { padding: 4px 10px; font-size: 13px; }
button.danger { color: var(--bad); }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.filters input { flex: 1; min-width: 200px; }

.bundle { white-space: pre-wrap; background: var(--code); padding: 12px; border-radius: 8px; max-height: 420px; overflow: auto; margin: 0; }
.entries { display: grid; gap: 10px; margin-top: 12px; }
.entry { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; }
.entry .body { white-space: pre-wrap; margin: 4px 0 8px; }
.entry .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; margin-bottom: 6px; }
.entry .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dim { opacity: .55; }
.pill { background: var(--pill); padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.pill.k-idea { background: #e8f0ff; color: #1f45a8; } .pill.k-instruction { background: #fde8e8; color: #9b1c1c; }
.pill.k-decision { background: #e6f6ec; color: #17673a; } .pill.k-todo { background: #fff2d9; color: #7a4b00; }
@media (prefers-color-scheme: dark) {
  .pill.k-idea { background: #1d2a4d; color: #a9c0ff; } .pill.k-instruction { background: #4a1f1f; color: #ffb4b4; }
  .pill.k-decision { background: #173a26; color: #9be2b5; } .pill.k-todo { background: #3d2e12; color: #ffd28a; }
}
.tag { color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.nowrap { white-space: nowrap; }
input.inline { padding: 4px 6px; width: 120px; background: transparent; }
input.inline.wide { width: 100%; min-width: 220px; }

.snippet { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.code { position: relative; }
.code pre { background: var(--code); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 0; white-space: pre; }
.code .copy { position: absolute; top: 8px; right: 8px; background: var(--surface); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 10; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.error { color: var(--bad); }

/* bundle Markdown preview */
.seg { display: inline-flex; gap: 4px; }
.seg button[aria-pressed="true"] { background: var(--pill); border-color: var(--accent); }
.bundle.md { white-space: normal; line-height: 1.55; }
.bundle.md h3 { font-size: 16px; margin: 0 0 6px; }
.bundle.md h4 { font-size: 14px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.bundle.md h5, .bundle.md h6 { font-size: 14px; margin: 10px 0 4px; }
.bundle.md p { margin: 0 0 8px; }
.bundle.md ul { margin: 0 0 8px; padding-left: 20px; }
.bundle.md li { margin: 2px 0; overflow-wrap: anywhere; }
.bundle.md code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.bundle.md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.pill.private { border: 1px solid var(--warn); color: var(--warn); background: var(--warn-bg); }
#gdocInfo.bad { color: var(--bad); }
