/* Pass 94 polish. Loaded last. 1 no focus outline on fields  2 add-block menu position  3 light, fast sheets  4 page menu look
   5 speak button animation  6 speed: no big blurs, paused when hidden, long lists skip off-screen work */

/* 1. Fields never draw a coloured outline or ring. The border stays as it is. */
:is(input,textarea,select,[contenteditable]):is(:focus,:focus-visible),
.qc .qc-field :is(textarea,input):focus, .auth .auth-field input[type]:focus, .srch .srch-field input[type=search]:focus,
.sx-search:focus, .sx input.sx-search:focus, .pl-input:focus, .ai-bar textarea:focus, textarea.sheet-title:focus, .cell:focus, .dbc-in:focus {
  outline: 0 !important; box-shadow: none !important; border-color: var(--rule) !important;
}
.nc-bar:focus-within, .pl-search:focus-within, .ai-bar.nc-bar:focus-within { outline: 0 !important; border-color: var(--rule) !important; box-shadow: 0 6px 24px -10px rgba(15,24,20,.18) !important; }
.auth .auth-field input[type]:focus { border-color: rgba(255,255,255,.28) !important; }

/* 2. The add-block menu opens above its button (it was moved up twice, so it slid under the top bar) and scrolls inside itself. */
.fab .menu-pop { transform: none; margin-bottom: 0; bottom: calc(100% + 56px); right: 0; max-height: min(56dvh, calc(100dvh - 17rem)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.fab .menu-pop::-webkit-scrollbar { display: none; }
.fab .bm { max-height: none; overflow: visible; }

/* 3. Sheets and menus: solid surface, no blur behind them, one short slide. This is what made the drawers lag. */
.ui-dlg, .menu-pop, dialog.qc, dialog.dlg { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: var(--sheet) !important; contain: layout paint style; }
.ui-dlg::backdrop, dialog::backdrop { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: rgba(12,20,15,.42); animation: pFade .16s ease-out; }
.ui-dlg[open], dialog.qc[open] { animation: pUp .22s cubic-bezier(.2,.8,.2,1) both; will-change: transform, opacity; }
.ui-dlg.closing { animation: pDown .14s ease-in forwards; }
.ui-item, .ui-cancel, .qc-tab { transition: none; }
@keyframes pUp { from { opacity: 0; transform: translate3d(0,28px,0); } }
@keyframes pDown { to { opacity: 0; transform: translate3d(0,40px,0); } }
@keyframes pFade { from { opacity: 0; } }
@media (min-width: 40.01rem) { @keyframes pUp { from { opacity: 0; transform: translate3d(0,8px,0) scale(.985); } } }

/* 4. Page menu sheet: icon tiles, quiet separators, a title that stays put, a fade where the list continues. */
.sheet-body { gap: .15rem; }
.ui-sheet-head { position: sticky; top: 0; z-index: 2; background: var(--sheet); padding: .35rem .6rem .7rem; }
.ui-sheet-head strong { font: 600 1.15rem/1.25 var(--sans); letter-spacing: -.02em; }
.ui-item { min-height: 52px; gap: .85rem; padding: 0 .55rem; border-radius: 16px; }
.ui-item > svg { flex: none; box-sizing: border-box; width: 36px; height: 36px; padding: 8px; border-radius: 12px; color: var(--indigo); background: color-mix(in srgb, var(--indigo) 9%, transparent); }
.ui-item.danger > svg { color: var(--margin); background: color-mix(in srgb, var(--margin) 10%, transparent); }
.ui-item .ui-val { margin-left: auto; color: var(--soft); font-size: 1.1rem; }
.ui-sep { margin: .35rem .9rem; border-top-color: color-mix(in srgb, var(--ink) 7%, transparent); }
.ui-foot { padding: .4rem .6rem .2rem; }
.pm-fonts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; padding: 0 .3rem .5rem; }
.pm-fonts button { min-height: 4.4rem; border-radius: 16px; border: 1.5px solid var(--rule); background: var(--paper); }
.pm-fonts button[aria-pressed=true] { border-color: var(--indigo); background: color-mix(in srgb, var(--indigo) 9%, var(--sheet)); }
.ui-dlg:has(.sheet-body)::after { content: ""; position: sticky; display: block; bottom: 0; height: 28px; margin-top: -28px; pointer-events: none; background: linear-gradient(transparent, var(--sheet)); }

/* 5. Speak button: while listening it becomes a pill with a pulsing mic, a moving wave and a timer. */
.dk { position: relative; display: inline-flex; align-items: center; gap: .55rem; overflow: hidden; transition: background-color .2s, color .2s, padding .25s; }
.dk-mic { position: relative; display: grid; place-items: center; width: 22px; height: 22px; flex: none; }
.dk-mic::before, .dk-mic::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; background: currentColor; opacity: 0; transform: scale(.6); }
.dk-live { display: none; align-items: center; gap: .55rem; font: 500 .84rem var(--sans); font-variant-numeric: tabular-nums; }
.dk-wave { display: inline-flex; align-items: center; gap: 3px; height: 20px; }
.dk-wave i { width: 3px; height: 100%; border-radius: 3px; background: currentColor; transform: scaleY(.25); transform-origin: center; }
.dk.rec-on { padding-inline: .95rem 1.1rem; background: color-mix(in srgb, var(--margin) 10%, var(--sheet)) !important; color: var(--margin) !important; border-color: color-mix(in srgb, var(--margin) 45%, transparent) !important; }
.dk.rec-on .dk-live { display: inline-flex; }
.dk.rec-on .dk-idle { display: none; }
.dk.rec-on .dk-mic::before { animation: dkRing 1.8s ease-out infinite; }
.dk.rec-on .dk-mic::after { animation: dkRing 1.8s ease-out .6s infinite; }
.dk.rec-on .dk-wave i { animation: dkBar .9s ease-in-out infinite; animation-delay: calc(var(--i) * -.13s); }
.dk.rec-on.hear .dk-wave i { animation-duration: .5s; }
@keyframes dkRing { 0% { opacity: .35; transform: scale(.6); } 100% { opacity: 0; transform: scale(2.1); } }
@keyframes dkBar { 0%, 100% { transform: scaleY(.25); } 50% { transform: scaleY(1); } }

/* 6. Speed */
:root { --lg-blur: 14px; --lg-sat: 1.25; --lg-bright: 1; }
.aurora i, .app-aurora i { animation: none !important; will-change: auto; }
:root[data-hidden] *, :root[data-hidden] *::before, :root[data-hidden] *::after { animation-play-state: paused !important; }
:is(.nb, .clip, .prow, .hm-card, .tcard, .pc-row) { content-visibility: auto; contain-intrinsic-size: auto 84px; }
img, video { content-visibility: auto; }
@media (prefers-reduced-motion: reduce) { .dk * { animation: none !important; } }

/* ===== Side bar as a page tree (Notion style) + drawer scrolling =====
   Scrolling: the drawer is the ONLY scroller. The lists inside it no longer scroll on their own (they used to, with a max-height,
   which trapped a swipe that started on them), the page behind is locked while the drawer is open, and the header stays put. */
.shell .side-sub, .shell .side-kids { max-height: none; overflow: visible; overscroll-behavior: auto; }
.shell .side {
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; scroll-padding: 4.5rem 0 6rem;
}
.shell .side::-webkit-scrollbar { display: none; }
.shell .side > * { flex: none; }
@media (max-width: 59.99rem) {
  .shell .side { padding-bottom: calc(1.4rem + env(safe-area-inset-bottom, 0px)); }
  .shell .side-head { position: sticky; top: 0; z-index: 3; background: color-mix(in srgb, var(--sheet) 88%, transparent); margin-top: -.35rem; }
}
html:has(body.drawer-open), body.drawer-open { overflow: hidden; overscroll-behavior: none; }
.scrim { touch-action: none; }

/* Rows */
.shell .side-sub { list-style: none; margin: 1px 0 6px; padding: 0; border: 0; display: flex; flex-direction: column; gap: 1px; }
.shell .side-kids { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.shell .side-kids[hidden], .shell .side-sub[hidden] { display: none; }
.shell .side-li { margin: 0; min-width: 0; }
.shell .side-trow {
  --tog: 24px;
  position: relative; display: flex; align-items: center; gap: 2px; min-height: 36px; border-radius: 9px;
  padding-left: calc(var(--d, 1) * 12px - 6px); padding-right: 2px; transition: background-color .12s;
}
.shell .side-trow:hover { background: var(--hover); }
.shell .side-trow:has(> a.active) { background: color-mix(in srgb, var(--indigo) 12%, transparent); }
.shell .side-trow > a.side-item {
  flex: 1; min-width: 0; min-height: 36px; padding: .15rem .35rem .15rem .15rem; gap: .5rem; border-radius: 8px;
  font-size: .9rem; font-weight: 400; color: color-mix(in srgb, var(--ink) 82%, var(--soft)); background: none; box-shadow: none;
}
.shell .side-trow > a.side-item:hover { background: none; color: var(--ink); }
.shell .side-trow > a.side-item.active { background: none; color: var(--ink); font-weight: 550; box-shadow: none; }
.shell .side-trow > a.side-item.active::before { display: none; }
.shell .side-ic { display: grid; place-items: center; flex: none; width: 20px; height: 20px; color: var(--soft); }
.shell .side-ic svg { width: 16px; height: 16px; }
.shell a.side-item.active .side-ic { color: var(--indigo); }
.shell .side-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The left chevron: points right when closed, down when open */
.shell .side-tog {
  flex: none; display: grid; place-items: center; width: var(--tog); height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: var(--soft); cursor: pointer;
}
.shell .side-tog.ph { pointer-events: none; }
.shell .side-tog svg { width: 14px; height: 14px; transform: rotate(-90deg); transition: transform .16s var(--ease, ease); }
.shell .side-li.open > .side-trow > .side-tog svg { transform: none; }
.shell .side-tog:not(.ph):hover { background: var(--hover2, var(--hover)); color: var(--ink); }

/* The + on a row: on hover with a mouse, always there (quiet) on a phone */
.shell .side-add {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 7px;
  background: none; color: var(--soft); opacity: 0; transition: opacity .12s, background-color .12s;
}
.shell .side-add:hover { background: var(--hover2, var(--hover)); color: var(--ink); }
.shell .side-trow:hover > .side-add, .shell .side-trow:focus-within > .side-add, .shell .side-add:focus-visible { opacity: 1; }
@media (pointer: coarse) {
  .shell .side-add { opacity: .55; width: 32px; height: 32px; }
  .shell .side-tog { width: 28px; height: 32px; }
  .shell .side-trow { min-height: 40px; }
  .shell .side-trow > a.side-item { min-height: 40px; }
}

/* Quiet rows: nothing inside, show more, add a page */
.shell .side-empty { padding: .3rem .5rem .3rem calc(var(--d, 1) * 12px + 24px + 6px); font-size: .82rem; color: var(--soft); opacity: .75; }
.shell .side-addrow button, .shell .side-more button, .shell .side-create button {
  display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 34px; border: 0; border-radius: 8px; background: none;
  color: var(--soft); font: 400 .86rem var(--sans); text-align: left; cursor: pointer;
}
.shell .side-addrow button { padding: .2rem .5rem .2rem calc(var(--d, 1) * 12px + 24px + 6px); }
.shell .side-more button, .shell .side-create button { padding: .2rem .5rem .2rem calc(24px + 12px - 6px + 2px); }
.shell .side-create button { border: 0; font-weight: 450; color: color-mix(in srgb, var(--indigo) 85%, var(--soft)); }
.shell .side-addrow button:hover, .shell .side-more button:hover, .shell .side-create button:hover { background: var(--hover); color: var(--ink); }
@media (prefers-reduced-motion: reduce) { .shell .side-tog svg, .shell .side-add, .shell .side-trow { transition: none; } }

/* ===== Listen button: playing icon + a ring on the border that fills as the page is read ===== */
@property --p { syntax: "<number>"; inherits: true; initial-value: 0; }
.listen-btn { position: relative; transition: --p .7s linear, background-color .15s, border-color .15s, color .15s; }
.listen-btn .lb-i { display: inline-grid; place-items: center; width: 16px; height: 16px; }
.listen-btn .lb-t { min-width: 3.6em; text-align: left; }
.listen-btn::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 2px; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: conic-gradient(from 0deg, var(--indigo) calc(var(--p) * 1%), transparent 0);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}
.listen-btn:not([data-state="idle"])::after { opacity: 1; }
.listen-btn[data-state="playing"] { color: var(--indigo); background: color-mix(in srgb, var(--indigo) 9%, transparent); }
.listen-btn[data-state="paused"] { color: var(--soft); }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; width: 14px; height: 14px; }
.eq i { flex: 1; height: 35%; border-radius: 1px; background: currentColor; animation: eq .9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -.3s; } .eq i:nth-child(3) { animation-delay: -.6s; }
@keyframes eq { 0%, 100% { height: 25%; } 50% { height: 100%; } }
@media (prefers-reduced-motion: reduce) { .eq i { animation: none; height: 70%; } .listen-btn { transition: none; } }

/* The two rows that scroll sideways keep their own swipes */
.etool, .sheet-tools { overscroll-behavior-x: contain; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }

/* ===== Skeleton loaders ===== */
:root { --sk-base: color-mix(in srgb, var(--ink) 8%, transparent); --sk-hi: rgba(255, 255, 255, .65); }
:root[data-theme="dark"] { --sk-hi: rgba(255, 255, 255, .07); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sk-hi: rgba(255, 255, 255, .07); } }
.skel { display: flex; flex-direction: column; gap: .9rem; padding: .4rem 0; max-width: 100%; }
.skel.on { animation: skIn .25s ease both; }
@keyframes skIn { from { opacity: 0; } }
.sk { position: relative; display: block; overflow: hidden; flex: none; border-radius: 8px; background: var(--sk-base); animation: none; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(100deg, transparent 20%, var(--sk-hi) 50%, transparent 80%); }
.skel.on .sk::after { animation: skSweep 1.5s ease-in-out infinite; will-change: transform; }
@keyframes skSweep { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skel.on .sk::after { animation: none; } .skel.on { animation: none; } }
.sk.line { height: .95rem; border-radius: 6px; }
.sk.title { height: 2rem; margin-bottom: .3rem; }
.sk.tall { height: 2.8rem; border-radius: 10px; }
.sk.pill { height: 34px; border-radius: 999px; }
.sk.bar { height: 56px; width: 100%; border-radius: 14px; }
.sk.dot { width: 2.6rem; height: 2.6rem; border-radius: 50%; }
.sk.box { width: 1.4rem; height: 1.4rem; border-radius: 6px; }
.sk.ic { width: 18px; height: 18px; border-radius: 5px; }
.sk-row { display: flex; align-items: center; gap: .8rem; }
.sk-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .6rem; margin-bottom: .9rem; }
.sk-row .sk-col { margin: 0; gap: .5rem; }
.sk-doc, .sk-pagew { display: flex; flex-direction: column; }
.sk-doc { gap: .5rem; min-height: 40dvh; padding: 1.2rem; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sheet); }
.sk-pagew { gap: .9rem; }
.sk-pills { display: flex; gap: .5rem; overflow: hidden; }
.sk-pager { display: flex; justify-content: center; margin-top: 1rem; }
.sk-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .8rem; }
.sk-cards.two { grid-template-columns: repeat(2, 1fr); }
.sk-card { display: flex; flex-direction: column; gap: .6rem; padding: .9rem; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sheet); }
.sk-bub { display: flex; flex-direction: column; gap: .5rem; width: 82%; padding: .8rem; border-radius: 16px; background: var(--sheet); border: 1px solid var(--rule); }
.sk-bub.me { align-self: flex-end; width: 62%; }
.side-skel { display: flex; align-items: center; gap: .6rem; min-height: 34px; padding: 0 .6rem 0 calc(24px + 12px); list-style: none; }
.side-skel .sk.line { flex: none; height: .75rem; }

/* ===== Drawer motion: smooth, no bounce ===== */
@media (max-width: 59.99rem) {
  .shell .side { transition: transform .24s cubic-bezier(.4, 0, .6, 1), visibility 0s linear .24s; will-change: transform; }   /* closing: quick and even */
  .shell .side.open { transition: transform .32s cubic-bezier(.2, .9, .25, 1); }                                              /* opening: settles without overshoot */
  .scrim { transition: opacity .28s ease; -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(14, 26, 19, .36); }   /* a blur behind a moving panel is redrawn every frame */
}

/* Sheets: a roomier handle to grab, and no page pull behind them */
@media (max-width: 47.99rem) { .ui-grab { height: 2.2rem; } .ui-grab::after { top: .85rem; } }
.ui-dlg { overscroll-behavior: contain; }
