:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede7;
  --border: #e3e0d7;
  --border-strong: #cfcbbf;
  --text: #1d1c1a;
  --muted: #6f6b62;
  --accent: #4338ca;
  --accent-soft: #e6e5fb;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --mark: #fde68a;
  --shadow: 0 1px 2px rgb(0 0 0 / .04), 0 4px 16px rgb(0 0 0 / .05);
  --shadow-lg: 0 10px 40px rgb(0 0 0 / .18);
  --t-quote: #b45309; --t-text: #475569; --t-article: #047857; --t-url: #1d4ed8; --t-image: #be185d; --t-note: #7c3aed; --t-event: #0e7490;
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212; --surface: #1b1b1b; --surface-2: #252525; --border: #2e2e2e; --border-strong: #404040;
    --text: #ecebe7; --muted: #9a968c; --accent: #8b93ff; --accent-soft: #272a4a; --accent-ink: #0d0d1a;
    --danger: #f97066; --mark: #7c5e10;
    --shadow: 0 1px 2px rgb(0 0 0 / .4); --shadow-lg: 0 10px 40px rgb(0 0 0 / .6);
    --t-quote: #fbbf24; --t-text: #94a3b8; --t-article: #34d399; --t-url: #60a5fa; --t-image: #f472b6; --t-note: #a78bfa; --t-event: #22d3ee;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
kbd {
  font: 11px/1 var(--mono); padding: 3px 5px; border-radius: 5px;
  border: 1px solid var(--border-strong); color: var(--muted); background: var(--surface);
}
.btn.primary kbd { background: transparent; color: inherit; border-color: currentColor; opacity: .7; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---- Top bar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; font-size: 17px; width: 216px; flex: none; }
.brand-mark { display: block; width: 30px; height: 30px; border-radius: 9px; background: #fff; object-fit: contain; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0;
  height: 40px; padding: 0 12px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--border);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .ic { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; }
.search input::-webkit-search-cancel-button { display: none; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.recommend-btn { flex: none; }
.rec-status { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; flex-basis: 100%; }
.rec-status p { margin: 0; flex: 1 1 220px; }
.review-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; padding: 12px 14px;
  border-radius: 12px; background: var(--accent-soft); border: 1px solid var(--accent);
}
.review-banner[hidden] { display: none; }
.review-spin { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: review-spin 1s linear infinite; }
@keyframes review-spin { to { transform: rotate(360deg); } }
.review-text { flex: 1 1 220px; display: grid; gap: 2px; min-width: 0; }
.review-timer { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
select {
  height: 36px; padding: 0 28px 0 10px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
  appearance: none; -webkit-appearance: none;
}
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--muted);
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.seg { display: flex; padding: 2px; border-radius: 10px; background: var(--surface-2); }
.seg button { display: grid; place-items: center; width: 34px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filter-toggle { display: none; }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: 42px; width: 250px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg);
}
.menu-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: 8px; background: transparent; text-align: left;
}
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.menu-note { margin: 4px 10px 6px; font-size: 12px; color: var(--muted); }

/* ---- Layout -------------------------------------------------------------- */
.layout {
  display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 28px;
  max-width: 1440px; margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.sidebar { position: sticky; top: 62px; align-self: start; max-height: calc(100vh - 80px); overflow: auto; padding: 20px 0; }
/* Everything above the first item stays put under the top bar while the items scroll beneath it. */
.pinned {
  position: sticky; top: var(--topbar-h, 0px); z-index: 10;
  max-height: var(--pinned-max, none); overflow-y: auto; overscroll-behavior: contain;
  margin: 0 -6px 12px; padding: 20px 6px 0;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
/* A short screen (a phone on its side) has no room for it, so it scrolls away there. */
@media (max-height: 560px) { .pinned { position: static; max-height: none; overflow: visible; } }
.sidebar h4 { margin: 18px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.sidebar h4:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar select { width: 100%; }
.nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px;
  border: 0; border-radius: 9px; background: transparent; text-align: left; color: var(--text);
}
.nav-btn .ic { width: 16px; height: 16px; color: var(--muted); }
.nav-btn:hover { background: var(--surface-2); }
.nav-btn.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-btn.on .ic { color: var(--accent); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-badge { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { margin: 20px 10px 0; font-size: 12px; color: var(--muted); line-height: 1.9; }
.hint code { font: 11px var(--mono); padding: 2px 5px; border-radius: 5px; background: var(--surface-2); white-space: nowrap; }
.scrim { display: none; }

/* ---- Composer ------------------------------------------------------------ */
.composer {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 14px 10px; margin-bottom: 22px;
  transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within, .composer.is-active { border-color: var(--border-strong); }
.composer textarea, .composer input {
  width: 100%; border: 0; outline: 0; background: transparent; resize: none;
}
#cap-text { font-size: 16px; min-height: 28px; max-height: 320px; padding: 2px 2px; }
.cap-fields { display: none; gap: 8px; grid-template-columns: 1fr 1fr; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.composer.is-active .cap-fields, .composer:focus-within .cap-fields { display: grid; }
.cap-fields > input, .cap-fields > textarea, .cap-fields .chips-input {
  border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; font-size: 14px; background: var(--bg);
}
.cap-fields > input:focus, .cap-fields > textarea:focus, .cap-fields .chips-input:focus-within { border-color: var(--accent); }
#cap-note { grid-column: 1 / -1; }
.cap-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.cap-hint { font-size: 12px; color: var(--muted); margin-left: 6px; }
.spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  border-radius: 9px; border: 1px solid var(--border); background: var(--surface); font-size: 14px; font-weight: 500;
}
.btn .ic { width: 16px; height: 16px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .4; cursor: default; }
.btn.danger { color: var(--danger); }
.cap-preview { display: grid; gap: 8px; margin-top: 4px; }
.pending {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px;
  border-radius: 10px; background: var(--bg); border: 1px solid var(--border);
}
.pending-body { flex: 1; min-width: 0; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.pending img { max-height: 120px; max-width: 100%; border-radius: 6px; display: block; }

/* chip input */
.chips-input { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; min-height: 36px; }
.chips-input input { flex: 1; min-width: 90px; border: 0 !important; padding: 0 !important; background: transparent; outline: 0; }
.chips { display: contents; }
.chip {
  display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 8px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 500; border: 0;
}
.chip button { border: 0; background: transparent; color: inherit; padding: 0 0 0 2px; font-size: 15px; line-height: 1; opacity: .7; }
button.chip:hover { filter: brightness(.95); }

/* ---- Results ------------------------------------------------------------- */
.results-head { display: flex; align-items: center; gap: 8px; margin: 0 2px 8px; min-height: 28px; }
.count { margin: 0; font-size: 13px; color: var(--muted); }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.active-filters .chip { background: var(--surface-2); color: var(--text); }
.results.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; align-items: start; }
/* Masonry: 1px rows; each card spans its own height plus the gap (set in app.js). */
.results.grid.masonry { grid-auto-rows: 1px; row-gap: 0; }
.results.list { display: flex; flex-direction: column; gap: 8px; }

.card {
  position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  padding: 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); cursor: pointer;
  transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--border-strong); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; }
.card-head time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.card-head .badge { margin-right: auto; }
.card-quick { display: flex; margin: -6px -6px -6px auto; }
.card-quick .icon-btn { width: 30px; height: 30px; }
.card-quick .icon-btn .ic { width: 15px; height: 15px; }
.card-quick .icon-btn.danger:hover { color: var(--danger); }
.stamp { border: 0; background: none; padding: 2px 4px; margin: -2px -4px; border-radius: 6px; font: inherit; color: var(--muted); cursor: pointer; }
.stamp:hover { background: var(--surface-2); color: var(--text); }
.stamp:hover time { color: inherit; }
.detail-head .stamp { font-size: 13px; }
.badge { --c: var(--t-text); display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--c); }
.badge .ic { width: 14px; height: 14px; }
.type-quote .badge, .badge.type-quote { --c: var(--t-quote); }
.type-article .badge, .badge.type-article { --c: var(--t-article); }
.type-url .badge, .badge.type-url { --c: var(--t-url); }
.type-image .badge, .badge.type-image { --c: var(--t-image); }
.type-note .badge, .badge.type-note { --c: var(--t-note); }
.type-event .badge, .badge.type-event { --c: var(--t-event); }
.card-title { margin: 0; font-size: 15.5px; line-height: 1.35; font-weight: 650; letter-spacing: -.005em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.excerpt { font-size: 14px; line-height: 1.55; color: var(--text); white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden; }
.excerpt.is-quote { font-family: var(--serif); font-size: 16.5px; line-height: 1.45; border-left: 3px solid var(--t-quote); padding-left: 12px; }
.link-desc { font-size: 13.5px; -webkit-line-clamp: 4; color: var(--muted); }
.page-text { margin-top: 10px; font-size: 14px; }
.page-text summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.page-text p { margin: 8px 0 0; }
.page-text .page-words { max-height: 320px; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
.detail-body .thumb { margin-bottom: 12px; }
.url-line { font: 13px var(--mono); color: var(--t-url); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.thumb { border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.thumb img { display: block; width: 100%; max-height: 340px; object-fit: cover; }
.card-note { margin: 0; font-size: 13px; color: var(--muted); font-style: italic; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-foot .src { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; flex-wrap: wrap; margin-right: auto; max-width: 100%; min-width: 0; white-space: nowrap; }
.card-foot .src > * { display: inline-flex; gap: 4px; align-items: center; overflow: hidden; text-overflow: ellipsis; }
.card-foot .src .src-link { color: var(--accent); text-decoration: none; font-weight: 500; flex-shrink: 1; max-width: 100%; }
.card-foot .src .src-link:hover { text-decoration: underline; }
.card-foot .src .src-add { font: inherit; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.card-foot .src .src-add:hover { color: var(--accent); }
.card-foot .src .src-add + .src-add { margin-left: 10px; }
.card-foot .src .via { white-space: pre; flex-shrink: 0; }
.card-foot .src .ic { width: 13px; height: 13px; }
.card-foot .src .sub-tag { margin-left: 8px; padding: 0 7px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; }
.card-foot .src .sub-signin { margin-left: 8px; color: var(--accent); }
.sub-rows { display: grid; gap: 10px; }
.sub-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
.sub-row > input, .sub-row > select { grid-column: 1; width: 100%; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: inherit; }
.sub-row > select { height: auto; padding-right: 28px; }
.sub-row > [data-sub-remove] { grid-column: 2; grid-row: 1; }
.src-via { margin: 4px 0 0; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; border-top: 1px solid var(--border); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.results.list .card { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 14px; row-gap: 4px; padding: 12px 14px; }
.results.list .card > * { grid-column: 1; }
.results.list .card > .thumb { grid-column: 2; grid-row: 1 / span 4; width: 120px; height: 84px; }
.results.list .thumb img { height: 100%; }
.results.list .excerpt { -webkit-line-clamp: 2; }
.results.list .excerpt.is-quote { font-size: 15px; }

.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h2 { margin: 12px 0 6px; color: var(--text); font-size: 20px; letter-spacing: -.01em; }
.empty p { margin: 0 auto; max-width: 420px; }
.empty .big { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); }
.empty .big .ic { width: 28px; height: 28px; }
.more-wrap { display: flex; justify-content: center; margin-top: 18px; }

/* ---- Detail dialog ------------------------------------------------------- */
dialog {
  width: min(760px, calc(100% - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgb(0 0 0 / .4); backdrop-filter: blur(2px); }
.detail { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 20px; }
.detail-head { display: flex; align-items: center; gap: 10px; }
.detail-head .spacer + .icon-btn { margin-right: -8px; }
.detail-title { width: 100%; border: 0; outline: 0; background: transparent; font-size: 22px; font-weight: 700; letter-spacing: -.015em; padding: 0; }
.detail-body { font-size: 15.5px; line-height: 1.65; overflow-wrap: anywhere; }
.detail-body .plain { white-space: pre-wrap; }
.detail-body .plain.is-quote { font-family: var(--serif); font-size: 19px; line-height: 1.5; border-left: 3px solid var(--t-quote); padding-left: 16px; }
.detail-body img { max-width: 100%; height: auto; border-radius: 10px; }
.detail-body .detail-img { display: block; margin: 0 auto; max-height: 60vh; }
.rich { font-family: var(--serif); font-size: 17px; }
.rich h1, .rich h2, .rich h3 { font-family: var(--font); line-height: 1.25; letter-spacing: -.01em; }
.rich blockquote { margin: 1em 0; padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.rich pre { overflow: auto; padding: 12px; border-radius: 8px; background: var(--surface-2); font: 13px var(--mono); }
.rich table { border-collapse: collapse; display: block; overflow: auto; }
.rich td, .rich th { border: 1px solid var(--border); padding: 4px 8px; }
.big-link { font: 15px var(--mono); word-break: break-all; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.field input, .field textarea, .field .chips-input {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; background: var(--bg); outline: 0; resize: vertical;
}
.field input:focus, .field textarea:focus, .field .chips-input:focus-within { border-color: var(--accent); }
.field .row { display: flex; gap: 6px; align-items: center; }
.field .sched-row input { width: 76px; flex: none; }
.detail-foot { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); }

/* ---- Overlay + toast ----------------------------------------------------- */
.drop-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 18%, transparent); backdrop-filter: blur(3px); pointer-events: none; }
.drop-box { display: flex; align-items: center; gap: 12px; padding: 22px 30px; border-radius: 18px; border: 2px dashed var(--accent); background: var(--surface); font-size: 18px; font-weight: 600; color: var(--accent); }
.drop-box .ic { width: 26px; height: 26px; }
.toast {
  position: fixed; inset: auto; margin: 0; border: 0; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 14px; padding: 10px 14px 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-size: 14px; max-width: calc(100% - 32px);
}
.script-box { width: 100%; font: 12px/1.4 ui-monospace, monospace; }
.toast:not(:popover-open) { display: none; }
.toast button { border: 0; background: transparent; color: var(--accent-soft); font-weight: 700; padding: 2px 4px; }

/* ---- Lock screen --------------------------------------------------------- */
body.locked #app { display: none; }
body:not(.locked) .lock { display: none; }
.lock {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.lock-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px;
  padding: 28px 24px 22px; border-radius: 20px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.lock-mark { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 2px; }
.lock-card h1 { margin: 0; text-align: center; font-size: 22px; letter-spacing: -.015em; }
.lock-sub { margin: -6px 0 4px; text-align: center; color: var(--muted); font-size: 14px; }
.pass-row { display: flex; gap: 6px; align-items: center; }
.pass-row input { flex: 1; min-width: 0; }
.btn.block { width: 100%; justify-content: center; height: 42px; font-size: 15px; }
.form-error { margin: -4px 0 0; min-height: 1em; color: var(--danger); font-size: 13.5px; }
.form-error:empty { display: none; }
.lock-notes { font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; }
.lock-notes p { margin: 0 0 8px; }
.lock-notes b { color: var(--text); }
.link-btn { align-self: center; border: 0; background: transparent; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.meter { display: flex; align-items: center; gap: 10px; margin-top: -6px; }
.meter-bar { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.meter-bar i { height: 4px; border-radius: 2px; background: var(--surface-2); }
.meter[data-level="1"] i:nth-child(-n+1) { background: var(--danger); }
.meter[data-level="2"] i:nth-child(-n+2) { background: var(--t-quote); }
.meter[data-level="3"] i:nth-child(-n+3) { background: var(--t-article); }
.meter[data-level="4"] i { background: var(--t-article); }
.meter-label { font-size: 12px; color: var(--muted); min-width: 64px; text-align: right; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; opacity: 0; }

.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 4px 4px 38px; font-size: 14px; }
.menu-row select { height: 30px; font-size: 13px; }

.small-dialog { width: min(420px, calc(100% - 32px)); }
.small-dialog dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.small-dialog dt { color: var(--muted); }
.small-dialog dd { margin: 0; overflow-wrap: anywhere; }
.small-dialog .detail-foot .spacer { flex: 1; }

/* Sync status: a dot on the cloud button. */
.sync-btn { position: relative; }
.sync-dot { position: absolute; right: 5px; bottom: 6px; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); display: none; }
.sync-btn[data-state="ok"] .sync-dot { display: block; background: var(--t-article); }
.sync-btn[data-state="syncing"] .sync-dot { display: block; background: var(--accent); animation: sync-pulse 1s ease-in-out infinite alternate; }
.sync-btn[data-state="offline"] .sync-dot { display: block; background: var(--muted); }
.sync-btn:is([data-state="error"], [data-state="needs-key"], [data-state="signed-out"]) .sync-dot { display: block; background: var(--danger); }
.sync-btn[data-state="off"] { opacity: .7; }
@keyframes sync-pulse { from { opacity: .35; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sync-btn[data-state="syncing"] .sync-dot { animation: none; } }
#lock-sync { gap: 8px; font-size: 14px; }
.small-dialog .detail { gap: 12px; }
.small-dialog h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.small-dialog p.msg { margin: 0; color: var(--muted); font-size: 14px; }
.small-dialog .detail-foot { justify-content: flex-end; }
.btn.primary.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ---- Mobile -------------------------------------------------------------- */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .brand { width: auto; flex: 1; }
  .brand > span:last-child { display: none; }
  .filter-toggle { display: inline-grid; margin-left: -8px; }
  .search { order: 10; flex-basis: 50%; }
  .recommend-btn { order: 11; }
  #sort { max-width: 130px; }
  .top-actions { gap: 6px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .pinned { padding-top: 14px; }
  .composer { margin-bottom: 10px; }
  .sidebar {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(300px, 84vw); max-height: none;
    padding: calc(20px + env(safe-area-inset-top)) 12px 20px max(12px, env(safe-area-inset-left));
    background: var(--surface); border-right: 1px solid var(--border); box-shadow: var(--shadow-lg);
    transform: translateX(-105%); transition: transform .22s ease;
  }
  body.drawer-open .sidebar { transform: none; }
  body.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / .35); }
  .desk-only { display: none !important; }
  .cap-fields { grid-template-columns: 1fr; }
  .results.grid { grid-template-columns: minmax(0, 1fr); }
  .results.list .card > .thumb { width: 88px; height: 66px; }
  dialog#detail { width: 100%; max-width: 100%; max-height: 100%; height: 100%; margin: 0; border-radius: 0; border: 0; }
  #detail .detail { padding: calc(14px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom)); }
  /* iOS zooms inputs under 16px */
  input, textarea, select { font-size: 16px !important; }
}

/* ---- Video ---- */
.video-thumb { position: relative; aspect-ratio: 16 / 9; }
.video-thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-thumb.no-poster { background: linear-gradient(135deg, var(--surface-2), var(--accent-soft)); }
.video-thumb .play { position: absolute; inset: 0; margin: auto; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .55); color: #fff; }
.video-thumb .play .ic { width: 22px; height: 22px; margin-left: 3px; }
.video-thumb .dur { position: absolute; right: 8px; bottom: 8px; padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, .7); color: #fff; font-size: 12px; font-variant-numeric: tabular-nums; }
.results.list .card > .video-thumb { aspect-ratio: auto; }
.results.list .video-thumb .play { width: 32px; height: 32px; }
.results.list .video-thumb .play .ic { width: 16px; height: 16px; }
.video-embed .thumb[data-act="play"] { cursor: pointer; }
.video-embed .thumb[data-act="play"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.detail-video, .video-frame { display: block; width: 100%; max-height: 60vh; border: 0; border-radius: 10px; background: #000; }
.video-frame { aspect-ratio: 16 / 9; height: auto; }
.video-frame.portrait { aspect-ratio: auto; width: min(100%, 340px); height: min(70vh, 600px); max-height: none; margin: 0 auto; }
.video-thumb.tiktok.no-poster { background: linear-gradient(135deg, #111 0%, #25f4ee33 45%, #fe2c5533 100%), #111; }
.video-thumb .who { position: absolute; left: 10px; top: 8px; right: 10px; color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.big-link .ic { vertical-align: -3px; margin-right: 4px; }
.pending video { max-height: 120px; max-width: 100%; border-radius: 6px; display: block; background: #000; }

/* ---- Capture tools dialog ---- */
.tools h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 18px 0 6px; }
.tools h3:first-child { margin-top: 4px; }
.tools ol { margin: 6px 0; padding-left: 22px; line-height: 1.55; }
.tools p { margin: 6px 0; }
.bookmarklet { cursor: grab; border-style: dashed; }
.note-warn { padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; }

/* ---- AI ---- */
.results-head { flex-wrap: wrap; }
.results-actions { display: flex; gap: 4px; margin-left: auto; }
.card-ai { display: flex; gap: 6px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.card-ai .ic { width: 14px; height: 14px; color: var(--accent); margin-top: 3px; }
.ai-box:empty { display: none; }
.ai-box { padding: 12px 14px; border-radius: 10px; background: var(--accent-soft); display: grid; gap: 6px; }
.ai-summary { display: flex; gap: 8px; margin: 0; }
.ai-summary .ic { color: var(--accent); flex: none; margin-top: 3px; }
.ai-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ai-box > p { margin: 0; }
.link-btn.small { font-size: 12px; }
#ai-dialog { width: min(760px, calc(100% - 24px)); }
.ai-panel h2 { margin: 4px 0 10px; font-size: 20px; }
.md { line-height: 1.6; overflow-wrap: anywhere; }
.md h2, .md h3, .md h4 { margin: 18px 0 6px; font-size: 16px; }
.md ul, .md ol { padding-left: 22px; }
.md blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--accent-soft); color: var(--muted); }
.md pre { overflow: auto; padding: 10px; border-radius: 8px; background: var(--surface-2); }
.cite { border: 0; padding: 0 5px; margin: 0 1px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font: 600 11px/1.5 inherit; vertical-align: 2px; cursor: pointer; }
.thinking { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.ai-sources { margin-top: 12px; font-size: 14px; }
.ai-sources summary { cursor: pointer; color: var(--muted); }
.ai-sources ol { padding-left: 22px; }
.ai-sources .link-btn { text-align: left; color: inherit; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 8px 0; flex-wrap: wrap; }
.field select, .check select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: inherit; }
.choices { border: 0; padding: 0; margin: 10px 0; }
.form-error:empty { display: none; }

/* ---- Insights ---- */
.insights { display: grid; gap: 16px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { padding: 14px; border-radius: 12px; background: var(--surface-2); display: grid; }
.stat b { font-size: 26px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.panel { padding: 16px 18px; border-radius: 14px; background: var(--surface-2); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; }
.radar, .sites, .report-list, .link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.radar li { display: grid; grid-template-columns: minmax(90px, 180px) 1fr 74px 32px; gap: 10px; align-items: center; }
.radar .radar-name { justify-self: start; color: inherit; text-decoration: none; font-size: 14px; text-align: left; }
.radar .radar-name:hover { text-decoration: underline; }
.bar { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.trend { font-size: 12px; color: var(--muted); }
.trend-rising, .trend-new { color: var(--accent); font-weight: 600; }
.sites li, .report-list li, .link-list li { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.sites .link-btn, .report-list .link-btn { color: inherit; text-align: left; }
@media (max-width: 560px) { .radar li { grid-template-columns: minmax(80px, 1fr) 1fr 60px 28px; } .results-actions { margin-left: 0; } }

/* ---- To Do ---- */
.card-quick .icon-btn.on { color: var(--accent); }
.todo { display: grid; gap: 14px; max-width: 760px; }
.todo-add { display: grid; gap: 10px; }
.todo-add > input { width: 100%; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: inherit; outline: 0; }
.todo-add > input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.todo-add p { margin: 0; }
.todo-add p .ic { width: 14px; height: 14px; vertical-align: -2px; }
.todo-add-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.todo-due { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.todo-due .ic { width: 15px; height: 15px; }
.todo-due input { font: inherit; font-size: 14px; color: var(--text); padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); min-height: 32px; }
.note-editor .todo-due { margin: 8px 0 0; }
.todo-empty { margin: 4px 2px; }
.todo-group .panel-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; }
.todo-group.overdue .panel-head h2 { color: var(--danger); }
.todo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.todo-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 10px; }
.todo-row:hover { background: var(--surface); }
.todo-check { flex: none; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid var(--border-strong); background: var(--surface); color: transparent; cursor: pointer; }
.todo-check .ic { width: 14px; height: 14px; stroke-width: 3; }
.todo-check:hover { border-color: var(--accent); color: var(--accent-soft); }
.todo-row.done .todo-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.todo-thumb { flex: none; width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
.todo-main { flex: 1; min-width: 0; display: grid; gap: 3px; padding: 2px 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.todo-title { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.todo-row.done .todo-title { text-decoration: line-through; color: var(--muted); }
.todo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.todo-meta .badge { font-size: 11.5px; }
.todo-meta .badge .ic { width: 12px; height: 12px; }
.todo-when { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--text); }
.todo-when .ic { width: 13px; height: 13px; }
.todo-row.overdue .todo-when { color: var(--danger); }
.todo-row.done .todo-when { color: var(--muted); font-weight: 500; }
.todo-row > .icon-btn { flex: none; width: 32px; height: 32px; }
.todo-field { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.todo-field .check { margin: 0; }
#d-todo > .btn { justify-self: start; }
.card.pinned { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.card-todo { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 10px; background: var(--accent-soft); font-size: 12.5px; }
.card-todo-when { display: inline-flex; align-items: center; gap: 5px; margin-right: auto; font-weight: 600; color: var(--accent); min-width: 0; }
.card-todo-when .ic { width: 14px; height: 14px; flex: none; }
.card-todo.overdue .card-todo-when { color: var(--danger); }
.card-todo.done { background: var(--surface-2); }
.card-todo.done .card-todo-when { color: var(--muted); font-weight: 500; }
.card-todo-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 5px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.card-todo-btn:hover { border-color: var(--accent); }
.card-todo-btn .todo-check { width: 18px; height: 18px; }
.card-todo-btn .todo-check .ic { width: 11px; height: 11px; }
.card-todo.done .card-todo-btn .todo-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
#d-todo p { margin: 4px 0 0; }

/* ---- Calendar ---- */
.cal { display: grid; gap: 14px; max-width: 900px; }
.cal-top { display: grid; grid-template-columns: minmax(250px, 300px) 1fr; gap: 14px; align-items: start; }
.cal-card { padding: 12px 12px 14px; }
.cal-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.cal-head h2 { margin: 0 4px; font-size: 15px; white-space: nowrap; }
.cal-head .icon-btn { width: 30px; height: 30px; }
.cal-head .btn { padding: 4px 10px; min-height: 0; font-size: 13px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-wd { font-size: 11px; font-weight: 600; color: var(--muted); padding: 2px 0 4px; }
.cal-d { position: relative; display: grid; place-items: center; aspect-ratio: 1; min-height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; font: inherit; font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; }
.cal-d:hover { background: var(--surface); }
.cal-d.out { color: var(--muted); opacity: .55; }
.cal-d.today span { color: var(--accent); font-weight: 700; }
.cal-d.sel { background: var(--accent); }
.cal-d.sel span { color: var(--accent-ink); font-weight: 700; }
.cal-dots { position: absolute; bottom: 3px; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; }
.cal-dots b { width: 4px; height: 4px; border-radius: 50%; background: var(--t-event); }
.cal-d.sel .cal-dots b { background: var(--accent-ink); }
.ev-add { display: grid; gap: 8px; }
.ev-add .panel-head { margin: 0; }
.ev-add > input { width: 100%; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: inherit; outline: 0; }
.ev-add > input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ev-read { margin: 0; min-height: 1.4em; }
.ev-fields { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: flex-end; }
.ev-fields select, .ev-fields input { font: inherit; font-size: 14px; color: var(--text); padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); min-height: 34px; }
.ev-f { display: grid; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.ev-where { flex: 1 1 160px; min-width: 0; }
.note-editor .ev-fields { margin-top: 8px; }
.note-editor .ev-read { margin-top: 8px; }
.ev-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 10px; }
.ev-row:hover { background: var(--surface); }
.ev-row.past { opacity: .6; }
.ev-date { flex: none; display: grid; place-items: center; width: 42px; padding: 3px 0; border-radius: 8px; background: var(--surface); line-height: 1.1; }
.ev-date b { font-size: 17px; }
.ev-date span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.ev-kind { font-weight: 600; color: var(--t-event); }
.ev-row.kind-meeting .ev-kind { color: var(--t-url); }
.ev-row.kind-appointment .ev-kind { color: var(--t-image); }
.ev-time { display: inline-flex; align-items: center; gap: 4px; }
.ev-time .ic { width: 12px; height: 12px; }
.ev-row > .icon-btn { flex: none; width: 32px; height: 32px; }
.card-event { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 10px; background: color-mix(in srgb, var(--t-event) 13%, transparent); color: var(--text); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; }
.card-event .ic { flex: none; width: 15px; height: 15px; color: var(--t-event); }
.card-event b { color: var(--t-event); }
.card-event.past { opacity: .65; }
#d-ev > .btn { justify-self: start; }
#d-ev p { margin: 6px 0 0; }
@media (max-width: 700px) { .cal-top { grid-template-columns: 1fr; } .cal-card { max-width: 380px; width: 100%; justify-self: center; } }

/* ---- Share ---- */
.share-url { width: 100%; font-size: 13px; }
body.viewing-share #app, body.viewing-share .lock { display: none !important; }
.share-view { max-width: 760px; margin: 0 auto; padding: 24px 16px 48px; }
.share-view h1 { margin: 0; font-size: 26px; }
.s-item { background: var(--surface, #fff); border-radius: 14px; padding: 18px 20px; margin: 16px 0; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.s-item h2 { margin: 0 0 4px; font-size: 19px; }
.s-meta, .s-tags { color: var(--muted); font-size: 13px; }
.s-summary { font-style: italic; }
.s-note { border-left: 3px solid var(--accent); padding-left: 10px; }
.s-item img { max-width: 100%; border-radius: 8px; }
.s-item .plain { white-space: pre-wrap; }
.s-foot { text-align: center; margin-top: 24px; }
.s-error { text-align: center; padding: 60px 0; }

/* "Save from iPhone" (iPhone Shortcut) */
.share-banner {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 10px 10px 10px 12px; margin-bottom: 12px;
}
.share-banner[hidden] { display: none; }
.share-banner #share-paste { flex: 1; justify-content: center; }
.build-own { margin-top: 10px; }
.build-own summary { cursor: pointer; color: var(--accent); font-size: 14px; }

/* ---- Notes ---------------------------------------------------------------- */
#note-dialog { width: min(620px, calc(100% - 24px)); }
.note-editor textarea, .note-body {
  width: 100%; min-height: 160px; resize: vertical; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: inherit; font: inherit; font-size: 15.5px; line-height: 1.6;
}
.note-body { min-height: 120px; }
.note-editor textarea:focus, .note-body:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.rec-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rec-hint { flex: 1 1 220px; line-height: 1.4; }
.btn.recording { color: var(--danger); border-color: var(--danger); }
.rec-time { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-size: 14px; }
.rec-time[hidden] { display: none; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: rec-blink 1s infinite; }
@keyframes rec-blink { 50% { opacity: .25; } }
.rec-audio { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rec-audio[hidden] { display: none; }
.rec-audio audio, .detail-audio { width: 100%; max-width: 420px; height: 40px; }
.detail-audio { display: block; margin-bottom: 10px; }
.note-editor .check { align-items: flex-start; flex-wrap: nowrap; margin: 0; color: var(--muted); }
.note-editor .check input { margin-top: 3px; }
.card-voice { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 13px; color: var(--t-note); font-weight: 600; }
.card-voice .ic { width: 14px; height: 14px; }

/* ---- Help ----------------------------------------------------------------- */
#help-dialog { width: min(760px, calc(100% - 24px)); height: min(88vh, 900px); }
.help { height: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: 12px; }
.help-search { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: inherit; font: inherit; }
.help-toc { display: flex; flex-wrap: wrap; gap: 6px; }
.help-toc[hidden] { display: none; }
.help-toc a { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 13px; }
.help-toc a:hover { background: var(--accent-soft); color: var(--accent); }
.help-toc .ic { width: 14px; height: 14px; color: var(--accent); }
.help-body { flex: 1; min-height: 0; overflow-y: auto; font-size: 15px; line-height: 1.6; padding-right: 4px; }
.help-body section { padding: 4px 0 14px; border-bottom: 1px solid var(--border); scroll-margin-top: 4px; }
.help-body section:last-of-type { border-bottom: 0; }
.help-body section[hidden] { display: none; }
.help-body h3 { margin: 10px 0 6px; font-size: 17px; }
.help-body h4 { margin: 10px 0 4px; font-size: 14.5px; }
.help-body p { margin: 6px 0; }
.help-body ul, .help-body ol { margin: 6px 0; padding-left: 22px; }
.help-body li { margin: 3px 0; }
.help-body a { color: var(--accent); }
.help-body kbd { font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
.help-body code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.help-table { border-collapse: collapse; width: 100%; margin: 6px 0; font-size: 14px; }
.help-table td { padding: 6px 8px; border-top: 1px solid var(--border); vertical-align: top; }
.help-table td:first-child { white-space: nowrap; width: 1%; }
@media (max-width: 860px) {
  #help-dialog { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border-radius: 0; border: 0; }
  .help { padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .help-table td:first-child { white-space: normal; }
  .help-toc { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .help-toc a { flex: none; }
}

/* ---- Demos (demos.js): an animated phone walking through a capture ---- */
#demo-dialog { width: min(880px, calc(100% - 24px)); max-height: 94vh; }
.demo { display: flex; flex-direction: column; gap: 12px; }
.demo-title { font-size: 16px; }
.demo-main { display: flex; gap: 28px; align-items: flex-start; justify-content: center; }
.demo-side { flex: 1; min-width: 0; max-width: 380px; }
.demo-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 4px; }
.demo-steps li { counter-increment: step; }
.demo-steps button { all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; padding: 8px 10px 8px 38px; position: relative; border-radius: 10px; font-size: 14px; line-height: 1.45; color: var(--muted); }
.demo-steps button::before { content: counter(step); position: absolute; left: 9px; top: 8px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.demo-steps button:hover { background: var(--surface-2); }
.demo-steps button:focus-visible { outline: 2px solid var(--accent); }
.demo-steps li.on button { color: var(--text); background: var(--accent-soft); }
.demo-steps li.on button::before { background: var(--accent); color: #fff; }
.demo-extra { margin: 12px 4px 0; line-height: 1.5; }
.demo-caption { display: none; margin: 0; font-size: 15px; line-height: 1.45; min-height: 3em; }
.demo-caption span { color: var(--muted); font-size: 13px; margin-right: 4px; }
.demo-controls { display: flex; justify-content: center; gap: 8px; }
.demo-controls .btn { min-width: 92px; justify-content: center; }
.demo-controls .ic { width: 14px; height: 14px; }

.demo-phone { --ph: #0d0d0f; font-size: min(13px, 1.75vh); flex: none; width: 21em; height: 44em; padding: .7em; border-radius: 3.2em; background: var(--ph); box-shadow: 0 0 0 2px #2b2b30, 0 18px 40px rgba(0,0,0,.25); position: relative; }
.demo-notch { position: absolute; top: 1.15em; left: 50%; transform: translateX(-50%); width: 6.4em; height: 1.8em; border-radius: 1em; background: #000; z-index: 3; }
.demo-screen { width: 100%; height: 100%; border-radius: 2.6em; overflow: hidden; position: relative; background: #fff; }
.ds { position: absolute; inset: 0; display: flex; flex-direction: column; font: 1em/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; color: #0f0f0f; background: #fff; overflow: hidden; }
.ds.enter { animation: ds-in .35s ease both; }
@keyframes ds-in { from { opacity: 0; transform: scale(.985); } }
.ds .ic { width: 1.15em; height: 1.15em; }
.ds-status { display: flex; justify-content: space-between; padding: 1.15em 2em .5em; font-size: .95em; flex: none; }
.ds-status span { letter-spacing: -.1em; font-size: .8em; }
.ds-status.dark { color: #fff; position: absolute; inset: 0 0 auto; z-index: 2; }
.ds-toast { position: absolute; left: 50%; bottom: 3.2em; transform: translateX(-50%); background: rgba(30,30,30,.92); color: #fff; padding: .55em 1.2em; border-radius: 2em; font-size: .95em; white-space: nowrap; z-index: 6; animation: toast-in .3s .35s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, .6em); } }

/* What to tap */
.ds [data-tap] { position: relative; }
.ds [data-tap]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 3.2em; height: 3.2em; margin: -1.6em 0 0 -1.6em; border-radius: 50%; background: rgba(67, 56, 202, .28); border: .18em solid rgba(67, 56, 202, .85); pointer-events: none; animation: tap-ring 1.4s .6s ease-out infinite both; z-index: 5; }
@keyframes tap-ring { 0% { transform: scale(.5); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }

/* Share sheets */
.sheet-dim { position: absolute; inset: 0; background: rgba(0,0,0,.4); z-index: 4; animation: fade-in .3s ease both; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; background: #fff; color: #0f0f0f; border-radius: 1.4em 1.4em 0 0; padding: .7em 1.1em 2.4em; animation: sheet-up .35s ease both; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
.sheet-grab { width: 2.8em; height: .3em; border-radius: 1em; background: #ccc; margin: 0 auto .7em; }
.sheet-title { display: block; font-size: 1.05em; margin-bottom: .9em; }
.share-row { display: flex; justify-content: space-between; gap: .4em; margin-bottom: 1em; }
.share-row span { display: flex; flex-direction: column; align-items: center; gap: .35em; font-size: .78em; width: 4.6em; text-align: center; }
.share-row i { font-style: normal; width: 3.4em; height: 3.4em; border-radius: 50%; display: grid; place-items: center; background: #ececec; font-size: 1.15em; color: #222; }
.share-row i .ic { width: 1.3em; height: 1.3em; }
.share-row i.copy { background: #e8e8e8; }
.share-row i.msg { background: #34c759; }
.share-row i.mail { background: #1e88ff; color: #fff; }
.share-row i.wa { background: #25d366; color: #fff; }

/* Video app drawn after YouTube's layout */
.yt-player { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, #c98a4b, #6b3d1d); flex: none; }
.yt-bigplay { position: absolute; inset: 0; margin: auto; width: 3.4em; height: 2.4em; border-radius: .7em; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; }
.yt-bar { position: absolute; left: 0; right: 0; bottom: 0; height: .25em; background: rgba(255,255,255,.35); }
.yt-bar i { display: block; height: 100%; width: 6%; background: #f00; }
.yt-bar.playing i { animation: progress 9s linear both; }
@keyframes progress { from { width: 6%; } to { width: 40%; } }
.yt-time { position: absolute; left: .8em; bottom: .7em; color: #fff; font-size: .75em; }
.yt-info { padding: .9em 1em .4em; display: grid; gap: .3em; }
.yt-info b { font-size: 1.05em; line-height: 1.3; }
.yt-info small { color: #606060; font-size: .8em; }
.yt-chips { display: flex; gap: .45em; padding: .5em 1em; overflow: hidden; }
.yt-chips span { flex: none; display: inline-flex; align-items: center; gap: .35em; background: #f0f0f0; padding: .45em .8em; border-radius: 2em; font-size: .82em; font-weight: 600; }
.yt-chips .ic { width: 1.05em; height: 1.05em; }
.yt-next { padding: .6em 1em; display: grid; gap: .8em; }
.yt-next div { display: flex; gap: .7em; }
.yt-next i { width: 8em; aspect-ratio: 16 / 9; border-radius: .5em; background: #e6e6e6; flex: none; }
.yt-next span { flex: 1; display: grid; align-content: start; gap: .45em; padding-top: .2em; }
.yt-next b { height: .75em; border-radius: .3em; background: #e3e3e3; }
.yt-next small { height: .6em; width: 60%; border-radius: .3em; background: #eee; }

/* Video app drawn after TikTok's layout */
.ds.tt { background: #000; color: #fff; }
.tt-video { position: absolute; inset: 0; background: radial-gradient(circle at 50% 42%, #f2c27b 0, #b3672c 30%, #2c1708 70%, #000 100%); display: grid; place-items: center; }
.tt-croissant { font-size: 5.5em; filter: drop-shadow(0 .1em .2em rgba(0,0,0,.4)); }
.tt-rail { position: absolute; right: .8em; bottom: 7.5em; display: grid; gap: 1.1em; z-index: 1; }
.tt-rail span { display: flex; flex-direction: column; align-items: center; font-size: 1.6em; line-height: 1; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.tt-rail small { font-size: .42em; margin-top: .35em; font-weight: 600; }
.tt-share { font-weight: 400; }
.tt-cap { position: absolute; left: 1em; right: 4.5em; bottom: 2.6em; display: grid; gap: .3em; font-size: .92em; text-shadow: 0 1px 3px rgba(0,0,0,.6); z-index: 1; }
.tt-sheet { padding-top: 1.2em; }

/* CatchAll, drawn with the app's own colors */
.ds.ca { background: var(--bg); color: var(--text); }
.ca-top { display: flex; align-items: center; gap: .5em; padding: .5em 1em .7em; }
.ca-top img { width: 1.7em; height: 1.7em; border-radius: .4em; }
.ca-top span { flex: 1; }
.ca-top .ic { color: var(--muted); margin-left: .5em; }
.ca-box { margin: 0 .8em; padding: .8em; border-radius: .9em; background: var(--surface); border: 1px solid var(--border); display: grid; gap: .65em; }
.ca-input { font-size: .9em; color: var(--muted); padding: .2em .1em; min-height: 1.4em; }
.ca-input.filled { color: var(--accent); word-break: break-all; animation: fade-in .4s ease both; }
.ca-preview { display: flex; gap: .7em; align-items: center; padding: .5em; border-radius: .6em; background: var(--surface-2); animation: fade-in .4s .2s ease both; }
.ca-preview .ca-thumb { width: 6em; }
.ca-preview small, .ca-card small { display: flex; align-items: center; gap: .3em; color: var(--muted); font-size: .75em; }
.ca-preview small .ic, .ca-card small .ic { width: 1.1em; height: 1.1em; }
.ca-actions { display: flex; gap: .4em; flex-wrap: wrap; }
.ca-actions span { display: inline-flex; align-items: center; gap: .3em; padding: .35em .6em; border-radius: .5em; background: var(--surface-2); font-size: .8em; }
.ca-save { justify-self: end; padding: .45em 1.3em; border-radius: .55em; background: var(--surface-2); color: var(--muted); font-size: .9em; font-weight: 600; }
.ca-save.ready { background: var(--accent); color: #fff; }
.ca-list { padding: .8em; display: grid; gap: .6em; }
.ca-card { display: flex; gap: .7em; align-items: center; padding: .6em; border-radius: .8em; background: var(--surface); border: 1px solid var(--border); }
.ca-card > div:last-child { display: grid; gap: .2em; min-width: 0; }
.ca-card b { font-size: .88em; line-height: 1.3; }
.ca-card.fresh { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); animation: card-in .5s ease both; }
@keyframes card-in { from { opacity: 0; transform: translateY(-.8em); } }
.ca-thumb { position: relative; flex: none; width: 6.6em; aspect-ratio: 16 / 9; border-radius: .5em; overflow: hidden; display: grid; place-items: center; }
.ca-thumb.plain { background: var(--surface-2); }
.ca-thumb i { width: 1.9em; height: 1.9em; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; font-style: normal; }
.ca-thumb i .ic { width: .95em; height: .95em; margin-left: .1em; }
.yt-thumb { background: linear-gradient(135deg, #c98a4b, #6b3d1d); }
.yt-thumb em { position: absolute; right: .3em; bottom: .25em; font-style: normal; font-size: .62em; color: #fff; background: rgba(0,0,0,.7); padding: 0 .3em; border-radius: .2em; }
.tt-thumb { background: linear-gradient(135deg, #111 0%, #25f4ee33 45%, #fe2c5533 100%), #111; }
.tt-thumb span { position: absolute; left: .45em; top: .3em; color: #fff; font-size: .62em; font-weight: 600; }
.dt-head { display: flex; align-items: center; gap: .6em; padding: .4em 1em .6em; }
.dt-head span:not(.ca-badge) { flex: 1; }
.dt-head .ic { color: var(--muted); }
.ca-badge { display: inline-flex; align-items: center; gap: .3em; font-size: .78em; padding: .2em .55em; border-radius: 2em; background: var(--surface-2); }
.dt-title { padding: 0 1em .7em; font-size: 1.1em; line-height: 1.3; }
.dt-player { position: relative; margin: 0 1em; border-radius: .7em; overflow: hidden; display: grid; place-items: center; background: #000; }
.yt-frame { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #d9a066, #7a4524); }
.dt-loaf { font-size: 3.4em; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-.12em) rotate(-4deg); } }
.tt-frame { width: 13em; height: 23em; justify-self: center; align-self: center; margin: 0 auto; background: radial-gradient(circle at 50% 42%, #f2c27b 0, #b3672c 30%, #2c1708 70%, #000 100%); }
.tt-frame .tt-croissant { font-size: 4em; animation: bob 2.4s ease-in-out infinite; }
.dt-tt-cap { position: absolute; left: .7em; right: .7em; bottom: .7em; color: #fff; font-size: .72em; display: grid; gap: .15em; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.dt-link { display: flex; align-items: center; gap: .4em; padding: .9em 1em; color: var(--accent); font-size: .9em; }
.help-demos { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.help-demos .ic { width: 15px; height: 15px; }

@media (prefers-reduced-motion: reduce) {
  .ds *, .ds, .ds *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
  .ds [data-tap]::after { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
  #demo-dialog { width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border-radius: 0; border: 0; }
  .demo { height: 100%; box-sizing: border-box; padding-top: calc(14px + env(safe-area-inset-top)); padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .demo-title { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .demo-main { flex: 1; min-height: 0; align-items: center; }
  .demo-side { display: none; }
  .demo-caption { display: block; text-align: center; padding: 0 8px; }
  .demo-phone { font-size: min(13px, 1.45vh, 3.6vw); }
}
.sheet ~ .ds-toast { bottom: 15em; }
.ds [data-tap]::before { content: ""; position: absolute; left: 50%; top: 50%; width: 2.6em; height: 2.6em; margin: -1.3em 0 0 -1.3em; border-radius: 50%; background: rgba(67, 56, 202, .1); border: .16em solid rgba(67, 56, 202, .9); box-shadow: 0 0 0 .2em rgba(255,255,255,.7); pointer-events: none; z-index: 5; animation: fade-in .3s .5s ease both; }
.ca-thumb[data-tap] { overflow: visible; }
.share-row span[data-tap]::before { top: 1.96em; width: 4.4em; height: 4.4em; margin: -2.2em 0 0 -2.2em; }
.share-row span[data-tap]::after { top: 1.96em; width: 5em; height: 5em; margin: -2.5em 0 0 -2.5em; }
.lock-remember { align-items: flex-start; flex-wrap: nowrap; margin: 2px 0 0; cursor: pointer; }
.lock-remember input { margin-top: 3px; flex: none; }
.lock-remember span { display: grid; gap: 2px; }
.lock-remember small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }

/* For You */
.rec-list { display: grid; gap: 12px; margin-top: 10px; }
.rec { display: flow-root; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.rec > .thumb { float: right; width: 160px; height: 110px; margin: 0 0 8px 14px; }
.rec > .thumb img { height: 100%; }
@media (max-width: 860px) { .rec > .thumb { width: 96px; height: 72px; margin-left: 10px; } }
.rec-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rec h3 { margin: 8px 0 4px; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; }
.rec h3 a { color: inherit; }
.rec-sum { margin: 0 0 6px; font-size: 14px; }
.rec-why { margin: 0 0 10px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: flex-start; }
.rec-why .ic { flex: none; width: 15px; height: 15px; margin-top: 1px; }
.rec-warn { color: #b45309; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.rec-explain { margin-top: 10px; font-size: 13px; }
.rec-explain summary { cursor: pointer; color: var(--muted); }
.rec-explain .chip button { margin-left: 4px; }
.proposal-list, .infer-list, .run-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.proposal-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.proposal-btns { display: flex; gap: 6px; }
.infer-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.infer-list .spacer { flex: 1; }
.infer-list .link-btn { color: inherit; text-align: left; }
.profile-dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 8px 0 0; font-size: 14px; }
.profile-dl dt { color: var(--muted); }
.profile-dl dd { margin: 0; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pre-line { white-space: pre-line; }
.form-sub { margin: 16px 0 6px; font-size: 14px; }
.panel-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.foryou .panel-head { flex-wrap: wrap; }
.tax { display: grid; gap: 8px; }
.tax > input, .tax-add input { width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: inherit; }
.tax-add { display: flex; gap: 6px; }
.tax-group { border: 1px solid var(--border); border-radius: 10px; }
.tax-group > summary { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; font-size: 14px; cursor: pointer; }
.tax-count { margin-left: auto; min-width: 20px; text-align: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.tax-count:empty { display: none; }
.tax-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 10px; padding: 0 12px 8px; }
.tax-item { margin: 5px 0; flex-wrap: nowrap; align-items: flex-start; }
.tax-item input { margin-top: 3px; flex: none; }
#form-dialog:has(.tax) .detail-foot { position: sticky; bottom: 0; flex-wrap: wrap; padding: 10px 0; background: var(--surface); }
.kinds { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.kinds legend { padding: 0; margin-bottom: 4px; font-size: 13px; color: var(--muted); }
.run-list summary { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: baseline; cursor: pointer; font-size: 14px; }
.run-cost { font-variant-numeric: tabular-nums; }
.run-sent { max-height: 280px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; padding: 10px; border-radius: 8px; background: var(--surface); }
@media (max-width: 560px) { .profile-dl { grid-template-columns: 1fr; gap: 2px; } .profile-dl dd { margin-bottom: 8px; } }
