:root {
  color-scheme: light dark;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --raised: #ffffff;
  --ink: #1b1a1f;
  --muted: #6d6b75;
  --line: #e6e4dd;
  --hover: rgba(27, 26, 31, 0.05);
  --accent: #5546d6;
  --accent-ink: #ffffff;
  --accent-soft: #eceaff;
  --danger: #c93838;
  --ok: #1f9d63;
  --c-note: #5546d6;
  --c-link: #2473d6;
  --c-task: #178a55;
  --c-snippet: #b56d0c;
  --c-image: #b83d86;
  --c-file: #5f6672;
  --shadow: 0 1px 2px rgba(20, 18, 30, 0.04), 0 4px 16px rgba(20, 18, 30, 0.04);
  --shadow-big: 0 24px 80px rgba(20, 18, 30, 0.28);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --side: 264px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131316;
    --surface: #1b1b20;
    --raised: #222228;
    --ink: #ececf1;
    --muted: #9896a3;
    --line: #2b2b33;
    --hover: rgba(255, 255, 255, 0.06);
    --accent: #9287ff;
    --accent-ink: #14131c;
    --accent-soft: #272548;
    --danger: #ff6b6b;
    --ok: #4fd093;
    --c-note: #a59cff;
    --c-link: #6cabff;
    --c-task: #4fd093;
    --c-snippet: #f0b455;
    --c-image: #f07fc0;
    --c-file: #a3aab8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-big: 0 24px 80px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd { font: 12px/1 var(--mono); padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; color: var(--muted); background: var(--surface); }
code { font: 0.9em var(--mono); background: var(--hover); padding: 0.1em 0.35em; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; }
.spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 550; white-space: nowrap; text-decoration: none !important; color: var(--ink);
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: 0.35; cursor: default; filter: none; }
.btn.big { padding: 13px 20px; font-size: 16px; border-radius: 12px; width: 100%; }
.btn.small { padding: 6px 11px; font-size: 14px; }
.btn.small svg, .btn.tiny svg { width: 15px; height: 15px; }
.btn.tiny { padding: 3px 9px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn.danger { color: var(--danger); }
.btn.round { width: 38px; height: 38px; padding: 0; border-radius: 50%; }
.btn.link { border: 0; background: none; color: var(--muted); font-weight: 400; text-decoration: underline !important; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.is-on { color: var(--accent); }
.icon-btn.is-on svg { fill: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---------- sign in ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); text-align: center; display: grid; gap: 14px; }
.login-logo { margin: 0 auto 4px; border-radius: 16px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 30px; letter-spacing: -0.02em; }
.login-card form { display: grid; gap: 12px; text-align: left; margin-top: 6px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.login-card input { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 12px calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 4px;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; color: var(--ink); font-weight: 700; font-size: 18px; letter-spacing: -0.01em; text-decoration: none !important; }
.brand img { border-radius: 8px; }
.nav { display: grid; gap: 1px; }
.nav-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 9px;
  background: none; color: var(--ink); text-align: left; text-decoration: none !important;
}
.nav-item svg { color: var(--muted); }
.nav-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item em { font-style: normal; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-item:hover { background: var(--hover); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item.is-active svg, .nav-item.is-active em { color: var(--accent); }
.side-foot { margin-top: auto; padding-top: 16px; display: grid; gap: 1px; }

.main { min-width: 0; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(12px + env(safe-area-inset-top)) 20px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; max-width: 560px; height: 40px; padding: 0 12px;
  border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 16px; -webkit-appearance: none; appearance: none; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.top .btn.primary { margin-left: auto; }
.column { max-width: 760px; margin: 0 auto; padding: 8px 20px 96px; }

/* ---------- quick capture ---------- */
.composer {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  padding: 12px 12px 8px 16px; transition: border-color 0.12s, box-shadow 0.12s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { display: block; width: 100%; border: 0; outline: 0; resize: none; background: none; font-size: 16px; line-height: 1.45; padding: 4px 0; max-height: 240px; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin: 4px 0 0 -8px; }
.composer-bar .hint { flex: 1; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-bar .btn.round { margin-left: auto; }
.composer-files { display: flex; flex-wrap: wrap; gap: 6px; }
.composer-files:not(:empty) { margin: 6px 0 2px; }

/* ---------- feed ---------- */
.feed-head { display: flex; align-items: baseline; gap: 10px; margin: 26px 2px 12px; }
.feed-head h1 { font-size: 22px; letter-spacing: -0.02em; }
.feed-head .btn { margin-left: auto; }
.chips { display: none; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; text-decoration: none !important; }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }
.feed { display: grid; gap: 10px; }
.empty { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 64px 20px; color: var(--muted); }
.empty b { color: var(--ink); font-size: 17px; }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 6px; cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s; overflow: hidden;
}
.card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--kind, transparent); opacity: 0.85; }
.card.t-note { --kind: var(--c-note); } .card.t-link { --kind: var(--c-link); } .card.t-task { --kind: var(--c-task); }
.card.t-snippet { --kind: var(--c-snippet); } .card.t-image { --kind: var(--c-image); } .card.t-file { --kind: var(--c-file); }
.card:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); box-shadow: var(--shadow); }
.card-main { display: flex; gap: 12px; align-items: flex-start; }
.card-body { flex: 1; min-width: 0; display: grid; gap: 6px; }
.card h3 { font-size: 16px; font-weight: 650; letter-spacing: -0.005em; }
.card.is-done h3, .card.is-done .link-title { color: var(--muted); }
.card.t-task.is-done h3 { text-decoration: line-through; }
.card .md { max-height: 320px; overflow: hidden; }
.more-hint { font-size: 13px; color: var(--accent); }
.link-title { font-weight: 650; font-size: 16px; color: var(--ink); line-height: 1.35; }
.host { font-size: 13px; color: var(--c-link); }
.desc { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.thumb { width: 96px; height: 72px; object-fit: cover; border-radius: 10px; flex: none; background: var(--hover); }
.card.t-snippet .md { font-family: var(--mono); font-size: 13.5px; }
.check {
  flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; border: 1.75px solid color-mix(in srgb, var(--muted) 60%, transparent);
  background: none; display: grid; place-items: center; color: transparent; padding: 0; transition: all 0.12s;
}
.card.t-link .check { border-radius: 7px; }
.check svg { width: 14px; height: 14px; stroke-width: 2.6; }
.check:hover { border-color: var(--ok); color: color-mix(in srgb, var(--ok) 50%, transparent); }
.check.is-on { background: var(--ok); border-color: var(--ok); color: #fff; }
.card-foot { display: flex; align-items: center; gap: 10px; margin-top: 6px; min-height: 36px; font-size: 12.5px; color: var(--muted); }
.kind { display: inline-flex; align-items: center; gap: 5px; color: var(--kind); font-weight: 600; }
.kind svg, .pinned svg { width: 14px; height: 14px; }
.pinned { color: var(--accent); display: inline-flex; }
.actions { display: flex; margin-right: -8px; opacity: 0; transition: opacity 0.12s; }
.card:hover .actions, .card:focus-within .actions { opacity: 1; }
.actions .icon-btn { width: 32px; height: 32px; }
.actions .icon-btn svg { width: 16px; height: 16px; }

.shots { display: grid; gap: 4px; border-radius: 10px; overflow: hidden; grid-template-columns: repeat(2, 1fr); }
.shots.n1 { grid-template-columns: 1fr; }
.shots.n3 { grid-template-columns: repeat(3, 1fr); }
.shot { position: relative; margin: 0; background: var(--hover); }
.shot img, .shot video { display: block; width: 100%; height: 100%; max-height: 420px; object-fit: cover; cursor: zoom-in; }
.shots.n1 .shot img { object-fit: contain; max-height: 460px; width: auto; max-width: 100%; }
.shots.n1 .shot { background: none; }
.shots:not(.n1) .shot { aspect-ratio: 1; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 5px 6px 5px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 13.5px; }
.file-chip a { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: var(--ink); padding-right: 4px; }
.file-chip b { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip i { font-style: normal; color: var(--muted); font-size: 12px; flex: none; }
.file-chip svg { width: 15px; height: 15px; color: var(--muted); }
.file-remove { border: 0; background: none; padding: 3px; border-radius: 6px; color: var(--muted); display: grid; place-items: center; }
.file-remove:hover { background: var(--hover); color: var(--danger); }
.shot .file-remove { position: absolute; top: 6px; right: 6px; background: rgba(0, 0, 0, 0.55); color: #fff; border-radius: 50%; padding: 5px; }
.audio { display: flex; align-items: center; gap: 6px; }
.audio audio { width: 100%; height: 36px; }

.facts { display: flex; flex-wrap: wrap; gap: 6px; }
.fact {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 5px 10px; border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--c-snippet) 35%, var(--line)); background: color-mix(in srgb, var(--c-snippet) 8%, var(--surface));
  font: 13px var(--mono); color: var(--ink);
}
.fact i { font: 600 10.5px var(--font); letter-spacing: 0.06em; text-transform: uppercase; color: var(--c-snippet); }
.fact svg { width: 14px; height: 14px; color: var(--muted); }
.fact:hover { border-color: var(--c-snippet); }
.fact:active { transform: scale(0.98); }

/* ---------- rendered Markdown ---------- */
.md { line-height: 1.55; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md table { margin: 0 0 0.7em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 0.4em; line-height: 1.25; letter-spacing: -0.01em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.08em; } .md h4 { font-size: 1em; }
.md ul, .md ol { padding-left: 1.4em; }
.md li { margin: 0.15em 0; }
.md li.task-list-item { list-style: none; margin-left: -1.4em; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.md li.task-list-item > ul { flex-basis: 100%; margin: 0 0 0 1.4em; }
.md input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; transform: translateY(2px); cursor: pointer; }
.md blockquote { border-left: 3px solid var(--line); padding: 0.1em 0 0.1em 0.9em; color: var(--muted); }
.md pre { background: var(--hover); padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; font-size: 13px; }
.md img { max-width: 100%; border-radius: 10px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 10px; text-align: left; }
.md th { background: var(--hover); font-weight: 600; }
.md a.tag { color: var(--accent); background: var(--accent-soft); padding: 0.05em 0.45em; border-radius: 999px; font-size: 0.92em; text-decoration: none; white-space: nowrap; }
.md a.wikilink { color: var(--accent); border-bottom: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent); text-decoration: none; }

/* ---------- sheets (dialogs) ---------- */
dialog { color: var(--ink); }
.sheet {
  width: min(1120px, calc(100vw - 48px)); height: min(860px, calc(100dvh - 48px)); max-width: none; max-height: none;
  padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-big); overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: rise 0.16s ease-out; }
.sheet::backdrop, .viewer::backdrop { background: rgba(12, 11, 18, 0.45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(0.99); } }
.sheet-head { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex: none; }
.sheet-head h2 { font-size: 17px; margin-left: 6px; }
.sheet-head select { border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 6px 8px; font-weight: 600; margin-left: 4px; }
.status { font-size: 13px; margin-left: 10px; }

.editor-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; }
.editor-write { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 18px 22px 0; border-right: 1px solid var(--line); }
.editor-read { overflow-y: auto; padding: 22px 26px; min-width: 0; background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
.ed-title { border: 0; outline: 0; background: none; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; padding: 0 0 8px; width: 100%; }
.ed-url { display: flex; align-items: center; gap: 8px; padding: 2px 4px 2px 10px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--c-link); }
.ed-url input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--c-link); font-size: 14.5px; }
.ed-text-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
#ed-text { flex: 1; width: 100%; border: 0; outline: 0; resize: none; background: none; font: 14.5px/1.6 var(--mono); padding: 4px 0 18px; tab-size: 2; }
.suggest { position: absolute; left: 0; bottom: 8px; z-index: 2; list-style: none; margin: 0; padding: 4px; width: min(340px, 100%); max-height: 220px; overflow-y: auto; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-big); }
.suggest li { padding: 7px 10px; border-radius: 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest li.is-active, .suggest li:hover { background: var(--accent-soft); color: var(--accent); }
.preview-link { padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.preview-link a { font-weight: 650; font-size: 1.1em; }
.preview-link span { color: var(--muted); font-size: 14px; }
.editor-foot { flex: none; max-height: 36%; overflow-y: auto; padding: 10px 22px 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.editor-foot:empty, .ed-files:empty, #ed-facts:empty { display: none; }
.ed-files .shots { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.ed-files .shots .shot { aspect-ratio: 1; background: var(--hover); }
.ed-files .shots .shot img { object-fit: cover; width: 100%; height: 100%; max-height: none; }
.ed-files .shots + .file-chips { margin-top: 8px; }
.ed-foot-row { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }
.backlinks { display: grid; gap: 4px; }
.backlinks h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.backlinks a { display: flex; gap: 8px; align-items: center; padding: 6px 8px; margin: 0 -8px; border-radius: 8px; color: var(--ink); text-decoration: none; min-width: 0; }
.backlinks a:hover { background: var(--hover); }
.backlinks a b { flex: none; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backlinks a span { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backlinks svg { color: var(--muted); width: 15px; height: 15px; }
.only-narrow { display: none; }
.preview-title { display: none; font-size: 24px; letter-spacing: -0.02em; margin: 0 0 14px; }

.settings { width: min(720px, calc(100vw - 48px)); }
.settings-body { overflow-y: auto; padding: 6px 24px 28px; }
.settings section { padding: 20px 0; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.settings section:last-child { border: 0; }
.settings h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.settings h3 svg { color: var(--accent); }
.settings h4 { font-size: 14px; margin-top: 6px; }
.settings p .btn { margin: 0 6px 6px 0; }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 10px; }
.steps ol { margin: 8px 0 0; padding-left: 1.2em; display: grid; gap: 8px; color: var(--muted); list-style: lower-alpha; }
.steps ol b, .steps ol code { color: var(--ink); }
.rows { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; }
.rows li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.rows li + li { border-top: 1px solid var(--line); }
.rows li div { flex: 1; min-width: 0; display: grid; }
.rows li span { font-size: 13px; color: var(--muted); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.token-box { margin-top: 8px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); display: grid; gap: 8px; justify-items: start; }
.token-box code { background: none; padding: 0; word-break: break-all; font-size: 13px; user-select: all; -webkit-user-select: all; }
.token-box p { font-size: 13px; }
.bookmarklet { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); cursor: grab; }
.keys { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; color: var(--muted); }

.viewer { border: 0; padding: 0; background: none; max-width: 100vw; max-height: 100dvh; width: 100vw; height: 100dvh; place-items: center; cursor: zoom-out; }
.viewer[open] { display: grid; }
.viewer::backdrop { background: rgba(8, 8, 12, 0.9); }
.viewer img { max-width: 96vw; max-height: 94dvh; object-fit: contain; border-radius: 6px; }

/* ---------- overlays ---------- */
.toasts { position: fixed; inset: auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2147483647; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow-big); font-weight: 500; animation: rise 0.16s ease-out; }
.toast.is-error { background: var(--danger); color: #fff; }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; padding: 0; }
.drop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 16%, transparent); backdrop-filter: blur(2px); pointer-events: none; }
.drop div { padding: 22px 34px; border: 2px dashed var(--accent); border-radius: 18px; background: var(--surface); font-weight: 650; font-size: 18px; color: var(--accent); }
.scrim { position: fixed; inset: 0; z-index: 19; background: rgba(12, 11, 18, 0.45); }
.popup-done { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center; padding: 24px; }
.popup-done b { font-size: 19px; }
.popup-done span { color: var(--muted); font-size: 14px; }
.popup-done.is-error b { color: var(--danger); }
.only-mobile { display: none; }

/* ---------- narrow editor: write or read, not both ---------- */
@media (max-width: 899px) {
  .editor-body { grid-template-columns: 1fr; }
  .editor-write { border-right: 0; }
  .editor-body.mode-read .editor-write, .editor-body:not(.mode-read) .editor-read { display: none; }
  .only-narrow { display: inline-grid; }
  .preview-title { display: block; }
  .editor-read { background: none; }
}

/* ---------- phones ---------- */
@media (max-width: 759px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 20; inset: 0 auto 0 0; width: min(300px, 84vw); background: var(--bg); transform: translateX(-102%); transition: transform 0.2s ease; padding-top: calc(18px + env(safe-area-inset-top)); }
  .side.is-open { transform: none; box-shadow: var(--shadow-big); }
  .only-mobile { display: inline-grid; }
  .only-desktop { display: none !important; }
  .top { padding-left: 10px; padding-right: 12px; gap: 4px; }
  .top .btn.primary { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
  .column { padding: 4px 14px calc(150px + env(safe-area-inset-bottom)); }
  .chips { display: flex; margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
  .feed-head { margin-top: 10px; }
  /* Quick capture sits at the thumb, like a chat. */
  .composer { position: fixed; z-index: 6; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); padding: 8px 8px 6px 14px; box-shadow: var(--shadow-big); }
  .composer-bar { position: absolute; right: 6px; bottom: 6px; margin: 0; }
  .composer textarea { padding-right: 88px; min-height: 40px; }
  .actions { opacity: 1; }
  .card { padding: 13px 14px 4px; }
  .thumb { width: 76px; height: 60px; }
  .sheet { width: 100vw; height: 100dvh; border: 0; border-radius: 0; margin: 0; }
  .sheet-head { padding-top: calc(8px + env(safe-area-inset-top)); }
  .editor-write { padding: 14px 16px 0; }
  .editor-read { padding: 16px; }
  .editor-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
  .settings-body { padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
  #ed-text { font-size: 16px; }
  .ed-title { font-size: 22px; }
  .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
