/* ekin-art.com — reader. The pages lead; chrome is misted glass floating at the edges. */

body.is-reader { height: 100svh; overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }

.reader {
  position: fixed; inset: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
.reader__haze { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--mist); }

.glass {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%);
  border: 1px solid color-mix(in srgb, var(--cloud) 55%, transparent);
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-edge);
}

/* ---- Top bar ---- */
.reader__top {
  position: relative; z-index: 20;
  display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 7px 8px 7px 20px; border-radius: 999px;
}
.reader__home { flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 6px 4px; }
.reader__title { min-width: 0; flex: 1; display: grid; padding-left: 14px; border-left: 1px solid var(--line); }
.reader__title h1 {
  font-size: 0.98rem; font-weight: 500; letter-spacing: 0; color: var(--ink); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.reader__title p { font-size: 0.8rem; color: var(--ink-3); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.reader__tools { display: flex; align-items: center; gap: 2px; flex: none; }
.reader__badge {
  margin-right: 8px; padding: 5px 11px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; color: var(--ink);
  background: color-mix(in srgb, var(--f2) 26%, var(--cloud));
}

.tool {
  position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0;
  background: transparent; color: var(--ink-2); cursor: pointer;
  transition: background-color 160ms, color 160ms, transform 110ms var(--ease-out);
}
.tool:hover { background: color-mix(in srgb, var(--cloud) 75%, transparent); color: var(--ink); }
.tool:active { transform: scale(0.92); }
.tool[aria-pressed="true"], .tool.is-on { background: var(--cloud); color: var(--ink); box-shadow: var(--shadow-sm); }
.tool:disabled { opacity: 0.35; cursor: default; }
.tool .icon { width: 21px; height: 21px; }

@media (max-width: 640px) {
  .reader__top { gap: 8px; padding-left: 14px; min-height: 54px; }
  .reader__home .wordmark { font-size: 1.15rem; }
  .reader__title { padding-left: 10px; }
  .reader__title h1 { font-size: 0.9rem; }
  .tool--wide { display: none; }
  .tool { width: 40px; height: 40px; }
  .reader__home .wordmark__art { display: none; }
}
@media (max-width: 360px) {
  .reader__tools [data-action="text"] { display: none; }
}

/* ---- Stage and book ---- */
.reader__stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 14px 0; }
.reader__frame {
  position: relative; width: var(--frame-w, min(100%, 420px));
  transition: transform 700ms var(--ease-out), opacity 500ms var(--ease-out);
  opacity: 0;
}
.reader.is-ready .reader__frame { opacity: 1; }
.reader__book { margin: 0 auto; }
.reader__book .page { background: #fff; overflow: hidden; box-shadow: 0 1px 2px rgba(30, 38, 50, 0.08), 0 18px 36px -18px rgba(30, 38, 50, 0.38); }
.reader__book .page img {
  width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none;
  opacity: 0; transition: opacity 360ms var(--ease-out);
}
.reader__book .page img.is-loaded { opacity: 1; }
.reader__book .page::before {
  /* Loading veil: a faint sheen moving across an unprinted sheet. */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, color-mix(in srgb, var(--f2) 10%, transparent) 45%, color-mix(in srgb, var(--f1) 10%, transparent) 55%, transparent 70%) #fff;
  background-size: 260% 100%; animation: sheen 1.6s linear infinite;
}
.reader__book .page.is-loaded::before { display: none; }
.reader__book .page::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.reader__book .stf__item.--left::after { background: linear-gradient(270deg, rgba(0, 0, 0, 0.13), rgba(0, 0, 0, 0.03) 3.5%, transparent 9%); }
.reader__book .stf__item.--right::after { background: linear-gradient(90deg, rgba(0, 0, 0, 0.13), rgba(0, 0, 0, 0.03) 3.5%, transparent 9%); }
.reader.is-portrait .reader__book .stf__item::after { background: none; }
@keyframes sheen { to { background-position: -160% 0; } }

.reader__poster {
  position: absolute; z-index: 1; height: calc(100% - 28px); width: auto; max-width: calc(100% - 24px); object-fit: contain;
  box-shadow: var(--shadow-page); background: #fff; transition: opacity 400ms var(--ease-out);
}
.reader.is-ready .reader__poster { opacity: 0; pointer-events: none; }

.edge {
  position: absolute; top: 50%; z-index: 5; display: grid; place-items: center; width: 52px; height: 52px; margin-top: -26px;
  border-radius: 50%; border: 1px solid color-mix(in srgb, var(--cloud) 55%, transparent); cursor: pointer; color: var(--ink-2);
  background: var(--glass); backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: var(--shadow-sm); transition: opacity 240ms, transform 140ms var(--ease-out), color 160ms;
}
.edge:hover { color: var(--ink); }
.edge:active { transform: scale(0.92); }
.edge:disabled { opacity: 0; pointer-events: none; }
.edge--prev { left: 6px; }
.edge--next { right: 6px; }
.edge .icon { width: 22px; height: 22px; }
@media (max-width: 900px), (hover: none) { .edge { display: none; } }

/* ---- Bottom bar ---- */
.reader__bottom {
  position: relative; z-index: 20; justify-self: center;
  display: flex; align-items: center; gap: 4px; width: min(680px, 100%); min-height: 58px; padding: 7px 8px; border-radius: 999px;
}
.scrub { position: relative; flex: 1; display: flex; align-items: center; gap: 14px; padding: 0 10px; min-width: 0; }
.scrub input {
  --pct: 0%;
  flex: 1; min-width: 0; height: 44px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
.scrub input::-webkit-slider-runnable-track {
  height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--f1), var(--f2) calc(var(--pct) * 0.5), var(--f3) var(--pct), var(--line-2) var(--pct));
}
.scrub input::-moz-range-track { height: 3px; border-radius: 3px; background: var(--line-2); }
.scrub input::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--fringe); }
.scrub input::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8.5px; border-radius: 50%; border: 0;
  background: var(--cloud); box-shadow: 0 0 0 1.5px var(--f3), 0 2px 8px rgba(30, 38, 50, 0.25);
  transition: transform 120ms var(--ease-out);
}
.scrub input:active::-webkit-slider-thumb { transform: scale(1.18); }
.scrub input::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--cloud); box-shadow: 0 0 0 1.5px var(--f3), 0 2px 8px rgba(30, 38, 50, 0.25); }
.scrub input:focus-visible { outline: none; }
.scrub input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent), 0 2px 8px rgba(30, 38, 50, 0.25); }
.scrub__label {
  flex: none; min-width: 74px; text-align: right; font-size: 0.9rem; font-weight: 500; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
}
@media (max-width: 640px) {
  .reader__bottom { min-height: 54px; }
  .scrub { gap: 10px; padding: 0 6px; }
  .scrub__label { min-width: 62px; font-size: 0.85rem; }
}

/* ---- Sheets: pages, search, text ---- */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end; padding: 10px; }
.sheet[hidden] { display: none; }
.sheet::before { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--ground) 30%, transparent); }
.sheet__panel {
  position: relative; display: flex; flex-direction: column; width: min(420px, 100%); max-height: 100%;
  border-radius: 28px; padding: 18px 18px 0; overflow: hidden;
  background: var(--glass-strong);
  animation: sheet-in 420ms var(--ease-out) both;
}
.sheet--text .sheet__panel { width: min(640px, 100%); }
@keyframes sheet-in { from { opacity: 0; transform: translateX(24px) scale(0.985); filter: blur(8px); } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 2px 12px 8px; }
.sheet__head h2 { font-size: 1.25rem; font-weight: 400; letter-spacing: -0.01em; }
.sheet__hint { padding: 12px 8px 6px; color: var(--ink-3); font-size: 0.9rem; }

.thumbs {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 18px 14px;
  overflow-y: auto; padding: 6px 6px 22px; margin: 0 -4px; overscroll-behavior: contain;
}
.thumb { display: grid; gap: 7px; border: 0; padding: 0; background: none; cursor: pointer; text-align: center; }
.thumb__sheet {
  display: block; aspect-ratio: var(--ratio, 0.707); background: var(--cloud); border-radius: 2px; overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform 300ms var(--ease-out), box-shadow 300ms;
}
.thumb__sheet img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover .thumb__sheet { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.thumb__no { font-size: 0.8rem; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.thumb.is-current .thumb__sheet { box-shadow: 0 0 0 2px var(--cloud), 0 0 0 3.5px var(--f3), var(--shadow-md); }
.thumb.is-current .thumb__no { color: var(--ink); }
.thumb__sheet { position: relative; }
.thumb.has-marks .thumb__no::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; vertical-align: 1px; border-radius: 50%; background: var(--f3);
}
.thumb.has-bookmark .thumb__sheet::after {
  content: ""; position: absolute; top: 0; right: 12%; width: 9px; height: 18%;
  background: linear-gradient(180deg, var(--f1), var(--f2) 55%, var(--f3)); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}

.search-field {
  display: flex; align-items: center; gap: 10px; margin: 0 4px; padding: 0 16px; height: 50px; border-radius: 999px;
  background: var(--cloud); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-3);
}
.search-field:focus-within { box-shadow: inset 0 0 0 1.5px var(--accent); }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 1rem; color: var(--ink); }
.results { list-style: none; margin: 0; padding: 4px 0 18px; overflow-y: auto; overscroll-behavior: contain; }
.results button {
  display: grid; grid-template-columns: 54px 1fr; gap: 12px; width: 100%; padding: 12px 10px; border: 0; border-radius: 14px;
  background: transparent; text-align: left; cursor: pointer; font-size: 0.93rem; line-height: 1.45; color: var(--ink-2);
}
.results button:hover, .results button:focus-visible { background: color-mix(in srgb, var(--cloud) 80%, transparent); }
.results b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; font-size: 0.85rem; padding-top: 1px; }
.results mark { background: color-mix(in srgb, var(--f2) 38%, transparent); color: var(--ink); border-radius: 3px; padding: 0 2px; }

.prose { overflow-y: auto; padding: 4px 8px 28px; overscroll-behavior: contain; }
.prose h3 { margin: 22px 0 10px; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.prose h3:first-child { margin-top: 4px; }
.prose p { max-width: 62ch; font-size: 1.12rem; line-height: 1.7; color: var(--ink); }
.prose p + p { margin-top: 0.85em; }
.prose .is-empty { color: var(--ink-3); font-size: 1rem; }

@media (max-width: 640px) {
  .sheet { align-items: flex-end; padding: 0; }
  .sheet__panel { width: 100%; max-height: 82svh; border-radius: 26px 26px 0 0; padding-bottom: env(safe-area-inset-bottom); animation-name: sheet-up; }
  .sheet--text .sheet__panel { max-height: 90svh; }
  .thumbs { grid-template-columns: repeat(3, 1fr); }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; filter: blur(6px); } }

/* ---- Zoom ---- */
.zoom { position: fixed; inset: 0; z-index: 50; background: var(--ground); animation: fade-in 260ms var(--ease-out); }
.zoom[hidden] { display: none; }
.zoom__viewport { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; }
.zoom__viewport.is-dragging { cursor: grabbing; }
.zoom__content { position: absolute; left: 0; top: 0; display: flex; transform-origin: 0 0; will-change: transform; }
.zoom__page { position: relative; flex: none; background: #fff; box-shadow: var(--shadow-page); }
.zoom__content img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; }
.zoom__bar {
  position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 4px; padding: 6px; border-radius: 999px;
}
@keyframes fade-in { from { opacity: 0; } }

/* ---- End of issue ---- */
.end {
  position: fixed; z-index: 30; right: max(16px, env(safe-area-inset-right)); bottom: calc(86px + env(safe-area-inset-bottom));
  width: min(360px, calc(100% - 32px)); padding: 18px 18px 14px; border-radius: 24px;
  animation: sheet-up 520ms var(--ease-out) both;
}
.end[hidden] { display: none; }
.end__title { font-size: 1.15rem; font-weight: 400; color: var(--ink); padding-right: 36px; }
.end__note { margin-top: 4px; font-size: 0.9rem; color: var(--ink-3); }
.end__list { display: grid; gap: 6px; margin-top: 12px; }
.end__item { display: flex; align-items: center; gap: 12px; padding: 6px; margin: 0 -6px; border-radius: 12px; font-size: 0.93rem; font-weight: 500; color: var(--ink); }
.end__item:hover { background: color-mix(in srgb, var(--cloud) 80%, transparent); }
.end__item img { width: 38px; aspect-ratio: 0.707; object-fit: cover; border-radius: 2px; box-shadow: 0 -1.5px 0 0 var(--f2), var(--shadow-sm); }
.end__actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.end__actions button.text-link { border: 0; background: none; cursor: pointer; padding: 0 0 2px; font-size: 0.93rem; }
.end__actions .text-link { font-size: 0.93rem; }
.end__close { position: absolute; top: 8px; right: 8px; }

/* ---- Toast ---- */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  /* Phones: in the empty band above the controls. Wide screens: inside the top bar, never over the page. */
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px); padding: 10px 10px 10px 20px; border-radius: 999px;
  font-size: 0.93rem; color: var(--ink); animation: toast-in 420ms var(--ease-out) both;
}
.toast[hidden] { display: none; }
.toast button {
  border: 0; border-radius: 999px; padding: 8px 14px; background: var(--ink); color: var(--ground); font-weight: 500; font-size: 0.88rem; cursor: pointer;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); filter: blur(6px); } }
@media (min-width: 901px) {
  .toast { top: calc(17px + env(safe-area-inset-top)); bottom: auto; min-height: 44px; padding-block: 6px; box-shadow: var(--shadow-sm); }
}

.reader__plain { display: grid; gap: 16px; justify-items: center; overflow-y: auto; height: 100%; padding: 16px; }
.reader__plain img { max-width: min(100%, 900px); box-shadow: var(--shadow-page); }

@media (prefers-reduced-transparency: reduce) {
  .glass, .edge { background: var(--glass-strong); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .reader__book .page::before { animation: none; }
}

/* Phone held sideways: thin chrome so the page gets the height. */
@media (max-height: 520px) and (orientation: landscape) {
  .reader { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .reader__top, .reader__bottom { min-height: 46px; padding-block: 3px; }
  .reader__title p { display: none; }
  .reader__stage { padding: 6px 0; }
  .tool { width: 40px; height: 40px; }
  .scrub input { height: 40px; }
  .toast { bottom: calc(60px + env(safe-area-inset-bottom)); }
}

/* ---- Marks: the reader's own inks on the paper ----
   Pages stay paper: highlighter multiplies into the print, pen and underline sit on top,
   notes are small coloured slips, a bookmark is a ribbon in the issue's fringe. */
.reader__bottom, .markbar { grid-row: 3; grid-column: 1; }
.marks { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.marks__ink { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; }
.marks__hl { mix-blend-mode: multiply; }
.mk { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.mk--h { stroke-opacity: 0.42; stroke-linecap: butt; }
.reader.marks-off .marks { visibility: hidden; }

.marks__pin {
  position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; padding: 0; border: 0; cursor: pointer; pointer-events: auto;
  border-radius: 9px 9px 9px 3px; background: var(--c); rotate: -5deg;
  box-shadow: 0 0 0 1.5px #fff, 0 3px 8px -2px rgba(36, 44, 58, 0.5);
  transition: transform 160ms var(--ease-out);
}
.marks__pin::before {
  /* Two ruled lines, and a 44px reach around the slip. */
  content: ""; position: absolute; inset: -9px;
  background: linear-gradient(rgba(33, 40, 52, 0.38), rgba(33, 40, 52, 0.38)) 18px 18px / 12px 1.5px no-repeat,
              linear-gradient(rgba(33, 40, 52, 0.38), rgba(33, 40, 52, 0.38)) 18px 23px / 8px 1.5px no-repeat;
}
.marks__pin:hover { transform: scale(1.1); }
.marks__pin:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.marks__pin.is-new { animation: pin-in 300ms var(--ease-out) both; }
@keyframes pin-in { from { transform: scale(0.5) translateY(-6px); opacity: 0; } }
.zoom__page .marks__pin { scale: calc(1 / var(--zs, 1)); }

.marks__ribbon {
  position: absolute; top: 0; right: 9%; width: 3.2%; min-width: 9px; height: 11%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--f1) 85%, #000), var(--f2) 55%, var(--f3));
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%);
  filter: drop-shadow(0 1px 1px rgba(36, 44, 58, 0.25));
}
.marks__ribbon.is-left { right: auto; left: 9%; }
.marks__ribbon.is-new { animation: ribbon-drop 520ms var(--ease-out) both; }
@keyframes ribbon-drop { from { transform: translateY(-100%); } }

/* The drawing surface over the book. */
.ink-layer {
  position: absolute; inset: 0; z-index: 4; cursor: crosshair; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.reader.is-marking .zoom__viewport { cursor: crosshair; }
.reader.is-marking[data-mark-tool="e"] .ink-layer, .reader.is-marking[data-mark-tool="e"] .zoom__viewport { cursor: none; }
.ink-ring {
  position: fixed; left: 0; top: 0; z-index: 57; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; pointer-events: none;
  border: 1.5px solid var(--ink-2); background: color-mix(in srgb, var(--cloud) 35%, transparent); box-shadow: 0 1px 4px rgba(36, 44, 58, 0.25);
}
.reader.is-marking .end { display: none; }
.reader.is-marking .zoom__bar { top: max(14px, env(safe-area-inset-top)); bottom: auto; }

/* ---- Markup toolbar ---- */
.markbar { position: relative; z-index: 56; justify-self: center; display: flex; align-items: center; gap: 10px; max-width: 100%; }
.markbar__pill { display: flex; align-items: center; gap: 2px; min-height: 58px; padding: 7px 8px; border-radius: 999px; animation: sheet-up 420ms var(--ease-out) both; }
.markbar__actions { animation-delay: 50ms; }
.markbar__sep { flex: none; width: 1px; height: 24px; margin: 0 6px; background: var(--line-2); }
.mtool__ink {
  position: absolute; left: 50%; bottom: 7px; width: 12px; height: 3px; margin-left: -6px; border-radius: 2px;
  background: var(--ink-c, transparent); box-shadow: 0 0 0 0.5px rgba(36, 44, 58, 0.15);
}
.mtool[data-tool="e"] .mtool__ink { display: none; }
.mtool .icon { margin-top: -3px; }
.mtool[data-tool="e"] .icon { margin-top: 0; }
.mswatch__dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--ink-c);
  box-shadow: 0 0 0 2px var(--cloud), 0 0 0 3px var(--line-2);
}
.mswatch:disabled .mswatch__dot { background: var(--mist); }
.mswatch[aria-expanded="true"] { background: var(--cloud); box-shadow: var(--shadow-sm); }
.markbar__nav { display: flex; align-items: center; }
.markbar__page {
  min-width: 56px; text-align: center; font-size: 0.88rem; font-weight: 500; color: var(--ink);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.markbar__done {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 18px 0 14px; margin-left: 4px;
  border: 0; border-radius: 999px; background: var(--ink); color: var(--ground); cursor: pointer;
  font: inherit; font-size: 0.93rem; font-weight: 500; white-space: nowrap;
  transition: transform 110ms var(--ease-out), opacity 160ms;
}
.markbar__done:hover { opacity: 0.88; }
.markbar__done:active { transform: scale(0.96); }
.markbar__done .icon { width: 18px; height: 18px; }
.markbar__done:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (min-width: 901px) and (hover: hover) { .markbar__nav { display: none; } }
@media (hover: none) { .markbar__zoom { display: none; } }

.markpop, .markmenu {
  position: fixed; z-index: 58; padding: 8px; border-radius: 24px; background: var(--glass-strong);
  transform-origin: var(--ox, 50%) 100%; animation: pop-in 240ms var(--ease-out) both;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.96); filter: blur(4px); } }
.markpop__row { display: flex; gap: 2px; }
.markpop__sizes { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); justify-content: center; }
.ink-dot, .size-dot {
  position: relative; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; cursor: pointer;
}
.ink-dot::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%; background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(36, 44, 58, 0.12); transition: transform 140ms var(--ease-out), box-shadow 140ms;
}
.ink-dot:hover::before { transform: scale(1.08); }
.ink-dot[aria-checked="true"]::before { box-shadow: 0 0 0 2.5px var(--cloud), 0 0 0 4.5px var(--c); }
.size-dot span { width: 24px; height: var(--w, 3px); border-radius: 3px; background: var(--ink-c); }
.size-dot.is-marker span { border-radius: 2px; opacity: 0.55; }
.size-dot:hover, .size-dot[aria-checked="true"] { background: var(--cloud); box-shadow: var(--shadow-sm); }
.ink-dot:focus-visible, .size-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.markmenu { display: grid; min-width: 250px; padding: 6px; border-radius: 20px; }
.markmenu button {
  display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 0 16px 0 14px; border: 0; border-radius: 14px;
  background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit; font-size: 0.93rem;
}
.markmenu button:hover, .markmenu button:focus-visible { background: color-mix(in srgb, var(--cloud) 85%, transparent); outline: none; }
.markmenu .icon { width: 19px; height: 19px; color: var(--ink-2); flex: none; }

/* ---- Note ---- */
.note-pop {
  position: fixed; z-index: 59; left: 50%; top: 96px; width: min(330px, calc(100% - 24px)); margin-left: calc(min(330px, calc(100% - 24px)) / -2);
  display: grid; gap: 10px; padding: 12px 12px 12px; border-radius: 24px; background: var(--glass-strong);
  animation: pop-in 260ms var(--ease-out) both;
}
.note-pop[style*="left"] { margin-left: 0; }
.note-pop__head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding-left: 6px; }
.note-pop__title { font-size: 0.85rem; font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.note-pop__colors { display: flex; }
.note-pop .ink-dot { width: 36px; height: 40px; }
.note-pop .ink-dot::before { width: 20px; height: 20px; }
.note-pop textarea {
  display: block; width: 100%; min-height: 120px; max-height: 42svh; resize: none; padding: 12px 14px; border: 0; border-radius: 16px;
  background: var(--cloud); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink);
  font: inherit; font-size: 1rem; line-height: 1.5;
}
.note-pop textarea::placeholder { color: var(--ink-3); }
.note-pop textarea:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
.note-pop__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.note-pop__del {
  display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 12px; border: 0; border-radius: 999px;
  background: none; color: var(--ink-2); cursor: pointer; font: inherit; font-size: 0.93rem;
}
.note-pop__del:hover { background: color-mix(in srgb, var(--cloud) 85%, transparent); color: var(--ink); }
.note-pop__del .icon { width: 18px; height: 18px; }
.note-pop .markbar__done { margin-left: 0; padding: 0 20px; }

/* ---- Pages sheet: tabs and the marks list ---- */
.tabs { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--mist); }
.tabs__tab {
  display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px;
  background: none; color: var(--ink-3); cursor: pointer; font: inherit; font-size: 0.92rem; font-weight: 500;
  transition: background-color 160ms, color 160ms;
}
.tabs__tab:hover { color: var(--ink); }
.tabs__tab[aria-selected="true"] { background: var(--cloud); color: var(--ink); box-shadow: var(--shadow-sm); }
.tabs__tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tabs__count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--line); color: var(--ink-2); font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.mlist { display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0 -18px; }
.mlist__items { flex: 1; min-height: 0; margin: 0; padding: 2px 10px 10px; list-style: none; overflow-y: auto; overscroll-behavior: contain; }
.mitem { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--line); }
.mitem:last-child { border-bottom: 0; }
.mitem__go {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 14px; padding: 8px; border: 0; border-radius: 16px;
  background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit;
}
.mitem__go:hover, .mitem__go:focus-visible { background: color-mix(in srgb, var(--cloud) 80%, transparent); outline: none; }
.mitem__thumb {
  position: relative; display: block; width: 44px; aspect-ratio: var(--ratio, 0.707); overflow: hidden;
  background: #fff; border-radius: 2px; box-shadow: var(--shadow-sm);
}
.mitem__thumb img { width: 100%; height: 100%; object-fit: cover; }
.mitem__ribbon {
  position: absolute; top: 0; right: 14%; width: 7px; height: 30%;
  background: linear-gradient(180deg, var(--f1), var(--f2) 55%, var(--f3)); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
}
.mitem__text { display: grid; gap: 2px; min-width: 0; }
.mitem__title { font-size: 0.97rem; font-weight: 500; }
.mitem__sum { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--ink-3); }
.mitem__inks { display: inline-flex; gap: 3px; }
.mitem__inks i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(36, 44, 58, 0.12); }
.mitem__del { color: var(--ink-3); }
.mitem__notes { grid-column: 1 / -1; display: grid; gap: 4px; margin: 0 8px 8px 66px; padding: 0; list-style: none; }
.mitem__note {
  width: 100%; padding: 9px 12px; border: 0; border-radius: 12px;
  background: color-mix(in srgb, var(--cloud) 72%, transparent); color: var(--ink-2); text-align: left; cursor: pointer;
  font: inherit; font-size: 0.9rem; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
}
.mitem__note::before {
  content: ""; float: left; width: 10px; height: 10px; margin: 5px 10px 0 0; border-radius: 3px 3px 3px 2px; background: var(--c);
}
.mitem__note:hover, .mitem__note:focus-visible { background: var(--cloud); color: var(--ink); outline: none; }
.mlist__foot { padding: 12px 22px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.mlist__foot p { font-size: 0.82rem; color: var(--ink-3); }
.mlist__actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
.mlist__btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; margin: 0 -14px; border: 0; border-radius: 999px;
  background: none; color: var(--ink-2); cursor: pointer; font: inherit; font-size: 0.92rem; font-weight: 500;
}
.mlist__btn:hover { background: color-mix(in srgb, var(--cloud) 85%, transparent); color: var(--ink); }
.mlist__btn .icon { width: 18px; height: 18px; }
.mlist__empty { display: grid; justify-items: center; gap: 10px; padding: 44px 28px 52px; text-align: center; }
.mlist__empty > .icon { width: 30px; height: 30px; color: var(--ink-3); }
.mlist__empty h3 { font-size: 1.2rem; font-weight: 400; letter-spacing: -0.01em; color: var(--ink); }
.mlist__empty p { max-width: 34ch; font-size: 0.93rem; color: var(--ink-3); }
.mlist__empty .markbar__done { margin: 8px 0 0; }

@media (max-width: 640px) {
  .markbar { flex-direction: column-reverse; gap: 8px; width: 100%; }
  .markbar__pill { width: 100%; min-height: 54px; padding: 5px 6px; }
  .markbar__tools { justify-content: space-between; }
  .markbar__sep { margin: 0 2px; }
  .markbar__nav { margin-right: auto; }
  .note-pop { top: calc(max(10px, env(safe-area-inset-top)) + 66px); }
  .reader.is-marking .toast { bottom: calc(146px + env(safe-area-inset-bottom)); }
  .sheet[data-sheet="pages"] .sheet__panel { height: 82svh; }
}
@media (max-width: 380px) {
  .markbar__page { display: none; }
  .markbar .tool { width: 38px; height: 38px; }
  .markbar__done { padding: 0 14px 0 10px; }
}
@media (max-width: 520px) {
  /* Phones turn pages by tapping or swiping the page; the space goes to the scrubber. */
  .reader__bottom .tool--step { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .markbar__pill { min-height: 46px; padding-block: 3px; }
}
@media (prefers-reduced-transparency: reduce) {
  .markpop, .markmenu, .note-pop { background: var(--cloud); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .marks__pin.is-new, .marks__ribbon.is-new, .markbar__pill, .markpop, .markmenu, .note-pop { animation: none; }
}
