:root {
  --bg: #f4f1ec; --ink: #1d1d1f; --muted: #6b6b70; --line: #e6e2db; --card: #fff;
  --accent: #2f6fed; --accent-soft: #e8efff;
  --open: #1f883d; --merged: #8250df; --closed: #cf222e;
  --note: #fff7d6; --note-line: #f0d98a; --note-ink: #5a4a12;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
h1, h2 { letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 4px 0; line-height: 1.3; }
h2 a { color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* logo */
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); }
.logo i { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.logo i::after { content: ""; position: absolute; inset: 6px 6px 8px 6px; border: 2px solid #fff; border-radius: 50%; }
.logo.big { font-size: 22px; } .logo.big i { width: 32px; height: 32px; border-radius: 9px; } .logo.big i::after { inset: 9px 9px 11px 9px; border-width: 3px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #d9c7a7; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #5b4a2b; object-fit: cover; flex: none; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; font-size: 14px; border: 1px solid #d8d8d8; background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--closed); }
.danger-text { color: var(--closed) !important; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; font-weight: 600; }
.input { width: 100%; border: 1px solid #d6d6d6; border-radius: 10px; padding: 10px 12px; background: #fff; color: var(--ink); font: inherit; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 96px; }
.field-label { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 14px 0 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid #d6d6d6; border-radius: 16px; padding: 6px 12px; font: inherit; font-size: 13px; background: #fff; color: var(--ink); cursor: pointer; }
.chip.on, .chip.radio:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip.radio input { position: absolute; opacity: 0; pointer-events: none; }
.toggles { padding: 2px 12px; gap: 0; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.toggle-row:last-child { border-bottom: 0; }
input.sw { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 11px; background: #ccc; position: relative; flex: none; cursor: pointer; margin: 0; transition: background .15s; }
input.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
input.sw:checked { background: var(--open); } input.sw:checked::after { left: 19px; }
.row { display: flex; gap: 8px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack > .field-label { margin-bottom: -2px; }
.paste { display: flex; gap: 8px; }
.paste .input { flex: 1; min-width: 0; }
.error, .warn, .ok { border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.error { background: #ffebe9; color: #82071e; border: 1px solid #ffcecb; }
.warn { background: #fff8c5; color: #6c5300; border: 1px solid #f0e2a0; font-size: 13px; }
.ok { background: #dafbe1; color: #116329; border: 1px solid #aceebb; }

/* cards */
.card { background: var(--card); border: 1px solid #eaeaea; border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; color: var(--ink); }
a.card:hover { border-color: #cfd8ea; }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card .title { font-weight: 600; }
.meta { color: var(--muted); font-size: 12.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; color: #fff; padding: 2px 8px; border-radius: 10px; }
.badge.open { background: var(--open); } .badge.merged { background: var(--merged); } .badge.closed { background: var(--closed); }
.note { background: var(--note); border: 1px solid var(--note-line); border-radius: 8px; padding: 8px 10px; font-size: 14px; color: var(--note-ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.note::before { content: "Why I saved this:"; display: block; font-weight: 700; }
.note.plain::before { content: none; }
.note:not(.plain) { white-space: normal; }
.note p, .note ul, .note ol, .note pre, .note blockquote { margin: 4px 0; }
.note ul, .note ol { padding-left: 20px; }
.note pre { overflow-x: auto; }
.note blockquote { padding-left: 8px; border-left: 3px solid var(--note-line); }
.card .note.plain { font-size: 13px; white-space: normal; }
.card .note.plain .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .note.plain .clamp > * { margin: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.account { flex-direction: row; align-items: center; gap: 12px; }

/* landing */
.landing { max-width: 420px; margin: 0 auto; padding: 56px 20px 40px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; }
.landing h1 { font-size: 26px; line-height: 1.2; margin: 4px 0 0; }
.landing .sample { width: 100%; text-align: left; }
.landing .btn.google { width: 100%; padding: 12px; }
.landing .dev { width: 100%; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.g { width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0); }

/* app shell: mobile first */
.appbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: #fff; border-bottom: 1px solid #eee; position: sticky; top: 0; z-index: 5; }
.appbar > :last-child { min-width: 40px; text-align: right; }
.tabs { display: flex; gap: 18px; padding: 0 16px; background: #fff; border-bottom: 1px solid #eee; }
.tabs a { padding: 10px 0; color: var(--muted); font-size: 14px; }
.tabs a span { font-size: 12px; }
.tabs a.on { color: var(--ink); font-weight: 600; border-bottom: 2px solid var(--ink); }
.list-body, .page-body { padding: 14px 16px 90px; display: flex; flex-direction: column; gap: 10px; }
.narrow { max-width: 640px; margin: 0 auto; min-height: 100vh; background: #fafafa; }
.side, .detail-empty { display: none; }
.has-detail .list { display: none; }
.detail { background: #fafafa; }
.detail-body { padding: 14px 16px 40px; display: flex; flex-direction: column; gap: 8px; }
.empty { text-align: center; padding: 40px 12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty .emoji { font-size: 40px; } .empty .title { font-weight: 700; font-size: 17px; }
.fab { position: fixed; right: 18px; bottom: max(20px, env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px; line-height: 52px; text-align: center; box-shadow: 0 4px 14px rgba(47,111,237,.45); }
.timeline { border-left: 2px solid #e5e5e5; margin: 2px 0 6px 6px; padding-left: 16px; display: flex; flex-direction: column; gap: 12px; }
.timeline > div { position: relative; font-size: 14px; }
.timeline > div a { color: var(--ink); }
.timeline > div::before { content: ""; position: absolute; left: -23px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #bbb; border: 2px solid #fafafa; }
.timeline > div.new::before { background: var(--accent); }
.timeline > div.new > a:first-child, .timeline > div.new { font-weight: 600; }
.excerpt { font-weight: 400; color: #555; font-size: 13px; border-left: 3px solid #e3e3e3; padding: 2px 8px; margin-top: 4px; white-space: pre-wrap; max-height: 7.5em; overflow: hidden; overflow-wrap: anywhere; }
.prefs summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.prefs form { display: flex; flex-direction: column; gap: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.actions form { display: contents; }
.actions .btn.primary { flex: 1 1 100%; }

/* edit-note sheet: bottom sheet on mobile, centered on desktop */
dialog.sheet { border: 0; padding: 18px; width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.15); }
dialog.sheet::backdrop { background: rgba(0,0,0,.35); }
dialog.sheet form { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 900px) {
  body { background: #eceae6; }
  .mobile-only { display: none !important; }
  .shell { display: grid; grid-template-columns: 210px minmax(320px, 1fr) minmax(360px, 440px); height: 100vh; }
  .side { display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; background: #fbfbfb; border-right: 1px solid #e8e8e8; }
  .side .logo { margin: 0 8px 14px; }
  .side-tabs { display: flex; flex-direction: column; gap: 2px; }
  .side-tabs a, .side-link { padding: 8px 10px; border-radius: 8px; color: #444; display: flex; justify-content: space-between; }
  .side-tabs a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .side-link { margin-top: auto; }
  .list, .has-detail .list { display: block; overflow-y: auto; background: #f7f6f3; border-right: 1px solid #e8e8e8; }
  .list-body { padding: 18px 18px 40px; }
  .detail { overflow-y: auto; }
  .detail-empty { display: flex; height: 100%; align-items: center; justify-content: center; padding: 20px; text-align: center; }
  .detail-body { padding: 20px 20px 40px; }
  .narrow { margin-top: 32px; min-height: 0; border-radius: 14px; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,.08); margin-bottom: 32px; }
  dialog.sheet { max-width: 520px; margin: auto; border-radius: 14px; }
}
