/* Margin: everything on top of the AntonOS styles in style.css.
   Layout idea: AntonOS's centred, text-only screens, plus one bold element (the note editor's
   Freeform-style glass pen tray). Tokens below; settings overwrite them on <html>. */
:root {
  --font: "Segoe UI", "Open Sans", system-ui, sans-serif;
  --glass-blur: 22px;
  --glass-tint: 0.28;
  --glass-color: #ffffff;
  --glass-sat: 1.8;
  --glass-edge: 0.55;
  --glass-shadow: 0.14;
  --glass-radius: 26px;
  --blob-alpha: 0.55;
  --part-fill: 0.06;
  --page-shadow: 0.12;
  --page-radius: 3px;
  --thumb: 170px;
  --tray-scale: 1;
  --desk: color-mix(in srgb, var(--bg), var(--ink) 7%);
  --pen-body: #fbfbfd;
  --pen-edge: rgba(0, 0, 0, 0.2);
  --soft-fill: color-mix(in srgb, var(--ink) calc(var(--part-fill) * 100%), transparent);
  color-scheme: light;
}

html {
  /* No double-tap zoom on iPad (the note editor handles its own zooming). */
  touch-action: manipulation;
}

body {
  background: var(--bg);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
[contenteditable="true"] {
  -webkit-user-select: text;
}

body.dark-ui {
  --pen-body: #ececf1;
  --pen-edge: rgba(0, 0, 0, 0.35);
}

input,
textarea,
button {
  -webkit-tap-highlight-color: transparent;
}

/* ---------- Liquid glass ---------- */

/* Colour blobs behind glass, so the frosting has something to blur. */
#backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  display: none;
  overflow: hidden;
  pointer-events: none;
}
.any-glass.backdrop-blobs #backdrop,
.any-glass.backdrop-aurora #backdrop,
.any-glass.backdrop-mesh #backdrop {
  display: block;
}
.in-editor #backdrop {
  display: none !important;
}
#backdrop span {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: var(--blob-alpha);
}
#backdrop span:nth-child(1) { left: -8vmax; top: -10vmax; background: color-mix(in srgb, var(--accent) 70%, #ffd6a5); }
#backdrop span:nth-child(2) { right: -12vmax; top: 10vmax; background: color-mix(in srgb, var(--accent) 35%, #a0c4ff); }
#backdrop span:nth-child(3) { left: 20vmax; bottom: -18vmax; background: color-mix(in srgb, var(--accent) 30%, #caffbf); }
#backdrop span:nth-child(4) { right: 18vmax; bottom: -6vmax; width: 30vmax; height: 30vmax; background: color-mix(in srgb, var(--accent) 40%, #ffc6ff); }
.backdrop-aurora #backdrop span { width: 90vmax; height: 26vmax; border-radius: 40%; filter: blur(70px); }
.backdrop-aurora #backdrop span:nth-child(1) { left: -20vmax; top: 4vh; transform: rotate(-12deg); }
.backdrop-aurora #backdrop span:nth-child(2) { right: -30vmax; top: 34vh; transform: rotate(8deg); }
.backdrop-aurora #backdrop span:nth-child(3) { left: -10vmax; bottom: 4vh; transform: rotate(-4deg); }
.backdrop-mesh #backdrop span { filter: blur(90px); width: 60vmax; height: 60vmax; }
.blob-motion #backdrop span { animation: blob 26s ease-in-out infinite alternate; }
.blob-motion #backdrop span:nth-child(2) { animation-duration: 32s; animation-delay: -8s; }
.blob-motion #backdrop span:nth-child(3) { animation-duration: 38s; animation-delay: -14s; }
.blob-motion #backdrop span:nth-child(4) { animation-duration: 30s; animation-delay: -4s; }
@keyframes blob {
  50% { translate: 6vmax -4vmax; scale: 1.12; }
  100% { translate: -4vmax 5vmax; scale: 0.94; }
}

/* The glass itself: frosted, tinted, with a bright edge and a soft shine. */
:root[data-toolbar-look="glass"] .tb-glass,
:root[data-look-modal="glass"] #modal .modal-card,
:root[data-look-home="glass"] .home .menu,
:root[data-look-home="glass"] .home .widget,
:root[data-look-settings="glass"] [data-area="settings"] > .side,
:root[data-look-settings="glass"] [data-area="settings"] > .panel,
:root[data-look-library="glass"] [data-area="library"] > .side,
:root[data-look-library="glass"] [data-area="library"] > .panel,
:root[data-look-ai="glass"] [data-area="ai"] > .side,
:root[data-look-ai="glass"] [data-area="ai"] > .panel,
:root[data-look-ai="glass"] .fc-face {
  position: relative;
  border: 1px solid color-mix(in srgb, #ffffff calc(var(--glass-edge) * 100%), transparent);
  border-radius: var(--glass-radius);
  background:
    linear-gradient(150deg,
      color-mix(in srgb, var(--glass-color) calc(var(--glass-tint) * 100% + 10%), transparent),
      color-mix(in srgb, var(--glass-color) calc(var(--glass-tint) * 70%), transparent));
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, #ffffff calc(var(--glass-edge) * 100%), transparent),
    inset 0 -1px 1px rgba(0, 0, 0, 0.04),
    0 2px 6px rgba(0, 0, 0, calc(var(--glass-shadow) * 0.5)),
    0 14px 44px rgba(0, 0, 0, var(--glass-shadow));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
}

:root[data-toolbar-look="glass"] .tb-glass::before,
:root[data-look-modal="glass"] #modal .modal-card::before,
:root[data-look-home="glass"] .home .menu::before,
:root[data-look-settings="glass"] [data-area="settings"] > .side::before,
:root[data-look-library="glass"] [data-area="library"] > .side::before,
:root[data-look-ai="glass"] [data-area="ai"] > .side::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.08) 26%, transparent 52%, rgba(255, 255, 255, 0.1) 100%);
  opacity: 0.7;
  pointer-events: none;
}
.no-shine .tb-glass::before,
.no-shine #modal .modal-card::before,
.no-shine .home .menu::before,
.no-shine .side::before {
  display: none;
}
.dark-ui .tb-glass::before,
.dark-ui #modal .modal-card::before {
  opacity: 0.25;
}

/* Part minimal: soft, quiet panels. */
:root[data-toolbar-look="part"] .tb-glass,
:root[data-look-modal="part"] #modal .modal-card,
:root[data-look-home="part"] .home .menu,
:root[data-look-settings="part"] [data-area="settings"] > .side,
:root[data-look-settings="part"] [data-area="settings"] > .panel,
:root[data-look-library="part"] [data-area="library"] > .side,
:root[data-look-library="part"] [data-area="library"] > .panel,
:root[data-look-ai="part"] [data-area="ai"] > .side,
:root[data-look-ai="part"] [data-area="ai"] > .panel {
  border-radius: calc(var(--radius) * 1.4);
  background: color-mix(in srgb, var(--bg), var(--ink) calc(var(--part-fill) * 100%));
}
:root[data-toolbar-look="part"] body.part-shadow .tb-glass,
:root[data-look-modal="part"] body.part-shadow #modal .modal-card,
:root[data-look-home="part"] body.part-shadow .home .menu,
:root[data-look-settings="part"] body.part-shadow [data-area="settings"] > *,
:root[data-look-library="part"] body.part-shadow [data-area="library"] > *,
:root[data-look-ai="part"] body.part-shadow [data-area="ai"] > * {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 8px 26px rgba(0, 0, 0, 0.06);
}

/* Panels with a fill get padding and lose the faded scroll edges. */
:root:is([data-look-settings="glass"], [data-look-settings="part"]) [data-area="settings"] > :is(.side, .panel),
:root:is([data-look-library="glass"], [data-look-library="part"]) [data-area="library"] > :is(.side, .panel),
:root:is([data-look-ai="glass"], [data-look-ai="part"]) [data-area="ai"] > :is(.side, .panel) {
  padding: 18px 20px 30px;
  margin-bottom: 24px;
  mask-image: none;
  -webkit-mask-image: none;
}
:root:is([data-look-home="glass"], [data-look-home="part"]) .home .menu {
  padding: 30px 56px;
}
:root[data-look-home="glass"] .home .widget {
  padding: 14px 18px;
  border-radius: calc(var(--glass-radius) * 0.8);
}

/* Minimal toolbar: flat, with a hairline edge. */
:root[data-toolbar-look="minimal"] .tb-glass {
  border: 1px solid var(--faint);
  border-radius: calc(var(--radius) * 1.3);
  background: var(--bg);
}

/* Glass pop-ups sit on a lighter veil. */
:root[data-look-modal="glass"] #modal,
:root[data-look-modal="part"] #modal {
  background: color-mix(in srgb, var(--bg) 45%, transparent);
}
:root[data-look-modal="glass"] #modal .modal-card,
:root[data-look-modal="part"] #modal .modal-card {
  max-height: 92vh;
  margin: 16px;
  padding: 34px 48px;
}
#modal .modal-card {
  max-width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
#modal .modal-card.wide {
  max-width: min(980px, calc(100vw - 32px));
}

/* ---------- Loading and passcode screens ---------- */

.view-splash,
.view-lock,
.view-editor {
  padding: 0;
}
.splash-screen,
.lock-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.splash-screen .title {
  font-size: 66px;
}
.splash-small .splash-screen .title {
  font-size: 44px;
}
.splash-large .splash-screen .title {
  font-size: 100px;
}
.lock-screen .lock-inner {
  gap: 12px;
}
.lock-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 4vh;
}
.lock-time .t {
  font-size: calc(var(--clock-size) * 0.9 * var(--text-scale));
  font-weight: var(--title-weight);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.lock-time .d {
  opacity: var(--muted);
}
@media (max-height: 660px) {
  .lock-time { display: none; }
}

/* ---------- Home ---------- */

.mini-notes {
  display: flex;
  gap: 12px;
}
.mini-note {
  display: grid;
  place-items: center;
  width: 54px;
  height: 70px;
  overflow: hidden;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: transform 0.35s var(--spring);
}
.mini-note img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.mini-note .icon {
  width: 26px;
  height: 26px;
  color: #8a8a8a;
}
.mini-note:hover {
  transform: translateY(-5px) rotate(-4deg) scale(1.08);
}
.cal-written {
  text-decoration: underline 2px var(--accent);
  text-underline-offset: 3px;
}

/* ---------- Take A Note (the notes list) ---------- */

.new-note {
  margin: 4px 0 22px;
  font-size: calc(30px * var(--text-scale));
  font-weight: var(--menu-weight);
}
.danger {
  color: #c0392b;
}
.dark-ui .danger {
  color: #ff8a80;
}

.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--thumb), 1fr));
  gap: 30px 22px;
}
.note-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.card-open {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.card-pic {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / var(--ratio);
  overflow: hidden;
  border-radius: max(4px, calc(var(--radius) * 0.45));
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 6px 18px rgba(0, 0, 0, 0.07);
  transition: transform 0.45s var(--spring), box-shadow 0.3s;
}
.cards-soft .card-pic {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 14px 34px rgba(0, 0, 0, 0.14);
}
.cards-tinted .card-pic {
  outline: 6px solid color-mix(in srgb, var(--accent) 14%, transparent);
}
.card-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}
.card-blank {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #9a9a9a;
}
.card-blank .icon {
  width: 34%;
  height: 34%;
  stroke-width: 1.2;
}
.card-star {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #e0a100;
}
.card-star .icon {
  fill: currentColor;
  width: 18px;
  height: 18px;
}
.card-open:hover .card-pic {
  transform: translateY(-6px) rotate(-1.5deg);
}
.card-title {
  overflow: hidden;
  font-size: calc(19px * var(--text-scale));
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: calc(13px * var(--text-scale));
  opacity: var(--muted);
}
.no-dates .card-meta {
  font-size: 0;
}
.no-dates .card-more {
  font-size: calc(13px * var(--text-scale));
}
.card-more {
  padding: 2px 4px;
  letter-spacing: 0.1em;
}
.hide-previews .card-pic img,
.hide-previews .mini-note img {
  display: none;
}

/* List layout. */
.library-list .note-grid {
  grid-template-columns: 1fr;
  gap: 6px;
}
.library-list .note-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.library-list .card-open {
  flex-direction: row;
  align-items: center;
  gap: 16px;
}
.library-list .card-pic {
  width: 46px;
  flex-shrink: 0;
}
.library-list .card-star {
  display: none;
}

/* ---------- Paper previews (paper picker) ---------- */

.pop-papers,
.pp-papers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pp-papers {
  justify-content: center;
}
.pop-paper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 78px;
  padding: 6px 2px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: calc(12px * var(--text-scale));
  line-height: 1.15;
  text-align: center;
  cursor: var(--cursor);
  transition: transform 0.3s var(--spring);
}
.pop-paper:hover {
  transform: translateY(-3px);
}
.pop-paper.on {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  font-weight: 600;
}
.paper-mini {
  --l: rgba(120, 160, 205, 0.55);
  width: 38px;
  height: 52px;
  border-radius: 3px;
  background-color: #fdfbf6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.08);
}
.paper-ruled { background-image: repeating-linear-gradient(to bottom, transparent 0 6px, var(--l) 6px 7px); }
.paper-class {
  background-image: linear-gradient(to right, transparent 8px, rgba(224, 102, 102, 0.8) 8px 9px, transparent 9px),
    repeating-linear-gradient(to bottom, transparent 0 6px, var(--l) 6px 7px);
}
.paper-dotted { background-image: radial-gradient(rgba(0, 0, 0, 0.35) 0.7px, transparent 1.1px); background-size: 5px 5px; }
.paper-grid {
  background-image: linear-gradient(var(--l) 1px, transparent 1px), linear-gradient(90deg, var(--l) 1px, transparent 1px);
  background-size: 6px 6px;
}
.paper-graph {
  background-image: linear-gradient(var(--l) 1px, transparent 1px), linear-gradient(90deg, var(--l) 1px, transparent 1px),
    linear-gradient(rgba(120, 160, 205, 0.25) 1px, transparent 1px), linear-gradient(90deg, rgba(120, 160, 205, 0.25) 1px, transparent 1px);
  background-size: 12px 12px, 12px 12px, 3px 3px, 3px 3px;
}
.paper-cornell {
  background-image: linear-gradient(to right, transparent 11px, var(--l) 11px 12px, transparent 12px),
    linear-gradient(to bottom, transparent 40px, var(--l) 40px 41px, transparent 41px),
    repeating-linear-gradient(to bottom, transparent 0 6px, rgba(120, 160, 205, 0.35) 6px 7px);
  background-size: 100% 40px, 100% 100%, 100% 40px;
  background-repeat: no-repeat;
}
.paper-music { background-image: repeating-linear-gradient(to bottom, transparent 0 4px, var(--l) 4px 5px, transparent 5px 6px, var(--l) 6px 7px, transparent 7px 8px, var(--l) 8px 9px, transparent 9px 16px); }
.paper-isometric {
  background-image: radial-gradient(rgba(0, 0, 0, 0.35) 0.7px, transparent 1.1px), radial-gradient(rgba(0, 0, 0, 0.35) 0.7px, transparent 1.1px);
  background-size: 6px 5px;
  background-position: 0 0, 3px 2.5px;
}

.paper-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  max-width: 860px;
}
.pp-colours {
  justify-content: center;
}
.pp-sizes {
  justify-content: center;
}
.pp-orient {
  display: flex;
  gap: 28px;
}

/* ---------- Pop-up parts (editor panels and dialogs) ---------- */

.pop-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pop-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pop-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: inherit;
  font: inherit;
  font-size: calc(14px * var(--text-scale));
  cursor: var(--cursor);
  transition: transform 0.3s var(--spring), background-color 0.2s;
}
.pop-chip:hover {
  transform: scale(1.05);
}
.pop-chip.on {
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
}
.chip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}
.pop-option {
  font-size: calc(18px * var(--text-scale));
  font-weight: 600;
  opacity: 0.5;
}
.pop-option.on {
  opacity: 1;
}
.pop-option.on .label {
  text-decoration: underline 2px var(--accent);
  text-underline-offset: 6px;
}
.modal-input {
  width: min(520px, 80vw);
  padding: 6px;
  border: 0;
  border-bottom: 2px solid var(--faint);
  outline: 0;
  background: transparent;
  font-size: calc(26px * var(--text-scale));
  text-align: center;
}
.modal-input:focus {
  border-bottom-color: var(--accent);
}
.modal-area {
  font-size: calc(20px * var(--text-scale));
  text-align: left;
  resize: vertical;
}
.grid-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border-radius: 50%;
  vertical-align: -1px;
}

/* ---------- The note editor ---------- */

.ed {
  position: absolute;
  inset: 0;
}
.ed-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--desk);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.ed-viewport[data-active-tool="pen"],
.ed-viewport[data-active-tool="shape"],
.ed-viewport[data-active-tool="eraser"],
.ed-viewport[data-active-tool="lasso"] {
  cursor: crosshair;
}
.ed-viewport[data-active-tool="hand"] {
  cursor: grab;
}
/* The pages and drawing canvases turn together around the middle of the screen. */
.ed-spin {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
}
.ed-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}
/* The angle while the page is turned: tap it to straighten. */
.ed-rot {
  position: absolute;
  left: max(22px, env(safe-area-inset-left, 0px));
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px 7px 10px;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font: inherit;
  font-size: calc(14px * var(--text-scale));
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  animation: ed-rot-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ed-rot[hidden] {
  display: none;
}
.ed-rot .icon {
  width: 16px;
  height: 16px;
}
.tray-bottom .ed-rot {
  bottom: calc(106px + env(safe-area-inset-bottom, 0px));
}
@keyframes ed-rot-in {
  from {
    opacity: 0;
    transform: scale(0.7);
  }
}
.ed-page {
  position: absolute;
  overflow: hidden;
  border-radius: var(--page-radius);
}
.page-shadow .ed-page {
  box-shadow: 0 1px 2px rgba(0, 0, 0, calc(var(--page-shadow) * 1.1)), 0 8px 26px rgba(0, 0, 0, var(--page-shadow));
}
.ed-canvas,
.ed-detail {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}
.ed-texts {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.ed-text {
  position: absolute;
  min-height: 1.35em;
  padding: 2px;
  outline: none;
  color: #1f2a44;
  font-style: normal;
  letter-spacing: normal;
  word-spacing: normal;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  -webkit-user-select: text;
  user-select: text;
  text-shadow: none;
}
.dark-paper .ed-text {
  color: #f5f5f0;
}
.tool-text .ed-text {
  pointer-events: auto;
  border-radius: 4px;
  outline: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  cursor: text;
}
.ed-text.editing {
  pointer-events: auto;
  border-radius: 4px;
  outline: 1.5px solid var(--accent);
  background: color-mix(in srgb, #ffffff 30%, transparent);
}
.ed-text.selected {
  outline: 1.5px dashed var(--accent);
}
.ed-live {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ed-loading {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: var(--desk);
}
.ed-loading .loading {
  font-size: calc(15px * var(--text-scale));
}

/* Top bar. */
.ed-top {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 6;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.3s;
}
.ed-top-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 1180px;
  min-height: 56px;
  padding: 6px 10px 6px 18px;
  pointer-events: auto;
  transition: transform 0.45s var(--spring);
}
.ed-top .back {
  position: static;
  flex-shrink: 0;
  font-size: calc(22px * var(--text-scale));
}
.ed-title {
  flex: 1;
  min-width: 60px;
  padding: 4px 6px;
  border: 0;
  border-radius: 8px;
  outline: 0;
  background: transparent;
  font-size: calc(20px * var(--text-scale));
  font-weight: 600;
  text-overflow: ellipsis;
}
.ed-title:focus {
  background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.ed-sync {
  display: inline-flex;
  opacity: 0.45;
}
.ed-sync .icon {
  width: 18px;
  height: 18px;
}
.ed-sync.sync-syncing,
.ed-sync.busy {
  animation: pulse 1.2s ease-in-out infinite;
}
.ed-sync.sync-error {
  color: #c0392b;
  opacity: 0.8;
}
@keyframes pulse {
  50% { opacity: 0.15; }
}
.ed-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ed-gap {
  width: 10px;
  flex-shrink: 0;
}
.ibtn {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  background: none;
  color: inherit;
  cursor: var(--cursor);
  transition: transform 0.35s var(--spring), background-color 0.2s;
}
.ibtn .icon {
  width: 21px;
  height: 21px;
}
.ibtn:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}
.ibtn:active {
  transform: scale(0.86);
}
.ibtn[disabled] {
  opacity: 0.28;
  pointer-events: none;
}
/* The top bar slides up out of the way; a little handle pulls it back down. */
.ed-top-inner {
  transition: transform 0.45s var(--spring), opacity 0.3s ease;
}
.ed-top.tucked .ed-top-inner {
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(-100% - 24px)) scale(0.96);
}
.ed-top-handle {
  position: absolute;
  top: -4px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 26px;
  padding: 0;
  border-radius: 999px;
  color: inherit;
  opacity: 0;
  pointer-events: none;
  cursor: var(--cursor);
  transform: translate(-50%, -140%);
  transition: transform 0.5s var(--spring), opacity 0.3s ease;
}
.ed-top-handle .icon {
  width: 18px;
  height: 18px;
}
.ed-top.tucked .ed-top-handle {
  opacity: 0.9;
  pointer-events: auto;
  transform: translate(-50%, 0);
  transition-delay: 0.15s;
}
.ed-top-handle:active {
  transform: translate(-50%, 4px) scale(0.92);
}
:root[data-toolbar-look="minimal"] .ed-top-handle {
  border: 1px solid var(--faint);
  background: var(--bg);
}

/* With the bar tucked away, a tray at the top moves up into its place. */
.ed-tray {
  transition: top 0.5s var(--spring), bottom 0.5s var(--spring), opacity 0.3s;
}
.tray-top .top-tucked .ed-tray {
  top: calc(26px + env(safe-area-inset-top, 0px));
}

/* The pen tray. Pens stand in it like a pen holder; the picked one pops up. */
.ed-tray {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 6;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.3s;
}
.tray-inner {
  display: flex;
  align-items: flex-end;
  max-width: calc((100vw - 24px) / var(--tray-scale));
  height: 82px;
  padding: 0 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  pointer-events: auto;
  transform: scale(var(--tray-scale));
  transform-origin: bottom center;
}
.tray-inner::-webkit-scrollbar {
  display: none;
}
.tray-pens {
  display: flex;
  flex-shrink: 0;
  align-items: flex-end;
  height: 100%;
}
.tray-pen {
  position: relative;
  display: flex;
  flex-shrink: 0;
  align-items: flex-end;
  justify-content: center;
  width: 36px;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: var(--cursor);
}
.tray-pen > svg {
  width: 30px;
  height: 90px;
  transform: translateY(34px);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.18));
  transition: transform 0.5s var(--spring);
}
.tray-pen:hover > svg {
  transform: translateY(28px);
}
.tray-pen.on > svg {
  transform: translateY(8px);
}
.tray-pen.on:hover > svg {
  transform: translateY(6px);
}
.no-tool-spring .tray-pen > svg {
  transition: transform 0.15s ease;
}
.tray-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 22px;
  border-radius: 11px;
  transition: transform 0.4s var(--spring), background-color 0.2s;
}
.tray-icon .icon {
  width: 22px;
  height: 22px;
}
.tray-pen.on .tray-icon {
  background: var(--ink);
  color: var(--bg);
  transform: translateY(-4px);
}
.tray-name {
  position: absolute;
  bottom: 2px;
  left: 50%;
  display: none;
  max-width: 64px;
  overflow: hidden;
  font-size: calc(9px * var(--text-scale));
  font-style: normal;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
}
.tray-labels .tray-name {
  display: block;
}
.tray-sep {
  flex-shrink: 0;
  align-self: center;
  width: 1px;
  height: 46px;
  margin: 0 10px;
  background: color-mix(in srgb, var(--ink) 16%, transparent);
}
.tray-colours {
  display: flex;
  flex-shrink: 0;
  align-self: center;
  align-items: center;
  gap: 8px;
}
.tray-colour {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
  cursor: var(--cursor);
  transition: transform 0.3s var(--spring);
}
.tray-colour:hover {
  transform: scale(1.15);
}
.tray-colour.on {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16), 0 0 0 2px #ffffff, 0 0 0 3.5px rgba(0, 0, 0, 0.28);
}
.tray-colour.big {
  width: 34px;
  height: 34px;
  margin-right: 4px;
  background: conic-gradient(#e05a5a, #e0c35a, #6ac46a, #5ab4e0, #8a6ae0, #e05ab4, #e05a5a);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.85), inset 0 0 0 12px var(--c);
}
.tray-sizes {
  display: flex;
  flex-shrink: 0;
  align-self: center;
  align-items: center;
  gap: 2px;
  margin-left: 12px;
}
.tray-size {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: var(--cursor);
}
.tray-size span {
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
}
.tray-size.on {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
}
.tray-size.on span {
  opacity: 1;
}
.no-tray-colors .tray-colours,
.no-tray-colors .tray-sep-colours,
.no-tray-sizes .tray-sizes {
  display: none;
}
body.writing .ed-tray,
body.writing .ed-top {
  opacity: 0.1;
}

/* Grip (drag to move) and minimise button at the ends of the tray. */
.tray-grip,
.tray-min {
  display: grid;
  flex-shrink: 0;
  align-self: center;
  place-items: center;
  width: 30px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: inherit;
  opacity: 0.45;
  cursor: grab;
  touch-action: none;
  transition: opacity 0.2s, transform 0.35s var(--spring), background-color 0.2s;
}
.tray-grip {
  margin: 0 6px 0 -8px;
}
.tray-min {
  margin: 0 -8px 0 8px;
  cursor: var(--cursor);
}
.tray-grip .icon,
.tray-min .icon {
  width: 18px;
  height: 18px;
}
.tray-grip:hover,
.tray-min:hover {
  opacity: 0.9;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}
.tray-min:active {
  transform: scale(0.85);
}
.tray-left .tray-grip,
.tray-right .tray-grip,
.tray-left .tray-min,
.tray-right .tray-min {
  width: 44px;
  height: 30px;
  margin: 0 auto;
}
.tray-left .tray-grip,
.tray-right .tray-grip {
  margin-top: -8px;
  margin-bottom: 6px;
}
.tray-left .tray-min,
.tray-right .tray-min {
  margin-top: 8px;
  margin-bottom: -6px;
}

/* Minimised tray: one round glass button in a corner. */
.ed-tray.is-min {
  left: auto;
  right: max(18px, env(safe-area-inset-right, 0px));
}
.tray-left .ed-tray.is-min {
  left: max(18px, env(safe-area-inset-left, 0px));
  right: auto;
}
.tray-bubble {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  padding: 0;
  overflow: hidden;
  border-radius: 50% !important;
  color: inherit;
  pointer-events: auto;
  cursor: var(--cursor);
  touch-action: none;
  transition: transform 0.4s var(--spring);
}
.tray-bubble > svg {
  width: 24px;
  height: 72px;
  transform: rotate(35deg) translateY(10px);
}
.tray-bubble .tray-icon {
  margin: 0;
}
.tray-bubble:hover {
  transform: scale(1.08);
}
.tray-bubble:active {
  transform: scale(0.92);
}

/* While dragging the tray, it lifts up and the side it will dock to lights up. */
.ed-tray.dragging {
  z-index: 30;
  transition: none;
}
.ed-tray.dragging > * {
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25) !important;
  scale: 1.04;
  transition: scale 0.25s var(--spring);
}
body.tray-moving .ed::after {
  content: "";
  position: absolute;
  z-index: 25;
  border-radius: 22px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent);
  pointer-events: none;
  transition: all 0.35s var(--spring);
}
body[data-tray-drop="bottom"] .ed::after { left: 12%; right: 12%; bottom: 8px; height: 96px; top: auto; width: auto; }
body[data-tray-drop="top"] .ed::after { left: 12%; right: 12%; top: 8px; height: 96px; bottom: auto; width: auto; }
body[data-tray-drop="left"] .ed::after { top: 14%; bottom: 14%; left: 8px; width: 96px; right: auto; height: auto; }
body[data-tray-drop="right"] .ed::after { top: 14%; bottom: 14%; right: 8px; width: 96px; left: auto; height: auto; }

/* Tray on the top, left or right. */
.tray-top .ed-tray {
  top: calc(80px + env(safe-area-inset-top, 0px));
  bottom: auto;
}
.tray-top .tray-inner {
  align-items: flex-start;
  transform-origin: top center;
}
.tray-top .tray-pens {
  align-items: flex-start;
}
.tray-top .tray-pen {
  align-items: flex-start;
}
.tray-top .tray-pen > svg {
  transform: rotate(180deg) translateY(34px);
}
.tray-top .tray-pen:hover > svg { transform: rotate(180deg) translateY(28px); }
.tray-top .tray-pen.on > svg { transform: rotate(180deg) translateY(8px); }
.tray-top .tray-icon {
  margin: 22px 0 0;
}
.tray-left .ed-tray,
.tray-right .ed-tray {
  top: 0;
  bottom: 0;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: auto;
  align-items: center;
}
.tray-right .ed-tray {
  left: auto;
  right: max(12px, env(safe-area-inset-right, 0px));
}
.tray-left .tray-inner,
.tray-right .tray-inner {
  flex-direction: column;
  align-items: flex-start;
  width: 82px;
  height: auto;
  max-height: calc((100vh - 120px) / var(--tray-scale));
  padding: 16px 0;
  overflow-x: hidden;
  overflow-y: auto;
  transform-origin: left center;
}
.tray-right .tray-inner {
  align-items: flex-end;
  transform-origin: right center;
}
.tray-left .tray-pens,
.tray-right .tray-pens {
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  height: auto;
}
.tray-right .tray-pens {
  align-items: flex-end;
}
.tray-left .tray-pen,
.tray-right .tray-pen {
  width: 100%;
  height: 34px;
  align-items: center;
  justify-content: flex-start;
  overflow: visible;
}
.tray-right .tray-pen {
  justify-content: flex-end;
}
.tray-left .tray-pen > svg,
.tray-right .tray-pen > svg {
  flex-shrink: 0;
}
.tray-left .tray-pen > svg { transform: translateX(-4px) rotate(90deg); }
.tray-left .tray-pen:hover > svg { transform: translateX(2px) rotate(90deg); }
.tray-left .tray-pen.on > svg { transform: translateX(22px) rotate(90deg); }
.tray-right .tray-pen > svg { transform: translateX(4px) rotate(-90deg); }
.tray-right .tray-pen:hover > svg { transform: translateX(-2px) rotate(-90deg); }
.tray-right .tray-pen.on > svg { transform: translateX(-22px) rotate(-90deg); }
.tray-left .tray-icon,
.tray-right .tray-icon {
  margin: 0 22px;
}
.tray-left .tray-sep,
.tray-right .tray-sep {
  width: 46px;
  height: 1px;
  margin: 10px auto;
}
.tray-left .tray-colours,
.tray-right .tray-colours,
.tray-left .tray-sizes,
.tray-right .tray-sizes {
  flex-direction: column;
  margin: 6px auto 0;
}

/* Editor pop-up panels. */
.ed-popover {
  position: fixed;
  z-index: 20;
  width: min(390px, calc(100vw - 20px));
  max-height: min(72vh, 660px);
  padding: 16px 18px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: calc(16px * var(--text-scale));
}
.ed-popover.pop-pens,
.ed-popover.pop-colour,
.ed-popover.pop-paper {
  width: min(460px, calc(100vw - 20px));
}
.pop-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 10px;
  font-size: calc(22px * var(--text-scale));
  font-weight: 600;
}
.pop-title small {
  font-size: calc(13px * var(--text-scale));
  font-weight: 400;
  opacity: var(--muted);
}
.pop-head {
  margin: 14px 0 7px;
  font-size: calc(12px * var(--text-scale));
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: var(--muted);
}
.pop-preview {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 560 / 120;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}
.pop-link {
  margin-top: 10px;
  font-size: calc(18px * var(--text-scale));
  font-weight: 600;
}
.pop-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-top: 8px;
}
.pop-actions .pop-link {
  margin-top: 4px;
}
.pop-sliders {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 12px;
}
.pop-row {
  display: grid;
  grid-template-columns: 104px 1fr 54px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}
.pop-label {
  font-size: calc(15px * var(--text-scale));
}
.pop-val {
  font-size: calc(13px * var(--text-scale));
  font-variant-numeric: tabular-nums;
  text-align: right;
  opacity: var(--muted);
}
.pop-range {
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: var(--cursor);
}
.pop-range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ink) 18%, transparent);
}
.pop-range::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--ink) 18%, transparent);
}
.pop-range::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: -9px;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.22);
  -webkit-appearance: none;
}
.pop-range::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.22);
}
.pop-toggles {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-top: 10px;
}
.pop-toggles .toggle {
  min-width: 0;
  justify-content: flex-start;
  font-size: calc(16px * var(--text-scale));
}
.pop-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 4px 0 8px;
}
.pop-scroll {
  max-height: 56vh;
  overflow-y: auto;
}
.pop-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
}
.pop-grid .cell {
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 4px;
  cursor: var(--cursor);
  transition: transform 0.2s var(--spring);
}
.pop-grid .cell:hover {
  position: relative;
  z-index: 1;
  transform: scale(1.35);
}
.pop-shapes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.pop-shape {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border: 0;
  border-radius: 14px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: inherit;
  font: inherit;
  font-size: calc(13px * var(--text-scale));
  cursor: var(--cursor);
}
.pop-shape .icon {
  width: 24px;
  height: 24px;
}
.pop-shape.on {
  background: var(--ink);
  color: var(--bg);
}
.pop-note {
  margin-top: 12px;
  font-size: calc(13px * var(--text-scale));
  line-height: 1.4;
  opacity: var(--muted);
}

/* Selection menu above lassoed things. */
.ed-select-menu {
  position: absolute;
  z-index: 7;
}
.sel-inner {
  display: flex;
  gap: 2px;
  padding: 6px;
}
.sel-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 58px;
  padding: 7px 8px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: calc(12px * var(--text-scale));
  cursor: var(--cursor);
  transition: background-color 0.2s, transform 0.3s var(--spring);
}
.sel-btn .icon {
  width: 21px;
  height: 21px;
}
.sel-btn:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}
.sel-btn:active {
  transform: scale(0.9);
}

.ed-pageinfo {
  position: absolute;
  right: max(22px, env(safe-area-inset-right, 0px));
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  font-size: calc(14px * var(--text-scale));
  opacity: 0.55;
}
.tray-bottom .ed-pageinfo {
  bottom: calc(112px + env(safe-area-inset-bottom, 0px));
}
.ed-zoom {
  position: absolute;
  top: calc(90px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 7;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: calc(15px * var(--text-scale));
  font-style: normal;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.25s;
}
.ed-zoom.in {
  opacity: 0.85;
}

/* ---------- Artificial Notes ---------- */

.ai-intro {
  margin: 4px 0 6px;
  font-size: calc(19px * var(--text-scale));
  opacity: 0.8;
}
.ai-go {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 22px;
  margin-top: 26px;
  font-size: calc(30px * var(--text-scale));
  font-weight: var(--menu-weight);
}
.ai-picked {
  font-size: calc(15px * var(--text-scale));
  font-weight: 400;
  opacity: var(--muted);
}
.ai-off,
.ai-thinking {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-top: 9vh;
  text-align: center;
}
.ai-off .big-icon .icon,
.ai-thinking .big-icon .icon {
  width: 70px;
  height: 70px;
}
.ai-off-title {
  max-width: 640px;
  font-size: calc(30px * var(--text-scale));
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}
.ai-off .empty {
  max-width: 560px;
}
.ai-spark .icon {
  animation: spark 2.4s ease-in-out infinite;
}
@keyframes spark {
  50% { opacity: 0.55; transform: rotate(18deg) scale(1.15); }
}
.ai-status {
  font-size: calc(18px * var(--text-scale));
  opacity: 0.75;
}
.ai-status .dots span {
  display: inline-block;
}
.ai-topic {
  width: 100%;
  max-width: 760px;
  padding: 8px 2px;
  border: 0;
  border-bottom: 2px solid var(--faint);
  outline: 0;
  background: transparent;
  font-size: calc(24px * var(--text-scale));
  resize: vertical;
}
.ai-topic:focus,
.chat-input:focus {
  border-bottom-color: var(--accent);
}
.set-del {
  margin-left: 14px;
  opacity: 0.5;
}
.set-del .icon {
  width: 18px;
  height: 18px;
}

.ai-answer {
  max-width: 780px;
}
.ai-text {
  line-height: 1.5;
}
.ai-text h3 {
  margin: 20px 0 6px;
  font-size: calc(26px * var(--text-scale));
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}
.ai-text h4 {
  margin: 14px 0 4px;
  font-size: calc(20px * var(--text-scale));
  font-weight: 600;
}
.ai-text p,
.ai-text li {
  font-size: calc(19px * var(--text-scale));
}
.ai-text p {
  margin: 6px 0;
}
.ai-text ul,
.ai-text ol {
  margin: 6px 0 10px;
  padding-left: 1.3em;
}
.ai-text li {
  margin: 3px 0;
}
.ai-answer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 30px;
  margin-top: 26px;
  font-size: calc(22px * var(--text-scale));
  font-weight: 600;
}

/* Quiz. */
.quiz {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 820px;
  margin: 0 auto;
  padding-top: 8px;
}
.quiz-count {
  font-size: calc(13px * var(--text-scale));
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: var(--muted);
}
.quiz-q {
  font-size: calc(36px * var(--text-scale));
  font-weight: var(--title-weight);
  line-height: 1.2;
  text-wrap: balance;
}
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quiz-option {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 8px 4px;
  font-size: calc(24px * var(--text-scale));
  font-weight: 600;
  text-align: left;
  transition: opacity 0.3s;
}
.quiz-letter {
  width: 1.3em;
  flex-shrink: 0;
  font-size: 0.68em;
  opacity: 0.45;
}
.quiz-option.done {
  opacity: 0.4;
  pointer-events: none;
}
.quiz-option.right {
  color: var(--accent);
  opacity: 1;
}
.quiz-option.right .label::after {
  content: "  ✓";
}
.quiz-option.wrong {
  opacity: 0.55;
}
.quiz-option.wrong .label {
  text-decoration: line-through 2px;
}
.quiz-why {
  font-size: calc(18px * var(--text-scale));
  line-height: 1.45;
  opacity: 0.8;
}
.quiz-next {
  font-size: calc(26px * var(--text-scale));
  font-weight: 600;
}
.quiz-end {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding-top: 8vh;
  text-align: center;
}
.quiz-end .big-stat {
  align-items: center;
}
.big-num small {
  font-size: 0.4em;
  opacity: var(--muted);
}

/* Flashcards flip over. */
.cards {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding-top: 6px;
}
.flashcard {
  width: min(640px, 100%);
  aspect-ratio: 3 / 2;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: var(--cursor);
  perspective: 1400px;
}
.fc-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.75s var(--spring);
}
.flipped .fc-inner {
  transform: rotateY(180deg);
}
.no-flip .fc-inner {
  transition: none;
}
.fc-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 30px;
  border-radius: calc(var(--radius) * 1.4);
  background: color-mix(in srgb, var(--bg), #ffffff 40%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 14px 40px rgba(0, 0, 0, 0.1);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.dark-ui .fc-face {
  background: color-mix(in srgb, var(--bg), #ffffff 8%);
}
.fc-back {
  transform: rotateY(180deg);
  background: color-mix(in srgb, var(--bg), var(--accent) 14%);
}
.fc-text {
  font-size: calc(30px * var(--text-scale));
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
}
.fc-face small {
  font-size: calc(13px * var(--text-scale));
  opacity: 0.45;
}
.cards-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 30px;
  font-size: calc(21px * var(--text-scale));
  font-weight: 600;
}
.cards-extra {
  display: flex;
  gap: 26px;
  opacity: 0.75;
}

/* Chat. */
.chat {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100%;
  max-width: 820px;
}
.chat-about {
  font-size: calc(15px * var(--text-scale));
  opacity: var(--muted);
}
.chat-about .small {
  margin-left: 10px;
  font-size: inherit;
  font-weight: 600;
}
.chat-log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 18px;
}
.msg {
  max-width: 86%;
  font-size: calc(18px * var(--text-scale));
  line-height: 1.45;
}
.msg-user {
  align-self: flex-end;
  font-weight: 600;
  text-align: right;
  opacity: 0.72;
}
.msg-assistant {
  align-self: flex-start;
}
.msg-assistant.ai-text p,
.msg p {
  margin: 4px 0;
}
.chat-form {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding: 16px 0 8px;
  background: linear-gradient(transparent, var(--bg) 35%);
}
.chat-input {
  flex: 1;
  padding: 6px 2px;
  border: 0;
  border-bottom: 2px solid var(--faint);
  outline: 0;
  background: transparent;
  font-size: calc(20px * var(--text-scale));
  resize: none;
}
.chat-send .icon {
  width: 26px;
  height: 26px;
}

/* ---------- Smaller screens ---------- */

@media (max-width: 1100px) {
  .split {
    grid-template-columns: 240px 1fr;
    gap: 26px;
  }
}

@media (max-width: 760px) {
  .view {
    padding: 22px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  }
  .back {
    top: 22px;
    left: 16px;
    font-size: calc(24px * var(--text-scale));
  }
  .page-head {
    padding-top: 26px;
  }
  .split {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 10px;
  }
  .side {
    flex: none;
    flex-direction: row;
    gap: 16px;
    padding: 4px 4px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    mask-image: none;
  }
  .side-item {
    white-space: nowrap;
  }
  .side-item.active .label {
    transform: none;
  }
  .row {
    flex-wrap: wrap;
    gap: 8px 18px;
  }
  .row-ctl {
    flex-shrink: 1;
    max-width: 100%;
  }
  .swatches,
  .theme-chips {
    justify-content: flex-start;
  }
  .stepper .val {
    min-width: 100px;
  }
  .item {
    font-size: calc(var(--menu-size) * 0.62 * var(--text-scale));
  }
  .corner {
    transform: scale(calc(var(--widget-scale) * 0.8));
  }
  .ed-pageinfo,
  .ed-gap {
    display: none;
  }
  .ed-top-inner {
    padding-left: 12px;
  }
  .note-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(var(--thumb), 42vw), 1fr));
  }
  .quiz-q {
    font-size: calc(28px * var(--text-scale));
  }
}

/* ---------- Folders ---------- */

.side-count {
  margin-left: auto;
  padding-left: 10px;
  font-size: 0.72em;
  font-style: normal;
  font-variant-numeric: tabular-nums;
  opacity: 0.55;
}
.side-item.active .side-count {
  transform: translateX(8px);
}
.side-new {
  opacity: 0.45;
}
.side-new:hover {
  opacity: 0.8;
}
.side-folder .bicon .icon {
  fill: color-mix(in srgb, currentColor 22%, transparent);
}

/* A drawn folder: back with a tab, a sheet of paper peeking out, and a front flap with the icon. */
.folder-shape {
  --fc: #3e63dd;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1.28;
  transition: transform 0.45s var(--spring);
}
.fs-back {
  position: absolute;
  inset: 9% 0 0;
  border-radius: 14px;
  background: color-mix(in srgb, var(--fc), #000 18%);
}
.fs-back::before {
  content: "";
  position: absolute;
  top: -9%;
  left: 0;
  width: 42%;
  height: 16%;
  border-radius: 10px 10px 0 0;
  background: inherit;
}
.fs-paper {
  position: absolute;
  top: 16%;
  left: 9%;
  right: 9%;
  height: 50%;
  border-radius: 6px;
  background: #fdfbf6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transform: rotate(-3deg);
  transition: transform 0.45s var(--spring);
}
.fs-paper::after {
  content: "";
  position: absolute;
  inset: 18% 12% auto;
  height: 40%;
  background: repeating-linear-gradient(to bottom, rgba(120, 160, 205, 0.5) 0 1px, transparent 1px 7px);
}
.fs-front {
  position: absolute;
  inset: 32% 0 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(170deg, color-mix(in srgb, var(--fc), #fff 18%), var(--fc));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 6px 16px color-mix(in srgb, var(--fc) 35%, transparent);
  color: #fff;
  transform-origin: bottom center;
  transition: transform 0.45s var(--spring);
}
.fs-front .icon {
  width: 34%;
  height: 34%;
  stroke-width: 1.8;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.2));
}
.folder-open:hover .folder-shape,
.drop-over .folder-shape {
  transform: translateY(-5px);
}
.folder-open:hover .fs-front,
.drop-over .fs-front {
  transform: perspective(500px) rotateX(-18deg);
}
.folder-open:hover .fs-paper,
.drop-over .fs-paper {
  transform: translateY(-14%) rotate(-5deg);
}
.folder-shape.add {
  display: grid;
  place-items: center;
  border: 2px dashed color-mix(in srgb, var(--ink) 25%, transparent);
  border-radius: 16px;
  color: color-mix(in srgb, var(--ink) 45%, transparent);
}
.folder-shape.add .icon {
  width: 30%;
  height: 30%;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 28px 22px;
}
.folder-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  border-radius: 18px;
  transition: background-color 0.25s, transform 0.35s var(--spring);
}
.folder-open {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.folder-name {
  overflow: hidden;
  font-size: calc(19px * var(--text-scale));
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.folder-add {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: var(--cursor);
}
button.folder-add:hover .folder-shape {
  transform: translateY(-4px) rotate(-2deg);
}

.folder-head {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 2px 0 18px;
}
.folder-head .folder-shape {
  width: 92px;
  flex-shrink: 0;
  cursor: var(--cursor);
}
.folder-title {
  font-size: calc(34px * var(--text-scale));
  font-weight: var(--title-weight);
  line-height: 1.1;
}
.folder-head .small {
  margin-top: 4px;
  font-size: calc(16px * var(--text-scale));
  opacity: 0.6;
}

.folder-badge {
  display: inline-grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  margin-right: 6px;
  border-radius: 7px;
  background: var(--fc);
  color: #fff;
  vertical-align: -0.35em;
}
.folder-badge .icon {
  width: 0.95em;
  height: 0.95em;
}
.pop-chip.on .folder-badge {
  box-shadow: 0 0 0 2px var(--bg);
}
.ai-folders {
  margin: 4px 0 12px;
}

/* Note cards in a folder get a coloured tab. */
.card-folder-tab {
  position: absolute;
  top: 0;
  left: 12px;
  width: 28px;
  height: 7px;
  border-radius: 0 0 5px 5px;
  background: var(--fc);
}
.card-folder {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  color: var(--fc);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 1;
}
.card-folder .icon {
  width: 13px;
  height: 13px;
}
.card-meta:has(.card-folder) {
  opacity: 1;
}
.card-meta:has(.card-folder) .card-more {
  opacity: var(--muted);
}

/* Folder editor. */
.fe-preview {
  width: 130px;
}
.fe-colours {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 470px;
}
.fe-colours .swatch {
  width: 30px;
  height: 30px;
}
.fe-icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, 44px);
  justify-content: center;
  gap: 6px;
  width: min(640px, 80vw);
  max-height: 30vh;
  padding: 4px;
  overflow-y: auto;
}
.fe-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  color: inherit;
  cursor: var(--cursor);
  transition: transform 0.3s var(--spring), background-color 0.2s;
}
.fe-icon .icon {
  width: 22px;
  height: 22px;
}
.fe-icon:hover {
  transform: scale(1.1);
}
.fe-icon.on {
  background: var(--ink);
  color: var(--bg);
  transform: scale(1.08);
}

/* Holding and dragging a note. */
.note-card.lifted .card-pic {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.14), 0 22px 50px rgba(0, 0, 0, 0.2);
  transform: translateY(-8px) scale(1.04);
}
.note-card.dragging-source {
  opacity: 0.35;
}
.drag-ghost {
  position: fixed;
  z-index: 90;
  margin: 0;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2), 0 30px 70px rgba(0, 0, 0, 0.25);
  transform-origin: var(--ox, 30%) var(--oy, 20%);
  transition: transform 0.06s linear;
}
body.note-dragging [data-drop-folder] {
  transition: background-color 0.2s, transform 0.3s var(--spring);
}
body.note-dragging .side-item[data-drop-folder] {
  opacity: 0.85;
}
.side-item.drop-over {
  opacity: 1 !important;
  transform: scale(1.06) translateX(6px);
}
.side-item.drop-over .label {
  text-decoration: underline 2px var(--accent);
  text-underline-offset: 6px;
}
.folder-tile.drop-over {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  transform: scale(1.04);
}

/* ---------- Home on narrower screens: keep the bottom widgets apart ---------- */

@media (max-width: 1100px) {
  .corner-bc .fact,
  .corner-tc .widget {
    max-width: min(620px, 34vw);
  }
  .widget-empty {
    max-width: 22vw;
  }
}

/* ---------- Settings rows wrap instead of squeezing the label ---------- */

@media (max-width: 1100px) {
  .row:has(.swatches, .theme-chips, .walls) {
    flex-wrap: wrap;
    gap: 8px 18px;
  }
  .row:has(.swatches, .theme-chips, .walls) .row-ctl {
    flex-shrink: 1;
    width: 100%;
  }
  .row:has(.swatches, .theme-chips, .walls) .swatches,
  .row:has(.swatches, .theme-chips, .walls) .theme-chips,
  .row:has(.swatches, .theme-chips, .walls) .walls {
    justify-content: flex-start;
    max-width: none;
  }
}

/* ---------- Movement everywhere ---------- */

/* Pens rise into the tray one after another when a note opens. */
.tray-enter .tray-pen > svg,
.tray-enter .tray-icon {
  animation: pen-rise 0.7s cubic-bezier(0.34, 1.4, 0.64, 1) backwards;
}
.tray-enter .tray-pen:nth-child(1) > *:first-child { animation-delay: 0.10s; }
.tray-enter .tray-pen:nth-child(2) > *:first-child { animation-delay: 0.16s; }
.tray-enter .tray-pen:nth-child(3) > *:first-child { animation-delay: 0.22s; }
.tray-enter .tray-pen:nth-child(4) > *:first-child { animation-delay: 0.28s; }
.tray-enter .tray-pen:nth-child(5) > *:first-child { animation-delay: 0.34s; }
.tray-enter .tray-pen:nth-child(6) > *:first-child { animation-delay: 0.40s; }
.tray-enter .tray-pen:nth-child(7) > *:first-child { animation-delay: 0.46s; }
.tray-enter .tray-pen:nth-child(8) > *:first-child { animation-delay: 0.52s; }
.tray-enter .tray-pen:nth-child(9) > *:first-child { animation-delay: 0.58s; }
.tray-enter .tray-pen:nth-child(10) > *:first-child { animation-delay: 0.64s; }
@keyframes pen-rise {
  from { translate: 0 70px; opacity: 0; }
}
.tray-left .tray-enter .tray-pen > svg,
.tray-right .tray-enter .tray-pen > svg {
  animation-name: pen-slide;
}
@keyframes pen-slide {
  from { opacity: 0; }
}
.tray-enter .tray-colour,
.tray-enter .tray-size {
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.45s backwards;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.3); }
}

/* Picking a pen: the others dip a little while it springs up. */
.tray-pen {
  transition: transform 0.4s var(--spring);
}
.tray-pen:active > svg {
  transition-duration: 0.12s;
}

/* The tray glides when it changes size or side. */
.tray-inner,
.tray-bubble {
  transition: box-shadow 0.3s, scale 0.3s var(--spring);
}

/* Selection handle and zoom label pop. */
.ed-zoom.in {
  animation: zoom-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes zoom-pop {
  from { transform: translateX(-50%) scale(0.7); }
}

/* Side menus: the active dot pops in, rows glide. */
.side-item {
  transition: opacity 0.25s, transform 0.35s var(--spring);
}
.side-item.active::after {
  animation: dot-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes dot-pop {
  from { transform: scale(0); }
}

/* Switches and swatches spring when changed. */
.toggle,
.swatch,
.theme-chip,
.pop-chip,
.pop-paper,
.fe-icon {
  transition: transform 0.35s var(--spring), opacity 0.2s, background-color 0.2s, box-shadow 0.25s;
}
.pop-chip:active,
.pop-paper:active,
.swatch:active,
.fe-icon:active,
.sel-btn:active,
.tray-colour:active {
  transform: scale(0.88);
}

/* Chat messages and answers slide up as they arrive. */
.msg {
  animation: rise-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.quiz-why,
.ai-answer-actions {
  animation: rise-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
}
.quiz-option.right {
  animation: right-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes right-pop {
  40% { transform: scale(1.06) translateX(6px); }
}

/* Cards in lists lift on hover and press in when tapped. */
.card-open:active .card-pic {
  transform: scale(0.97);
  transition-duration: 0.12s;
}
.folder-open:active .folder-shape {
  transform: scale(0.95);
}

/* Text boxes and the editor's handle appear softly. */
.ed-text {
  transition: outline-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

/* Toasts get a little bounce. */
.toast.in {
  transition: opacity 0.35s, transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Everything holds still when animations are off (Settings → Animations / Accessibility). */
.motion-off *,
.motion-off *::before,
.motion-off *::after {
  animation-duration: 0.001ms !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  transition-delay: 0s !important;
}

/* iPad in portrait: give the settings and notes panels more room. */
@media (min-width: 761px) and (max-width: 900px) {
  .view {
    padding-left: max(30px, env(safe-area-inset-left, 0px));
    padding-right: max(30px, env(safe-area-inset-right, 0px));
  }
  .back {
    left: 30px;
  }
  .split {
    grid-template-columns: 200px 1fr;
    gap: 18px;
  }
  .stepper .val {
    min-width: 116px;
  }
  .toggle {
    min-width: 80px;
  }
}

/* ---------- Speed ---------- */

/* Colour blobs are soft gradients instead of blurred shapes: same look, far less work. */
#backdrop span,
.backdrop-aurora #backdrop span,
.backdrop-mesh #backdrop span {
  filter: none;
  background: radial-gradient(closest-side, var(--blob), transparent) !important;
}
#backdrop span:nth-child(1) { --blob: color-mix(in srgb, var(--accent) 70%, #ffd6a5); }
#backdrop span:nth-child(2) { --blob: color-mix(in srgb, var(--accent) 35%, #a0c4ff); }
#backdrop span:nth-child(3) { --blob: color-mix(in srgb, var(--accent) 30%, #caffbf); }
#backdrop span:nth-child(4) { --blob: color-mix(in srgb, var(--accent) 40%, #ffc6ff); }
.blob-motion #backdrop span {
  will-change: transform;
}

/* No blurring the whole screen behind pop-ups (very heavy on iPad); a solid veil instead. */
.modal-open #app {
  filter: none;
}
#modal {
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}

/* While the pen is on the page, the glass stops blurring what's behind it for a moment. */
.inking .tb-glass {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  background: color-mix(in srgb, var(--glass-color) 90%, var(--bg)) !important;
}
.dark-ui .inking .tb-glass {
  background: color-mix(in srgb, var(--bg) 88%, #ffffff) !important;
}

/* The line being written sits on its own canvas above the pages. */
.ed-ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Faded scroll edges make touch scrolling slow on iPad, so they're only used with a mouse. */
@media (pointer: coarse) {
  .scroll {
    -webkit-mask-image: none;
    mask-image: none;
  }
}

/* Smooth momentum scrolling in lists. */
.scroll {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
