/* The browser's stylesheet — the phone's screens, in a desktop shell.
 *
 * The component language is the designer's prototype (`RE.ORDER Prototype v3`);
 * the measurements and colours are the phone's (`app/lib/theme/app_theme.dart`,
 * `ui/widgets/re_widgets.dart`). Where the two disagree the phone wins, so a
 * bookseller who learned a screen on the phone recognises it on a laptop.
 * Colours come from tokens.css only — nothing here invents one.
 */

/* ───────────────────────────── base ───────────────────────────── */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
  text-wrap: balance;
  line-height: 1.15;
}
a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input,
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
textarea {
  resize: vertical;
}
input[type="color"] {
  width: 40px;
  height: 32px;
  padding: 2px;
  border-radius: 8px;
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
}
label {
  display: block;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
}
label > input,
label > select,
label > textarea {
  margin-top: 4px;
}
.hidden {
  display: none !important;
}
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--ink-2);
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 600;
}
.big {
  font-family: var(--display);
  font-size: 34px;
  line-height: 1.05;
}
.center {
  text-align: center;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ───────────────────────────── shell ─────────────────────────────
 * A left sidebar with Find · Map · Settings, the content on the right
 * (the prototype's desktop view). No counts and no badges in it: the shelf
 * bars carry attention, nothing nags (decision 7). Below 760 px the sidebar
 * becomes the phone's three tabs along the bottom. */

.shell {
  display: flex;
  min-height: 100%;
}
.side {
  width: 240px;
  flex: none;
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  background: var(--paper-2);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.side .shop {
  font-family: var(--display);
  font-size: 20px;
  line-height: 1.2;
  margin: 2px 10px 22px;
  word-break: break-word;
}
.side .shop small {
  display: block;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 400;
  margin-top: 4px;
}
.navitem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 500;
}
.navitem svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.navitem:hover,
.navitem[aria-current="page"] {
  background: var(--card);
  color: var(--ink);
}
.navitem[aria-current="page"] {
  color: var(--accent);
}
.side .foot {
  margin-top: auto;
  padding: 14px 10px 0;
  font-size: 12px;
  color: var(--ink-2);
}
.side .foot .warn {
  display: block;
  color: var(--bad);
  font-weight: 600;
  margin-bottom: 8px;
}
.content {
  flex: 1;
  min-width: 0;
  position: relative;
}
.screen {
  max-width: 1180px;
  padding: 0 36px 56px;
}
.shell.bare .side {
  display: none;
}
.shell.bare .screen {
  margin: 0 auto;
}

@media (max-width: 760px) {
  .shell {
    flex-direction: column;
  }
  .side {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: auto;
    height: auto;
    z-index: 40;
    flex-direction: row;
    padding: 6px 6px calc(8px + env(safe-area-inset-bottom, 0px));
    border-right: 0;
    border-top: 1px solid var(--line);
    background: var(--paper);
  }
  .side .shop,
  .side .foot {
    display: none;
  }
  .side nav {
    display: flex;
    width: 100%;
  }
  .navitem {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    justify-content: center;
    padding: 6px 0;
  }
  .navitem[aria-current="page"] {
    background: transparent;
  }
  .screen {
    padding: 0 16px 96px;
  }
}

/* ───────────────────────────── header ───────────────────────────── */

.hdr {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--paper);
  padding: 16px 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
}
.hdr .back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  margin-left: -8px;
  color: var(--ink);
  flex: none;
}
.hdr .back:hover {
  background: var(--card);
}
.hdr h1 {
  font-size: 22px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hdr .act {
  font-weight: 600;
  color: var(--accent);
  padding: 6px 4px;
  white-space: nowrap;
}
.hdr .act:disabled {
  opacity: 0.4;
}
.hdr .menu {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 18px;
}
.hdr .menu:hover {
  background: var(--card);
}
.sub {
  color: var(--ink-2);
  margin: -6px 0 16px;
  font-size: 13px;
}
.hdr + .sub {
  margin-top: 0;
}

/* ───────────────────────────── controls ───────────────────────────── */

.btn,
button.primary,
button.quiet,
button.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  background: var(--card);
  border: 1px solid var(--line);
  min-height: 46px;
  color: var(--ink);
  text-decoration: none;
}
.btn:hover:not(:disabled),
button.quiet:hover:not(:disabled) {
  border-color: var(--ink-2);
}
.btn.primary,
button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn.primary:hover:not(:disabled),
button.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}
.btn.ghost,
button.quiet {
  background: transparent;
}
.btn.danger,
button.danger {
  color: var(--bad);
}
.btn.block {
  width: 100%;
}
.btn.sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 9px;
}
.btn:disabled,
button.primary:disabled,
button.quiet:disabled {
  opacity: 0.5;
}
.linkbtn {
  color: var(--accent);
  font-weight: 600;
}
.linkbtn:hover {
  text-decoration: underline;
}
.linkbtn.info {
  color: var(--info);
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
}
.seg button {
  padding: 6px 13px;
  font-size: 13px;
  color: var(--ink-2);
}
.seg button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chip {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 500;
  background: var(--card);
  font-size: 13px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.chip:hover {
  border-color: var(--ink-2);
}
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: transparent;
}
.chip .n {
  font-family: var(--mono);
  font-size: 11px;
  opacity: 0.75;
}

.stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  margin-top: 4px;
  height: 46px;
}
.stepper button {
  width: 46px;
  height: 100%;
  font-size: 20px;
  color: var(--accent);
}
.stepper button:disabled {
  opacity: 0.35;
}
.stepper b {
  flex: 1;
  text-align: center;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.stepper.sm {
  width: 120px;
  height: 38px;
  margin: 0;
}
.stepper.sm button {
  width: 38px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  margin: 0 0 14px;
}
.search input {
  border: 0;
  background: transparent;
  padding: 12px 0;
}
.search input:focus-visible {
  outline: none;
}
.search:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.search svg {
  width: 18px;
  height: 18px;
  color: var(--ink-2);
  flex: none;
}

/* ───────────────────────────── surfaces ───────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.card.tap {
  cursor: pointer;
  text-align: left;
  width: 100%;
  display: block;
}
.card.tap:hover {
  border-color: var(--ink-2);
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.row.between {
  justify-content: space-between;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.two {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 32px;
  align-items: start;
}
@media (max-width: 1000px) {
  .two {
    grid-template-columns: minmax(0, 1fr);
  }
}
.narrow {
  max-width: 560px;
}
.hint {
  background: var(--paper-2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-2);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.hint b {
  color: var(--ink);
}
.hint .ico {
  font-size: 16px;
  line-height: 1.2;
  flex: none;
}
.notice {
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  background: var(--paper-2);
  color: var(--ink);
}
.notice.error {
  background: color-mix(in srgb, var(--bad) 14%, var(--card));
  color: var(--bad);
}
.notice.stale {
  background: color-mix(in srgb, var(--cuts) 30%, var(--card));
}
.list {
  display: flex;
  flex-direction: column;
}
.li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  color: inherit;
}
.li:last-child {
  border-bottom: 0;
}
button.li:hover .t b,
a.li:hover .t b {
  color: var(--accent);
}
a.li:hover {
  text-decoration: none;
}
.li .t {
  flex: 1;
  min-width: 0;
}
.li .t b {
  display: block;
  font-weight: 600;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.li .t span {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.li .chev {
  color: var(--ink-2);
  flex: none;
}
.li .ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--paper-2);
  display: grid;
  place-items: center;
  flex: none;
  font-size: 15px;
}
.li .trail {
  max-width: 42%;
  flex: none;
}
.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  margin: 0;
}
.kv dt {
  color: var(--ink-2);
}
.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.badge.soft {
  background: transparent;
  border: 1px solid var(--line);
}
.badge.good {
  background: color-mix(in srgb, var(--checked) 16%, transparent);
  color: var(--checked);
}
.badge.bar {
  background: var(--barcode);
  color: #fff;
}
.badge.info {
  background: color-mix(in srgb, var(--info) 16%, transparent);
  color: var(--info);
}
.badge.bad {
  background: color-mix(in srgb, var(--bad) 16%, transparent);
  color: var(--bad);
}
.badge.warn {
  background: color-mix(in srgb, var(--cuts) 35%, transparent);
  color: var(--cuts-dark);
}
.badge.lent {
  background: color-mix(in srgb, var(--lent) 18%, transparent);
  color: var(--lent);
}
:root[data-theme="dark"] .badge.warn {
  color: var(--cuts);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.warn {
    color: var(--cuts);
  }
}

.prog {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}
.prog i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.4s linear;
}

/* A toast, the phone's floating snackbar. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 500;
  z-index: 90;
  box-shadow: var(--shadow);
  max-width: min(90vw, 640px);
  text-align: center;
  animation: up 0.25s ease;
}
@keyframes up {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
}

/* A sheet — on a desktop, a centred dialog. */
.sheet-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sheet {
  background: var(--card);
  width: min(440px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.sheet h2 {
  font-size: 20px;
  margin-bottom: 8px;
}
.sheet p {
  margin: 0 0 12px;
  color: var(--ink-2);
}
.sheet .opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 500;
  font-size: 15px;
}
.sheet .opt small {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-2);
}
.sheet .opt:hover {
  background: var(--paper);
}
.sheet .opt:last-of-type {
  border-bottom: 0;
}
.sheet .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* ───────────────────────────── map ─────────────────────────────
 * One bookcase, drawn on a canvas by `paint.js` from the phone's
 * `CellPainter`, with a transparent button over every cell for the pointer
 * and the keyboard. */

.casechips {
  margin-bottom: 14px;
}
.casehead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 8px;
}
.casehead h2 {
  font-size: 20px;
}
.casehead .muted {
  font-size: 12.5px;
}
.mapwrap {
  position: relative;
  margin: 0 auto;
}
.mapwrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.mapwrap .hit {
  position: absolute;
  border-radius: 3px;
  cursor: pointer;
}
.mapwrap .hit:hover,
.mapwrap .hit:focus-visible {
  outline: 2px solid var(--highlight);
  outline-offset: 1px;
  z-index: 2;
}
.mapwrap .hit.inert {
  cursor: default;
}
.mapwrap .hit.inert:hover {
  outline: 0;
}
.mapwrap .tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: var(--ink);
  color: var(--paper);
  font-size: 12.5px;
  line-height: 1.35;
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  max-width: 280px;
  transform: translate(-50%, calc(-100% - 10px));
  white-space: normal;
}
.mapwrap .tip b {
  display: block;
  font-family: var(--display);
  font-weight: 500;
  font-size: 14px;
}
.mapwrap.mini {
  cursor: pointer;
  margin: 0;
}
.maplegend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 14px;
}
.maplegend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.maplegend i {
  display: inline-block;
  width: 16px;
  height: 5px;
  border-radius: 1px;
}
.maplegend i.sq {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--wood-2);
  color: #fff;
  font-style: normal;
  font-size: 9px;
  line-height: 12px;
  text-align: center;
}
.sw-checked {
  background: var(--checked);
}
.sw-read {
  background: var(--read);
}
.sw-unread {
  background: var(--unread);
}
.sw-cuts {
  background: repeating-linear-gradient(
    90deg,
    var(--cuts) 0 3px,
    var(--cuts-dark) 3px 5px
  );
}
.statline {
  font-size: 13px;
  color: var(--ink-2);
}

/* ───────────────────────────── strip & spines ───────────────────────────── */

/* The row's own photograph, or a stretch of it. */
.shelfpic {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: var(--wood-2);
}
.shelfpic.pan {
  overflow-x: auto;
}
.shelfpic img {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
/* 1.2.0: every book is its OUTLINE, one SVG overlay in strip pixels. */
.shelfpic svg.ol {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
}
.shelfpic .rg {
  stroke: transparent;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}
.shelfpic .rg:not(.gap) {
  fill: transparent;
  cursor: pointer;
}
.shelfpic .rg:not(.gap):hover,
.shelfpic .rg:not(.gap):focus-visible {
  fill: rgba(255, 216, 107, 0.16);
  stroke: var(--highlight);
  outline: none;
}
.shelfpic .rg.hl {
  fill: rgba(255, 216, 107, 0.14);
  stroke: var(--highlight);
  stroke-width: 3px;
}
.shelfpic .rg.faded {
  fill: rgba(26, 23, 19, 0.55);
  stroke: rgba(255, 216, 107, 0.7);
  stroke-dasharray: 5 4;
}
.shelfpic .rg.lent {
  fill: rgba(26, 23, 19, 0.45);
  stroke: var(--lent);
}
.shelfpic .rg.hidden {
  stroke: rgba(255, 255, 255, 0.55);
  stroke-dasharray: 2 3;
}
.shelfpic .rg.gap {
  cursor: default;
}
.shelfpic .mk.pin {
  position: absolute;
  transform: translateX(-50%);
  pointer-events: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
  color: #fff;
  border: 2px solid rgba(20, 16, 12, 0.85);
}
.mk.read {
  background: transparent;
  border-color: var(--read) !important;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4);
}
.mk.checked {
  background: var(--checked);
}
.mk.barcode {
  background: var(--barcode);
}
.mk.unread {
  background: var(--unread);
  color: #1a1208 !important;
}
.shelfpic .slot {
  position: absolute;
  top: 6%;
  bottom: 6%;
  border: 2px dashed var(--highlight);
  border-radius: 3px;
  background: rgba(255, 216, 107, 0.08);
  pointer-events: none;
}
.shelfpic .caption {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 6px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}
.shelfpic.empty {
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  text-align: center;
  padding: 18px;
  min-height: 120px;
}

/* Spines on a board — drawn only when every book on the row has a box. */
.board {
  position: relative;
  border-radius: 8px;
  background: linear-gradient(180deg, #3a2f28 0, #2c241f 100%);
  box-shadow: inset 0 -14px 20px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.board::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 9px;
  background: #5b4636;
  border-top: 1px solid #7a6049;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 10px;
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.legend i.ring {
  border: 2px solid var(--read);
}

/* The book's own spine, in a list or a card. */
.minispine {
  width: 30px;
  height: 44px;
  border-radius: 4px;
  background: var(--wood-2);
  flex: none;
  overflow: hidden;
  position: relative;
}
.minispine img {
  position: absolute;
  height: 100%;
  max-width: none;
}
.minispine.plain {
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
}

/* Where it stands: the crop, one neighbour each side. */
.wherecard {
  display: flex;
  gap: 16px;
  align-items: stretch;
}
.wherecard .crop {
  flex: none;
  cursor: zoom-in;
  width: 46%;
  max-width: 280px;
}
.wherecard .place {
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.25;
  margin: 4px 0 8px;
}

/* Full screen spine. */
.zoom {
  position: fixed;
  inset: 0;
  background: rgba(11, 10, 9, 0.94);
  z-index: 85;
  display: flex;
  flex-direction: column;
}
.zoom .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  color: #fff;
  font-weight: 600;
}
.zoom .topbar button {
  color: #fff;
}
.zoom .pane {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.zoom .pane canvas,
.zoom .pane img {
  max-height: 72vh;
  max-width: 92vw;
  cursor: zoom-out;
}
.zoom .hintline {
  color: #aaa;
  font-size: 12px;
  text-align: center;
  padding: 0 16px 16px;
}

/* ───────────────────────────── cut check ───────────────────────────── */

.cutpane {
  position: relative;
  overflow-x: auto;
  border-radius: 8px;
  background: #1b1714;
  user-select: none;
  touch-action: pan-x;
}
.cutpane .inner {
  position: relative;
}
.cutpane img {
  display: block;
  height: 100%;
  pointer-events: none;
}
/* 1.2.0: the item editor draws outlines in one SVG, in strip pixels. */
.cutpane svg.ol {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
}
/* Every outline a bright line over a dark halo, tinted cyan / pink in turn
   (the phone's item_canvas.dart: lerp(tint, white, 0.35)); a book nothing has
   read yet is filled with its tint at 16% so overlapping boxes show. */
.cutpane .halo {
  fill: none;
  stroke: rgba(0, 0, 0, 0.55);
  stroke-width: 3.5px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  pointer-events: none;
}
.cutpane .halo.dashed,
.cutpane .it.hidden,
.cutpane .it.behind,
.cutpane .it.reserved {
  stroke-dasharray: 6 4;
}
.cutpane .it {
  stroke: #8be0ec;
  stroke-width: 1.8px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  pointer-events: none;
}
.cutpane .it.t1 {
  stroke: #f599b8;
}
.cutpane .it.reserved {
  stroke: #b9cde4;
}
.cutpane .it.book {
  fill: transparent;
}
.cutpane .it.book.unread.t0 {
  fill: rgba(77, 208, 225, 0.16);
}
.cutpane .it.book.unread.t1 {
  fill: rgba(240, 98, 146, 0.16);
}
.cutpane rect.it.gap {
  stroke: none;
}
.cutpane .it.behind {
  opacity: 0.6;
}
.cutpane .it.stacked {
  stroke: var(--read);
}
.cutpane .it.sel {
  fill: rgba(255, 216, 107, 0.28);
  stroke: var(--highlight);
  stroke-width: 3px;
}
.cutpane .n {
  position: absolute;
  transform: translateX(-50%);
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 0 6px;
  border-radius: 999px;
  font-family: var(--mono);
  pointer-events: none;
  z-index: 1;
}
.cutpane .edge {
  cursor: ew-resize;
  outline: none;
}
.cutpane .edge .hit {
  stroke: transparent;
}
.cutpane .edge .halo {
  stroke: rgba(0, 0, 0, 0.6);
  stroke-width: 4px;
}
.cutpane .edge .line {
  stroke: #fff;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}
.cutpane .edge .knob {
  fill: #fff;
}
.cutpane .edge:hover .halo,
.cutpane .edge:focus-visible .halo,
.cutpane .edge.sel .halo {
  stroke-width: 5.5px;
}
.cutpane .edge:hover .line,
.cutpane .edge:focus-visible .line,
.cutpane .edge.sel .line {
  stroke: var(--highlight);
  stroke-width: 3.5px;
}
.cutpane .edge:hover .knob,
.cutpane .edge:focus-visible .knob,
.cutpane .edge.sel .knob {
  fill: var(--highlight);
}
.cutpane .corner {
  fill: #fff;
  stroke: #1a1208;
  stroke-width: 1.5px;
  vector-effect: non-scaling-stroke;
  cursor: move;
  outline: none;
}
.cutpane .corner:hover,
.cutpane .corner:focus-visible,
.cutpane .corner.sel {
  fill: var(--highlight);
}
.cutpane .veil {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 2;
}
.cutpane .endmark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  margin-left: -9px;
  z-index: 4;
  cursor: ew-resize;
}
.cutpane .endmark::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 3px;
  transform: translateX(-50%);
  background: var(--highlight);
}
.cutpane .endmark span {
  position: absolute;
  top: 6px;
  font-size: 10px;
  font-family: var(--mono);
  color: #1a1208;
  background: var(--highlight);
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
}
.cutpane .endmark.start span {
  left: 12px;
}
.cutpane .endmark.end span {
  right: 12px;
}
.cutpanel {
  margin-top: 12px;
  min-height: 92px;
}
.zoombar {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ───────────────────────────── review cards ───────────────────────────── */

.rv {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.rv .thumb {
  height: 120px;
  border-radius: 6px;
  background: #2c241f;
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
}
.rv .thumb.none {
  background: var(--paper-2);
  border: 1px dashed var(--line);
  cursor: default;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  font-size: 10.5px;
  text-align: center;
  line-height: 1.25;
  padding: 4px;
}
.rv h3 {
  font-size: 16px;
}
.rv .acts {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.rv.done {
  opacity: 0.6;
}
.rvgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 12px;
}
.changes .li {
  align-items: flex-start;
}
.changes .ico {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-weight: 700;
}

.hist {
  border-left: 2px solid var(--line);
  padding-left: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-left: 6px;
}
.hist .h {
  position: relative;
}
.hist .h::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
}
.hist .h.now::before {
  background: var(--accent);
}
.hist .when {
  font-size: 12px;
  color: var(--ink-2);
  font-family: var(--mono);
}
.hist .h.now .when {
  color: var(--accent);
}

/* ───────────────────────────── welcome, mode ───────────────────────────── */

.welcome {
  padding-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 560px;
}
.welcome .steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.welcome .step {
  display: flex;
  gap: 12px;
}
.welcome .step i {
  font-style: normal;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--paper-2);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 12px;
  flex: none;
}
.modepick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modepick button {
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 18px 16px;
  text-align: left;
  background: var(--card);
}
.modepick button[aria-pressed="true"] {
  border: 2px solid var(--accent);
  padding: 17.5px 15.5px;
}
.modepick b {
  display: block;
  font-family: var(--display);
  font-weight: 500;
  font-size: 18px;
  margin-bottom: 4px;
}
.modepick span {
  font-size: 13px;
  color: var(--ink-2);
}

.account {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.account .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--paper-2);
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 18px;
  flex: none;
}
.set .eyebrow {
  margin-top: 18px;
}

/* ───────────────────────────── layout editors ───────────────────────────── */

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.swatches button {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}
.swatches button[aria-pressed="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.lay {
  position: relative;
  border-radius: 10px;
  touch-action: none;
  user-select: none;
  overflow: hidden;
  max-width: 100%;
}
.lay .cellbox {
  position: absolute;
  border-radius: 3px;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
}
.lay .cellbox.gap {
  background: var(--paper) !important;
  color: transparent;
}
.lay .hz,
.lay .vt {
  position: absolute;
  z-index: 3;
  cursor: row-resize;
}
.lay .vt {
  cursor: col-resize;
}
.lay .hz::before,
.lay .vt::before {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}
.lay .hz::before {
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
}
.lay .vt::before {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  transform: translateX(-50%);
}
.lay .hz:hover::before,
.lay .vt:hover::before {
  background: rgba(255, 216, 107, 0.7);
}
.lay .sel::before {
  background: var(--highlight) !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 0 8px var(--highlight);
}
.lay .hz.sel::after,
.lay .vt.sel::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--highlight);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.lay .guide {
  position: absolute;
  height: 0;
  border-top: 1px dashed var(--highlight);
  z-index: 4;
  pointer-events: none;
}
.lay .addb {
  position: absolute;
  z-index: 3;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 16px;
  line-height: 24px;
  text-align: center;
}
.lay .addb:hover {
  background: var(--highlight);
  color: #111;
}
.laytool {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  min-height: 40px;
  margin-top: 10px;
}
.laytool .what {
  font-weight: 600;
  margin-right: auto;
}

/* ───────────────────────────── sign in, legal ─────────────────────────────
 * The screens a stranger can reach (auth.js, carried over from the old app
 * with its words unchanged). Plain class names, styled here. */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.login > .card,
.login > form {
  width: min(440px, 100%);
  padding: 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.login h1 {
  font-size: 28px;
}
.login .sub {
  margin: 0;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.field.kinds {
  gap: 8px;
}
.radio {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  color: var(--ink);
  font-weight: 400;
}
.radio input {
  margin-top: 3px;
}
.privacy {
  font-size: 13px;
  color: var(--ink-2);
}
.privacy summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}
.privacy-body p {
  margin: 8px 0;
}
.prose {
  max-width: 720px;
  padding: 28px 0 56px;
}
.prose h1 {
  font-size: 30px;
  margin-bottom: 10px;
}
.prose h2 {
  font-size: 19px;
  margin: 26px 0 8px;
}
.prose p,
.prose li {
  line-height: 1.6;
}
.prose li {
  margin-bottom: 6px;
}
.shell.bare .prose {
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
