/* Philosophize — dark, amber campfire. All colors live in the tokens below so the look is easy to refine later. */
:root {
  --bg: #121110;
  --surface: #1b1917;
  --surface-2: #232019;
  --surface-3: #2b2722;
  --line: #2f2a25;
  --line-strong: #3d362f;
  --text: #ece6de;
  --muted: #9d948b;
  --faint: #6f675f;
  --amber: #e8a13a;
  --amber-bright: #f5b94f;
  --amber-dim: #8f5e1b;
  --amber-rgb: 232, 161, 58;
  --amber-wash: rgba(var(--amber-rgb), 0.1);
  --amber-line: rgba(var(--amber-rgb), 0.28);
  --danger: #e0645a;
  --radius: 14px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 520px at 50% -8%, #22160a 0%, rgba(18, 17, 16, 0) 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 8px; }
svg { display: block; }

/* ───── top bar ───── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 10px max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left));
  background: rgba(18, 17, 16, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: 0.2px; }
.brand-flame { color: var(--amber); width: 18px; height: 18px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 10px; color: var(--muted); font-size: 14px;
}
.tabs a:hover { color: var(--text); background: var(--surface); }
.tabs a.active { color: var(--amber-bright); background: var(--amber-wash); }
.tabs svg { width: 16px; height: 16px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: 10px; color: var(--muted);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; }
/* the + button matches the app icon: black disc, gold ring, gold plus */
.icon-btn.accent { background: #000; color: #ffbe00; border: 2px solid #ffbe00; border-radius: 50%; width: 34px; height: 34px; }
.icon-btn.accent svg { stroke-width: 2.4; }
.icon-btn.accent:hover { background: rgba(255, 190, 0, 0.14); color: #ffd24d; border-color: #ffd24d; }
.icon-btn.danger:hover { color: var(--danger); }

/* ───── layout ───── */
main { max-width: 1040px; margin: 0 auto; padding: 28px 18px 120px; outline: none; }
.narrow { max-width: 680px; margin: 0 auto; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.2px; }
.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .count { color: var(--faint); font-size: 13px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ───── buttons ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 550;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
}
.btn:hover { background: var(--surface-3); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #1a1208; }
.btn.primary:hover { background: var(--amber-bright); border-color: var(--amber-bright); }
.btn.ghost { background: transparent; border-color: var(--line-strong); }
.btn.ghost-amber { background: transparent; color: var(--amber); border-color: var(--amber-line); }
.btn.ghost-amber:hover { background: var(--amber-wash); }
.btn.danger { background: transparent; color: var(--danger); border-color: rgba(224, 100, 90, 0.4); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ───── inputs ───── */
.field, .search input, textarea.field {
  width: 100%; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px;
  padding: 10px 12px; color: var(--text);
}
.field:focus, .search input:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-wash); }
textarea.field { resize: vertical; min-height: 90px; line-height: 1.5; }
label.lbl { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; letter-spacing: 0.3px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search input { padding-left: 36px; }
.counter { text-align: right; font-size: 12px; color: var(--faint); margin-top: 4px; }
.counter.over { color: var(--danger); }

/* ───── chips & segmented ───── */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { background: transparent; border: 0; padding: 5px 11px; border-radius: 8px; color: var(--muted); font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--amber-wash); color: var(--amber-bright); }
.seg button svg { width: 14px; height: 14px; }
.by { font-size: 12px; color: var(--faint); display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.pill { padding: 1px 9px; border-radius: 99px; font-size: 12px; border: 1px solid transparent; background: transparent; color: var(--faint); }
.pill.on { background: var(--amber-wash); color: var(--amber-bright); border-color: var(--amber-line); }
.pill[disabled] { cursor: not-allowed; opacity: 0.7; }
select.sel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; color: var(--muted); font-size: 13px; }

/* ───── spark cards ───── */
.grid { columns: 3 290px; column-gap: 14px; }
.grid.list { columns: 1; max-width: 720px; margin: 0 auto; }
.card {
  position: relative; break-inside: avoid; margin: 0 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 12px;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--amber-line); background: var(--surface-2); }
/* the tools sit in reserved space at the bottom right, so they never cover the text */
@media (hover: hover) { .card { padding-bottom: 46px; } }
.card.pinned { border-color: var(--amber-line); background: linear-gradient(180deg, rgba(var(--amber-rgb),0.06), rgba(var(--amber-rgb),0) 60%), var(--surface); }
.q { font-family: var(--serif); font-size: 17px; line-height: 1.5; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.src { margin-top: 10px; font-size: 13px; color: var(--muted); }
.note { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line-strong); font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.meta { margin-top: 8px; font-size: 12px; color: var(--amber-dim); }
.card .tools {
  position: absolute; bottom: 8px; right: 8px; display: flex; gap: 2px; padding: 3px;
  background: rgba(27, 25, 23, 0.96); border: 1px solid var(--line-strong); border-radius: 10px;
  opacity: 0; transform: translateY(2px); transition: opacity 0.12s; pointer-events: none;
}
.card:hover .tools, .card:focus-within .tools { opacity: 1; pointer-events: auto; transform: none; }
@media (hover: none) { .card .tools { display: none; } }
.card .tools .icon-btn { width: 28px; height: 28px; }
.card .tools .icon-btn.on { color: var(--amber); }

.mantel { margin-bottom: 26px; }
.mantel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--amber-bright); font-weight: 600; font-size: 14px; }
.mantel-head svg { width: 15px; height: 15px; }
.mantel-head .faint { font-weight: 400; font-size: 12px; }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 12px; padding: 4px 6px; }
.link-btn:hover { color: var(--text); }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h2 { color: var(--text); font-weight: 600; font-size: 18px; margin: 0 0 6px; }

/* ───── home ───── */
.home { min-height: 58vh; display: grid; place-items: center; }
.spark-hero {
  width: 100%; max-width: 620px; background: linear-gradient(180deg, rgba(var(--amber-rgb),0.07), rgba(var(--amber-rgb),0) 70%), var(--surface);
  border: 1px solid var(--amber-line); border-radius: 18px; padding: 22px 24px 20px; box-shadow: var(--shadow), 0 0 80px rgba(var(--amber-rgb), 0.06);
}
.label { display: flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: 1.2px; color: var(--amber-dim); font-weight: 650; text-transform: uppercase; }
.label svg { width: 12px; height: 12px; }
.spark-hero .q { font-size: 23px; color: var(--amber-bright); margin-top: 14px; line-height: 1.45; }
.spark-hero .src { font-size: 14px; }
.hero-actions { display: flex; gap: 10px; margin-top: 22px; align-items: center; }
.hero-actions .btn.primary { flex: 1; padding: 11px 14px; }
.saved-when { margin-top: 12px; font-size: 12px; color: var(--faint); }

/* ───── journal list ───── */
.list-items { display: flex; flex-direction: column; gap: 10px; }
.item { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.item:hover { border-color: var(--amber-line); background: var(--surface-2); }
.item .t { font-weight: 600; margin-bottom: 3px; }
.item .p { color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .m { color: var(--faint); font-size: 12px; margin-top: 6px; }

/* ───── session ───── */
.session-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.session-head .back { color: var(--amber); display: inline-flex; align-items: center; gap: 4px; font-size: 14px; }
.session-head .back svg { width: 14px; height: 14px; }
.title-wrap { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: 17px; min-width: 0; flex: 1 1 200px; }
.title-wrap > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.title-wrap input { font: inherit; font-weight: 650; background: var(--surface); border: 1px solid var(--amber); border-radius: 8px; padding: 4px 8px; color: var(--text); min-width: 260px; }
.thread { display: flex; flex-direction: column; gap: 16px; }
.msg-card { align-self: center; width: 100%; max-width: 560px; border: 1px solid var(--amber-line); background: var(--amber-wash); border-radius: var(--radius); padding: 14px 16px; position: relative; }
.msg-card .q { color: var(--amber-bright); font-size: 16.5px; margin-top: 8px; }
.msg-card.question { border-style: dashed; }
.msg-card.question .q { font-family: var(--font); font-size: 16px; color: var(--text); }
.msg-card.linked { cursor: pointer; }
.msg-card.linked:hover { background: rgba(var(--amber-rgb), 0.16); }
.msg-tools { display: flex; gap: 2px; justify-content: flex-end; margin-top: 6px; opacity: 0.0; transition: opacity 0.12s; }
.msg-card:hover .msg-tools, .bubble-wrap:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
@media (hover: none) { .msg-tools { opacity: 1; } }
.msg-tools .icon-btn { width: 26px; height: 26px; }
.bubble-wrap { align-self: stretch; max-width: 100%; }
.bubble { background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px 15px; overflow-wrap: anywhere; line-height: 1.6; }
.bubble-wrap .msg-tools { justify-content: flex-start; }
.edit-box { width: 100%; }
.edit-box textarea { min-height: 110px; }
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.composer-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  background: linear-gradient(180deg, rgba(18,17,16,0), var(--bg) 28%);
  padding: 22px 18px calc(16px + env(safe-area-inset-bottom));
}
.composer { max-width: 680px; margin: 0 auto; }
.chips { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 9px; align-items: center; }
.chips-mid { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; }
.nav-arrow { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); }
.nav-arrow svg { width: 17px; height: 17px; }
.nav-arrow:hover:not(:disabled) { color: var(--amber-bright); border-color: var(--amber-line); background: var(--surface-3); }
.nav-arrow:disabled { opacity: 0.3; cursor: default; }
.chips .by-label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); margin-right: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; font-size: 13px; background: var(--surface); border: 1px solid var(--line-strong); color: var(--text); }
.chip svg { width: 13px; height: 13px; }
.chip.spark { color: var(--amber); border-color: var(--amber-line); }
.chip.reflect { color: #8ab4e8; border-color: rgba(138, 180, 232, 0.35); }
.chip:hover:not(:disabled) { background: var(--surface-3); }
.chip:disabled { opacity: 0.45; cursor: not-allowed; }
.input-row { display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; padding: 6px 6px 6px 14px; }
.input-row:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-wash); }
.input-row .ed { flex: 1; min-width: 0; }
.input-row .ed-area { padding: 8px 0; max-height: 220px; border: 0; background: transparent; border-radius: 0; box-shadow: none; min-height: 0; }
.input-row .ed-toolbar { border: 0; background: transparent; padding: 0 0 2px; }
.input-row .icon-btn { width: 36px; height: 36px; }
.input-row .icon-btn.send { background: var(--amber); color: #1a1208; border-radius: 12px; }
.input-row .icon-btn.send:disabled { background: var(--surface-3); color: var(--faint); cursor: default; }
.hint { text-align: center; font-size: 11px; color: var(--faint); margin-top: 6px; }

/* ───── modal ───── */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.62); display: grid; place-items: center; padding: 18px; backdrop-filter: blur(3px); }
.modal { width: min(560px, 100%); max-height: min(86vh, 760px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow); }
.modal-head { padding: 16px 18px 6px; display: flex; align-items: flex-start; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 8px 18px 14px; overflow: auto; }
.modal-foot { padding: 12px 18px 16px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }
.pick-title { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--amber-dim); margin: 14px 0 8px; display: flex; align-items: center; justify-content: space-between; }
.pick { display: block; width: 100%; text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; margin-bottom: 8px; }
.pick:hover { border-color: var(--amber-line); background: var(--surface-3); }
.pick .t { font-weight: 600; font-size: 14px; }
.pick .q { font-size: 14.5px; }
.pick .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pick .p { font-size: 13px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ───── toasts ───── */
#toasts { position: fixed; z-index: 80; left: 50%; bottom: 160px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: #2a2622; border: 1px solid var(--line-strong); padding: 9px 14px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; }
.toast.err { border-color: rgba(224, 100, 90, 0.5); }
/* a notice with an Undo gets a thick gold edge so it can't be missed; click anywhere on it (but Undo) to dismiss */
.toast { cursor: pointer; animation: toast-in 0.22s ease-out; transition: opacity 0.2s, transform 0.2s; }
.toast.out { opacity: 0; transform: translateY(6px) scale(0.98); pointer-events: none; }
.toast.has-action { border: 3px solid var(--amber); padding: 9px 12px 9px 16px; font-weight: 500; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55), 0 0 22px rgba(var(--amber-rgb), 0.25); }
.toast.has-action button { color: var(--amber); font-weight: 700; padding: 5px 12px; border-radius: 8px; border: 1px solid var(--amber-line); background: rgba(var(--amber-rgb), 0.12); }
.toast.has-action button:hover { background: rgba(var(--amber-rgb), 0.26); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.toast button { background: none; border: 0; color: var(--amber); font-weight: 600; padding: 0; }

@media (max-width: 640px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .tabs a span { display: none; }
  .tabs a { padding: 8px 10px; }
  .spark-hero .q { font-size: 20px; }
  .bubble-wrap { max-width: 96%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }


/* ───── home: the campfire ───── */
main.fullbleed { max-width: none; padding: 0; }
main { position: relative; z-index: 1; }
.fireside {
  position: relative; min-height: calc(100vh - 58px); min-height: calc(100dvh - 58px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 28px 210px;
}
.fireside .center { width: 100%; max-width: 760px; }
.stage { min-height: 190px; transition: opacity 0.65s cubic-bezier(0.22, 0.8, 0.3, 1), transform 0.85s cubic-bezier(0.16, 1, 0.3, 1); }
/* Leaving: starts slowly, accelerates, and is fully faded before it would visibly slow down. */
.stage.leave-left, .stage.leave-right { transition: opacity 0.26s cubic-bezier(0.5, 0, 0.9, 0.6), transform 0.46s cubic-bezier(0.55, 0, 0.9, 0.55); }
.stage.leave-left { opacity: 0; transform: translateX(-46px); }
.stage.leave-right { opacity: 0; transform: translateX(46px); }
/* Entering: arrives already moving, then eases gently to a stop. */
.stage.enter-right { opacity: 0; transform: translateX(46px); transition: none; }
.stage.enter-left { opacity: 0; transform: translateX(-46px); transition: none; }
@media (prefers-reduced-motion: reduce) { .stage.leave-left, .stage.leave-right, .stage.enter-left, .stage.enter-right { transform: none; } }
.stage .saved { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: rgba(var(--amber-rgb), 0.78); font-weight: 600; margin-bottom: 18px; }
.stage .quote {
  margin: 0; font-family: var(--serif); font-weight: 500; color: #f3eadb;
  font-size: clamp(25px, 3.1vw, 40px); line-height: 1.38; letter-spacing: -0.005em; text-wrap: pretty;
  white-space: pre-line; text-shadow: 0 2px 30px rgba(0, 0, 0, 0.5);
}
.stage .quote[style*="--len:1"], .stage .quote[style*="--len:2"] { font-size: clamp(22px, 2.6vw, 34px); }
.stage .attrib { margin-top: 20px; font-size: 15px; color: var(--muted); }
.stage .fnote { margin-top: 12px; font-size: 13px; color: var(--faint); font-style: italic; max-width: 560px; }
.controls { display: flex; align-items: center; gap: 12px; margin-top: 34px; }
.ctl {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--amber-line); background: rgba(var(--amber-rgb), 0.06); color: var(--amber-bright);
}
.ctl svg { width: 18px; height: 18px; stroke-width: 2.2; }
.ctl.big { width: 56px; height: 56px; background: rgba(var(--amber-rgb), 0.14); }
.ctl.big svg { width: 20px; height: 20px; fill: currentColor; stroke-width: 2.6; }
.ctl:hover:not(:disabled) { background: rgba(var(--amber-rgb), 0.22); }
.ctl:disabled { opacity: 0.3; cursor: default; }
.when-label { font-size: 14px; color: var(--muted); margin-left: 6px; min-width: 100px; }
.actions { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 26px; }
.act { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; color: var(--muted); font-size: 14px; padding: 6px 2px; }
.act svg { width: 15px; height: 15px; }
.act:hover { color: var(--amber-bright); }
.act.on { color: var(--amber); }
.form-hint { margin-top: 12px; font-size: 12.5px; color: var(--faint); }
.form-hint .link-btn { font-size: inherit; }

/* ───── import preview ───── */
.import-preview { margin-top: 12px; max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 8px; }
.pv-head { font-size: 12px; color: var(--faint); letter-spacing: 0.4px; }
.pv { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--surface-2); }
.pv.dup { opacity: 0.5; }
.pv-q { font-family: var(--serif); font-size: 14px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pv-s { font-size: 12px; color: var(--amber-dim); margin-top: 3px; }

@media (max-width: 640px) {
  .fireside { padding: 28px 20px 190px; }
}

/* ───── ambiance layer (persistent, behind every page) ───── */
#ambiance { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; transition: opacity 0.8s ease; }
#ambiance.off { opacity: 0; visibility: hidden; transition: opacity 0.5s ease, visibility 0s 0.5s; }
.amb-glow {
  position: absolute; left: 50%; bottom: -22vh; width: 130vw; height: var(--glow-h, 90vh); transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(var(--glow-rgb, 232,150,40), calc(0.20 * var(--glow-k, 1))), rgba(var(--glow-rgb, 232,150,40), calc(0.07 * var(--glow-k, 1))) 55%, rgba(0, 0, 0, 0) 100%);
  animation: glowBreath var(--glow-breathe, 6s) ease-in-out infinite alternate;
}
.amb-embers { position: absolute; inset: 0; width: 100%; height: 100%; transition: filter 0.6s; }
.amb-fire {
  position: absolute; left: 50%; transform: translateX(-50%) scale(var(--fire-s, 1)); transform-origin: 50% 100%;
  filter: brightness(var(--fire-b, 1)); transition: filter 0.6s, transform 0.6s, opacity 0.6s;
}
.amb-fire img, .amb-fire video { width: 100%; display: block; }
#ambiance.stoked .amb-embers { filter: brightness(1.5); }
#ambiance.stoked .amb-fire { filter: brightness(calc(var(--fire-b, 1) * 1.35)) saturate(1.2); }
#ambiance-btn { color: var(--faint); }
#ambiance-btn.on { color: var(--amber); }
.nav-arrow.plus:not(:disabled) { color: var(--amber); border-color: var(--amber-line); }

/* ───── tune panel (dev only: open the app with ?tune=1) ───── */
.tune-toggle { position: fixed; right: 64px; bottom: 14px; z-index: 70; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--amber-line); background: var(--surface); color: var(--amber); font-size: 12px; letter-spacing: 0.6px; }
.tune-panel { position: fixed; right: 14px; bottom: 56px; z-index: 70; width: 310px; max-height: 76vh; display: flex; flex-direction: column; background: rgba(27, 25, 23, 0.96); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.tune-title { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line); }
.tune-x { background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1; }
.tune-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tune-actions button { padding: 5px 10px; font-size: 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); }
.tune-prev { font-size: 12px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.tune-status { font-size: 11px; color: var(--amber); }
.tune-body { overflow: auto; padding: 4px 14px 14px; }
.tune-h { margin: 14px 0 4px; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--amber-dim); }
.tune-row { display: block; margin: 8px 0; }
.tune-l { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.tune-v { color: var(--amber); font-variant-numeric: tabular-nums; }
.tune-row input[type=range] { width: 100%; accent-color: var(--amber); }
.tune-row input[type=text] { width: 100%; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); font-size: 12px; }
.tune-note { margin: 10px 0 2px; font-size: 11.5px; line-height: 1.45; color: var(--faint); }

/* ───── screen and dialog transitions ───── */
main { transition: opacity 0.17s ease-in; }
main.leaving { opacity: 0; }
main.entering { animation: viewIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes viewFade { from { opacity: 0; } to { opacity: 1; } }
/* Home holds fixed corner items; a transform on main would make them scroll with it, then snap when it ends. Fade only. */
main.fullbleed.entering { animation-name: viewFade; }
.composer-dock { animation: viewIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) both; transition: opacity 0.17s ease-in; }
.composer-dock.leaving { opacity: 0; }
.backdrop { animation: backdropIn 0.22s ease-out both; }
.modal { animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both; }
.backdrop.closing { animation: backdropOut 0.19s ease-in both; pointer-events: none; }
.backdrop.closing .modal { animation: modalOut 0.19s ease-in both; }
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdropOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes modalOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.97) translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  main.entering, .composer-dock, .backdrop, .modal, .backdrop.closing, .backdrop.closing .modal { animation: none; }
}

/* ───── search: vibe toggle, time chip, setup help ───── */
.pill.soft { opacity: 0.75; border-color: var(--line-strong); }
.vibe-note { margin-left: 6px; color: var(--amber-dim); }
.time-slot:empty { display: none; }
.time-chip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 0; padding: 7px 12px; font-size: 13px; color: var(--muted); background: var(--amber-wash); border: 1px solid var(--amber-line); border-radius: 10px; }
.time-chip svg { width: 14px; height: 14px; color: var(--amber); flex: none; }
.time-chip strong { color: var(--amber-bright); font-weight: 600; }
.time-chip .link-btn { margin-left: auto; color: var(--amber); }
.vibe-help ol { margin: 6px 0 12px; padding-left: 20px; line-height: 1.7; font-size: 14px; }
.vibe-help li { margin-bottom: 8px; }
.vibe-help .cmd { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line-strong); color: var(--amber-bright); font-size: 13px; margin-top: 4px; user-select: all; }
.vibe-why { margin: 0 0 8px; padding: 8px 12px; font-size: 13px; color: var(--muted); border-left: 2px solid var(--amber-line); background: var(--surface-2); border-radius: 6px; }

/* Stage 3: Question / Related */
.chip.busy { opacity: 0.7; animation: chip-pulse 1.2s ease-in-out infinite; }
@keyframes chip-pulse { 50% { opacity: 0.35; } }
.pick.static { cursor: default; }
.pick.static:hover { border-color: var(--line); background: var(--surface-2); }
.pick.static .q { margin: 6px 0 10px; }
.pick .s { color: var(--text-dim, #9a8f80); font-size: 12px; font-weight: 400; }
.pick-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.pick-actions .btn { font-size: 12px; padding: 5px 10px; }
.msg-card.rerolling .q { opacity: 0.4; transition: opacity 0.2s; }
.msg-card.rerolling .msg-tools { opacity: 1; }
.msg-card.rerolling .icon-btn:disabled svg { animation: chip-pulse 0.9s ease-in-out infinite; }

/* Journal list: delete on hover (always shown on touch); no swipe-to-delete, reflections are kept on purpose */
.item-wrap { position: relative; border-radius: var(--radius); overflow: hidden; transition: opacity 0.25s, max-height 0.25s; max-height: 220px; }
.item-wrap.gone { opacity: 0; max-height: 0; pointer-events: none; }
.item-wrap .item { position: relative; z-index: 1; transition: transform 0.2s ease-out, border-color 0.15s, background 0.15s; touch-action: pan-y; }
.item-wrap .item-del { position: absolute; z-index: 2; top: 10px; right: 10px; opacity: 0; transition: opacity 0.12s; }
.item-wrap:hover .item-del, .item-wrap .item-del:focus-visible { opacity: 1; }
@media (hover: none) { .item-wrap .item-del { opacity: 0.75; } }

/* Card is clickable: opens the focus view */
.card { cursor: pointer; }
.card:focus-visible { outline: 2px solid var(--amber-line); outline-offset: 2px; }

/* Focus view: one spark, presented like Home */
.focus-overlay { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 28px 22px; background: rgba(12, 10, 8, 0.7); backdrop-filter: blur(5px); animation: backdropIn 0.25s ease-out both; overflow-y: auto; }
.focus-overlay.closing { animation: backdropOut 0.2s ease-in both; pointer-events: none; }
.focus-center { width: 100%; max-width: 760px; margin: auto; animation: modalIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both; }
.focus-overlay.closing .focus-center { animation: modalOut 0.2s ease-in both; }
.focus-x { position: fixed; top: 16px; right: 16px; width: 38px; height: 38px; }
.focus-stage { min-height: 0; }
.focus-tools { margin-top: 28px; }
.focus-tools .tools { gap: 2px; position: static; opacity: 1; pointer-events: auto; transform: none; display: inline-flex; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 4px; }
.focus-tools .tools .icon-btn { width: 40px; height: 40px; }
.focus-tools .tools .icon-btn.on { color: var(--amber); }

/* Home: the same actions appear when you hover the quote (always shown on touch) */
.quote-tools { height: 44px; margin-top: 16px; display: flex; align-items: center; opacity: 0; transition: opacity 0.2s; }
@media (hover: hover) { .stage:hover .quote-tools, .quote-tools:focus-within { opacity: 1; } }
.quote-tools .tools { gap: 2px; position: static; opacity: 1; pointer-events: auto; transform: none; display: inline-flex; background: none; border: 0; padding: 0; }
.quote-tools .tools .icon-btn { width: 34px; height: 34px; }
.quote-tools .tools .icon-btn.on { color: var(--amber); }
@media (hover: none) { .quote-tools { opacity: 0.85; } }
.modal .foot-left, .foot-left { margin-right: auto; }
@media (prefers-reduced-motion: reduce) { .focus-overlay, .focus-center { animation: none; } }

/* Home and focus view: the quote marks hang in the margin so the text itself stays flush with the attribution below */
.stage .quote { position: relative; }
.stage .quote::before { content: '\201C'; position: absolute; right: 100%; top: 0; padding-right: 0.08em; color: rgba(var(--amber-rgb), 0.9); }
.stage .quote::after { content: '\201D'; color: rgba(var(--amber-rgb), 0.9); }

.tune-color { display: flex; gap: 8px; align-items: center; }
.tune-color input[type=color] { width: 38px; height: 28px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: none; }
.tune-color .tune-hex { flex: 1; min-width: 0; }


/* ── rich-text editor ── */
.ed { display: flex; flex-direction: column; position: relative; }
.ed-toolbar { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; padding: 4px 6px; border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--surface-2); position: relative; }
.ed-btn { display: inline-flex; align-items: center; gap: 4px; min-width: 30px; height: 28px; padding: 0 7px; justify-content: center; background: transparent; border: 0; border-radius: 7px; color: var(--muted, #b9ad9a); cursor: pointer; font: inherit; font-size: 14px; }
.ed-btn svg { width: 16px; height: 16px; }
.ed-btn:hover { background: var(--surface-3); color: var(--text, #f3e9d8); }
.ed-btn.on { background: var(--amber-wash); color: var(--amber-bright, var(--amber)); }
.ed-btn .aa { font-size: 13px; letter-spacing: .02em; }
.ed-sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 4px; }
.ed-menu { position: absolute; z-index: 30; min-width: 170px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 4px; box-shadow: 0 10px 30px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.ed-menu-item { text-align: left; background: transparent; border: 0; color: inherit; font: inherit; padding: 7px 10px; border-radius: 7px; cursor: pointer; }
.ed-menu-item:hover { background: var(--surface-3); }
.ed-menu-item.h1 { font-size: 1.35em; font-weight: 600; } .ed-menu-item.h2 { font-size: 1.15em; font-weight: 600; } .ed-menu-item.h3 { font-weight: 600; } .ed-menu-item.bq { font-style: italic; border-left: 2px solid var(--amber); border-radius: 0 7px 7px 0; }
.ed-area { min-height: 90px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 0 0 10px 10px; background: var(--surface); line-height: 1.55; outline: none; overflow-y: auto; overflow-wrap: anywhere; position: relative; }
.ed-area:focus { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-wash); }
.ed-area.is-empty::before { content: attr(data-placeholder); color: var(--faint); position: absolute; pointer-events: none; }
.ed-light .ed-area { min-height: 80px; }
.ed-area p, .md p { margin: 0; min-height: 1.5em; }
.ed-area h1, .md h1 { font-size: 1.5em; margin: .5em 0 .2em; line-height: 1.25; } .ed-area h2, .md h2 { font-size: 1.25em; margin: .5em 0 .2em; line-height: 1.25; } .ed-area h3, .md h3 { font-size: 1.08em; margin: .5em 0 .2em; }
.ed-area ul, .ed-area ol, .md ul, .md ol { margin: .2em 0; padding-left: 1.5em; }
.ed-area blockquote, .md blockquote { margin: .3em 0; padding: 0 0 0 12px; border-left: 3px solid var(--amber-dim, var(--amber)); color: var(--muted, inherit); font-style: italic; }
.ed-area a, .md a { color: var(--amber-bright, var(--amber)); text-decoration: underline; }
.ed-area hr, .md hr { border: 0; border-top: 1px solid var(--line-strong); margin: .6em 0; }
.caps-hint { margin-top: 6px; font-size: 13px; color: var(--amber-bright, var(--amber)); }
.caps-hint[hidden] { display: none; }
.edit-box .ed { width: 100%; }
.fix-caps{display:flex;align-items:center;gap:8px;margin:10px 0 2px;font-size:13px;color:var(--muted,#b9ad9a)}
.input-row .ed-area, .input-row .ed-area:focus { border: 0; box-shadow: none; background: transparent; }
.input-row .ed-area.is-empty::before { left: 0; }

.composer-dock.editing { display: none; }

/* dictation */
.ed-spacer { flex: 1; }
.icon-btn.mic.recording { color: #ff6b5a; background: rgba(255,107,90,.14); display: inline-flex; align-items: center; gap: 6px; width: auto; padding: 0 10px; animation: micPulse 1.4s ease-in-out infinite; }
.icon-btn.mic .mic-time { font-size: 12px; font-variant-numeric: tabular-nums; }
.icon-btn.mic.busy { position: relative; color: #ff6b5a; pointer-events: none; animation: none; }
/* after you stop: a ring turns around the mic until the words arrive */
.icon-btn.mic.busy::after { content: ''; position: absolute; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px; box-sizing: border-box; border-radius: 50%; border: 2px solid rgba(255, 107, 90, 0.2); border-top-color: #ff6b5a; border-right-color: #ff6b5a; animation: micSpin 0.8s linear infinite; }
@keyframes micSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.mic.busy::after { animation-duration: 2.4s; } }
.ed-toolbar .icon-btn.mic { width: 30px; height: 28px; border-radius: 7px; }
.ed-toolbar .icon-btn.mic.recording { width: auto; }
@keyframes micPulse { 50% { opacity: .55; } }

/* ⌘K palette */
.palette-backdrop { align-items: start; padding-top: 12vh; }
.palette { width: min(640px, 100%); max-height: 70vh; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) both; }
.palette-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted, #b9ad9a); }
.palette-top svg { width: 18px; height: 18px; flex: none; }
.palette-input { flex: 1; background: transparent; border: 0; outline: none; color: var(--text, #f3e9d8); font: inherit; font-size: 16px; }
.palette-top kbd, .palette-foot { font-size: 11px; color: var(--faint); }
.palette-top kbd { border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 6px; }
.palette-list { overflow-y: auto; padding: 6px; }
.palette-head { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 10px 10px 4px; }
.palette-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: transparent; border: 0; color: inherit; font: inherit; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.palette-row svg { width: 16px; height: 16px; flex: none; color: var(--muted, #b9ad9a); }
.palette-row.sel { background: var(--amber-wash); }
.palette-row.sel svg { color: var(--amber-bright, var(--amber)); }
.pr-main { display: flex; flex-direction: column; min-width: 0; }
.pr-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-s { font-size: 12px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-empty { padding: 22px; text-align: center; color: var(--faint); }
.palette-foot { display: flex; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--line); }

.msg-card.openable { cursor: pointer; }

/* picture sparks */
.pic-box { margin-top: 10px; }
.pic-prev { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.pic-prev img { width: 96px; max-height: 96px; object-fit: cover; border-radius: 8px; flex: none; }
.pic-side { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted, #b9ad9a); align-items: flex-start; }
.pic-existing { display: block; max-width: 100%; max-height: 220px; border-radius: 10px; margin-bottom: 10px; }
.modal.dropping { outline: 2px dashed var(--amber); outline-offset: -6px; }
.stage-img { max-width: min(100%, 760px); max-height: 42vh; border-radius: 12px; display: block; margin: 0 auto 14px; }
.quote.small { font-size: clamp(18px, 2.4vw, 26px); }
.thread-img { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; margin: 8px 0; }

.brand-icon { width: 38px; height: 38px; border-radius: 9px; display: block; }
.brand-logo { height: 32px; width: auto; display: block; }
.cv-brand { display: block; flex: none; line-height: 0; border-radius: 22px; margin-right: 4px; }
.cv-brand img { height: 30px; width: auto; display: block; }
@media (max-width: 620px) { .cv-brand { width: 32px; overflow: hidden; } .cv-overlay .sk-top a.sk-btn span { display: none; } }

/* backup dialog */
.backup-h { margin: 18px 0 4px; font-size: 14px; }
.backup-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.backup-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.backup-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; color: inherit; text-decoration: none; }
.backup-row span:first-child { flex: 1; }
.backup-row svg { width: 16px; height: 16px; color: var(--muted, #b9ad9a); }
.backup-row:hover { background: var(--surface-2); }
.backup code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
.muted.small { font-size: 13px; margin: 4px 0 8px; }

/* long sparks */
.card .q.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 7; line-clamp: 7; overflow: hidden; }
.more-hint { margin-top: 8px; font-size: 12px; letter-spacing: 0.4px; color: var(--amber, #d9a441); display: inline-flex; align-items: center; gap: 2px; }
.more-hint .icon, .more-hint svg { width: 14px; height: 14px; }
.stage .quote-rest { margin-top: 22px; max-width: 62ch; font-family: var(--font); font-size: 16px; line-height: 1.65; color: var(--text); }
.stage .quote-rest p { margin: 0 0 12px; white-space: pre-line; overflow-wrap: anywhere; }
.stage a, .card .q a, .msg-card .q a { color: var(--amber-bright, #f0c36a); text-decoration: underline; text-underline-offset: 2px; }
.sp-head { display: block; font-family: var(--font); font-weight: 650; font-size: 0.8em; letter-spacing: 0.06em; text-transform: uppercase; color: var(--amber-bright, #f0c36a); margin: 0.9em 0 0.25em; }
.sp-head:first-child { margin-top: 0; }
.ed-btn.hd .aa { font-weight: 700; }
.sp-head.l1 { font-family: var(--serif); font-size: 1.25em; font-weight: 600; letter-spacing: 0; text-transform: none; color: inherit; margin: 0.6em 0 0.25em; }
.ed-btn.hd { min-width: 28px; }

/* touch screens: tools hidden until you tap */
@media (hover: none) {
  .touch-toggle .msg-tools { display: none; }
  .touch-toggle.tools-open .msg-tools { display: flex; }
  .touch-toggle { -webkit-tap-highlight-color: transparent; }
  .touch-toggle.tools-open { box-shadow: 0 0 0 1px rgba(var(--amber-rgb), 0.35); border-radius: 12px; }
  .quote-tools { opacity: 0; pointer-events: none; }
  .stage.tools-on .quote-tools { opacity: 0.95; pointer-events: auto; }
  .fireside .center { touch-action: pan-y; }
}

.pin-on svg { fill: currentColor; fill-opacity: 0.3; }
.mantel-head svg { width: 15px; height: 15px; }

/* corner buttons: About (lower left) and fire sound (lower right) */
.corner-btn { position: fixed; bottom: 14px; z-index: 40; width: 34px; height: 34px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(20, 18, 16, 0.55); color: var(--muted); cursor: pointer; backdrop-filter: blur(6px); opacity: 0.7; transition: opacity 0.15s, color 0.15s, border-color 0.15s; }
.corner-btn[hidden] { display: none; }
.corner-btn:hover, .corner-btn:focus-visible { opacity: 1; color: var(--text); border-color: var(--amber-line); }
.corner-btn.on { color: var(--amber-bright, var(--amber)); }
.corner-btn svg { width: 17px; height: 17px; }
.corner-left { left: calc(14px + env(safe-area-inset-left)); }
.corner-right { right: calc(14px + env(safe-area-inset-right)); }
@media (max-width: 700px) { body:has(.composer-dock) .corner-btn { display: none; } }

.keep-orig { display: flex; align-items: center; gap: 6px; margin: 8px 0 4px; font-size: 13px; color: var(--muted, #b9ad9a); cursor: pointer; }
.keep-orig input { accent-color: var(--amber, #ffb627); }

/* narrow phones: keep Reflect / Pin / Stoke / Discover on one line */
@media (max-width: 640px) { .actions { gap: 10px; } .act { gap: 5px; font-size: 13.5px; } .act svg { width: 14px; height: 14px; } }

/* ───────────────────────── sketch editor ───────────────────────── */
html.sk-open, html.sk-open body { overflow: hidden; overscroll-behavior: none; }
.sk-overlay button { -webkit-tap-highlight-color: transparent; }
.sk-overlay { position: fixed; inset: 0; width: 100%; max-width: 100vw; overflow: hidden; z-index: 48; display: flex; flex-direction: column; background: var(--bg); color: var(--text); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.sk-top { display: flex; align-items: center; gap: 8px; padding: calc(8px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left)); background: var(--surface); border-bottom: 1px solid var(--line); }
.sk-title { font-family: var(--serif); font-size: 17px; margin-left: 4px; white-space: nowrap; }
.sk-spacer { flex: 1; }
.sk-btn { min-width: 40px; height: 40px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: 11px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); font-size: 14px; cursor: pointer; }
.sk-btn svg { width: 18px; height: 18px; }
@media (hover: hover) { .sk-btn:hover:not(:disabled) { background: var(--surface-3); } }
.sk-btn:disabled { opacity: 0.35; cursor: default; }
.sk-btn.on { background: var(--amber-wash); border-color: var(--amber); color: var(--amber-bright); }
.sk-save { height: 40px; padding: 0 16px; }
.sk-bgs { display: inline-flex; gap: 6px; padding: 0 4px; }
.sk-bg { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line-strong); padding: 0; cursor: pointer; }
.sk-bg-dark { background: #1b1917; }
.sk-bg-paper { background: #f6f1e7; }
.sk-bg.on { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber-wash); }
.sk-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; cursor: crosshair; }
.sk-stage.hand, .sk-stage.pannable { cursor: grab; }
.sk-stage.panning { cursor: grabbing; }
.sk-stage.erase { cursor: cell; }
.sk-canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.sk-guide { position: absolute; pointer-events: none; border: 2px dashed var(--amber-bright); border-radius: 4px; box-shadow: 0 0 0 9999px rgba(8, 7, 6, 0.62); }
.sk-palette { position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 24px); display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: rgba(27, 25, 23, 0.94); border: 1px solid var(--line-strong); border-radius: 18px; box-shadow: var(--shadow); backdrop-filter: blur(8px); overflow-x: auto; scrollbar-width: none; }
.sk-palette::-webkit-scrollbar { display: none; }
.sk-palette .sk-btn { flex: none; }
.sk-sep { flex: none; width: 1px; align-self: stretch; margin: 4px 4px; background: var(--line-strong); }
.sk-size { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; border: 1px solid transparent; background: transparent; padding: 0; cursor: pointer; }
.sk-size i { display: block; border-radius: 50%; background: var(--text); }
.sk-size.on { border-color: var(--amber); background: var(--amber-wash); }
.sk-color { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 2px solid transparent; background: transparent; padding: 0; cursor: pointer; }
.sk-color i { display: block; width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.25); }
.sk-overlay[data-bg="paper"] .sk-color i { border-color: rgba(0, 0, 0, 0.3); }
.sk-color.on { border-color: var(--amber-bright); }
.sk-chip { flex: none; height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap; }
.sk-chip.on { background: var(--amber-wash); border-color: var(--amber); color: var(--amber-bright); }
.sk-zoom { position: absolute; right: calc(12px + env(safe-area-inset-right)); top: calc(66px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 4px; padding: 4px; background: rgba(27, 25, 23, 0.9); border: 1px solid var(--line-strong); border-radius: 14px; }
.sk-zoom .sk-btn { height: 34px; min-width: 34px; border-color: transparent; font-size: 18px; }
.sk-zoomval { min-width: 56px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.sk-framebar { position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(560px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 10px; padding: 14px; background: rgba(27, 25, 23, 0.97); border: 1px solid var(--amber-line); border-radius: 18px; box-shadow: var(--shadow); }
.sk-frame-hint { font-size: 14px; color: var(--muted); }
.sk-frame-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sk-aspects { display: flex; gap: 6px; flex-wrap: wrap; }
.sk-overlay.framing .sk-palette, .sk-overlay.framing .sk-zoom { display: none; }
.sk-export { display: flex; flex-direction: column; gap: 12px; }
.sk-exp-prev { display: grid; place-items: center; min-height: 120px; padding: 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.sk-exp-img, .sk-save-img { max-width: 100%; max-height: 38vh; width: auto; height: auto; border-radius: 8px; }
.sk-save-prev { display: grid; place-items: center; padding: 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); margin-bottom: 8px; }
.sk-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.sk-act { gap: 7px; }
@media (max-width: 760px) {
  .sk-wide span { display: none; }
  .sk-title { display: none; }
  .sk-top { gap: 6px; }
  .sk-save { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) { .sk-overlay * { transition: none !important; } }

/* selection (lasso) */
.sk-selbar { position: absolute; left: 50%; top: calc(66px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: calc(100% - 150px); display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: rgba(27, 25, 23, 0.95); border: 1px solid var(--amber-line); border-radius: 16px; box-shadow: var(--shadow); overflow-x: auto; scrollbar-width: none; }
.sk-selbar[hidden] { display: none; }
.sk-selbar .sk-chip { height: 36px; }
.sk-selbar .sk-chip.danger { color: #e0645a; border-color: rgba(224, 100, 90, 0.5); }
.sk-selbar .sk-count { flex: none; font-size: 12px; color: var(--muted, #9a9189); padding: 0 6px; }
.sk-stage.select { cursor: crosshair; }
.sk-overlay { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sk-hold { position: absolute; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; border: 3px solid var(--amber-bright, #f2b84b); pointer-events: none; opacity: 0; }
.sk-hold.go { animation: skhold 320ms linear forwards; }
@keyframes skhold { from { transform: scale(1.5); opacity: 0.1; } to { transform: scale(0.8); opacity: 0.9; } }
.sk-selbar .sk-btn { height: 38px; min-width: 38px; padding: 0 8px; flex: none; }
.sk-selbar .sk-btn svg { width: 22px; height: 22px; }
.sk-selbar .sk-btn.danger { color: #e0645a; border-color: rgba(224, 100, 90, 0.5); }
.sk-build { font-size: 11px; font-weight: 400; color: var(--muted, #9a9189); }
@media (max-width: 760px) { .sk-build { display: none; } }

/* ───────────────────────── library and sketchbook canvas ───────────────────────── */
.lib { max-width: 1100px; margin: 0 auto; padding: 8px 4px 80px; }
.lib-head h2 { font-family: var(--serif); font-weight: 500; font-size: 26px; margin: 8px 0 4px; }
.lib-head p { margin: 0 0 24px; color: var(--muted); max-width: 560px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 26px 22px; }
.book { display: flex; flex-direction: column; gap: 7px; background: none; border: 0; padding: 0; text-align: left; color: inherit; text-decoration: none; cursor: pointer; font: inherit; -webkit-tap-highlight-color: transparent; }
.book-cover { position: relative; aspect-ratio: 3 / 4; border-radius: 5px 14px 14px 5px; overflow: hidden; display: flex; align-items: flex-end; box-shadow: 0 12px 26px rgba(0, 0, 0, 0.42), inset 7px 0 9px -5px rgba(0, 0, 0, 0.55); transition: transform 0.18s ease-out, box-shadow 0.18s; }
@media (hover: hover) { .book:hover .book-cover { transform: translateY(-4px); box-shadow: 0 16px 30px rgba(0, 0, 0, 0.5), inset 7px 0 9px -5px rgba(0, 0, 0, 0.55); } }
.book-cover.c0 { background: linear-gradient(160deg, #6a4631, #3b2518); }
.book-cover.c1 { background: linear-gradient(160deg, #335247, #1f3029); }
.book-cover.c2 { background: linear-gradient(160deg, #3b4a70, #222b45); }
.book-cover.c3 { background: linear-gradient(160deg, #6a3b54, #3d2030); }
.book-cover.c4 { background: linear-gradient(160deg, #6c5a2a, #3f3317); }
.book-cover.c5 { background: linear-gradient(160deg, #4b4b4b, #2b2b2b); }
.book-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.book-cover-title { position: relative; width: 100%; padding: 26px 14px 14px; font-family: var(--serif); font-size: 19px; line-height: 1.2; color: #f4ecdc; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); background: linear-gradient(transparent, rgba(0, 0, 0, 0.55)); overflow-wrap: anywhere; }
.book-cover-new { background: transparent !important; border: 2px dashed var(--line-strong); box-shadow: none !important; display: grid; place-items: center; color: var(--muted); }
.book-cover-new svg { width: 30px; height: 30px; }
.book-new:hover .book-cover-new { border-color: var(--amber); color: var(--amber-bright); }
.book-name { font-size: 15px; line-height: 1.25; overflow-wrap: anywhere; }
.book-meta { font-size: 12px; color: var(--muted); }

html.cv-open, html.cv-open body { overflow: hidden; overscroll-behavior: none; }
html.cv-open body { position: fixed; inset: 0; width: 100%; }
.cv-overlay { position: fixed; inset: var(--topbar-h, 56px) 0 0 0; width: 100%; max-width: 100vw; overflow: hidden; z-index: 42; display: flex; flex-direction: column; background: var(--bg); color: var(--text); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
.cv-overlay button, .cv-overlay a { -webkit-tap-highlight-color: transparent; }
.cv-overlay .sk-top a.sk-btn { text-decoration: none; color: var(--text); }
.cv-title { background: none; border: 0; color: var(--text); font-family: var(--serif); font-size: 17px; padding: 6px 8px; border-radius: 9px; cursor: text; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .cv-title:hover { background: var(--surface-3); } }
.cv-count { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cv-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background-image: radial-gradient(circle, rgba(236, 230, 222, 0.2) 1.1px, transparent 1.7px); }
.cv-stage.hand { cursor: grab; }
.cv-world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; --k: 1; }
.cv-hint { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); pointer-events: none; padding: 20px; }
.cv-hint[hidden] { display: none; }
.cv-hint h3 { margin: 0 0 4px; font-family: var(--serif); font-weight: 500; font-size: 20px; color: var(--text); }
.cv-hint p { margin: 0; max-width: 340px; }
.cv-card { position: absolute; box-sizing: border-box; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38); pointer-events: none; }
.cv-card.sel { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber), 0 12px 32px rgba(0, 0, 0, 0.5); }
.cv-body { position: absolute; inset: 0; overflow: hidden; border-radius: 13px; padding: 14px 16px; }
.cv-text, .cv-session { -webkit-mask-image: linear-gradient(#000 78%, transparent); mask-image: linear-gradient(#000 78%, transparent); }
.cv-q { font-family: var(--serif); font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
.cv-q p { margin: 0 0 8px; }
.cv-src, .cv-meta { margin-top: 8px; font-size: 12px; color: var(--muted); }
.cv-note { margin-top: 8px; font-size: 12px; color: var(--muted); font-style: italic; }
.cv-pic { padding: 0; }
.cv-pic img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-user-drag: none; }
.cv-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 9px; font-size: 13px; color: #f4ecdc; background: linear-gradient(transparent, rgba(0, 0, 0, 0.62)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cv-kicker { display: flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: 0.7px; text-transform: uppercase; color: var(--amber); margin-bottom: 6px; }
.cv-kicker svg { width: 13px; height: 13px; }
.cv-sess-title { font-family: var(--serif); font-size: 18px; line-height: 1.25; overflow-wrap: anywhere; }
.cv-sess-prev { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.4; }
.cv-x { position: absolute; top: -12px; right: -12px; width: 24px; height: 24px; padding: 0; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted); opacity: 0; cursor: pointer; pointer-events: none; transform: scale(calc(1 / var(--k))); }
.cv-x svg { width: 12px; height: 12px; }
.cv-card.sel .cv-x { opacity: 1; pointer-events: auto; color: var(--text); }
.cv-grip { position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--amber); background: var(--bg); pointer-events: none; opacity: 0; cursor: nwse-resize; transform: scale(calc(1 / var(--k))); }
.cv-card.sel .cv-grip { opacity: 1; pointer-events: auto; }
.cv-selbar { top: calc(66px + env(safe-area-inset-top)); }
.cv-add { display: inline-flex; align-items: center; gap: 6px; }
.cv-add svg { width: 17px; height: 17px; }
.cv-palette .sk-chip { height: 40px; }

.pick { display: flex; flex-direction: column; gap: 10px; }
.pick-bar { display: flex; gap: 6px; }
.pick-list { max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin: 0 -4px; padding: 0 4px; }
.pick-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
@media (hover: hover) { .pick-row:hover:not(.there) { background: var(--surface-2); border-color: var(--amber-line); } }
.pick-row.there { opacity: 0.5; cursor: default; }
.pick-row input { flex: none; accent-color: var(--amber); width: 16px; height: 16px; pointer-events: none; }
.pick-thumb { flex: none; width: 46px; height: 46px; object-fit: cover; border-radius: 8px; }
.pick-text { min-width: 0; }
.pick-lead { font-size: 14px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pick-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pick-none { padding: 24px 6px; text-align: center; }

/* ── notebooks: hidden buttons, Cover, text labels, the add-existing picker, the notebook chooser ── */
.sk-btn[hidden], .sk-chip[hidden] { display: none; }
.cv-cover-btn { gap: 6px; font-size: 13px; padding: 0 12px; }
.cv-cover-btn.on { background: var(--amber-wash); border-color: var(--amber); color: var(--amber-bright); }
.cv-card.is-cover::after { content: 'Cover'; position: absolute; left: 8px; top: 8px; padding: 2px 9px; border-radius: 99px; background: var(--amber); color: #1b1917; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; pointer-events: none; }
.cv-tglyph { font-family: Georgia, 'Times New Roman', serif; font-size: 17px; margin-right: 2px; }

.cv-k-label { background: transparent; border: 1px dashed transparent; box-shadow: none; min-height: 20px; }
.cv-k-label.sel, .cv-k-label.editing { border-color: var(--amber); box-shadow: none; }
.cv-label, .cv-edit { padding: 7px 34px 7px 14px; line-height: 1.25; color: var(--text); overflow-wrap: anywhere; }
.cv-lbl-text { white-space: pre-wrap; }
.cv-lbl-list { margin: 0; padding-left: 1.3em; }
.cv-lbl-list li { white-space: pre-wrap; }
.cv-lbl-link { font-size: 0.5em; vertical-align: super; margin-left: 4px; opacity: 0.75; }
.cv-edit { white-space: pre-wrap; outline: none; min-height: 1.25em; pointer-events: auto; user-select: text; -webkit-user-select: text; caret-color: var(--amber); }
.cv-fmtbar { max-width: calc(100% - 24px); overflow-x: auto; scrollbar-width: none; }
.cv-fmtbar::-webkit-scrollbar { display: none; }
.cv-fmtbar .sk-btn b, .cv-fmtbar .sk-btn s, .cv-fmtbar .cv-it { font-size: 17px; font-family: Georgia, serif; }
.cv-fmtbar .cv-sizebtn { font-size: 14px; font-weight: 600; }
.cv-swatch { display: block; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line-strong); }
.cv-pop { position: absolute; z-index: 60; display: flex; gap: 6px; padding: 8px; background: rgba(27, 25, 23, 0.97); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.cv-pop[hidden] { display: none; }
.cv-dot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; outline: 1px solid var(--line-strong); cursor: pointer; padding: 0; }
.cv-dot.on { border-color: var(--amber-bright); outline-color: var(--amber-bright); }

.pick-bar { align-items: center; }
.pick-bar .sk-spacer, .pick-meta .sk-spacer { flex: 1; }
.pick-mode { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.pick-kinds { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pick-kinds[hidden] { display: none; }
.pick-kinds .sk-chip { height: 30px; font-size: 12.5px; }
.pick-meta { display: flex; align-items: center; gap: 12px; margin: 10px 0 6px; font-size: 12px; min-height: 18px; }
.pick-count { color: var(--amber-bright); }
.pick-note { font-size: 12.5px; color: var(--muted); font-style: italic; margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.pick-thumb { width: 56px; height: 56px; }
.pick-more { width: 100%; margin-top: 8px; }
.pick-more[hidden] { display: none; }
.pick-list { max-height: 44vh; }

.nbp { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow-y: auto; }
.nbp-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: transparent; color: var(--text); text-align: left; cursor: pointer; width: 100%; }
@media (hover: hover) { .nbp-row:hover { background: var(--surface-2); border-color: var(--amber-line); } }
.nbp-swatch { flex: none; width: 44px; height: 44px; border-radius: 9px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line-strong); }
.nbp-swatch svg { width: 22px; height: 22px; }
.nbp-swatch img { width: 100%; height: 100%; object-fit: cover; }
.nbp-swatch.plus { border-style: dashed; color: var(--amber-bright); }
.nbp-text { display: flex; flex-direction: column; min-width: 0; }
.nbp-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nbp-meta { font-size: 12px; color: var(--muted); }

.nbp-swatch.c0 { background: linear-gradient(160deg, #6a4631, #3b2518); }
.nbp-swatch.c1 { background: linear-gradient(160deg, #335247, #1f3029); }
.nbp-swatch.c2 { background: linear-gradient(160deg, #3b4a70, #222b45); }
.nbp-swatch.c3 { background: linear-gradient(160deg, #6a3b54, #3d2030); }
.nbp-swatch.c4 { background: linear-gradient(160deg, #6c5a2a, #3f3317); }
.nbp-swatch.c5 { background: linear-gradient(160deg, #4b4b4b, #2b2b2b); }
.cv-k-label .cv-body { position: static; inset: auto; overflow: visible; border-radius: 0; padding: 7px 34px 7px 14px; }
.cv-k-label .cv-label { position: relative; }
.cv-k-label .cv-lbl-link { position: absolute; right: 0; top: -6px; }

/* ── connector lines ── */
.cv-links { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 0; }
.cv-link { fill: none; stroke: #a8843f; stroke-width: 2.2; stroke-linecap: round; }
.cv-link.on { stroke: var(--amber-bright); stroke-width: 3.4; }
.cv-link.preview { stroke-dasharray: 6 5; stroke: var(--amber); }
.cv-arrow { fill: #a8843f; stroke: none; }
.cv-arrow.on { fill: var(--amber-bright); }
.cv-link-text { fill: var(--text); stroke: var(--bg); paint-order: stroke; font-family: inherit; }
.cv-card.cv-from { outline: 2px dashed var(--amber-bright); outline-offset: 4px; }
.cv-stage.connecting { cursor: crosshair; }
.cv-linkbar { max-width: calc(100% - 24px); }

/* ── round 1: floating bars, outlines ── */
.cv-overlay .cv-selbar { left: 0; top: 0; transform: none; max-width: calc(100% - 16px); }
.cv-overlay.dragging .cv-selbar { visibility: hidden; }
.cv-add.locked { box-shadow: 0 0 0 2px var(--amber-bright); }
.book-cover { border: 1.5px solid var(--line-strong); }
.book-cover-new { border: 2px dashed var(--line-strong); }

/* ── round 1.5: notes are rich text ── */
.cv-fmtbar.rich { overflow: visible; flex-wrap: wrap; max-width: min(740px, calc(100% - 16px)); }
.cv-fmtbar .ed-toolbar { border: 0; border-radius: 0; background: transparent; padding: 0; flex-wrap: wrap; flex: none; }
.cv-fmtbar .ed-btn { height: 36px; min-width: 34px; }
.cv-fmtbar .ed-btn svg { width: 19px; height: 19px; }
.cv-fmtbar .ed-menu { z-index: 60; }
.cv-k-label .ed-area.cv-edit { min-height: 1.25em; padding: 7px 34px 7px 14px; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; line-height: 1.25; white-space: normal; }
.cv-k-label .ed-area.cv-edit:focus { border: 0; box-shadow: none; }
.cv-k-label .ed-area.is-empty::before { left: 14px; top: 7px; }
.cv-label .cv-lbl-text { white-space: normal; }
.cv-label .md p, .cv-edit p { margin: 0; min-height: 1.25em; }
.cv-label .md a { color: var(--amber-bright, var(--amber)); text-decoration: underline; pointer-events: auto; }
.nb-hits-box { margin-bottom: 14px; }
.nb-hit { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: 9px 12px; margin-top: 6px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.nb-hit:hover { border-color: var(--amber); }
.nb-hit-book { font-size: 12px; color: var(--amber); }

/* ── checklists ── */
li.task { list-style: none; position: relative; margin-left: -1.5em; padding-left: 1.7em; }
li.task::before { content: ''; position: absolute; left: 0; top: .28em; width: 1em; height: 1em; box-sizing: border-box; border: 1.6px solid var(--muted, #9a9189); border-radius: 50%; cursor: pointer; }
li.task[data-done]::before { background: var(--amber) no-repeat center / 70% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23161412' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5 9-10'/%3E%3C/svg%3E"); border-color: var(--amber); }
li.task[data-done] { color: var(--muted, #9a9189); text-decoration: line-through; text-decoration-thickness: 1px; }
.ed-check { display: inline-block; width: 15px; height: 15px; border: 1.8px solid currentColor; border-radius: 50%; position: relative; }
.ed-check::after { content: ''; position: absolute; left: 3px; top: 0px; width: 4px; height: 8px; border: solid currentColor; border-width: 0 1.8px 1.8px 0; transform: rotate(40deg); }

/* ── round 2: connectors ── */
.cv-aps { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 99999; }
.cv-ap { fill: var(--bg, #121110); stroke: var(--amber-bright, #f0b24a); stroke-width: 2; vector-effect: non-scaling-stroke; }
.cv-ap.hot { fill: var(--amber-bright, #f0b24a); }
.cv-end { fill: var(--amber-bright, #f0b24a); stroke: var(--bg, #121110); stroke-width: 2.5; vector-effect: non-scaling-stroke; }

/* "Appears in" chips on a spark's detail view */
.appears-in { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 22px; }
.ai-lbl { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ai-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.ai-chip svg { width: 16px; height: 16px; }
.ai-chip:hover { border-color: var(--accent, currentColor); }

/* ⌘K: turn a notebook note into a spark */
.pr-act { margin-left: auto; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-strong); opacity: .55; }
.palette-row.sel .pr-act, .pr-act:hover { opacity: 1; background: var(--surface); }
@media (hover: none) { .pr-act { opacity: 1; } }

/* elbow line: drag handle for the middle segment */
.cv-bend { stroke: #0a84ff; stroke-width: 7px; stroke-linecap: round; cursor: grab; pointer-events: none; }

/* sticky notes: a note with a colour of its own */
.cv-k-label.sticky { background: var(--stk, #ffe08a); border: 0; border-radius: 3px; box-shadow: 0 8px 16px rgba(0,0,0,.28), 0 1px 3px rgba(0,0,0,.25); }
.cv-k-label.sticky.sel, .cv-k-label.sticky.editing { outline: 2px solid var(--amber); outline-offset: 2px; border: 0; }
.cv-k-label.sticky .cv-body { min-height: 100%; box-sizing: border-box; }
.cv-k-label.sticky .cv-label, .cv-k-label.sticky .ed-area.cv-edit { padding: 16px 18px; color: #2a2316; min-height: 100%; box-sizing: border-box; caret-color: #2a2316; }
.cv-k-label.sticky .ed-area.is-empty::before { left: 18px; top: 16px; color: rgba(42,35,22,.45); }
.cv-k-label.sticky .md a, .cv-k-label.sticky .cv-edit a { color: #5a3a00; }
.cv-k-label.sticky .md li.task::before, .cv-k-label.sticky .cv-edit li.task::before { border-color: #2a2316; }

/* picking several cards together */
.cv-marquee { position: absolute; z-index: 99999; pointer-events: none; background: rgba(10,132,255,.10); outline: calc(1.5px / var(--k, 1)) solid #0a84ff; }
.cv-card.multi .cv-x, .cv-card.multi .cv-grip { display: none !important; }
.cv-multibar .cv-multi-n { padding: 0 12px; font-size: 14px; color: var(--muted); white-space: nowrap; align-self: center; }

/* drawing and notebook canvases: nothing here is selectable text, and the picture itself must not take touches (iPad Live Text and the Copy / Look Up callout) */
.sk-canvas { pointer-events: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sk-stage, .cv-stage { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.cv-stage .cv-edit, .cv-stage .cv-edit * { -webkit-user-select: text; user-select: text; }
.cv-lassosvg { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; z-index: 99998; }
.cv-lasso { fill: rgba(10,132,255,.10); stroke: #0a84ff; stroke-width: 2px; stroke-dasharray: 6 4; stroke-linejoin: round; }
.cv-stage .sk-hold { z-index: 5; }

/* ── Stage 4: drawing on a notebook ── */
.cv-ink { position: absolute; inset: 0; z-index: 3; display: block; pointer-events: none; -webkit-user-select: none; user-select: none; }
.sk-overlay.sk-ink { background: transparent; }
.sk-overlay.sk-ink .sk-top { position: absolute; left: 0; right: 0; top: 0; z-index: 4; }
.sk-overlay.sk-ink .sk-palette, .sk-overlay.sk-ink .sk-zoom, .sk-overlay.sk-ink .sk-selbar { z-index: 5; }
.cv-overlay.inking .sk-top, .cv-overlay.inking .cv-palette, .cv-overlay.inking .sk-zoom, .cv-overlay.inking .cv-selbar, .cv-overlay.inking .cv-hint, .cv-overlay.inking .cv-pop { visibility: hidden; }

/* export: drag a box */
.cv-boxpick { position: fixed; z-index: 44; cursor: crosshair; touch-action: none; background: rgba(0, 0, 0, 0.28); }
.cv-boxsel { position: absolute; border: 2px dashed var(--amber-bright, #f2b84b); background: rgba(232, 161, 58, 0.12); box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35); pointer-events: none; }
.cv-boxhint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; background: rgba(27, 25, 23, 0.96); border: 1px solid var(--line-strong); border-radius: 99px; font-size: 14px; color: var(--text); white-space: nowrap; }

/* rearranging notebooks */
.lib-grid a.book { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.lib-grid.reordering { cursor: grabbing; }
.book-lifted { opacity: 0.25; }
.book-ghost { filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.55)); transition: none; }
.book-ghost .book-name, .book-ghost .book-meta { opacity: 0.9; }

/* Journal: grid view and sort */
.wide-journal { max-width: 1100px; margin: 0 auto; }
.list-items.as-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.list-items.as-grid .item-wrap { max-height: none; height: 100%; }
.list-items.as-grid .item { height: 100%; }

/* drag to rearrange a reflection */
.msg-tools .icon-btn.grip { cursor: grab; touch-action: none; margin-right: auto; opacity: 0.8; }
.bubble-wrap .msg-tools .icon-btn.grip { margin-right: 0; }
.thread.sorting { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.sort-lifted { opacity: 0.25; }
.sort-ghost { filter: drop-shadow(0 16px 26px rgba(0, 0, 0, 0.5)); transition: none; }
.sort-ghost .msg-tools { opacity: 0; }

/* journal tiles: a longer excerpt */
.item .p.jp { -webkit-line-clamp: 4; line-height: 1.45; }
.list-items.as-grid .item .p.jp { -webkit-line-clamp: 7; }

/* Home: the notebook you had open last */

/* top bar: icons never squash; the tabs give way first */
.topbar .icon-btn, .brand { flex: none; }
.tabs { min-width: 0; }
.icon-btn[hidden] { display: none; }
@media (max-width: 640px) {
  .brand-logo { height: 26px; }
  .tabs { gap: 0; }
  .tabs a { padding: 8px 8px; }
  .topbar { gap: 4px; padding-left: 10px; padding-right: 10px; }
}

/* phones: keep the whole formatting row, mic included, on one line */
@media (max-width: 640px) {
  .ed-toolbar { flex-wrap: nowrap; gap: 0; padding-left: 2px; padding-right: 2px; overflow-x: auto; scrollbar-width: none; }
  .ed-toolbar::-webkit-scrollbar { display: none; }
  .ed-toolbar .ed-btn { min-width: 27px; padding: 0 4px; flex: none; }
  .ed-toolbar .ed-sep { margin: 0 2px; flex: none; }
  .ed-toolbar .ed-spacer { flex: 1 0 0; min-width: 0; }
  .ed-toolbar .icon-btn.mic { width: 30px; flex: none; }
}

/* ───── the journal page: one calm document (CreativeFlame) ───── */
html:has(.doc-dock) { scroll-padding-bottom: 140px; }

.doc-page { --doc-fs: calc(17px * var(--rs, 1)); --doc-w: 680px; --doc-ff: var(--serif); padding-bottom: 40px; }
.doc-page[data-size="s"] { --doc-fs: calc(15.5px * var(--rs, 1)); } .doc-page[data-size="l"] { --doc-fs: calc(19.5px * var(--rs, 1)); }
.doc-page[data-width="s"] { --doc-w: 580px; } .doc-page[data-width="l"] { --doc-w: 820px; }
.doc-page[data-font="sans"] { --doc-ff: var(--font); }
.doc-head { max-width: var(--doc-w); margin: 0 auto 6px; transition: opacity 0.35s ease; flex-wrap: nowrap; }
.doc-head .btn { white-space: nowrap; }
.doc-head .spacer { flex: 1; }
.doc-page.typing .doc-head { opacity: 0.12; }
.doc-page.typing .doc-head:hover, .doc-head:focus-within { opacity: 1; }
.doc-status { font-size: 12px; color: var(--faint); min-width: 62px; text-align: right; }
.doc-status.bad { color: var(--danger); }
.doc-words { font-size: 12px; color: var(--faint); white-space: nowrap; }
.doc-col { max-width: var(--doc-w); margin: 18px auto 0; font-family: var(--doc-ff); }
.doc-title { display: block; width: 100%; background: transparent; border: 0; outline: none; padding: 0; margin: 0 0 18px; color: var(--text); font-family: var(--doc-ff); font-weight: 500; font-size: calc(var(--doc-fs) * 1.6); line-height: 1.25; letter-spacing: -0.005em; }
.doc-title::placeholder { color: var(--faint); font-weight: 500; }
.doc-col .ed-area.doc-area { border: 0; background: transparent; box-shadow: none; padding: 0 0 38vh; min-height: 56vh; overflow: visible; font-family: var(--doc-ff); font-size: var(--doc-fs); font-weight: 400; line-height: 1.65; border-radius: 0; caret-color: var(--amber-bright); }
.doc-col .ed-area.doc-area:focus { border: 0; box-shadow: none; }
.doc-area.is-empty::before { color: var(--faint); }
.doc-area p { margin: 0 0 0.7em; min-height: 1.7em; }
.doc-area p:has(> br:only-child) { min-height: 1em; margin-bottom: 0.25em; }
.doc-area h1 { font-size: 1.4em; margin: 1.1em 0 0.35em; font-weight: 600; }
.doc-area h2 { font-size: 1.15em; margin: 1em 0 0.3em; font-weight: 600; }
.doc-area h3 { font-size: 1.03em; margin: 0.9em 0 0.3em; font-weight: 600; }
.doc-area blockquote { margin: 0.9em 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--amber-dim); font-style: italic; color: #cfc6ba; }
.doc-area blockquote p { margin: 0 0 0.4em; }
.doc-area hr { margin: 1.6em 0; width: 100%; border: 0; border-top: 1px solid rgba(236, 228, 216, 0.34); }
.doc-area ul, .doc-area ol { margin: 0.2em 0 0.8em; padding-left: 1.6em; }
/* Lists: wrapped lines sit close together; space goes between items so each bullet reads as one block. */
.doc-area li { line-height: 1.42; margin: 0 0 0.6em; }
.doc-area li:last-child { margin-bottom: 0; }
.doc-area li > p { margin: 0; min-height: 0; }
.doc-area li > ul, .doc-area li > ol { margin: 0.5em 0 0; }
.doc-area ul, .doc-area ol { margin-bottom: 1em; }
.doc-area ::selection { background: rgba(var(--amber-rgb), 0.32); }

/* sparks, related sparks and reflections sitting in the text */
.doc-blk { position: relative; margin: 1.3em 0; padding: 14px 18px 14px; border: 1px solid var(--amber-line); background: var(--amber-wash); border-radius: var(--radius); font-family: var(--font); font-size: 15px; line-height: 1.5; user-select: none; -webkit-user-select: none; }
.doc-blk.blk-reflection { border-color: rgba(138, 180, 232, 0.35); background: rgba(138, 180, 232, 0.07); }
.doc-blk.openable { cursor: pointer; }
.doc-blk.openable:hover { background: rgba(var(--amber-rgb), 0.15); }
.doc-blk.blk-reflection.openable:hover { background: rgba(138, 180, 232, 0.13); }
.doc-blk .label { display: flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--amber); margin-bottom: 6px; }
.doc-blk.blk-reflection .label { color: #8ab4e8; }
.doc-blk .label svg { width: 12px; height: 12px; }
.doc-blk .q { color: var(--amber-bright); font-family: var(--serif); font-size: 16.5px; line-height: 1.55; margin: 4px 0 0; }
.doc-blk .blk-title { font-family: var(--serif); font-size: 16.5px; margin: 4px 0 0; }
.doc-blk .src { color: var(--muted); font-size: 13px; margin-top: 6px; }
.doc-blk .blk-gone { color: var(--muted); margin: 4px 0 0; font-style: italic; }
.blk-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.doc-blk:hover .blk-tools, .doc-blk:focus-within .blk-tools { opacity: 1; }
@media (hover: none) { .blk-tools { opacity: 0.7; } }
.blk-tools .icon-btn { width: 28px; height: 28px; background: rgba(18, 17, 16, 0.7); }

/* the toolbar floats at the bottom, like a pill */
.doc-dock { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--kb, 0px) + env(safe-area-inset-bottom)); max-width: calc(100vw - 20px); }
.doc-dock .ed-toolbar { border: 1px solid var(--line-strong); border-radius: 16px; background: rgba(30, 27, 22, 0.94); backdrop-filter: blur(12px); box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55); padding: 5px 8px; gap: 1px; justify-content: center; }
.doc-dock .ed-btn { height: 32px; min-width: 32px; }
.doc-dock .ed-btn svg { width: 17px; height: 17px; }
.doc-dock .ed-btn.ed-insert { color: var(--amber-bright); padding: 0 11px 0 8px; font-size: 13.5px; }
.doc-dock .ed-btn.ed-insert:hover { background: var(--amber-wash); }
.doc-dock .ed-sep { margin: 0 5px; }
.doc-dock .ed-spacer { flex: 0 0 6px; }
.ed-mi { display: inline-flex; align-items: center; gap: 9px; }
.ed-mi svg { width: 15px; height: 15px; color: var(--muted); }
.ed-alignicon { display: inline-flex; }

/* the side panel: Format and Related */
.doc-side { position: fixed; z-index: 14; top: 55px; right: 0; bottom: 0; width: 360px; background: var(--surface); border-left: 1px solid var(--line); transform: translateX(105%); transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column; font-size: 14px; }
body.doc-side-open .doc-side { transform: none; }
@media (min-width: 901px) {
  body.doc-side-open main { max-width: none; padding-right: 378px; }
  body.doc-side-open .doc-dock { left: calc(50% - 180px); }
  body.doc-side-open .doc-side-toggle { right: 378px; }
}
.fp-tabs { display: flex; align-items: center; gap: 4px; padding: 10px 12px 6px; border-bottom: 1px solid var(--line); }
.fp-tab { background: transparent; border: 0; padding: 6px 12px; border-radius: 9px; color: var(--muted); }
.fp-tab.on { color: var(--amber-bright); background: var(--amber-wash); }
.fp-body { overflow-y: auto; flex: 1; padding: 6px 14px 40px; }
.fp-h { font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--faint); margin: 18px 0 8px; }
.fp-row { display: flex; gap: 6px; flex-wrap: wrap; }
.fp-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.fp-btn { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font-size: 13px; }
.fp-btn svg { width: 16px; height: 16px; }
.fp-btn:hover { background: var(--surface-3); }
.fp-btn.on { color: var(--amber-bright); border-color: var(--amber-line); background: var(--amber-wash); }
.fp-row .fp-btn { flex: 1 1 auto; }
.fp-read { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.fp-label { font-size: 12.5px; color: var(--muted); }
.fp-seg { display: flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; }
.fp-seg-btn { flex: 1; padding: 7px 4px; background: var(--surface-2); border: 0; border-right: 1px solid var(--line-strong); color: var(--muted); font-size: 13px; }
.fp-seg-btn:last-child { border-right: 0; }
.fp-seg-btn.on { background: var(--amber-wash); color: var(--amber-bright); }
.fp-related .pick { margin-bottom: 8px; }
.fp-related .pick-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fp-refresh { margin-top: 14px; }
.rel-seg { margin: 12px 0 0; }
.rel-order { font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--faint); margin: 14px 2px 10px; }
.rel-card { display: block; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 15px 15px; margin-bottom: 10px; cursor: pointer; }
.rel-card.static { cursor: default; }
.rel-card:hover:not(.static) { border-color: var(--amber-line); background: var(--surface-3); }
.rel-kick { font-family: var(--sans, inherit); font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--amber-dim); margin-bottom: 8px; }
.rel-when { text-transform: none; letter-spacing: 0; color: var(--muted); }
.rel-q { font-family: var(--serif, Georgia, serif); font-size: 17px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.rel-s { font-size: 12px; color: var(--muted); margin-top: 8px; }
.rel-card .pick-actions { margin-top: 10px; }
@media (max-width: 900px) {
  .doc-side { top: auto; left: 0; right: 0; width: auto; height: min(64vh, 560px); border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 18px 18px 0 0; transform: translateY(105%); box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.5); }
  body.doc-side-open .doc-side { transform: none; }
  body.doc-side-open .doc-dock { display: none; }
  body:has(.doc-dock) .corner-btn { display: none; }
  .doc-head { flex-wrap: wrap; row-gap: 6px; }
  .doc-head .btn { padding: 6px 9px; }
}
@media (max-width: 560px) {
  .doc-head .btn { font-size: 0; gap: 0; } /* icon-only on phones */
  .doc-title { font-size: 1.45em; }
}

/* the bar scrolls sideways instead of wrapping; its menus are placed on the page so nothing clips them */
.doc-dock .ed-toolbar { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; justify-content: flex-start; -webkit-overflow-scrolling: touch; }
.doc-dock .ed-toolbar::-webkit-scrollbar { display: none; }
.doc-dock .ed-btn, .doc-dock .ed-sep, .doc-dock .icon-btn { flex: none; }
.doc-dock .ed-btn.ed-insert span { white-space: nowrap; }
.doc-dock .doc-done { display: none; }
.ed-menu-fixed { position: fixed; z-index: 70; overflow-y: auto; }
.doc-dock-touch { position: fixed; left: 0; top: 0; bottom: auto; margin: 0; z-index: 40; display: flex; align-items: stretch; justify-content: center; gap: 6px; padding: 6px 8px; background: rgba(24, 22, 19, 0.97); border-top: 1px solid var(--line-strong); backdrop-filter: blur(12px); transition: opacity 0.15s; max-width: none; }
.doc-dock-touch .ed-toolbar { flex: 0 1 720px; min-width: 0; border: 0; background: transparent; box-shadow: none; padding: 0; border-radius: 0; }
.doc-dock-touch .doc-done { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 38px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); }
.doc-dock-touch .doc-done svg { width: 18px; height: 18px; }
/* a button that is always in the top right, so the side panel can be opened or closed from anywhere */
.doc-side-toggle { position: fixed; z-index: 41; top: 66px; right: 18px; background: rgba(24, 22, 19, 0.85); border: 1px solid var(--line); backdrop-filter: blur(8px); transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.doc-side-toggle.on { color: var(--amber-bright); }
@media (max-width: 900px) { .doc-side-toggle { right: 10px; top: 64px; } .doc-side { z-index: 42; } }
.nbp-h { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--faint); margin: 8px 2px 0; }
.nbp-row.nbp-here { border-color: var(--amber-line); background: var(--amber-wash); }
.nbp-row.nbp-here .nbp-meta { color: var(--amber); }

/* shade between the fire and the text */
/* your gradient: solid black for the bottom quarter, fading to clear at the top; 480px desktop, 300px tablet, 400px phone */
.doc-tint { position: fixed; z-index: 0; left: 0; right: 0; bottom: 0; height: 480px; pointer-events: none; opacity: 0; transition: opacity 0.35s ease; background: linear-gradient(to top, #000 0%, #000 25%, rgba(0, 0, 0, 0) 100%); }
@media (hover: none) and (min-width: 901px) { .doc-tint { height: 300px; } }
@media (max-width: 900px) { .doc-tint { height: 400px; } }
@media (max-width: 560px) { .doc-head { padding-right: 46px; } }

/* the toolbar stays out of the way until you click into the text (every screen) */
.doc-dock { transition: opacity 0.2s ease; }
.doc-dock:not(.editing) { opacity: 0; pointer-events: none; }

/* side panel: actions at the head, copy and download at the foot */
.fp-tabs .icon-btn { flex: none; }
.fp-foot { display: flex; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.fp-foot .btn { flex: 1; justify-content: center; }

/* the side-panel button: same tile as the arrows, brighter and larger, lined up under the header's + */
.doc-side-toggle { width: 38px; height: 38px; border-radius: 10px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line-strong); opacity: 1; display: grid; place-items: center; }
.doc-side-toggle svg { width: 20px; height: 20px; }
.doc-side-toggle:hover { border-color: var(--amber-line); color: var(--amber-bright); }
.doc-side-toggle.on { background: var(--amber-wash); border-color: var(--amber-line); color: var(--amber-bright); }

/* history arrows beside Search */
.topbar .nav-hist { margin: 0; }
@media (max-width: 560px) { .topbar .nav-hist { width: 30px; height: 30px; border-radius: 9px; } .topbar .nav-hist svg { width: 15px; height: 15px; } }

/* every page leaves room to scroll the flame fully into view */
main:not(.fullbleed) { padding-bottom: 230px; }

/* ───── the open notebook under the global header ───── */
.crumb { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.crumb[hidden] { display: none; }
body.cv-crumb .tabs { display: none; }
.crumb-link { color: var(--muted); font-size: 14px; white-space: nowrap; }
.crumb-link:hover { color: var(--amber-bright); }
.crumb-sep { color: var(--faint); }
.crumb .cv-title { font-size: 18px; max-width: min(46vw, 520px); }
.crumb .cv-count { padding-left: 6px; }
.cv-overlay .sk-zoom { top: 12px; right: calc(70px + env(safe-area-inset-right)); transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.cv-overlay.side-open .sk-zoom { right: calc(430px + env(safe-area-inset-right)); }
.cv-overlay .cv-selbar { top: 0; }
.cv-side-toggle { position: absolute; z-index: 31; top: 10px; right: calc(18px + env(safe-area-inset-right)); width: 38px; height: 38px; border-radius: 10px; color: var(--text); background: var(--surface-2); border: 1px solid var(--line-strong); display: grid; place-items: center; transition: right 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.cv-side-toggle svg { width: 20px; height: 20px; }
.cv-side-toggle:hover { border-color: var(--amber-line); color: var(--amber-bright); }
.cv-side-toggle.on { background: var(--amber-wash); border-color: var(--amber-line); color: var(--amber-bright); }
.cv-overlay.side-open .cv-side-toggle { right: calc(378px + env(safe-area-inset-right)); }
.cv-side { position: absolute; z-index: 30; top: 0; right: 0; bottom: 0; width: 360px; background: var(--surface); border-left: 1px solid var(--line); transform: translateX(105%); transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1); display: flex; flex-direction: column; font-size: 14px; user-select: text; -webkit-user-select: text; }
.cv-overlay.side-open .cv-side { transform: none; }
.cv-side-note { color: var(--muted); margin: 0; }
.cv-side .icon-btn { flex: none; }
@media (max-width: 900px) {
  .cv-overlay .sk-zoom { right: calc(62px + env(safe-area-inset-right)); }
  .cv-overlay.side-open .sk-zoom { right: calc(62px + env(safe-area-inset-right)); }
  .cv-side { top: auto; left: 0; right: 0; width: auto; height: min(52vh, 440px); border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 18px 18px 0 0; transform: translateY(105%); box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.5); }
  .cv-overlay.side-open .cv-side-toggle { right: calc(10px + env(safe-area-inset-right)); }
  .cv-side-toggle { right: calc(10px + env(safe-area-inset-right)); }
  .crumb .cv-title { max-width: 42vw; }
}
@media (max-width: 560px) { .crumb-link, .crumb-sep { display: none; } .crumb .cv-count { display: none; } }

.cv-overlay.inking .cv-side-toggle, .cv-overlay.inking .cv-side { visibility: hidden; }

@media (min-width: 901px) { .cv-overlay .cv-palette { transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.25s; } .cv-overlay.side-open .cv-palette { left: calc(50% - 180px); max-width: calc(100% - 384px); } }
@media (max-width: 900px) { .cv-overlay.side-open .cv-palette { visibility: hidden; } }
.cv-side .sk-wide span { display: inline; }
.cv-side .fp-foot .sk-btn { flex: 1; justify-content: center; gap: 8px; }
.fp-foot .spacer { flex: 1; }
.fp-foot .icon-btn { flex: none; }

/* footer with three places: add on the left, the middle action in the centre, remove on the far right */
.fp-foot-3 { display: grid; grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr); align-items: center; gap: 6px; }
.fp-foot-3 .fp-zone { display: flex; align-items: center; }
.fp-foot-3 .fp-zone.start { justify-content: flex-start; }
.fp-foot-3 .fp-zone.mid { justify-content: center; }
.fp-foot-3 .fp-zone.end { justify-content: flex-end; }
.cv-side .fp-foot-3 .sk-btn { flex: none; padding: 0 8px; gap: 5px; font-size: 12.5px; white-space: nowrap; }
.cv-side .fp-foot-3 .sk-btn svg { width: 15px; height: 15px; }

/* the canvases of a notebook, listed in the side panel */
.cv-canvases { display: flex; flex-direction: column; gap: 4px; }
.cv-canvas { display: flex; align-items: center; gap: 2px; border-radius: 10px; border: 1px solid transparent; }
.cv-canvas:hover { background: var(--surface-2); }
.cv-canvas.on { background: var(--amber-wash); border-color: var(--amber-line); }
.cv-canvas-main { flex: 1; min-width: 0; display: flex; flex-direction: row; align-items: center; gap: 10px; background: transparent; border: 0; padding: 8px 10px; color: var(--text); text-align: left; }
.cv-canvas.on .cv-canvas-name { color: var(--amber-bright); }
.cv-canvas-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.cv-canvas-n { font-size: 12px; color: var(--faint); }
.cv-canvas-act { opacity: 0; width: 30px; height: 30px; }
.cv-canvas:hover .cv-canvas-act, .cv-canvas:focus-within .cv-canvas-act { opacity: 1; }
@media (hover: none) { .cv-canvas-act { opacity: 0.8; } }
/* a phone has room for one name: the canvas when the notebook has several, otherwise the notebook */
@media (max-width: 560px) {
  .crumb[data-multi="1"] .cv-title:not(.crumb-canvas) { display: none; }
  .crumb[data-multi="0"] .crumb-canvas { display: none; }
  .crumb .crumb-sep { display: none; }
  .crumb .crumb-canvas { max-width: 44vw; font-size: 16px; color: var(--text); }
}

/* crumb: the notebook name is a link to all its canvases; the canvas is where you are */
.crumb a.cv-title { cursor: pointer; text-decoration: none; }
.crumb a.cv-title:hover { color: var(--amber-bright); }
.crumb .crumb-title-now { cursor: default; }
.crumb .crumb-canvas { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 15px; min-width: 0; }
.crumb .crumb-canvas svg { width: 17px; height: 17px; flex: none; }
.crumb .crumb-canvas-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .crumb .crumb-canvas { max-width: 52vw; color: var(--text); } }

/* the canvases list in the panel: grip, thumbnail slot, name and meta */
.cv-canvas-text { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0; }
.cv-canvas-thumb { flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.cv-canvas-thumb svg { width: 20px; height: 20px; }
.cv-canvas.on .cv-canvas-thumb { color: var(--amber-bright); border-color: var(--amber-line); }
.cv-canvas-grip { flex: none; width: 16px; text-align: center; color: var(--faint); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; font-size: 13px; letter-spacing: -2px; align-self: stretch; display: grid; place-items: center; }
.cv-canvases.sorting .cv-canvas-grip { cursor: grabbing; }
.cv-canvas.sort-lifted { opacity: 0.35; }
.sort-ghost.cv-canvas { background: var(--surface-3); border: 1px solid var(--amber-line); border-radius: 10px; box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5); }
.fp-add { width: 38px; height: 38px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); color: var(--text); display: grid; place-items: center; }
.fp-add svg { width: 22px; height: 22px; }
.fp-add:hover { border-color: var(--amber-line); color: var(--amber-bright); }

/* all the canvases of a notebook */
.cvg-title { display: flex; align-items: center; gap: 6px; }
.cvg-rename { opacity: 0.55; }
.cvg-title:hover .cvg-rename, .cvg-rename:focus-visible { opacity: 1; }
.cvg-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.cvg-card { position: relative; display: flex; flex-direction: column; gap: 7px; background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.cvg-open { display: flex; flex-direction: column; gap: 7px; color: inherit; text-decoration: none; }
.cvg-thumb { aspect-ratio: 4 / 3; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); display: grid; place-items: center; color: var(--faint); background-image: radial-gradient(circle, rgba(255, 255, 255, 0.07) 1px, transparent 1.5px); background-size: 18px 18px; transition: border-color 0.15s, color 0.15s; }
.cvg-thumb svg { width: 44px; height: 44px; }
.cvg-card:hover .cvg-thumb { border-color: var(--amber-line); color: var(--amber-bright); }
.cvg-thumb-new { border-style: dashed; background-image: none; }
.cvg-acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.cvg-card:hover .cvg-acts, .cvg-acts:focus-within { opacity: 1; }
.cvg-acts .icon-btn { width: 30px; height: 30px; background: rgba(24, 22, 19, 0.85); border: 1px solid var(--line); }
@media (hover: none) { .cvg-acts { opacity: 0.9; } }
@media (min-width: 561px) { .crumb a.crumb-canvas { pointer-events: none; cursor: default; } }
.crumb a.crumb-canvas { text-decoration: none; }
@media (max-width: 560px) { .cvg-grid { grid-template-columns: repeat(2, 1fr); gap: 20px 14px; } }

/* the Add Spark tab of the notebook panel */
.cv-host.is-add { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.pick-pane { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 0; }
.pick-pane .pick-top { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 0; }
.pick-pane .pick-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0 14px 14px; }
.pick-pane .pick-list { max-height: none; overflow: visible; margin: 0; padding: 0; }
.pick-pane .pick-meta { flex-wrap: wrap; gap: 6px 10px; margin: 0 0 2px; }
.pick-pane .pick-kinds { margin-top: 0; }
.pick-pane .pick-foot { display: flex; align-items: center; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.pick-pane .pick-foot .sk-spacer { flex: 1; }
.pick-pane .pick-foot .btn { white-space: nowrap; }
.pick-search { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 12px; padding-right: 8px; }
.pick-search:focus-within { border-color: var(--amber); box-shadow: 0 0 0 3px var(--amber-wash); }
.pick-search .field { flex: 1; min-width: 0; border: 0; background: transparent; box-shadow: none; }
.pick-search .field:focus, .pick-search .field:focus-visible { outline: none; box-shadow: none; border: 0; }
.pick-search .pick-mode { flex: none; flex-wrap: nowrap; }
.pick-pane .pick-row { padding: 7px 9px; }
@media (max-width: 900px) { .cv-overlay.side-add .cv-side { height: min(78vh, 660px); } }
.fp-foot[hidden], .pick-mode[hidden] { display: none; }
.pick-pane .pick-top { gap: 10px; }
.pick-pane .pick-foot .btn[hidden] { display: none; }

/* canvas pictures: big previews in the panel list, as in the mockup, and in the grid */
.cv-canvas { position: relative; display: block; padding: 0; }
.cv-canvas-main { width: 100%; flex-direction: column; align-items: stretch; gap: 7px; padding: 8px; }
.cv-canvas-thumb { width: 100%; height: auto; aspect-ratio: 16 / 10; border-radius: 9px; overflow: hidden; background: #121110; background-image: radial-gradient(circle, rgba(255, 255, 255, 0.07) 1px, transparent 1.5px); background-size: 16px 16px; }
.cv-canvas-thumb svg { width: 30px; height: 30px; }
.cv-canvas-thumb img, .cvg-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; background: #121110; }
.cv-canvas-text { padding: 0 2px 2px; }
.cv-canvas-grip { position: absolute; z-index: 2; left: 14px; top: 14px; width: 22px; height: 26px; border-radius: 7px; background: rgba(18, 17, 16, 0.78); color: var(--text); align-self: auto; }
.cv-canvas-act { position: absolute; z-index: 2; top: 14px; right: 14px; background: rgba(18, 17, 16, 0.78); border: 1px solid var(--line); }
.cv-canvas-act + .cv-canvas-act { right: 50px; }
.cvg-thumb { overflow: hidden; }
.cvg-thumb img { border-radius: 11px; }
/* the text of a plain note keeps clear of the remove button, the resize handle and the attach points */
.cv-k-label:not(.sticky) .cv-x { top: -14px; right: -14px; }
/* drag handle on a canvas card in the all-canvases grid */
.cvg-grip { position: absolute; z-index: 2; left: 8px; top: 8px; width: 22px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: rgba(18, 17, 16, 0.78); color: var(--text); font-size: 13px; letter-spacing: -2px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; opacity: 0; transition: opacity 0.15s; }
.cvg-card:hover .cvg-grip, .cvg-grid.sorting .cvg-grip { opacity: 1; }
@media (hover: none) { .cvg-grip { opacity: 0.9; } }
.cvg-grid.sorting { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.cvg-card.sort-lifted { opacity: 0.35; }
.sort-ghost.cvg-card { border-radius: 12px; opacity: 0.95; }

/* ── action buttons live in the lower corners, like a spark card: actions lower right, grips lower left ── */
.cvg-media { position: relative; }
.cvg-acts { top: auto; right: 6px; bottom: 6px; }
.cvg-grip { top: auto; left: 6px; bottom: 6px; }
.cv-canvas-text { height: 40px; }
.cv-canvas-grip { top: auto; left: 14px; bottom: 61px; }
.cv-canvas-act { top: auto; right: 14px; bottom: 61px; }
.cv-canvas-act + .cv-canvas-act { right: 50px; }
.item-wrap .item-del { top: auto; bottom: 10px; }

/* Recent canvases on the shelf, and the all-canvases page */
.recent-canvases { margin-top: 38px; }
.recent-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 8px; margin-bottom: 18px; border-bottom: 1px solid var(--amber-dim, var(--amber-line)); }
.recent-head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 24px; }
.recent-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.recent-grid .cvg-card { text-decoration: none; }
.recent-grid .cvg-thumb { aspect-ratio: 4 / 3; }
@media (min-width: 900px) { .recent-canvases .recent-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 560px) { .recent-grid { grid-template-columns: repeat(2, 1fr); gap: 20px 14px; } }

/* tap or drag a row from the panel onto the canvas */
.pick-row { position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer; }
.pick-row.adding { opacity: 0.5; pointer-events: none; }
.pick-row .pick-row-x { position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; opacity: 0.8; }
.pick-row:has(.pick-row-x) .pick-text { padding-bottom: 22px; }
.pick-row input[type="checkbox"] { display: none; }
.cv-drag-ghost { max-width: 220px; padding: 8px 12px; border-radius: 10px; background: var(--surface-3, #2a2724); border: 1px solid var(--amber-line); color: var(--text); font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5); opacity: 0.92; }
.cv-drag-ghost.over { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(var(--amber-rgb), 0.35), 0 12px 26px rgba(0, 0, 0, 0.5); }
.cv-overlay.dropping .cv-stage { outline: 2px dashed var(--amber-line); outline-offset: -6px; }
.cv-palette .cv-add { touch-action: none; }
.lib-head .back { color: var(--amber); display: inline-flex; align-items: center; gap: 4px; font-size: 14px; margin-bottom: 8px; text-decoration: none; }
.lib-head .back svg { width: 14px; height: 14px; }

/* header crumbs use the interface font like everything else (serif is for journal content only), and carry no icon */
.crumb .cv-title, .crumb .crumb-title-now, .crumb a.cv-title { font-family: inherit; font-size: 16px; font-weight: 500; }
.cv-ctx { position: fixed; z-index: 960; min-width: 170px; padding: 5px; display: flex; flex-direction: column; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 14px 30px rgba(0, 0, 0, 0.5); }
.cv-ctx-i { background: none; border: 0; color: var(--text); text-align: left; padding: 9px 12px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; }
.cv-ctx-i:hover:not(:disabled) { background: var(--surface-3); }
.cv-ctx-i:disabled { color: var(--faint); cursor: default; }

/* Journal tiles: a grip in the lower left to drag them into your own order */
.item-wrap .item { padding-left: 34px; }
.item-wrap .item-grip { position: absolute; z-index: 2; left: 8px; bottom: 10px; width: 22px; height: 26px; display: grid; place-items: center; border-radius: 7px; color: var(--faint); font-size: 13px; letter-spacing: -2px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; opacity: 0.55; transition: opacity 0.12s; }
.item-wrap:hover .item-grip { opacity: 1; color: var(--text); }
.list-items.sorting { cursor: grabbing; }
.sort-ghost.item-wrap { background: var(--surface-3, #2a2724); border-radius: var(--radius); }

/* grid view: the whole tile is the drag handle (mouse drags at once, a finger holds first); the grip is not needed there */
.list-items.as-grid .item-wrap { cursor: grab; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.list-items.as-grid .item-wrap .item-grip { display: none; }
.list-items.as-grid .item-wrap .item { padding-left: 16px; }
.list-items.as-grid.sorting .item-wrap { cursor: grabbing; }

/* sparks and canvases: the whole card is the drag handle */
.grid .card[data-id] { -webkit-touch-callout: none; }
.grid.sorting .card { cursor: grabbing; }
.sort-ghost.card { box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55); }
.cvg-card, .grid .card[data-id] { user-select: none; -webkit-user-select: none; }
.share-menu { min-width: 150px; }

/* the touch toolbar always spans the screen, even with the side panel open (the desktop shift must not apply to it) */
body.doc-side-open .doc-dock.doc-dock-touch { left: 0; }


/* ───── About: opened from the logo (arrow or fire goes Home and stokes) ───── */
.about-page { min-height: calc(100vh - 58px); min-height: calc(100dvh - 58px); display: flex; justify-content: center; align-items: center; padding: 40px 28px 210px; } /* same centring as the Home quote */
.about-col { width: 100%; max-width: 1124px; font-family: var(--font); }
.about-lede { text-wrap: pretty; margin: 0 0 40px; font-size: clamp(24px, 3.4vw, 38px); line-height: 1.14; font-weight: 400; color: var(--text); letter-spacing: -0.005em; }
.about-lede strong { color: var(--amber-bright, var(--amber)); font-weight: 650; }
.about-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px 40px; padding: 26px 0 30px; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.about-pt h2 { margin: 0 0 10px; font-size: clamp(18px, 1.9vw, 24px); font-weight: 400; color: var(--amber-bright, var(--amber)); letter-spacing: 0; }
.about-pt p { text-wrap: balance; margin: 0; font-size: clamp(14px, 1.35vw, 17px); line-height: 1.55; color: var(--muted); }
@media (max-width: 820px) { .about-points { grid-template-columns: 1fr; gap: 24px; } .about-page { padding-bottom: 230px; } }

/* Discover: while the quote is on its way the icon turns into a spinning ring (same look as the mic after you stop). */
.act.discover-btn.busy { pointer-events: none; color: var(--amber-bright, var(--amber)); }
.act.discover-btn.busy svg { opacity: 0; }
.act.discover-btn { position: relative; }
.act.discover-btn.busy::before { content: ''; position: absolute; left: 2px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; box-sizing: border-box; border-radius: 50%; border: 2px solid rgba(226, 150, 40, 0.25); border-top-color: var(--amber-bright, var(--amber)); border-right-color: var(--amber-bright, var(--amber)); animation: micSpin 0.8s linear infinite; }
@media (prefers-reduced-motion: reduce) { .act.discover-btn.busy::before { animation-duration: 2.4s; } }

.about-tag { margin: 28px 0 0; text-align: center; text-wrap: balance; font-size: clamp(14px, 1.25vw, 17px); line-height: 1.5; font-style: italic; color: var(--muted); }

/* Corner items sit a fixed distance from the bottom and right edges. iPad Safari reports a home-indicator inset even in the browser, and an installed iPad web app
   has the same small indicator, so neither adds it. Only an installed iPhone web app, where the indicator is tall, needs the extra room. */
@media (display-mode: standalone) and (max-width: 640px) { .corner-btn { bottom: calc(14px + env(safe-area-inset-bottom)); } }
.cvg-card.cvg-recent { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* dictation: while words are being transcribed the page is blocked, so they cannot be lost */
.mic-shield { position: fixed; inset: 0; z-index: 9000; cursor: progress; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 28px; background: transparent; transition: padding-right 0.25s; }
.mic-shield-pill { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 16px; border-radius: 999px; background: rgba(24, 22, 19, 0.96); border: 1px solid var(--amber-line); color: var(--text); font-size: 13.5px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5); }
.mic-shield-pill .btn { padding: 4px 12px; font-size: 12.5px; }
.mic-shield-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff6b5a; animation: shieldPulse 1s ease-in-out infinite; }
@keyframes shieldPulse { 50% { opacity: 0.3; } }
/* the sound button gives way to any open side panel */
body.doc-side-open .corner-btn, body:has(.side-open) .corner-btn { display: none; }
/* Share is the notebook's main outward action */

.rel-head { padding-top: 4px; }
.rel-head .pick-search { margin-top: 10px; }
.rel-head .pick-kinds { margin-top: 10px; }
.rel-head .pick-kinds .sk-chip { height: 30px; padding: 0 11px; font-size: 12.5px; }
.rel-pic .rel-img { display: block; width: 100%; max-height: 240px; object-fit: cover; border-radius: 9px; margin-bottom: 8px; background: var(--surface-3); }
.rel-cap { font-size: 13.5px; color: var(--muted); }
.rel-list[hidden], .rel-head [hidden] { display: none; }

.cv-addcanvas { display: block; width: 100%; background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 8px 8px 8px; margin-top: 4px; cursor: pointer; text-align: left; font: inherit; color: var(--amber-bright, var(--amber)); }
.cv-addcanvas .cv-addcanvas-thumb { border: 1px dashed var(--amber-line); background: var(--surface-2); color: var(--amber-bright, var(--amber)); margin-bottom: 6px; }
.cv-addcanvas .cv-addcanvas-thumb svg { width: 26px; height: 26px; }
.cv-addcanvas:hover { background: var(--amber-wash); border-color: var(--amber-line); }
.cv-addcanvas .cv-canvas-name { display: block; font-size: 14px; }
.mic-shield-dot.live { animation-duration: 1.4s; }
.mic-shield-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.mic-shield-pill .btn { white-space: nowrap; }
@media (min-width: 901px) { body.doc-side-open .mic-shield, body:has(.cv-overlay.side-open) .mic-shield { padding-right: 360px; } }
body:has(.cv-palette) .mic-shield { padding-bottom: 88px; }

.about-page { cursor: pointer; }
.rel-order { display: flex; align-items: center; gap: 8px; }
.rel-order.busy::after { content: ''; width: 12px; height: 12px; box-sizing: border-box; border-radius: 50%; border: 2px solid rgba(226, 150, 40, 0.25); border-top-color: var(--amber-bright, var(--amber)); border-right-color: var(--amber-bright, var(--amber)); animation: micSpin 0.8s linear infinite; }
body.doc-dragging, body.doc-dragging * { user-select: none; -webkit-user-select: none; }
.rel-card { -webkit-touch-callout: none; }
body:has(.doc-dock-touch.editing) .mic-shield, body:has(.cv-fmtbar:not([hidden])) .mic-shield { padding-bottom: 84px; }
.mic-shield { box-sizing: border-box; }

/* things placed in a reflection read as neutral cards; gold only when you point at them */
.doc-blk { border-color: var(--line); background: rgba(255, 255, 255, 0.035); }
.doc-blk .label, .doc-blk.blk-reflection .label { color: var(--muted); }
.doc-blk .q { color: var(--text); }
.doc-blk.openable:hover { background: rgba(var(--amber-rgb), 0.10); border-color: var(--amber-line); }
.doc-blk.blk-reflection { border-color: var(--line); background: rgba(255, 255, 255, 0.035); }
.doc-blk.blk-reflection.openable:hover { background: rgba(138, 180, 232, 0.10); border-color: rgba(138, 180, 232, 0.4); }
.doc-blk.blk-media { padding: 10px; }
.doc-blk.blk-media .label { margin: 2px 4px 8px; }
.doc-blk.blk-media .thread-img { width: 100%; max-width: 100%; max-height: none; height: auto; margin: 0; border-radius: 10px; }
.doc-blk .cap { color: var(--muted); font-size: 13.5px; margin: 8px 4px 2px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ───────── Embers ───────── */
.ember-card { border-color: var(--amber-line); background: linear-gradient(180deg, rgba(var(--amber-rgb), 0.06), transparent 55%), var(--surface); }
.ember-card:hover { border-color: var(--amber); }
.ember-kicker { display: flex; align-items: center; gap: 6px; font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--amber); margin-bottom: 8px; }
.ember-kicker svg { width: 14px; height: 14px; }
.ember-img { display: block; width: 100%; border-radius: 10px; margin: 0 0 10px; }
.ember-title { font-family: var(--serif); font-size: 17px; line-height: 1.3; font-weight: 600; margin: 0 0 6px; }
.ember-text.clamp { display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden; }
.ember-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.ember-from { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; max-width: 100%; }
.ember-from:hover { color: var(--amber-bright); }
.ember-from svg { width: 12px; height: 12px; flex: none; }
.empty-ember svg { width: 44px; height: 44px; color: var(--amber); opacity: 0.85; }
.page-sub { margin: -8px 0 16px; color: var(--muted); font-size: 14px; }
.btn svg + *, .btn .em-spin + * { margin-left: 0; }

/* canvas ember card */
.cv-ember { background: linear-gradient(180deg, rgba(var(--amber-rgb), 0.09), transparent 60%); border-radius: 13px; -webkit-mask-image: linear-gradient(#000 82%, transparent); mask-image: linear-gradient(#000 82%, transparent); }
.cv-ember .cv-kicker { color: var(--amber); }
.cv-ember .cv-kicker svg { width: 13px; height: 13px; vertical-align: -2px; }
.cv-ember-title { font-family: var(--serif); font-weight: 600; font-size: 1.05em; line-height: 1.3; margin: 2px 0 6px; }
.cv-ember-text { line-height: 1.5; }
.cv-ember-img { display: block; max-width: 100%; max-height: 55%; object-fit: contain; border-radius: 8px; margin: 4px 0 8px; }

/* the + menu: a drop-down by the button, a sheet of big buttons on a phone */
.add-menu-backdrop { position: fixed; inset: 0; z-index: 60; animation: backdropIn 0.14s ease-out both; }
.add-menu-backdrop.closing { animation: backdropOut 0.14s ease-in both; pointer-events: none; }
.add-menu { position: fixed; width: min(320px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.add-grab { display: none; }
.add-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 11px; background: transparent; color: var(--text); text-align: left; }
.add-item:hover, .add-item:focus-visible { background: var(--amber-wash); outline: none; }
.add-item svg { width: 22px; height: 22px; flex: none; color: var(--amber); }
.add-text { display: flex; flex-direction: column; min-width: 0; }
.add-label { font-weight: 600; font-size: 15px; }
.add-hint { font-size: 12.5px; color: var(--muted); }
@media (max-width: 640px) {
  .add-menu-backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
  .add-menu { left: 0; right: 0; bottom: 0; top: auto !important; width: auto; border-radius: 22px 22px 0 0; padding: 8px 14px calc(18px + env(safe-area-inset-bottom)); gap: 8px; animation: sheetIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both; }
  .add-grab { display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: 4px auto 6px; }
  .add-item { padding: 16px 16px; min-height: 60px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 15px; }
  .add-item svg { width: 26px; height: 26px; }
  .add-label { font-size: 17px; }
}
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }

/* Find embers pane (in the reflection's side panel) */
.em-pane { display: flex; flex-direction: column; gap: 10px; padding-bottom: 20px; }
.em-intro, .em-note { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.em-note.warn { color: var(--amber); }
.em-err { color: var(--danger); }
.em-err { font-size: 13px; margin: 0; }
.em-how { display: flex; width: 100%; }
.em-how button { flex: 1; padding: 6px 4px; font-size: 12.5px; }
.em-how button.off { opacity: 0.55; }
.em-find { align-self: flex-start; }
.em-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(26, 18, 8, 0.35); border-top-color: #1a1208; animation: em-rot 0.8s linear infinite; display: inline-block; }
@keyframes em-rot { to { transform: rotate(360deg); } }
.em-summary p { margin: 0 0 4px; font-size: 14px; line-height: 1.55; }
.em-sug-head { display: flex; align-items: center; justify-content: space-between; }
.em-sug { border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px; background: var(--surface-2); }
.em-sug.done { border-color: var(--amber-line); background: var(--amber-wash); }
.em-sug-kind { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--amber); }
.em-sug-title { font-weight: 600; margin: 3px 0 2px; font-size: 14px; }
.em-sug-text { font-size: 13.5px; line-height: 1.5; }
.em-sug-act { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.em-make { padding: 5px 11px; font-size: 13px; }
.em-made { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--amber-bright); }
.em-made svg { width: 14px; height: 14px; }
.em-by { margin: 2px 0 0; font-size: 12px; color: var(--faint); }
.em-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.em-row-main { flex: 1; min-width: 0; background: none; border: 0; text-align: left; color: var(--text); padding: 8px 2px; display: flex; flex-direction: column; gap: 2px; }
.em-row-title { font-size: 13.5px; }
.em-row-text { font-size: 12.5px; color: var(--muted); }
.em-prompt, .em-reply { font-size: 13px; width: 100%; box-sizing: border-box; }
.em-foot { margin-top: 6px; }

/* five tabs on a phone: icons only, evenly spread */
@media (max-width: 640px) {
  .tabs { justify-content: space-between; }
  .tabs a { padding: 8px 9px; }
}
@media (max-width: 640px) {
  .nav-hist { display: none; } /* a phone has its own back gesture; the room goes to the five tabs */
  .tabs { flex: 1; }
}

.em-review { align-self: flex-start; margin-top: 4px; }

/* Embers inside a reflection */
.doc-blk.blk-ember { border-color: rgba(var(--amber-rgb), 0.55); }
.doc-blk.blk-ember .blk-title { font-weight: 600; }
.doc-blk.blk-ember .cap { margin: 6px 0 0; color: var(--muted); }
.em-apply { width: 100%; margin-top: 10px; justify-content: center; }
.em-review { display: block; margin-top: 8px; }
.fp-refresh[hidden] { display: none; }

/* ember priority and archive */
.ember-pri { margin-left: auto; font-size: 10.5px; letter-spacing: 0.6px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--amber-line); color: var(--amber-bright); }
.ember-pri.p0 { background: var(--amber); color: #1a1208; border-color: var(--amber); }
.ember-pri.arch { color: var(--muted); border-color: var(--line); }
.ember-pri + .ember-pri { margin-left: 6px; }
.pri-pick { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pri-chip { background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: 999px; min-width: 38px; height: 34px; padding: 0 10px; font-size: 14px; }
.pri-chip:hover { color: var(--text); }
.pri-chip.on { border: 2px solid var(--amber); color: var(--amber-bright); }
.pri-chip.arch.on { border-color: var(--muted); color: var(--text); }
@media (max-width: 640px) { .modal-foot { flex-wrap: wrap; } .pri-pick { flex: 1 0 100%; margin-bottom: 4px; } }
.ember-pri.done { background: rgba(120, 200, 140, 0.16); border-color: rgba(120, 200, 140, 0.55); color: #8fd6a2; }
.ember-pri + .ember-pri.done { margin-left: 6px; }
.ember-done-note { margin-top: 8px; font-size: 13px; color: #8fd6a2; }
.pri-chip.fin.on { border-color: #8fd6a2; color: #8fd6a2; }
.done-note-box { margin-top: 4px; }
.modal-foot .btn { white-space: nowrap; } .modal-foot { flex-wrap: wrap; } .pri-pick { gap: 2px; } .pri-chip { min-width: 34px; padding: 0 8px; }

/* Sketch editor on a phone: the top bar must fit the screen so Close and Save never slide off to the side */
.sk-top { min-width: 0; flex-wrap: wrap; row-gap: 6px; }
@media (max-width: 700px) {
  .sk-top { gap: 6px; padding-left: calc(8px + env(safe-area-inset-left)); padding-right: calc(8px + env(safe-area-inset-right)); }
  .sk-title, .sk-build { display: none; }
  .sk-top .sk-btn { min-width: 36px; padding: 0 7px; }
  .sk-top .sk-save { padding: 0 12px; white-space: nowrap; }
  .sk-save-more { display: none; }
  .sk-top .sk-bgs { padding: 0 2px; }
}

/* Notebook canvas on a phone: the closed side panel waits off-screen to the right and must not widen the page */
.cv-overlay .sk-top { min-width: 0; }
@media (max-width: 700px) {
  .cv-overlay .sk-top { gap: 6px; padding-left: calc(8px + env(safe-area-inset-left)); padding-right: calc(8px + env(safe-area-inset-right)); }
  .cv-overlay .sk-top .sk-btn { min-width: 36px; padding: 0 7px; }
}

/* Notebook toolbar on a phone: icons only, so Connect, Paste and Hand all fit on screen */
@media (max-width: 700px) {
  .cv-palette .cv-lbl { display: none; }
  .cv-palette .sk-chip { min-width: 44px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; }
  .cv-palette { gap: 4px; padding: 8px; }
}

/* Settings: text size (Settings sets --rs on <html>; 1 = normal) */
.q { font-size: calc(17px * var(--rs, 1)); }
.spark-hero .q { font-size: calc(23px * var(--rs, 1)); }
.msg-card .q, .doc-blk .q, .doc-blk .blk-title { font-size: calc(16.5px * var(--rs, 1)); }
.pv-q { font-size: calc(14px * var(--rs, 1)); }
.cv-q { font-size: calc(17px * var(--rs, 1)); }
.stage .quote { font-size: calc(clamp(25px, 3.1vw, 40px) * var(--rs, 1)); }
.stage .quote[style*="--len:1"], .stage .quote[style*="--len:2"] { font-size: calc(clamp(22px, 2.6vw, 34px) * var(--rs, 1)); }

/* Settings panel: a small pop-up above the gear; a bottom sheet on phones */
.settings-menu { position: fixed; right: calc(14px + env(safe-area-inset-right)); bottom: 58px; width: min(330px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px 8px; display: flex; flex-direction: column; animation: backdropIn 0.14s ease-out both; }
.set-title { font-weight: 600; font-size: 15px; margin: 0 0 6px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.set-row.set-col { flex-direction: column; align-items: stretch; gap: 10px; }
.set-text { min-width: 0; }
.set-label { font-size: 14.5px; font-weight: 550; }
.set-hint { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.set-switch { flex: none; position: relative; width: 44px; height: 26px; padding: 0; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface-3); cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.set-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background 0.15s; }
.set-switch.on { background: var(--amber-wash); border-color: var(--amber-line); }
.set-switch.on::after { transform: translateX(18px); background: var(--amber-bright, var(--amber)); }
.set-switch:focus-visible, .set-size:focus-visible { outline: 2px solid var(--amber-line); outline-offset: 2px; }
.set-sizes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.set-size { height: 40px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted); cursor: pointer; display: grid; place-items: center; font-family: var(--serif); }
.set-size:hover { color: var(--text); }
.set-size.on { color: var(--amber-bright, var(--amber)); border-color: var(--amber-line); background: var(--amber-wash); }
@media (max-width: 640px) {
  .settings-backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
  .settings-menu { left: 0; right: 0; bottom: 0; width: auto; border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); animation: sheetIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both; }
  .set-row { padding: 14px 0; }
  .set-switch { width: 52px; height: 30px; }
  .set-switch::after { width: 24px; height: 24px; }
  .set-switch.on::after { transform: translateX(22px); }
  .set-size { height: 48px; }
}

.set-range { width: 100%; accent-color: var(--amber); }
.set-foot { border-top: 1px solid var(--line); padding: 10px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.set-links { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.set-link { background: none; border: 0; padding: 4px 0; color: var(--amber); font-size: 13.5px; cursor: pointer; }
.set-link:hover, .set-link:focus-visible { color: var(--amber-bright, var(--amber)); text-decoration: underline; outline: none; }
.set-build { font-size: 11.5px; color: var(--faint); }
.keys section { margin: 0 0 14px; }
.keys h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.keys-row { display: flex; gap: 12px; align-items: baseline; padding: 4px 0; font-size: 14px; }
.keys-row kbd { flex: none; min-width: 120px; font-family: inherit; font-size: 12.5px; color: var(--amber-bright, var(--amber)); }
.keys-row span { color: var(--text); }
@media (max-width: 640px) { .keys-row { flex-direction: column; gap: 0; } .set-link { padding: 8px 0; font-size: 15px; } }

/* link card: Open, Edit, Remove under a link in a note */
.cf-linkcard { position: fixed; z-index: 100; max-width: min(340px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.lc-url { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-row { display: flex; gap: 6px; }
.lc-btn { flex: 1; text-align: center; padding: 6px 12px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text); font-size: 13.5px; cursor: pointer; text-decoration: none; }
.lc-btn:hover, .lc-btn:focus-visible { border-color: var(--amber-line); color: var(--amber-bright, var(--amber)); outline: none; }
.lc-danger:hover, .lc-danger:focus-visible { color: var(--danger); border-color: var(--danger); }
@media (max-width: 640px) { .lc-btn { padding: 11px 12px; font-size: 15px; } .lc-url { font-size: 13px; } }

/* hover shortcut under Notebooks in the top bar */
.nav-peek { position: fixed; z-index: 60; width: 112px; padding: 8px 8px 7px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); animation: backdropIn 0.14s ease-out both; }
.nav-peek:hover, .nav-peek:focus-visible { background: var(--surface-3); outline: none; }
.nav-peek:hover .np-t, .nav-peek:focus-visible .np-t { color: var(--text); }
.nav-peek .book-cover { width: 100%; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), inset 5px 0 7px -4px rgba(0, 0, 0, 0.55); }
.nav-peek .book-cover-title { font-size: 12px; padding: 18px 8px 8px; }
.nav-peek .book-cover img { display: block; }
.np-t { font-size: 12.5px; font-weight: 500; color: var(--muted); text-align: center; transition: color 0.12s; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
