/* ============================================================
   Notebook (js/notebook.js), its way in from the library,
   and the quote card sheet (js/quotecard.js)
   ============================================================ */

/* ---------- library: the Notebook button and the latest passages ---------- */
.libbar .nb-entry {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px 0 11px; border-radius: 999px;
  font: 600 14px/1 var(--ui); color: var(--ink-2);
  transition: background-color .2s, color .2s, transform .15s var(--ease);
}
.libbar .nb-entry:hover { background: var(--bg-2); color: var(--ink); }
.libbar .nb-entry:active { transform: scale(.97); }
.libbar .nb-entry svg { width: 19px; height: 19px; color: var(--crimson); }
.nb-entry-n {
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; display: inline-grid; place-items: center;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--gold); background: color-mix(in oklab, var(--gold) 13%, transparent);
}
.libbar .nb-entry ~ .sync-btn { margin-left: 6px; }

.nb-teaser { margin: clamp(48px, 7vw, 80px) 0 0; }
.nb-t-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.nb-t-head h2 { margin: 0; font: 500 22px/1.2 var(--serif); font-variation-settings: "opsz" 32; letter-spacing: -0.01em; }
.nb-t-all { font-size: 14px; font-weight: 600; color: var(--crimson); }
.nb-t-all:hover { text-decoration: underline; text-underline-offset: 3px; }
.nb-t-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.nb-t-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 18px 20px 16px 22px; border-radius: 14px;
  background: color-mix(in oklab, var(--surface) 70%, var(--bg));
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--line) 80%, transparent);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.nb-t-card::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: var(--dot); }
.nb-t-card:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px color-mix(in oklab, var(--line) 80%, transparent), 0 14px 30px -16px rgba(var(--shade), .45); }
.nb-t-q { font: italic 400 16px/1.55 var(--serif); color: var(--ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.nb-t-note { display: flex; gap: 6px; font-size: 13px; line-height: 1.45; color: var(--ink-2); }
.nb-t-note svg { flex: none; width: 14px; height: 14px; margin-top: 2px; color: var(--ink-3); }
.nb-t-note span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.nb-t-meta { margin-top: auto; font-size: 12px; font-weight: 600; color: var(--ink-3); }

/* ---------- the Notebook page ---------- */
.notebook {
  max-width: 820px; margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-left)) 180px max(var(--gutter), env(safe-area-inset-left));
}
.nb-bar { display: flex; align-items: center; gap: 6px; height: 72px; padding-top: env(safe-area-inset-top); box-sizing: content-box; margin-left: -10px; }
.nb-export { margin-left: auto; }
.nb-hero { padding: 8px 0 26px; }
.nb-kicker { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--crimson); }
.nb-kicker svg { width: 18px; height: 18px; }
.nb-title { margin: 0; font: 400 clamp(38px, 6vw, 60px)/1 var(--serif); font-variation-settings: "opsz" 72; letter-spacing: -0.025em; text-wrap: balance; }
.nb-stats { margin: 12px 0 0; color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; }

.nb-tools {
  position: sticky; top: 0; z-index: 5; display: flex; flex-direction: column; gap: 10px;
  margin: 0 -12px; padding: calc(10px + env(safe-area-inset-top)) 12px 12px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.3) blur(14px); backdrop-filter: saturate(1.3) blur(14px);
  border-bottom: 1px solid color-mix(in oklab, var(--line) 70%, transparent);
}
.nb-search { position: relative; display: flex; align-items: center; }
.nb-search > svg { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.nb-sq {
  width: 100%; height: 44px; padding: 0 44px 0 42px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: 16px var(--ui); outline: none; transition: border-color .2s, box-shadow .2s;
}
.nb-sq::placeholder { color: var(--ink-3); }
.nb-sq:focus { border-color: color-mix(in oklab, var(--gold) 70%, var(--line)); box-shadow: 0 0 0 3px color-mix(in oklab, var(--gold) 16%, transparent); }
.nb-sq::-webkit-search-cancel-button { filter: grayscale(1); opacity: .6; }
.nb-slash { position: absolute; right: 12px; pointer-events: none; opacity: .8; }
.nb-sq:focus ~ .nb-slash, .nb-sq:not(:placeholder-shown) ~ .nb-slash { display: none; }
.nb-chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; overscroll-behavior-x: contain; }
.nb-chips::-webkit-scrollbar { display: none; }
.nb-chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.nb-chip:hover { color: var(--ink); background: var(--bg-2); }
.nb-chip[aria-checked="true"], .nb-chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); box-shadow: none; }
.nb-chip svg { width: 15px; height: 15px; }
.nb-n { font-size: 12px; opacity: .7; font-variant-numeric: tabular-nums; }
.nb-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.nb-sp { flex: 1; }
.nb-sort { flex: none; }
.nb-sort button { min-width: 82px; }

.nb-list { padding-top: 6px; }
.nb-list > .loading { margin-top: 60px; }
.nb-book { position: relative; isolation: isolate; padding-top: 30px; }
.nb-bh { position: relative; display: flex; align-items: center; gap: 16px; margin: 0 0 6px; }
.nb-bh::before {
  content: ""; position: absolute; z-index: -1; left: -40px; top: -40px; width: 260px; height: 160px;
  background: radial-gradient(closest-side, rgba(var(--c1, 178, 38, 46), .18), transparent);
  filter: blur(8px); pointer-events: none;
}
.nb-cover { flex: none; width: 52px; }
.nb-cover img { width: 52px; height: auto; border-radius: 5px; box-shadow: 0 1px 2px rgba(var(--shade), .14), 0 8px 18px -8px rgba(var(--shade), .4); }
.nb-bt h2 { margin: 0; font: 500 26px/1.15 var(--serif); font-variation-settings: "opsz" 40; letter-spacing: -0.01em; }
.nb-bt p { margin: 3px 0 0; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nb-ch h3 {
  margin: 22px 0 6px; padding-left: 2px;
  font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--crimson);
}

.nb-it {
  position: relative; margin: 0 -14px; padding: 12px 14px 8px 26px; border-radius: 14px;
  transition: background-color .2s;
}
.nb-it::before { content: ""; position: absolute; left: 12px; top: 16px; bottom: 16px; width: 3px; border-radius: 2px; background: var(--dot); }
.nb-it:hover, .nb-it:focus-within, .nb-it.editing { background: color-mix(in oklab, var(--bg-2) 70%, transparent); }
.nb-q { display: block; width: 100%; text-align: left; border-radius: 8px; }
.nb-qt { font: 400 18px/1.62 var(--serif); color: var(--ink); text-wrap: pretty; }
.nb-qt mark {
  color: inherit; background: var(--hlc); padding: .06em .18em; border-radius: .24em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.nb-qt .nb-hit, .nb-note .nb-hit { background: color-mix(in oklab, var(--gold) 34%, transparent); color: inherit; border-radius: 3px; box-shadow: 0 0 0 1px color-mix(in oklab, var(--gold) 50%, transparent); }
.nb-q:hover .nb-qt mark { background: color-mix(in oklab, var(--hlc) 100%, var(--dot) 12%); }
.nb-note { display: flex; gap: 8px; margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: color-mix(in oklab, var(--dot) 9%, var(--surface)); }
.nb-note-i svg { width: 15px; height: 15px; margin-top: 3px; color: var(--ink-3); }
.nb-note p { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
.nb-edit { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.nb-edit .note-ta { min-height: 90px; resize: none; }
.nb-edit-acts { display: flex; align-items: center; gap: 8px; }
.nb-edit-hint { flex: 1; font-size: 12px; color: var(--ink-3); }
.nb-foot { display: flex; align-items: center; gap: 8px; min-height: 36px; margin-top: 4px; }
.nb-meta { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nb-where { font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.nb-tag { padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--gold); background: color-mix(in oklab, var(--gold) 12%, transparent); }
.nb-acts { display: flex; align-items: center; gap: 0; opacity: .5; transition: opacity .2s; }
.nb-it:hover .nb-acts, .nb-it:focus-within .nb-acts { opacity: 1; }
.nb-a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; color: var(--ink-2); transition: background-color .15s, color .15s; }
.nb-a:hover { background: var(--bg-2); color: var(--ink); }
.nb-a svg { width: 18px; height: 18px; }
.nb-del:hover { color: var(--crimson); }
.nb-gone {
  display: flex; align-items: center; gap: 12px; margin: 4px 0; padding: 10px 14px; border-radius: 12px;
  background: var(--bg-2); font-size: 14px; color: var(--ink-2);
  transition: opacity .25s, transform .25s var(--ease);
}
.nb-gone.out { opacity: 0; transform: scale(.98); }
.nb-undo { margin-left: auto; padding: 6px 12px; border-radius: 999px; font-weight: 700; color: var(--crimson); }
.nb-undo:hover { background: color-mix(in oklab, var(--crimson) 10%, transparent); }
.nb-flash { animation: nb-flash 2.4s ease-out; }
@keyframes nb-flash { 0%, 30% { background: color-mix(in oklab, var(--gold) 20%, transparent); } }
.nb-rise { animation: nb-rise .5s var(--spring, var(--ease)) both; animation-delay: calc(var(--k, 0) * 35ms); }
@keyframes nb-rise { from { opacity: 0; transform: translateY(10px); } }

.nb-foot-export { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 44px; padding-top: 18px; border-top: 1px solid var(--line); }
.nb-foot-export p { flex: 1 1 100%; margin: 0 0 4px; font-size: 13px; color: var(--ink-3); }
.nb-none { padding: 40px 0; text-align: center; color: var(--ink-2); }
.nb-none p { margin: 0 0 14px; font: italic 400 18px/1.4 var(--serif); }

/* ---------- empty: how to highlight ---------- */
.nb-empty { max-width: 520px; padding: 10px 0 20px; }
.nb-empty h2 { margin: 30px 0 10px; font: 500 24px/1.2 var(--serif); font-variation-settings: "opsz" 40; }
.nb-demo { position: relative; padding: 24px 22px 70px; border-radius: 16px; background: var(--surface); box-shadow: 0 0 0 1px color-mix(in oklab, var(--line) 80%, transparent); }
.nb-demo p { margin: 0; font: 400 19px/1.65 var(--serif); color: var(--ink); }
.nb-demo-l { color: var(--ink-2); }
.nb-demo-h { position: relative; z-index: 0; }
.nb-demo-h i {
  position: absolute; z-index: -1; left: -3px; right: -3px; top: 0; bottom: 0; border-radius: .3em;
  background: var(--hl-gold); transform-origin: 0 50%;
  animation: nb-sweep 3.6s cubic-bezier(.3, .7, .2, 1) infinite;
}
@keyframes nb-sweep { 0%, 12% { transform: scaleX(0); } 34%, 88% { transform: scaleX(1); } 100% { transform: scaleX(1); opacity: 0; } }
.nb-demo-bar {
  position: absolute; left: 22px; bottom: 16px; display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: 14px; background: var(--bg);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--line) 85%, transparent), 0 10px 26px -12px rgba(var(--shade), .45);
}
.nb-demo-bar i { width: 16px; height: 16px; border-radius: 50%; }
.nb-demo-bar .d-gold { background: var(--hl-gold-dot); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.2px var(--hl-gold-dot); }
.nb-demo-bar .d-red { background: var(--hl-red-dot); }
.nb-demo-bar .d-green { background: var(--hl-green-dot); }
.nb-demo-bar .d-blue { background: var(--hl-blue-dot); }
.nb-demo-bar .d-violet { background: var(--hl-violet-dot); }
.nb-demo-bar b { width: 1px; height: 16px; margin: 0 2px; background: var(--line); }
.nb-demo-bar svg { width: 17px; height: 17px; color: var(--ink-2); }
.nb-steps { margin: 0 0 14px; padding: 0 0 0 1.3em; display: flex; flex-direction: column; gap: 8px; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.nb-steps b { color: var(--ink); font-weight: 650; }
.nb-steps li::marker { color: var(--crimson); font-weight: 700; }
.nb-tip { margin: 0 0 22px; font-size: 13px; color: var(--ink-3); }

/* ---------- quote card sheet ---------- */
.modal-qc { align-items: center; }
.modal-qc .modal-card { width: min(560px, 100%); max-height: min(94vh, 980px); padding: 16px 18px 18px; gap: 14px; overflow-y: auto; overscroll-behavior: contain; }
.qc-head { display: flex; align-items: center; justify-content: space-between; }
.qc-head h2 { margin: 0; font: 500 22px/1.2 var(--serif); font-variation-settings: "opsz" 40; }
.qc-stage {
  position: relative; display: grid; place-items: center; padding: 14px; border-radius: 14px;
  background: var(--bg-2);
}
.qc-canvas {
  display: block; width: auto; height: auto; max-width: 100%;
  max-height: min(46vh, 420px); aspect-ratio: 1; border-radius: 6px;
  box-shadow: 0 1px 2px rgba(var(--shade), .14), 0 18px 40px -16px rgba(var(--shade), .5);
  transition: opacity .2s;
}
.qc-stage[data-shape="story"] .qc-canvas { aspect-ratio: 9 / 16; max-height: min(52vh, 520px); }
.qc-stage.busy .qc-canvas { opacity: .55; }
.qc-busy { position: absolute; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--crimson); opacity: 0; animation: qc-spin .8s linear infinite; transition: opacity .2s; }
.qc-stage.busy .qc-busy { opacity: 1; transition-delay: .25s; }
@keyframes qc-spin { to { transform: rotate(360deg); } }
.qc-opts { display: flex; flex-direction: column; gap: 12px; }
.qc-styles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.qc-style { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px 6px; border-radius: 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); transition: background-color .15s, color .15s; }
.qc-style:hover { background: var(--bg-2); color: var(--ink); }
.qc-sw { position: relative; width: 44px; height: 44px; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(128, 112, 108, .3); overflow: hidden; transition: box-shadow .2s, transform .2s var(--spring, var(--ease)); }
.qc-sw i { position: absolute; left: 9px; right: 9px; top: 13px; height: 3px; border-radius: 2px; box-shadow: 0 7px 0 currentColor, 0 14px 0 currentColor; color: inherit; background: currentColor; opacity: .7; }
.qcs-parchment .qc-sw { background: #EFE5CC; color: #4A3A26; }
.qcs-hearth .qc-sw { background: radial-gradient(circle at 50% -10%, #6b3a1f, #1A120D 75%); color: #F1E1C6; }
.qcs-cover .qc-sw { background: linear-gradient(160deg, #7a2a24, #2a1712); color: #FFF3E6; }
.qcs-minimal .qc-sw { background: #FBF9F6; color: #1E1817; }
.qc-style[aria-checked="true"] { color: var(--ink); }
.qc-style[aria-checked="true"] .qc-sw { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--crimson); }
.qc-style:active .qc-sw { transform: scale(.94); }
.qc-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.qc-shape { width: min(260px, 100%); }
.qc-shape button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.qc-ico { display: inline-block; border: 1.6px solid currentColor; border-radius: 2px; opacity: .8; }
.qc-ico.sq { width: 12px; height: 12px; }
.qc-ico.st { width: 9px; height: 15px; }
.qc-actions { display: flex; align-items: center; gap: 8px; padding-top: 2px; }

@media (max-width: 720px), (pointer: coarse) and (max-height: 500px) {
  .libbar .nb-entry { padding: 0 10px; min-height: 44px; }
  .libbar .nb-entry .nb-entry-t { display: none; }
  .nb-t-row { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: min(78vw, 300px); overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 2px var(--gutter) 10px; }
  .nb-t-row::-webkit-scrollbar { display: none; }
  .nb-t-card { scroll-snap-align: start; }
  .nb-bar { height: 56px; }
  .nb-hero { padding-bottom: 18px; }
  /* a phone's screen is short: the filters scroll away with the page */
  .nb-tools { position: static; margin: 0 calc(-1 * var(--gutter)); padding: 10px var(--gutter) 12px; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .nb-chips { margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter); }
  .nb-slash { display: none; }
  .nb-sort button { min-width: 0; }
  .nb-it { margin: 0 -10px; padding: 12px 10px 6px 22px; }
  .nb-it::before { left: 9px; }
  .nb-qt { font-size: 17px; }
  .nb-acts { opacity: .8; }
  .nb-a { width: 42px; height: 42px; }
  .nb-edit-acts .btn.sm { height: 44px; }
  .modal-qc { align-items: end; padding: 0; }
  .modal-qc .modal-card { width: 100%; max-height: 96vh; border-radius: 20px 20px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
  .qc-canvas { max-height: 40vh; }
  .qc-stage[data-shape="story"] .qc-canvas { max-height: 44vh; }
  .qc-actions .btn.sm { height: 46px; padding: 0 18px 0 14px; font-size: 15px; }
  .qc-actions .btn-primary { flex: 1; justify-content: center; }
}
@media (hover: none) { .nb-acts { opacity: .85; } }

@media (prefers-reduced-motion: reduce) {
  .nb-rise, .nb-flash, .nb-demo-h i, .qc-busy { animation: none; }
  .nb-demo-h i { transform: none; }
}
:root[data-motion="still"] .nb-rise, :root[data-motion="still"] .nb-flash, :root[data-motion="still"] .qc-busy { animation: none; }
:root[data-motion="still"] .nb-demo-h i { animation: none; transform: none; }
:root[data-motion="still"] .nb-t-card:hover { transform: none; }
@media (pointer: coarse) { .nb-tip { display: none; } }
