/* Noteboard: soft grey page, white rounded surfaces, black pills, mint accent. */

@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/vendor/outfit-ext.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/vendor/outfit.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #e9ebe8;
  --panel: #f3f4f2;
  --surface: #ffffff;
  --sunken: #eceeeb;
  --ink: #0f1110;
  --ink-2: #555b57;
  --ink-3: #8c928e;
  --line: #e0e3df;
  --line-strong: #d2d6d1;
  --mint: #d5ebe4;
  --mint-ink: #1d6b56;
  --stamp: #1f7a5f;
  --danger: #c8372d;
  --on-ink: #ffffff;
  --shadow-sm: 0 1px 2px rgba(17, 24, 20, .05);
  --shadow: 0 1px 2px rgba(17, 24, 20, .04), 0 8px 24px -10px rgba(17, 24, 20, .12);
  --shadow-lg: 0 24px 60px -20px rgba(17, 24, 20, .35);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 26px;
  --font: 'Outfit', system-ui, 'Segoe UI', sans-serif;
  /* effect timings (tune here) */
  --fx-morph: 420ms;      /* note / category grow and shrink */
  --fx-collapse: 280ms;   /* notes sliding into a gap */
  --fx-delete: 1800ms;    /* whole delete scan, including the fade */
  --fx-add: 1800ms;       /* new note: code fades in, then the scan turns it into the note */
  --mask-dur: 700ms;      /* New category / Done hover dissolve */
  --glow-dur: 1200ms;     /* Add note glow */
  /* effect colours */
  --glow-strength: 55%;   /* how strongly a note's colour fills its corner */
  --scan-color: #14d9c9;
  --scan-code: #1d6b56;
  --gold: #d9a521;        /* search matches */
  --gold-ink: #9a6f05;
  --ac-light: #34d1a1;    /* Add note glow */
  --ac-fill: #0d0f0e;
  --glass: color-mix(in srgb, var(--bg) 45%, transparent);
  --cube-size: 26px;
  --cube-ink: #0f1110;
  --cube-fade: #ffffff;
  --cube-lid: #413d3f;
  --cube-shadow: rgba(15, 17, 16, .45);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d0f0e;
  --panel: #141716;
  --surface: #1b1f1d;
  --sunken: #232825;
  --ink: #eef1ef;
  --ink-2: #a8afab;
  --ink-3: #6e7672;
  --line: #262b28;
  --line-strong: #323834;
  --mint: #1e3f36;
  --mint-ink: #94d8c2;
  --stamp: #6fd0ae;
  --danger: #ff7a6e;
  --on-ink: #0d0f0e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 26px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .8);
  --glow-strength: 62%;
  --scan-code: rgba(170, 240, 220, .8);
  --gold: #f2c14e;
  --gold-ink: #f2c14e;
  --ac-light: #ffffff;
  --ac-fill: #000000;
  --cube-ink: #eef1ef;
  --cube-fade: #0d0f0e;
  --cube-lid: #c9cecb;
  --cube-shadow: rgba(238, 241, 239, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.has-sheet { overflow: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--mint-ink); outline-offset: 2px; }
.i { flex: none; display: block; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 20px; border: 0; border-radius: 999px;
  font-weight: 500; white-space: nowrap;
  transition: transform .12s ease, background-color .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-dark { background: var(--ink); color: var(--on-ink); box-shadow: var(--shadow); }
.btn-dark:hover { opacity: .88; }
.btn-ghost { background: var(--sunken); }
.btn-ghost:hover { background: var(--line-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }

/* Mask dissolve (effect from codepen.io/pizza3/pen/qmerBv; sprite from Codrops'
   css-mask-animation, see THIRD_PARTY_NOTICES.md). fx.js steps --mask-frame (0-22)
   forward on hover and back on leave, always on whole sprite frames. */
.mask-btn {
  position: relative; overflow: hidden; isolation: isolate;
  background: transparent; color: var(--ink); border: 1.5px solid var(--ink);
}
.mask-under, .mask-fill { display: inline-flex; align-items: center; justify-content: center; gap: inherit; }
.mask-fill {
  position: absolute; inset: 0;
  background: var(--ink); color: var(--on-ink);
  -webkit-mask: url(/img/nature-sprite.png) 0 0 / 2300% 100% no-repeat;
  mask: url(/img/nature-sprite.png) 0 0 / 2300% 100% no-repeat;
  -webkit-mask-position: calc(var(--mask-frame, 0) * 100% / 22) 0;
  mask-position: calc(var(--mask-frame, 0) * 100% / 22) 0;
}
#new-category { box-shadow: var(--shadow); }

.round-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 0;
  display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.round-btn:hover { background: var(--sunken); }

.icon-btn {
  width: 32px; height: 32px; border-radius: 10px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--ink-2);
}
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn.danger:hover { color: var(--danger); }
.folder-btn.has-folder { color: var(--mint-ink); }

.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13.5px; font-weight: 500;
}
.pill-btn:hover { background: var(--sunken); }

/* ---------- inputs ---------- */
.field { display: grid; gap: 6px; }
.field-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.input {
  width: 100%; height: 42px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--ink-3); box-shadow: 0 0 0 3px var(--mint); }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row .input { flex: 1; min-width: 0; }
.pick-btn { flex: none; height: 42px; padding: 0 16px; }
.dialog-status:empty { display: none; }
.dialog-status { color: var(--ink-2); }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(380px, 100%); display: grid; gap: 18px; padding: 28px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.login-error { margin: -6px 0 0; min-height: 1em; color: var(--danger); font-size: 13.5px; }

/* ---------- shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 28px;
}
.board-status { display: flex; align-items: center; gap: 18px; min-width: 0; }
.board-stats {
  margin: 0; min-width: 0; font-size: 14px; color: var(--ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.board-stats span + span::before { content: '·'; margin: 0 8px; color: var(--ink-3); }
.board-stats .is-urgent { color: var(--danger); font-weight: 600; }

/* rotating cube (adapted from uiverse.io/Juanes200122/light-lion-95, MIT) */
.cube {
  --s: var(--cube-size);
  position: relative; flex: none; width: var(--s); height: var(--s); margin: 0 4px 0 8px;
  transform-style: preserve-3d; transform: rotateX(-30deg);
  animation: cube-spin 4s linear infinite;
}
@keyframes cube-spin {
  from { transform: rotateX(-30deg) rotateY(0); }
  to { transform: rotateX(-30deg) rotateY(360deg); }
}
.cube-wrapper { position: absolute; inset: 0; transform-style: preserve-3d; }
.cube-wrapper span {
  position: absolute; inset: 0;
  transform: rotateY(calc(90deg * var(--i))) translateZ(calc(var(--s) / 2));
  background: linear-gradient(to bottom, var(--cube-ink) 12%, var(--cube-fade) 100%);
}
.cube-top {
  position: absolute; inset: 0; background: var(--cube-lid);
  transform: rotateX(90deg) translateZ(calc(var(--s) / 2)); transform-style: preserve-3d;
}
.cube-top::before { /* soft shadow under the cube */
  content: ''; position: absolute; inset: 0;
  background: var(--cube-shadow); filter: blur(calc(var(--s) * .16));
  transform: translateZ(calc(var(--s) * -1.25));
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ink); color: var(--on-ink);
}
.brand strong { display: block; font-size: 19px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }
.brand small { display: block; font-size: 12.5px; color: var(--ink-2); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* live search (app.js applySearch) */
.top-search {
  position: relative; flex: 0 1 220px; min-width: 150px; margin-right: auto;
  display: flex; align-items: center; height: 42px; padding: 0 12px; gap: 8px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  color: var(--ink-3); cursor: text; transition: border-color .15s, box-shadow .15s;
}
.top-search:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }
.top-search.is-searching { border-color: color-mix(in srgb, var(--gold) 70%, transparent); }
.top-search-icon { display: grid; place-items: center; flex: none; }
.top-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  color: var(--ink); font: inherit; font-size: 14px;
}
.top-search input::-webkit-search-cancel-button { cursor: pointer; }
.top-search-count { flex: none; font-size: 12.5px; color: var(--gold-ink); white-space: nowrap; }
.top-search-count:empty { display: none; }
.top-search-key {
  flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px;
  border: 1px solid var(--line-strong); font: 12px/1 ui-monospace, Consolas, monospace; color: var(--ink-3);
}
.top-search:focus-within .top-search-key, .top-search.is-searching .top-search-key { display: none; }

/* matching notes glow gold; the rest turn into blurred code */
.card.is-hit {
  box-shadow: 0 0 0 1.5px var(--gold), 0 0 22px -4px color-mix(in srgb, var(--gold) 75%, transparent);
}
.card.is-miss, .card.is-miss.has-bg, .card.is-miss.has-border {
  background: transparent; border: 1px solid color-mix(in srgb, var(--scan-code) 35%, transparent); box-shadow: none;
}
.card.is-miss > :not(.card-code), .card.is-miss::before, .card.is-miss::after { opacity: 0; }
.card > * { transition: opacity .3s ease; }
.card-code {
  position: absolute; inset: 0; z-index: 6; margin: 0; overflow: hidden; border-radius: inherit;
  font: 11px/13px ui-monospace, 'Cascadia Mono', Consolas, monospace; white-space: pre;
  color: var(--scan-code); opacity: .75; pointer-events: none;
  animation: code-in .35s ease both;
}
@keyframes code-in { from { opacity: 0; } }

.sync-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 16px; border-radius: 999px;
  background: var(--mint); color: var(--mint-ink); font-size: 14px; font-weight: 500;
}
.sync-pill i { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.sync-pill.is-busy i { animation: pulse 1s ease-in-out infinite; }
.sync-pill.is-off { background: var(--sunken); color: var(--ink-2); }
@keyframes pulse { 50% { opacity: .25; } }


/* ---------- board ---------- */
.board {
  flex: 1; min-height: 0;
  display: flex; align-items: stretch;
  margin: 0 28px 24px; padding: 6px;
  background: var(--panel); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto; overflow-y: hidden;
}
.column {
  position: relative;
  flex: 1 0 280px; min-width: 0;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
}
.column:last-child { border-right: 0; }
.column-ghost { opacity: .4; }

.column.has-width { flex: 0 0 var(--col-w); }
/* The last column's saved width gives way when the window is too narrow for it, so it doesn't
   push the board past the window's edge (but never below the column minimum, 410px). */
@media (min-width: 761px) {
  .column.has-width:last-child, .col-slot.has-width:last-child { flex-shrink: 1; }
}
/* drag the divider between columns to resize; double-click resets */
.col-resizer {
  position: absolute; top: 0; bottom: 0; right: -5px; width: 10px; z-index: 3;
  cursor: col-resize; touch-action: none;
}
.col-resizer:hover, .col-resizer:active { background: linear-gradient(to right, transparent 4px, var(--mint-ink) 4px, var(--mint-ink) 6px, transparent 6px); }
.col-head {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 10px 10px 14px; min-height: 58px;
}
.col-tools .icon-btn { width: 28px; height: 28px; border-radius: 9px; }
.col-grip { color: var(--ink-3); cursor: grab; margin-left: -6px; padding: 4px 0; opacity: 0; transition: opacity .12s; }
.col-head:hover .col-grip { opacity: 1; }
.col-name {
  margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; outline: none;
  border-radius: 6px; padding: 2px 4px;
}
.col-name[contenteditable="plaintext-only"], .col-name[contenteditable="true"] {
  background: var(--surface); box-shadow: 0 0 0 2px var(--mint); text-overflow: clip;
}
.col-count {
  flex: none; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink); font-size: 12px; font-weight: 600;
}
.col-tools { margin-left: auto; display: flex; align-items: center; }

.col-cards {
  flex: 1; min-height: 60px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 10px 10px;
  scrollbar-width: thin;
}
/* Add note: dark button lit from its bottom edge; the light widens on hover
   (adapted from uiverse.io/0xnihilism/fresh-cobra-9, MIT) */
.add-card {
  position: relative; flex: none; height: 42px; margin: 2px 10px 12px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 12px; background: rgba(255, 255, 255, .05);
  color: #fff; font-size: 14px; font-weight: 500; letter-spacing: .02em;
  transition: transform .12s ease;
}
.add-card:active { transform: scale(.97); }
.ac-glow, .ac-stroke {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  transition: opacity var(--glow-dur) ease-in-out;
}
.ac-glow.ac-rest { background: radial-gradient(15% 50% at 50% 100%, var(--ac-light) 0%, transparent 100%); filter: blur(15px); }
.ac-glow.ac-hover { background: radial-gradient(60.6% 50% at 50% 100%, var(--ac-light) 0%, transparent 100%); filter: blur(18px); }
.ac-stroke.ac-rest { background: radial-gradient(10.7% 50% at 50% 100%, var(--ac-light) 0%, transparent 100%); }
.ac-stroke.ac-hover { background: radial-gradient(60.1% 50% at 50% 100%, var(--ac-light) 0%, transparent 100%); }
.ac-hover { opacity: 0; }
.add-card:hover .ac-rest, .add-card:focus-visible .ac-rest { opacity: 0; }
.add-card:hover .ac-hover, .add-card:focus-visible .ac-hover { opacity: 1; }
.ac-fill { position: absolute; inset: 1px; z-index: 1; border-radius: 11px; background: var(--ac-fill); pointer-events: none; }
.ac-label {
  position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 6px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
.add-card:focus-visible { outline-offset: 3px; }

.empty { margin: auto; text-align: center; color: var(--ink-2); }

/* the expanded category's empty place on the board */
.col-slot { flex: 1 0 280px; border-right: 1px solid var(--line); }
.col-slot:last-child { border-right: 0; }
.col-slot.has-width { flex: 0 0 var(--col-w); }

/* expanded category: a centred panel over a glass backdrop, cards in a grid */
.cat-overlay {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; padding: 32px;
  background: var(--glass); -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  animation: fx-fade-in var(--fx-morph) ease both;
}
.cat-panel {
  width: min(1280px, 100%); height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
}
.cat-overlay:not(.is-entering) .cat-panel { animation: fx-fade-in 180ms ease both; }
.cat-overlay.is-entering .cat-panel, .cat-overlay.is-leaving .cat-panel { visibility: hidden; }
.cat-overlay.is-leaving { pointer-events: none; }
.cat-panel .column { flex: 1 1 auto; min-height: 0; border-right: 0; }
.cat-panel .col-head { padding: 16px 16px 12px 20px; }
.cat-panel .col-cards {
  display: grid; align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px; padding: 4px 18px 18px;
}
.cat-panel .add-card { width: 240px; margin: 0 18px 14px; }

/* shared by the expand and full-screen animations */
@keyframes fx-fade-in { from { opacity: 0; } }
.is-lifted { visibility: hidden; }
.fx-ghost {
  position: fixed; z-index: 41; pointer-events: none;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.fx-ghost.is-panel { background: var(--panel); border-color: transparent; }

/* ---------- card ---------- */
.card {
  position: relative;
  display: flex; flex-direction: column; flex-shrink: 0;
  min-height: 132px; padding: 14px 14px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); color: var(--ink);
  cursor: grab;
  transition: box-shadow .15s ease, border-color .15s ease;
}
.card:hover { border-color: var(--line-strong); }
.card.is-editing { cursor: auto; border-color: var(--ink-3); box-shadow: 0 0 0 3px var(--mint), var(--shadow); }
.card-title {
  font-size: 15.5px; font-weight: 600; line-height: 1.3; letter-spacing: -.005em;
  outline: none; border-radius: 6px; margin: -2px -4px 4px; padding: 2px 4px;
  overflow-wrap: anywhere;
}
.card-title[contenteditable] { cursor: text; background: var(--sunken); }
.card-title:focus-visible:not([contenteditable]) { box-shadow: 0 0 0 2px var(--mint-ink); }
.card-title:empty::before, .sheet-title:empty::before { content: attr(data-placeholder); color: var(--ink-3); }

.rich { font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.rich.ql-editor { padding: 0; height: auto; overflow: visible; white-space: normal; }
.card-body {
  flex: 1; max-height: 240px; overflow: hidden; cursor: text;
  -webkit-mask-image: linear-gradient(to bottom, #000 200px, transparent 240px);
  mask-image: linear-gradient(to bottom, #000 200px, transparent 240px);
}
.card-body .placeholder { color: var(--ink-3); }
.rich a { color: var(--mint-ink); }
.rich h2 { font-size: 1.2em; font-weight: 600; color: var(--ink); margin: .2em 0; }
.rich strong { color: var(--ink); font-weight: 600; }
.rich li { padding-left: 1.4em; }
.rich ol { padding-left: 0; }
.rich li[data-list="checked"], .rich li[data-list="unchecked"] { padding-left: 1.6em; }
.rich li[data-list="checked"] > .ql-ui::before,
.rich li[data-list="unchecked"] > .ql-ui::before {
  content: ''; width: 15px; height: 15px; margin-left: -1.6em; margin-right: .5em;
  border: 1.5px solid var(--ink-3); border-radius: 5px; vertical-align: -2px;
  box-sizing: border-box; cursor: pointer;
}
.rich li[data-list="checked"] > .ql-ui::before {
  content: '✓'; background: var(--ink); border-color: var(--ink); color: var(--on-ink);
  font-size: 11px; line-height: 12px; text-align: center; font-weight: 700;
}
.rich li[data-list="checked"] { color: var(--ink-3); text-decoration: line-through; }
.card-body .ql-ui { cursor: pointer; }

.card-actions {
  display: flex; align-items: center; gap: 2px;
  margin: 8px -6px 0; padding-top: 6px; border-top: 1px solid var(--line);
}
.spacer { flex: 1; }
.done-btn { height: 30px; padding: 0 12px; }
.done-btn.mask-btn, .done-btn.mask-btn:hover { background: transparent; border: 1.5px solid var(--ink); color: var(--ink); }

.ql-container { font-family: inherit; font-size: inherit; height: auto; }
.ql-editor:focus-visible { outline: none; }

/* inline editor on the card */
/* Same size and spacing as the preview, so the card does not jump when editing starts. */
.card-editor { flex: 1; min-height: 21px; }
.card-editor .ql-editor {
  padding: 0; max-height: 240px; overflow-y: auto;
  font-size: 14px; line-height: 1.5; color: var(--ink); white-space: pre-wrap;
}
.card > .card-toolbar {
  position: absolute; top: 6px; right: 6px; z-index: 4; max-width: calc(100% - 12px);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.card > .card-toolbar button { width: 26px; height: 26px; }
.ql-editor.ql-blank::before { left: 0; right: 0; font-style: normal; color: var(--ink-3); }

.rt-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 3px; border-radius: 12px; background: var(--sunken); align-self: flex-start;
}
.rt-toolbar button {
  width: 30px; height: 28px; border: 0; border-radius: 8px; background: transparent;
  display: grid; place-items: center; color: var(--ink-2);
}
.rt-toolbar button:hover { color: var(--ink); background: var(--surface); }
.rt-toolbar button.ql-active { background: var(--ink); color: var(--on-ink); }
.rt-sep { width: 1px; height: 18px; margin: 0 3px; background: var(--line-strong); }
/* text size picker (normal + four 1px steps; see editor.js) */
.rt-size {
  height: 28px; padding: 0 20px 0 8px; border: 0; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--ink-2);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 6px center;
  appearance: none; -webkit-appearance: none;
}
.rt-size:hover, .rt-size:focus-visible { color: var(--ink); background-color: var(--surface); }
.rt-size option { background: var(--surface); color: var(--ink); }
.card > .card-toolbar .rt-size { height: 26px; }
.rich .ql-size-p1 { font-size: calc(1em + 1px); }
.rich .ql-size-p2 { font-size: calc(1em + 2px); }
.rich .ql-size-p3 { font-size: calc(1em + 3px); }
.rich .ql-size-p4 { font-size: calc(1em + 4px); }

/* done state + stamp */
.card.is-done .card-title, .card.is-done .card-body { opacity: .38; }
.card.is-done .card-title, .card.is-done .card-body, .card.is-done .card-body .ql-ui { cursor: default; }
.stamp {
  position: absolute; left: 50%; top: 46%;
  transform: translate(-50%, -50%) rotate(-11deg);
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 18px 5px; border: 3px solid var(--stamp); border-radius: 12px;
  color: var(--stamp); pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3.5px var(--stamp);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  animation: stamp-in .22s cubic-bezier(.2, 1.6, .4, 1);
}
.stamp-word { font-size: 26px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; line-height: 1; margin-right: -.22em; }
.stamp-date { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; margin-top: 3px; }
@keyframes stamp-in { from { opacity: 0; transform: translate(-50%, -50%) rotate(-11deg) scale(1.6); } }

/* custom colours, icon, thumbnail */
.card.has-bg, .sheet-paper.has-bg, .fx-ghost.has-bg {
  background:
    radial-gradient(120% 165% at 100% 0%, color-mix(in srgb, var(--glow) var(--glow-strength), transparent) 0%, transparent 62%),
    var(--surface);
}
/* a lit edge near the coloured corner (a chosen border colour replaces it) */
.card.has-bg::after, .sheet-paper.has-bg::after, .fx-ghost.has-bg::after {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: radial-gradient(85% 140% at 100% 0%, var(--glow) 0%, transparent 72%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.has-bg.has-border::after { display: none; }
.card.has-border, .sheet-paper.has-border, .fx-ghost.has-border { border: 2px solid var(--card-border); }
.card.has-border:hover { border-color: var(--card-border); }
.card.has-bg .rich { color: var(--ink-2); }
.has-bg .rich a { text-decoration: underline; }
.card-head { display: flex; align-items: flex-start; gap: 8px; padding-right: 30px; }

/* urgent toggle (top-right of the note) */
.urgent-btn {
  height: 28px; min-width: 28px; padding: 0; border: 0; border-radius: 9px; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.urgent-btn:hover { background: var(--sunken); color: var(--ink); }
.urgent-btn.is-on { padding: 0 4px 0 10px; color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.urgent-btn.is-on:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 20%, transparent); }
.urgent-btn.is-on .i { stroke-width: 2.6; }
.card-urgent { position: absolute; top: 9px; right: 8px; z-index: 3; }
.card.is-urgent .card-head { padding-right: 92px; }
.card:has(.card-thumb) .card-head { padding-right: 0; }
.card:has(.card-thumb) .card-urgent:not(.is-on) { background: var(--surface); box-shadow: var(--shadow); }
.card.is-editing .card-urgent { visibility: hidden; } /* the editing toolbar sits there */
.card-head .card-title { flex: 1; min-width: 0; }
.card-icon {
  flex: none; width: 26px; height: 26px; margin-top: -2px;
  display: grid; place-items: center; border: 0; border-radius: 8px;
  background: var(--sunken); color: var(--ink);
}
button.card-icon:hover { background: var(--line-strong); }
.card-icon-lg { width: 44px; height: 44px; border-radius: 13px; margin: 0; }
.card-thumb {
  margin: -14px -14px 10px; height: 140px; overflow: hidden; cursor: pointer;
  border-radius: calc(var(--r) - 1px) calc(var(--r) - 1px) 0 0; background: var(--sunken);
}
.card-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.card.is-done .card-thumb { opacity: .45; }
.card-body img { display: none; }
.card-editor img, .sheet-editor img, .card.is-open .card-body img {
  display: block; max-width: 100%; height: auto; margin: 6px 0; border-radius: 10px;
}
.card-editor .ql-editor img { max-height: 140px; width: auto; }

/* note height (drag the handle at the bottom edge) */
.card { container-type: inline-size; }
.card.has-height { min-height: 0; }
.card.has-height .card-body {
  max-height: none; min-height: 0;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 28px), transparent);
}
.card.has-height .card-editor { min-height: 0; display: flex; flex-direction: column; }
.card.has-height .card-editor .ql-editor { flex: 1; min-height: 0; max-height: none; }
.card-resize {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 44px; height: 9px; cursor: ns-resize; touch-action: none; z-index: 2;
  display: grid; place-items: center;
}
.card-resize::before {
  content: ''; width: 28px; height: 3px; border-radius: 2px; background: var(--line-strong);
  opacity: 0; transition: opacity .15s;
}
.card:hover .card-resize::before, .card-resize:hover::before { opacity: 1; }
@media (hover: none) { .card-resize::before { opacity: 1; } }
.card.is-readonly .card-resize { display: none; }
/* width grip on the right edge (desktop only) */
.card-resize-x {
  position: absolute; top: 50%; right: 0; transform: translateY(-50%);
  width: 9px; height: 44px; cursor: ew-resize; touch-action: none; z-index: 2;
  display: grid; place-items: center;
}
.card-resize-x::before {
  content: ''; width: 3px; height: 28px; border-radius: 2px; background: var(--line-strong);
  opacity: 0; transition: opacity .15s;
}
.card:hover .card-resize-x::before, .card-resize-x:hover::before { opacity: 1; }
.card.is-readonly .card-resize-x, .cat-panel .card-resize-x { display: none; }

/* Desktop: notes flow side by side when the column is wide enough (app.js sizeNoteRows sets
   --auto-w, the shared width of notes without their own). Columns fit at least one note. */
@media (min-width: 761px) {
  .column, .col-slot { flex-basis: 410px; min-width: 410px; }
  #board .col-cards { flex-direction: row; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; }
  #board .col-cards > .card { flex: 0 0 var(--auto-w, 100%); min-width: 370px; max-width: 520px; }
  #board .col-cards > .card.has-w { flex-basis: var(--card-w); }
}
@media (max-width: 760px) { .card-resize-x { display: none; } }

/* compact action row; the Done label hides on narrow cards */
.card-actions .icon-btn { width: 28px; height: 28px; border-radius: 9px; }
@container (max-width: 240px) {
  .done-btn .lbl { display: none; }
  .done-btn { padding: 0 8px; }
}

/* image move/resize in the full-screen note */
.sheet-editor .ql-editor img { cursor: grab; }
.sheet-editor .ql-editor img.is-moving { opacity: .3; }
.img-frame {
  position: absolute; z-index: 5; pointer-events: none; box-sizing: border-box;
  border: 2px solid var(--mint-ink); border-radius: 12px;
}
.img-move, .img-size {
  position: absolute; display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; background: rgba(15, 17, 16, .78); color: #fff; font-size: 12px; user-select: none;
}
.img-move { top: 8px; left: 8px; height: 26px; padding: 0 10px 0 6px; pointer-events: auto; cursor: grab; touch-action: none; }
.img-size { right: 10px; bottom: 10px; padding: 2px 8px; }
.img-size:empty { display: none; }
.img-resize {
  position: absolute; right: -8px; bottom: -8px; width: 18px; height: 18px;
  border-radius: 6px; border: 2px solid var(--mint-ink); background: var(--surface);
  pointer-events: auto; cursor: nwse-resize; touch-action: none;
}
.img-drop-line {
  position: absolute; left: 0; right: 0; height: 3px; margin-top: -2px; z-index: 5;
  border-radius: 2px; background: var(--mint-ink); pointer-events: none;
}
.img-drop-vline {
  position: absolute; width: 3px; z-index: 5;
  border-radius: 2px; background: var(--mint-ink); pointer-events: none;
}
/* up to 3 images side by side: a line holding several images becomes a row */
.rich p:has(> img + img) { display: flex; gap: 8px; align-items: flex-start; }
.rich p:has(> img + img) > img { flex: 0 1 auto; min-width: 0; }
.img-ghost {
  position: fixed; z-index: 80; width: 140px; height: auto; pointer-events: none;
  border-radius: 10px; opacity: .85; box-shadow: var(--shadow-lg);
  transform: translate(-50%, -50%) rotate(2deg);
}

/* drag states */
.card-ghost { opacity: .3; }
.card-chosen { box-shadow: var(--shadow-lg); }
.card-drag { transform: rotate(2deg); box-shadow: var(--shadow-lg) !important; cursor: grabbing; }
.sortable-fallback { opacity: .95 !important; }

/* ---------- full-screen sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  background: var(--glass); -webkit-backdrop-filter: blur(18px) saturate(1.3); backdrop-filter: blur(18px) saturate(1.3);
  animation: fx-fade-in var(--fx-morph) ease both;
}
.sheet.trash { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; animation-duration: .18s; }
.sheet.is-entering .sheet-paper, .sheet.is-leaving .sheet-paper { visibility: hidden; }
.sheet:not(.is-entering) .sheet-paper { animation: fx-fade-in 180ms ease both; }
.sheet.is-leaving { pointer-events: none; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 18px 28px; }
.sheet-actions { display: flex; align-items: center; gap: 6px; }
.sheet-main { flex: 1; min-height: 0; overflow-y: auto; padding: 0 28px 28px; }
.sheet-paper {
  position: relative;
  max-width: 900px; min-height: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 34px 40px 22px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); color: var(--ink);
}
.sheet-title-row { display: flex; align-items: center; gap: 14px; }
.sheet-icon-slot:empty { display: none; }
.sheet-title {
  flex: 1; min-width: 0;
  font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15;
  outline: none; overflow-wrap: anywhere;
}
.sheet-editor { flex: 1; min-height: 240px; }
.sheet-editor .ql-editor { padding: 0; min-height: 240px; font-size: 16px; line-height: 1.6; color: var(--ink); }
.sheet.is-done .sheet-title, .sheet.is-done .sheet-editor { opacity: .5; }
.sheet-stamp-slot .stamp { top: 64px; left: auto; right: 10px; transform: rotate(-11deg); animation: none; z-index: 1; }
.sheet-foot {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding-top: 16px; border-top: 1px solid var(--line);
}
.sheet-foot .field { flex: 1 1 320px; max-width: 560px; }
.sheet-meta { font-size: 13px; color: var(--ink-3); }

/* ---------- dialogs, menu, toast ---------- */
.dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0; border: 0;
  border-radius: var(--r-lg); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 14, 12, .35); backdrop-filter: blur(2px); }
.dialog-form { display: grid; gap: 14px; padding: 24px; }
.dialog-title { margin: 0; font-size: 19px; font-weight: 600; }
.dialog-msg { margin: -6px 0 0; color: var(--ink-2); }
.dialog-body { display: grid; gap: 8px; }
.dialog-hint { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.dialog-check { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.dialog-check input { width: 16px; height: 16px; accent-color: var(--mint-ink); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.menu {
  position: fixed; z-index: 60; min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; font-size: 14px;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--sunken); outline: none; }
.menu-item.is-danger { color: var(--danger); }

/* popovers: colours and icon picker */
.popover { position: fixed; z-index: 60; }
.pop-panel {
  display: grid; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.pop-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pop-title { margin: 0; font-size: 14px; font-weight: 600; }
.pill-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.color-row { display: grid; grid-template-columns: 92px 48px auto; align-items: center; gap: 10px; }
.color-label { font-size: 13.5px; color: var(--ink-2); }
.color-input {
  width: 48px; height: 32px; padding: 3px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 7px; }
.color-input::-moz-color-swatch { border: 0; border-radius: 7px; }
.icon-grid { display: grid; grid-template-columns: repeat(8, 34px); gap: 4px; }
.icon-choice {
  width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent;
  display: grid; place-items: center; color: var(--ink-2);
}
.icon-choice:hover { background: var(--sunken); color: var(--ink); }
.icon-choice.is-active { background: var(--ink); color: var(--on-ink); }

/* ---------- trash ---------- */
.trash-btn { position: relative; }
.badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.danger-pill { color: var(--danger); }
.danger-pill:disabled { opacity: .4; cursor: default; }
.trash-body { max-width: 1200px; margin: 0 auto; padding-bottom: 24px; }
.trash-title { margin: 0; font-size: 34px; font-weight: 600; letter-spacing: -.02em; }
.trash-sub { margin: 4px 0 0; color: var(--ink-2); }
.trash-h2 {
  margin: 28px 0 12px; font-size: 13px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3);
}
.trash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.trash-cat { margin-bottom: 14px; padding: 14px; background: var(--panel); border-radius: var(--r-lg); }
.trash-cat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trash-cat:has(.trash-grid) .trash-cat-head { margin-bottom: 14px; }
.trash-cat-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); }
.trash-cat-text h3 { margin: 0; font-size: 17px; font-weight: 600; }
.trash-cat-text p { margin: 0; font-size: 13px; color: var(--ink-3); }
.card.is-readonly { cursor: pointer; min-height: 0; }
.card.is-readonly .card-body { cursor: pointer; }
.card.is-open .card-body { max-height: none; -webkit-mask-image: none; mask-image: none; }
.trash-meta { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-3); }

.toast-host { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 70; display: flex; justify-content: center; pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  max-width: min(640px, calc(100vw - 32px));
  padding: 10px 10px 10px 18px; border-radius: 999px;
  background: #0f1110; color: #e9ebe8; box-shadow: var(--shadow-lg);
  font-size: 14px; animation: sheet-in .18s ease-out;
}
[data-theme="dark"] .toast { background: #eef1ef; color: #0f1110; }
.toast-icon { opacity: .7; }
.toast.is-error .toast-icon { display: none; }
.toast-msg { overflow-wrap: anywhere; }
.toast-action {
  border: 0; border-radius: 999px; padding: 6px 14px;
  background: rgba(255, 255, 255, .12); color: inherit; font-weight: 600;
}
[data-theme="dark"] .toast-action { background: rgba(0, 0, 0, .08); }
.toast:not(:has(.toast-action)) { padding-right: 18px; }

/* ---------- delete: scan line turns the note into code (fx.js) ---------- */
.scan-fx { position: fixed; z-index: 35; pointer-events: none; }
.scan-code {
  position: absolute; inset: 0; margin: 0; overflow: hidden;
  font: 11px/13px ui-monospace, 'Cascadia Mono', Consolas, monospace; white-space: pre;
  color: var(--scan-code);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .3), #000 var(--scan-y, 100%));
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .3), #000 var(--scan-y, 100%));
  animation: scan-glitch .12s steps(2) infinite alternate;
}
@keyframes scan-glitch { from { opacity: .8; } to { opacity: 1; transform: translateX(.6px); } }
.scan-beam {
  position: absolute; left: 0; right: 0; top: -1.5px; height: 3px; border-radius: 3px;
  background: linear-gradient(to right, transparent, var(--scan-color) 12%, #fff 50%, var(--scan-color) 88%, transparent);
  box-shadow: 0 0 12px var(--scan-color), 0 0 30px color-mix(in srgb, var(--scan-color) 60%, transparent);
}
.scan-beam::before {
  content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 28px;
  background: linear-gradient(to top, color-mix(in srgb, var(--scan-color) 24%, transparent), transparent);
}

@media (prefers-reduced-motion: reduce) {
  .cube { animation: none; }
  .sheet, .sheet-paper, .cat-overlay, .cat-panel { animation: none !important; }
}

/* ---------- Jarvis chat (chat.js): floating, movable; above the board and sheets ---------- */
.chat {
  --chat-w: 430px;
  position: fixed; z-index: 55; left: 50%; top: 10px;
  width: min(var(--chat-w), calc(100vw - 16px)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  transition: width .32s cubic-bezier(.2, .8, .2, 1);
}
.chat.is-expanded { --chat-w: 560px; }
.chat.is-low { flex-direction: column-reverse; }
.chat.is-dragging { transition: none; user-select: none; }
.chat-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px;
  min-height: 50px; padding: 5px 5px 5px 2px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 25px;
  box-shadow: var(--shadow-lg), var(--shadow-sm);
  transition: border-radius .3s ease, padding .3s ease;
}
.chat.is-expanded .chat-box { border-radius: 22px; padding: 8px 8px 8px 4px; }
/* Sweep effect on the chat box (adapted from the "ShinyButton" snippet; see THIRD_PARTY_NOTICES.md):
   a bright arc runs round the border, with a dotted speckle and a soft sheen inside. On hover or
   while typing the arc widens and the speed changes; the inner glow breathes. */
@property --cb-angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@property --cb-offset { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
@property --cb-percent { syntax: "<percentage>"; initial-value: 5%; inherits: false; }
@property --cb-shine { syntax: "<color>"; initial-value: white; inherits: false; }
.chat-box {
  --cb-accent: #ff5f00;
  --cb-accent-soft: #ff9253;
  --cb-anim: cb-angle linear infinite;
  --cb-dur: 3s;
  --cb-ease: .8s cubic-bezier(.25, 1, .5, 1);
  position: relative; isolation: isolate; overflow: hidden;
  border-color: transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    conic-gradient(from calc(var(--cb-angle) - var(--cb-offset)),
      transparent,
      var(--cb-accent) var(--cb-percent),
      var(--cb-shine) calc(var(--cb-percent) * 2),
      var(--cb-accent) calc(var(--cb-percent) * 3),
      transparent calc(var(--cb-percent) * 4)) border-box;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-lg), var(--shadow-sm);
  transition: border-radius .3s ease, padding .3s ease, --cb-offset var(--cb-ease), --cb-percent var(--cb-ease), --cb-shine var(--cb-ease);
}
.chat-box::before, .chat-box::after, .chat-glow {
  content: ''; pointer-events: none; position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: -1;
}
.chat-box::before { /* speckle: fine dots, lit near the arc */
  width: calc(100% - 6px); height: calc(100% - 6px); border-radius: inherit;
  background: radial-gradient(circle at 2px 2px, #fff .5px, transparent 0) padding-box;
  background-size: 4px 4px; background-repeat: space;
  -webkit-mask-image: conic-gradient(from calc(var(--cb-angle) + 45deg), #000, transparent 10% 90%, #000);
  mask-image: conic-gradient(from calc(var(--cb-angle) + 45deg), #000, transparent 10% 90%, #000);
  opacity: .4;
}
.chat-box::after { /* sheen: a soft band of the accent turning slowly */
  --cb-anim: cb-shimmer linear infinite;
  width: 100%; aspect-ratio: 1;
  background: linear-gradient(-50deg, transparent, var(--cb-accent), transparent);
  -webkit-mask-image: radial-gradient(circle at bottom, transparent 40%, #000);
  mask-image: radial-gradient(circle at bottom, transparent 40%, #000);
  opacity: .6;
}
.chat-glow { /* inner glow, shown on hover / while typing */
  width: calc(100% + 1rem); height: calc(100% + 1rem);
  box-shadow: inset 0 -1ex 2rem 4px var(--cb-accent);
  opacity: 0; transition: opacity var(--cb-ease);
  animation: calc(var(--cb-dur) * 1.5) cb-breathe linear infinite;
}
.chat-box, .chat-box::before, .chat-box::after {
  animation: var(--cb-anim) var(--cb-dur), var(--cb-anim) calc(var(--cb-dur) / .4) reverse paused;
  animation-composition: add;
}
.chat-box:is(:hover, :focus-within) { --cb-percent: 20%; --cb-offset: 95deg; --cb-shine: var(--cb-accent-soft); }
.chat-box:is(:hover, :focus-within), .chat-box:is(:hover, :focus-within)::before, .chat-box:is(:hover, :focus-within)::after {
  animation-play-state: running;
}
.chat-box:is(:hover, :focus-within) .chat-glow { opacity: 1; }
@keyframes cb-angle { to { --cb-angle: 360deg; } }
@keyframes cb-shimmer { to { rotate: 360deg; } }
@keyframes cb-breathe { from, to { scale: 1; } 50% { scale: 1.2; } }
.chat-grip {
  flex: none; width: 26px; height: 36px; border: 0; border-radius: 8px;
  display: grid; place-items: center; background: transparent; color: var(--ink-3);
  cursor: grab; touch-action: none;
}
.chat-grip:hover { color: var(--ink); }
.chat.is-dragging .chat-grip { cursor: grabbing; }
.chat-field { flex: 1 1 0; min-width: 0; display: flex; }
.chat-input {
  width: 100%; max-height: 168px; padding: 7px 6px; border: 0; outline: none; resize: none;
  background: transparent; color: var(--ink); font: inherit; font-size: 15px; line-height: 22px;
}
.chat-input::placeholder { color: var(--ink-3); }
.chat-tools { display: flex; align-items: center; gap: 4px; }
.chat.is-expanded .chat-field { flex-basis: calc(100% - 34px); }
.chat.is-expanded .chat-tools { flex: 1 1 100%; padding-left: 26px; }
.chat:not(.is-expanded) .chat-chip, .chat:not(.is-expanded) .chat-tools .spacer { display: none; }
.chat-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink-2); font-size: 13px; font-weight: 500;
}
.chat-chip:hover { background: var(--sunken); color: var(--ink); }
.chat-chip.is-on { background: var(--mint); color: var(--mint-ink); }
.chat-chip span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-icon {
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: transparent; color: var(--ink-2);
}
.chat-icon:hover, .chat-icon.is-on { background: var(--sunken); color: var(--ink); }
.chat-send {
  flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--ink); color: var(--on-ink);
  transition: transform .15s ease;
}
.chat-send:hover { transform: scale(1.06); }

/* voice typing (voice.js): round mic buttons like the send button */
.mic-btn {
  flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; background: var(--ink); color: var(--on-ink);
  transition: transform .15s ease, background-color .15s ease, color .15s ease;
}
.mic-btn[hidden] { display: none; }
.mic-btn:hover { transform: scale(1.06); }
.mic-btn.is-recording { background: var(--danger); color: #fff; animation: mic-pulse 1.2s ease-out infinite; }
.mic-btn.is-busy svg { animation: mic-spin .9s linear infinite; }
@keyframes mic-pulse { from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 55%, transparent); } to { box-shadow: 0 0 0 12px transparent; } }
@keyframes mic-spin { to { rotate: 360deg; } }
/* the mic that follows the text field you are in */
.mic-float { position: fixed; z-index: 65; width: 30px; height: 30px; box-shadow: var(--shadow); }
.mic-float.is-in-dialog { position: absolute; }
.mic-float svg { width: 15px; height: 15px; }
/* chat: an empty box shows just the mic; with text the send button appears and the mic steps back */
.chat:not(.has-text) .chat-mic:not([hidden]) ~ .chat-send { display: none; }
.chat.has-text .chat-mic:not(.is-recording):not(.is-busy) { background: transparent; color: var(--ink-2); }
.chat.has-text .chat-mic:not(.is-recording):not(.is-busy):hover { background: var(--sunken); color: var(--ink); }
.chat-panel {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg);
  animation: fx-fade-in .2s ease both;
}
.chat-panel-head { display: flex; align-items: center; gap: 6px; padding: 10px 10px 6px 18px; }
.chat-title { font-size: 14px; font-weight: 600; }
.chat-log {
  display: flex; flex-direction: column; gap: 12px;
  max-height: min(560px, var(--chat-room, 60vh)); padding: 6px 18px 16px;
  overflow-y: auto; overscroll-behavior: contain;
}
.chat-msg.is-user { align-self: flex-end; max-width: 85%; }
.chat-bubble {
  padding: 9px 14px; border-radius: 18px 18px 6px 18px;
  background: var(--ink); color: var(--on-ink);
  font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat-answer { font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.chat-answer p, .chat-answer ul, .chat-answer ol, .chat-answer pre { margin: 0 0 8px; }
.chat-answer > :last-child { margin-bottom: 0; }
.chat-answer ul, .chat-answer ol { padding-left: 20px; }
.chat-answer code { padding: 1px 5px; border-radius: 6px; background: var(--sunken); font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.chat-answer pre { padding: 10px 12px; border-radius: 10px; background: var(--sunken); overflow-x: auto; }
.chat-answer pre code { padding: 0; background: none; }
.chat-wait { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.chat-wait-label {
  background: linear-gradient(90deg, var(--ink-3) 0%, var(--ink) 50%, var(--ink-3) 100%) 0 0 / 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: chat-shimmer 1.6s linear infinite;
}
@keyframes chat-shimmer { to { background-position: -200% 0; } }
.chat-cite {
  display: inline-flex; align-items: center; gap: 4px; max-width: 230px; height: 22px;
  margin: 0 2px; padding: 0 8px; vertical-align: 1px;
  border: 1px solid transparent; border-radius: 999px; background: var(--mint); color: var(--mint-ink);
  font-size: 12px; font-weight: 500;
}
.chat-cite span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-cite:hover { border-color: var(--mint-ink); }
.chat-error { margin: 6px 0 0; color: var(--danger); font-size: 13.5px; }
.chat-model-menu { min-width: 240px; }
.chat-model-menu .menu-item { gap: 8px; }
.menu-check { width: 16px; display: grid; place-items: center; color: var(--mint-ink); }
.menu-label { flex: 1; }
.menu-meta { color: var(--ink-3); font-size: 12.5px; }
.menu-empty { max-width: 240px; margin: 6px 8px; color: var(--ink-2); font-size: 13.5px; }
.chat-menu-note {
  max-width: 260px; margin: 6px 0 0; padding: 8px 8px 2px; border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 12.5px; line-height: 1.4;
}

/* the book: saved conversations, newest first, loads more while scrolling */
.book-title { margin: 0 0 0 6px; font-size: 18px; font-weight: 600; }
.book-body { display: flex; flex-direction: column; gap: 16px; max-width: 820px; margin: 0 auto; padding-bottom: 24px; }
.book-list { display: flex; flex-direction: column; gap: 16px; }
.book-entry { padding: 18px 22px 20px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.book-entry-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.book-entry-meta { flex: 1; min-width: 0; }
.book-time { display: block; color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.book-entry-title { margin: 2px 0 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.book-msgs { display: flex; flex-direction: column; gap: 12px; }
.book-more { margin: 8px 0 0; color: var(--ink-3); font-size: 14px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .chat, .chat-box, .chat-send { transition: none; }
  .chat-box, .chat-box::before, .chat-box::after, .chat-glow { animation: none !important; }
  .mic-btn.is-recording { animation: none; }
  .chat-box:is(:hover, :focus-within) .chat-glow { opacity: 0; }
  .chat-panel { animation: none; }
  .chat-wait-label { animation: none; color: var(--ink-2); background: none; }
}

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .brand small, .sync-pill span, #new-category .lbl { display: none; }
  .sync-pill { width: 42px; padding: 0; justify-content: center; }
  #new-category { width: 42px; padding: 0; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; row-gap: 8px; }
  .top-search { order: 3; flex: 1 0 100%; margin: 0; height: 38px; }
  .top-search-key { display: none; }
  .board-status { gap: 12px; }
  .board-stats { font-size: 13px; }
  .cat-overlay { padding: 8px; }
  .board { margin: 0 8px 8px; scroll-snap-type: x mandatory; }
  .column, .column.has-width, .col-slot, .col-slot.has-width { flex: 0 0 86vw; max-width: none; scroll-snap-align: start; }
  .col-resizer { display: none; }
  .sheet-head { padding: 12px 14px; }
  .sheet-main { padding: 0 8px 8px; }
  .sheet-paper { padding: 22px 18px 16px; }
  .sheet-title { font-size: 26px; }
  .topbar-actions { gap: 6px; }
  .sheet-head { gap: 4px; }
  .sheet-head > .pill-btn span { display: none; }
  .sheet-head > .pill-btn { padding: 0 9px; }
  .sheet-actions { gap: 0; }
  .trash-title { font-size: 28px; }
}
@media (max-width: 430px) {
  .brand strong { display: none; }
  .round-btn, #new-category { width: 34px; height: 34px; }
  .sync-pill { width: 22px; height: 22px; }
  .topbar-actions { gap: 4px; }
  /* phones: just notes and urgent, on two lines */
  .board-stats { display: grid; font-size: 12px; line-height: 1.3; }
  .board-stats span:nth-child(1), .board-stats span:nth-child(3) { display: none; }
  .board-stats span + span::before { content: none; }
}
