/* Shared structure. Themes (theme-*.css) own type, palette, density and their one signature move. */

/* Values that follow the pointer are registered as non-inherited: they are read
   by the element they are set on, and its children (a thousand covers in the
   side panel) are not restyled every time the pointer moves. */
@property --glow {
  syntax: '<color>';
  inherits: false;
  initial-value: transparent;
}

@property --gx {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 30%;
}

@property --gy {
  syntax: '<percentage>';
  inherits: false;
  initial-value: 10%;
}

@property --mx {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: -600px;
}

@property --my {
  syntax: '<length-percentage>';
  inherits: false;
  initial-value: -600px;
}

:root {
  --bg: #111;
  --bg-2: #181818;
  --bg-3: #222;
  --cover-fallback: linear-gradient(160deg, var(--bg-3), var(--bg-2));
  --bar: #0c0c0c;
  --ink: #f2f2f2;
  --ink-2: #c4c4c4;
  --ink-3: #9a9a9a;
  --line: rgba(255, 255, 255, 0.1);
  --line-2: rgba(255, 255, 255, 0.2);
  --accent: #ffd23f;
  --accent-ink: #111;
  --focus: #ffd23f;
  --sel: #ffd23f;
  --match: #7fd3ff;
  --danger: #ff6b5e;
  --ok: #5fe3a1;
  --font-ui: system-ui, sans-serif;
  --font-display: var(--font-ui);
  --font-label: var(--font-ui);
  --r-1: 7px;
  --r-2: 11px;
  --r-3: 16px;
  --tile-r: 3px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-2: 0 18px 40px rgba(0, 0, 0, 0.5), 0 3px 8px rgba(0, 0, 0, 0.35);
  --topbar-h: 68px;
  --btn-h: 46px;
  --cart-w: clamp(300px, 27vw, 470px);
  --label-w: 112px;
  --tw: 112px;
  --th: 168px;
  --ease: cubic-bezier(0.2, 0.75, 0.2, 1);
  --toast-bg: #f2f2f2;
  --toast-ink: #111;
  --tip-bg: #f2f2f2;
  --tip-ink: #111;
  --menu-bg: var(--bg-3);
  --field: rgba(0, 0, 0, 0.25);
  --deck-bg: #000;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  caret-color: var(--accent);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

::selection {
  background: var(--accent);
  color: var(--accent-ink);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-2) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 10px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 5px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  color: var(--ink-2);
  font: 700 11px/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- icons and buttons ---------- */

.i {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: none;
}

.i svg {
  width: 100%;
  height: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: var(--btn-h);
  padding: 0 19px;
  border-radius: var(--r-1);
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  color: var(--ink);
  font-weight: 650;
  font-size: 15.5px;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}

.btn:hover {
  background: color-mix(in srgb, var(--bg-3), var(--ink) 9%);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.38;
  cursor: default;
  transform: none;
}

.btn:disabled:hover {
  background: var(--bg-3);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.btn.primary:hover {
  background: color-mix(in srgb, var(--accent), white 14%);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}

.btn.ghost:hover {
  background: color-mix(in srgb, transparent, var(--ink) 10%);
}

.btn.danger {
  color: var(--danger);
}

.btn.icon-only {
  width: var(--btn-h);
  padding: 0;
  background: transparent;
  border-color: transparent;
}

.btn.icon-only:hover {
  background: color-mix(in srgb, transparent, var(--ink) 11%);
}

.btn.icon-only:disabled:hover {
  background: transparent;
}

.btn kbd {
  height: 18px;
  min-width: 18px;
  margin-right: -4px;
  font-size: 10.5px;
  opacity: 0.8;
}

.btn.primary kbd {
  color: inherit;
  border-color: currentColor;
  opacity: 0.55;
}

.btn.push-left {
  margin-right: auto;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- top bar ---------- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px 0 10px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 6;
}

.tb-left,
.tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tb-group {
  display: flex;
  gap: 2px;
  padding-right: 6px;
  margin-right: 2px;
  border-right: 1px solid var(--line);
}

.title-wrap {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.list-title {
  font: 800 20px/1.2 var(--font-display);
  background: none;
  border: 0;
  padding: 6px 8px;
  border-radius: var(--r-1);
  max-width: 34vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.list-title:hover {
  background: color-mix(in srgb, transparent, var(--ink) 8%);
}

.title-input {
  font: 800 20px/1.2 var(--font-display);
  width: min(34vw, 420px);
  padding: 5px 8px;
  border-radius: var(--r-1);
  border: 0;
  outline: 2px solid var(--focus);
  background: var(--field);
}

.save-status {
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

.save-status[data-state='error'] {
  color: var(--danger);
}

.status-retry {
  border: 0;
  background: none;
  padding: 0;
  color: var(--danger);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.wordmark {
  font: 900 28px/1 var(--font-display);
  letter-spacing: -0.01em;
  padding-left: 8px;
  white-space: nowrap;
}

.wordmark b {
  color: var(--accent);
  font-weight: inherit;
}

/* ---------- editor layout ---------- */

.editor {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  position: relative;
}

.ed-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7px var(--cart-w);
  min-height: 0;
}

.board {
  overflow: auto;
  min-height: 0;
  padding: 26px 28px 140px;
  overscroll-behavior: contain;
}

.tiers {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tier {
  display: grid;
  grid-template-columns: var(--label-w) minmax(0, 1fr);
  position: relative;
}

.talker {
  grid-row: 1;
  grid-column: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.talker-letter {
  border: 0;
  background: none;
  color: inherit;
  padding: 2px 4px;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
  border-radius: 4px;
}

.talker-letter.is-editing {
  width: 100%;
}

.tier-input {
  width: 100%;
  min-width: 0;
  padding: 6px;
  border: 0;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font: 800 22px/1.1 var(--font-label);
  text-align: center;
  outline: 2px solid var(--focus);
}

.spine,
.shade {
  display: none;
}

/* the book wrapper only gains depth in Aurora's rooms of objects */
.book {
  position: relative;
}

.pool {
  position: relative;
}

.talker-more {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 38px;
  height: 38px;
  opacity: 0;
  transition: opacity 0.15s;
}

.tier:hover .talker-more,
.talker-more:focus-visible,
.talker-more[aria-expanded='true'] {
  opacity: 0.85;
}

.tier-drop {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  gap: 16px 12px;
  padding: 14px 16px;
  min-height: calc(var(--th) * var(--k, 1) + 30px);
  min-width: 0;
}

.add-tier {
  margin-top: 22px;
  color: var(--ink-2);
}

.splitter {
  cursor: col-resize;
  background: transparent;
  position: relative;
}

.splitter::after {
  content: '';
  position: absolute;
  inset: 0 3px;
  background: var(--line);
  transition: background-color 0.15s;
}

.splitter:hover::after,
.splitter:focus-visible::after {
  background: var(--accent);
}

/* ---------- unranked cart ---------- */

.cart {
  --k: 0.84;
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  background: var(--bg-2);
}

.cart-head {
  display: grid;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.cart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.cart-title h2 {
  font: 800 22px/1 var(--font-display);
}

.pool-count {
  font-size: 13px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  height: 50px;
  border-radius: var(--r-1);
  background: var(--field);
  border: 1px solid var(--line-2);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
}

.search > .i {
  margin: 0 8px 0 12px;
  color: var(--ink-3);
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: none;
  outline: none;
  font-size: 15px;
}

.search-input::placeholder {
  color: var(--ink-3);
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  width: 32px;
  height: 32px;
  margin-right: 4px;
  display: none;
}

.is-searching .search-clear {
  display: inline-flex;
}

.search-kbd {
  margin-right: 10px;
}

.is-searching .search-kbd,
.search:focus-within .search-kbd {
  display: none;
}

.cart-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-3);
}

.sort {
  height: 38px;
  padding: 0 28px 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") right 8px center / 14px no-repeat;
  appearance: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.sort option {
  background: var(--bg-3);
  color: var(--ink);
}

.pool {
  overflow: auto;
  min-height: 0;
  padding: 14px 14px 30px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 14px 10px;
}

.pool-empty {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 46%;
  transform: translateY(-50%);
  display: grid;
  justify-items: start;
  gap: 8px;
  color: var(--ink-2);
  font-size: 14px;
  pointer-events: none;
}

.pool-empty > * {
  pointer-events: auto;
}

.pool-empty .btn {
  margin-top: 8px;
}

.pool-empty-title {
  font: 800 22px/1.15 var(--font-display);
  color: var(--ink);
}

.cart-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
}

.cart-hint {
  font-size: 12.5px;
  color: var(--ink-3);
}

.cover-note {
  flex-basis: 100%;
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
}

.cover-note:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
}

.cover-bar {
  flex-basis: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

.cover-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
  transition: transform 0.4s var(--ease);
}

/* ---------- items ---------- */

.item {
  position: relative;
  flex: none;
  width: calc(var(--tw) * var(--k, 1));
  border-radius: var(--tile-r);
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.item[hidden] {
  display: none;
}

.cov {
  position: relative;
  width: 100%;
  height: calc(var(--th) * var(--k, 1));
  border-radius: var(--tile-r);
  overflow: hidden;
  background: #0006;
  isolation: isolate;
}

.cov img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 1;
}

.cov.is-loaded img {
  opacity: 1;
}

.cov.fit-contain::before {
  content: '';
  position: absolute;
  inset: -14%;
  z-index: 1;
  background: var(--bg) center / cover no-repeat;
  filter: blur(14px) saturate(1.2) brightness(0.5);
}

.cov.fit-contain img {
  object-fit: contain;
  object-position: 50% 50%;
  z-index: 1;
}

.cov.has-bg {
  background:
    radial-gradient(120% 85% at 50% 15%, color-mix(in oklab, var(--tile-bg) 62%, #fff) 0%, var(--tile-bg) 52%, color-mix(in oklab, var(--tile-bg) 60%, #000) 100%);
}

.cov.has-bg img {
  object-fit: contain;
  object-position: 50% 100%;
}

.cov.has-bg.fit-contain::before {
  display: none;
}

.cov-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  padding: 9% 9% 8%;
  background: var(--cover-fallback);
  color: var(--ink);
}

.cov.is-shown .cov-text {
  visibility: hidden;
}

/* Hidden tabs and reduced motion may never emit transitionend. */
.cov.is-loaded .cov-text { opacity: 0; }

.cov-text b {
  font: 800 calc(var(--tw) * var(--k, 1) * 0.15) / 1.02 var(--font-label);
  text-transform: uppercase;
  overflow-wrap: break-word;
  hyphens: auto;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cov-text i {
  font-style: normal;
  font-weight: 700;
  font-size: calc(var(--tw) * var(--k, 1) * 0.1);
  opacity: 0.7;
}

.cap {
  display: none;
}

[data-captions='always'] .cap {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 7px;
  font-size: 12.5px;
  line-height: 1.25;
  text-align: center;
  color: var(--ink-2);
}

[data-captions='always'] .cap-n {
  display: none;
}

[data-captions='hover'] .cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 6px;
  padding: 22px 7px 6px;
  border-radius: 0 0 var(--tile-r) var(--tile-r);
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.88) 55%);
  color: #fff;
  font-size: 12px;
  line-height: 1.2;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

[data-captions='hover'] .item:hover .cap,
[data-captions='hover'] .item:focus-visible .cap,
[data-captions='hover'] .item.is-selected .cap,
[data-captions='hover'] .item.is-match .cap {
  opacity: 1;
}

.cap-name {
  overflow: hidden;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.cap-n {
  flex: none;
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

.item.is-selected .cov {
  outline: 3px solid var(--sel);
  outline-offset: 2px;
}

.item.is-selected::before {
  content: '';
  position: absolute;
  top: -7px;
  right: -7px;
  z-index: 4;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--sel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / 13px no-repeat;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.item:focus-visible .cov {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.item.is-match .cov {
  outline: 3px solid var(--match);
  outline-offset: 2px;
}

.item.is-dim {
  opacity: 0.2;
  filter: grayscale(0.85);
}

.item.is-placeholder {
  cursor: grabbing;
}

.item.is-placeholder > * {
  opacity: 0;
}

.item.is-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--tile-r);
  border: 2px dashed var(--line-2);
  background: color-mix(in srgb, transparent, var(--ink) 5%);
}

.item.is-carried {
  display: none;
}

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  pointer-events: none;
  border-radius: var(--tile-r);
  box-shadow: 0 26px 40px -10px rgba(0, 0, 0, 0.7), 0 6px 12px rgba(0, 0, 0, 0.4);
  will-change: transform;
}

.drag-ghost .book,
.drag-ghost .cov {
  width: 100%;
  height: 100%;
  border-radius: var(--tile-r);
}

.drag-ghost.is-stack::before,
.drag-ghost.is-stack::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--tile-r);
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  z-index: -1;
  transform: rotate(5deg) translate(6px, 2px);
}

.drag-ghost.is-stack::after {
  transform: rotate(-4deg) translate(-5px, 3px);
}

.drag-ghost.is-landing {
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

.drag-count {
  position: absolute;
  top: -11px;
  right: -11px;
  z-index: 3;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

/* While a cover is carried, one invisible sheet over the window holds the
   grabbing cursor and keeps hover effects asleep. (A rule on every element
   under body.is-dragging would restyle the whole page at each pick-up.) */
.drag-shield {
  position: fixed;
  inset: 0;
  z-index: 99;
  cursor: grabbing;
}

.item.just-dropped {
  animation: settle 0.34s var(--ease);
}

@keyframes settle {
  0% {
    transform: scale(1.06);
  }
  100% {
    transform: none;
  }
}

.is-file-drag .tier.is-file-target,
.is-file-drag .cart.is-file-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* ---------- selection bar ---------- */

.selbar {
  position: absolute;
  left: calc((100% - var(--cart-w)) / 2);
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px 7px 14px;
  max-width: calc(100% - var(--cart-w) - 40px);
  background: var(--menu-bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-2);
  animation: rise 0.2s var(--ease);
}

.selbar[hidden] {
  display: none;
}

.selbar-count {
  font-weight: 750;
  font-size: 14px;
  margin-right: 6px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.selbar-tiers {
  display: flex;
  gap: 4px;
  padding-right: 6px;
  margin-right: 2px;
  border-right: 1px solid var(--line);
  overflow-x: auto;
}

.selbar-tier {
  min-width: 42px;
  height: 42px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-1);
  background: var(--tc);
  color: var(--tc-ink);
  font: 900 16px/1 var(--font-label);
  transition: transform 0.12s;
}

.selbar-tier:hover {
  transform: translateY(-2px);
}

.selbar .btn {
  height: 42px;
  padding: 0 14px;
}

.selbar .btn.icon-only {
  width: 42px;
  padding: 0;
}

@keyframes rise {
  from {
    transform: translate(-50%, 12px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* ---------- menus ---------- */

.menu {
  position: fixed;
  z-index: 200;
  min-width: 230px;
  max-width: 340px;
  max-height: calc(100vh - 16px);
  overflow: auto;
  padding: 6px;
  background: var(--menu-bg);
  border: 1px solid var(--line-2);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-2);
  outline: none;
  animation: pop 0.14s var(--ease);
}

/* a menu taller than its space scrolls inside; its foot fades while there is more */
.menu.has-more {
  -webkit-mask-image: linear-gradient(#000 calc(100% - 34px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 34px), transparent);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--r-1);
  background: none;
  text-align: left;
  font-size: 15px;
  line-height: 1.25;
}

.menu-item:hover:not(:disabled),
.menu-item:focus-visible {
  background: color-mix(in srgb, transparent, var(--ink) 10%);
  outline: none;
}

.menu-item:disabled {
  opacity: 0.4;
  cursor: default;
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item .i {
  color: var(--ink-3);
}

.menu-item.danger .i {
  color: inherit;
}

.menu-label {
  flex: 1;
  min-width: 0;
}

.menu-label small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-3);
}

.menu-item kbd {
  margin-left: auto;
}

.menu-check {
  color: var(--accent) !important;
}

.menu-heading {
  padding: 9px 10px 4px;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.menu-sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--line);
}

.menu-swatch {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 5px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.theme-menu .menu-swatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.menu-foot {
  padding: 8px 10px 6px;
  font-size: 12px;
  color: var(--ink-3);
}

.swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  padding: 4px 8px 10px;
}

.swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 7px;
  border: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  transition: transform 0.12s;
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch[aria-pressed='true'] {
  box-shadow: 0 0 0 2px var(--menu-bg), 0 0 0 4px var(--ink);
}

.swatch-custom {
  display: grid;
  place-items: center;
  background: var(--bg-2);
  color: var(--ink-2);
  cursor: pointer;
}

.swatch-custom input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ---------- dialogs and forms ---------- */

.dialog {
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r-3);
  background: var(--bg-2);
  color: var(--ink);
  box-shadow: var(--shadow-2);
}

.dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dialog-in 0.2s var(--ease);
}

.dialog.wide {
  width: min(980px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

/* A title sheet whose cover flies in from its card comes in by fading only: a
   transform on the dialog would become the box the flying copy is placed in. The
   :root keeps these above a theme's own opening. */
:root .dialog[open].is-fly-in {
  animation: dialog-fade 0.2s var(--ease);
}

.dialog.is-flying {
  overflow: visible;
}

@keyframes dialog-fade {
  from {
    opacity: 0;
  }
}

/* Every dialog leaves with a short fade. The dialog itself is closed at once (no
   [open]); the closed element stays a moment as a picture of itself, centred and
   out of reach, with a scrim for the backdrop's colour. */
:root .dialog.is-leaving {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  margin: auto;
  box-sizing: border-box;
  z-index: 250;
  pointer-events: none;
  animation: dialog-out 0.16s var(--ease) forwards;
}

.dialog-scrim.is-leaving {
  position: fixed;
  inset: 0;
  z-index: 249;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.62);
  animation: backdrop-out 0.16s var(--ease) forwards;
}

.dialog-scrim.is-leaving.deck {
  background: rgba(0, 0, 0, 0.6);
}

/* the backdrop of the themes that dress it (their own sheets style `dialog::backdrop`, which a scrim is not) */
[data-theme='aurora'] .dialog-scrim.is-leaving {
  background: var(--veil);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
}

[data-theme='aurora'] .dialog-scrim.is-leaving.deck {
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(38px) saturate(0.35);
  backdrop-filter: blur(38px) saturate(0.35);
}

@keyframes dialog-out {
  to {
    opacity: 0;
    transform: translateY(6px) scale(0.99);
  }
}

@keyframes backdrop-out {
  to {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root .dialog.is-leaving,
  .dialog-scrim.is-leaving {
    display: none;
  }

  :root .dialog[open].is-fly-in {
    animation: none;
  }
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 14px 6px 24px;
}

.dialog-head h2 {
  font: 800 22px/1.2 var(--font-display);
}

.dialog-body {
  padding: 10px 24px 20px;
  overflow: auto;
  min-height: 0;
}

.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
}

/* On a narrow screen the action that stands apart on the left ("Remove item") takes a row of its own under the
   others: beside them it ran off the edge of the dialog, its first letters cut away. */
@media (max-width: 520px) {
  .dialog-foot .btn.push-left {
    order: 2;
    flex-basis: 100%;
    justify-content: flex-start;
    margin-right: 0;
  }
}

/* a hint in a field that does not fit ends in an ellipsis instead of at the field's edge */
input {
  text-overflow: ellipsis;
}

.confirm p {
  color: var(--ink-2);
  max-width: 60ch;
}

.form {
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  gap: 7px;
}

.form-pair {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
}

.form-label {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.field {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--r-1);
  border: 1px solid var(--line-2);
  background: var(--field);
  font-size: 15px;
}

textarea.field {
  height: auto;
  padding: 10px 12px;
  line-height: 1.45;
  resize: vertical;
}

.field:focus {
  outline: 2px solid var(--focus);
  outline-offset: -1px;
  border-color: transparent;
}

.field::placeholder {
  color: var(--ink-3);
}

.hint {
  font-size: 13px;
  color: var(--ink-3);
  max-width: 70ch;
}

.hint.error,
.lib-error {
  color: var(--danger);
}

.form-hint {
  font-size: 13px;
  color: var(--ink-3);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--r-1);
  background: var(--field);
  border: 1px solid var(--line);
  width: max-content;
}

.segmented button {
  height: 40px;
  padding: 0 15px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--ink-2);
  font-weight: 650;
  font-size: 13.5px;
}

.segmented button[aria-checked='true'] {
  background: var(--accent);
  color: var(--accent-ink);
}

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 38px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: var(--line-2);
  transition: background-color 0.18s;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s var(--ease);
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track .switch-thumb {
  transform: translateX(16px);
  background: var(--accent-ink);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.switch-text {
  display: grid;
  font-size: 14px;
  font-weight: 600;
}

.switch-text small {
  font-weight: 500;
  font-size: 12px;
  color: var(--ink-3);
}

.shape-pick {
  display: flex;
  gap: 10px;
}

.shape {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: 92px;
  padding: 12px 8px 10px;
  border-radius: var(--r-2);
  border: 1px solid var(--line-2);
  background: var(--field);
  font-weight: 650;
  font-size: 13px;
  color: var(--ink-2);
}

.shape[aria-checked='true'] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: var(--ink);
}

.shape-box {
  height: 48px;
  aspect-ratio: 2 / 3;
  border-radius: 3px;
  background: var(--ink-3);
}

.shape[data-aspect='square'] .shape-box {
  aspect-ratio: 1;
}

.shape[data-aspect='wide'] .shape-box {
  height: 30px;
  margin: 9px 0;
  aspect-ratio: 16 / 9;
}

.shape[aria-checked='true'] .shape-box {
  background: var(--accent);
}

/* add items */

.tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  padding: 10px 14px 11px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-3);
  font-weight: 700;
  font-size: 14px;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected='true'] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.add-dialog .dialog-body {
  min-height: 420px;
}

.add-count {
  margin-right: auto;
  font-size: 13.5px;
  color: var(--ok);
  font-weight: 650;
}

.wiki-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.wiki-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
  padding: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-3);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.wiki-card:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
}

.wiki-thumb {
  aspect-ratio: 3 / 4;
  background: #0008;
}

.wiki-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.wiki-text {
  display: grid;
  gap: 3px;
  padding: 9px 10px 11px;
}

.wiki-text b {
  font-size: 13.5px;
  line-height: 1.25;
}

.wiki-text small {
  font-size: 12px;
  line-height: 1.3;
  color: var(--ink-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wiki-add {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.wiki-card.is-added .wiki-add {
  background: var(--ok);
  color: #0b1a10;
}

.wiki-card.is-busy {
  opacity: 0.55;
  pointer-events: none;
}

.dropzone {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 56px 24px;
  border: 2px dashed var(--line-2);
  border-radius: var(--r-3);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--accent);
  background: color-mix(in srgb, transparent, var(--ink) 4%);
}

.dropzone .i {
  width: 40px;
  height: 40px;
  color: var(--ink-3);
}

.dropzone-title {
  font: 800 22px/1.2 var(--font-display);
}

/* item editor */

.edit {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 26px;
}

.edit-left {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 10px;
}

.edit-preview {
  display: grid;
  place-items: center;
  min-height: 160px;
}

.edit-preview .item {
  cursor: default;
}

.edit-where {
  font-size: 13px;
  color: var(--ink-3);
}

.edit-right {
  display: grid;
  gap: 16px;
  align-content: start;
}

.edit-pic-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-wiki {
  display: grid;
  gap: 10px;
}

.edit-wiki-results {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.edit-wiki-pick {
  flex: none;
  width: 84px;
  height: 116px;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  overflow: hidden;
  background: #0008;
}

.edit-wiki-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.edit-wiki-pick:hover {
  outline: 2px solid var(--accent);
}

.edit-wiki-pick.is-busy {
  opacity: 0.5;
}

.edit-link {
  display: flex;
  gap: 8px;
}

/* export */

.export {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
}

.export-stage {
  min-height: 320px;
  max-height: min(66vh, 760px);
  overflow: auto;
  padding: 14px;
  border-radius: var(--r-2);
  background: var(--field);
  display: grid;
  place-items: start center;
  transition: opacity 0.2s;
}

.export-stage.is-busy {
  opacity: 0.6;
}

.export-canvas {
  width: 100%;
  height: auto;
  border-radius: 3px;
  box-shadow: var(--shadow-1);
}

.export-side {
  display: grid;
  align-content: start;
  gap: 18px;
}

.export-dims {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.export-toggles {
  display: grid;
  gap: 12px;
}

.export-actions {
  display: grid;
  gap: 8px;
}

.export-actions .btn {
  height: 44px;
  font-size: 15px;
}

.btn.is-done {
  background: var(--ok);
  color: #0b1a10;
}

/* shortcuts */

.keys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
  gap: 22px 32px;
}

.keys h3 {
  font: 800 16px/1.2 var(--font-display);
  margin-bottom: 10px;
  color: var(--accent);
}

.keys dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 9px 16px;
  align-items: center;
}

.keys dt {
  display: flex;
  gap: 4px;
  align-items: center;
}

.keys dd {
  font-size: 14px;
  color: var(--ink-2);
}

.kdash {
  color: var(--ink-3);
}

/* ---------- toasts and tooltips ---------- */

#toasts {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 300;
  display: grid;
  gap: 8px;
  justify-items: start;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(520px, calc(100vw - 44px));
  padding: 9px 8px 9px 16px;
  border-radius: var(--r-2);
  background: var(--toast-bg);
  color: var(--toast-ink);
  box-shadow: var(--shadow-2);
  font-weight: 650;
  font-size: 14px;
  animation: toast-in 0.22s var(--ease);
}

.toast.error {
  background: var(--danger);
  color: #fff;
}

.toast.is-leaving {
  animation: toast-out 0.2s forwards;
}

.toast-action {
  border: 0;
  background: none;
  padding: 4px 2px;
  color: inherit;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.toast-x {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  opacity: 0.6;
}

.toast-x .i {
  width: 16px;
  height: 16px;
}

.toast-x:hover {
  opacity: 1;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

.tooltip {
  position: fixed;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--tip-bg);
  color: var(--tip-ink);
  font: 650 12.5px/1.2 var(--font-ui);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.12s, transform 0.12s;
  box-shadow: var(--shadow-1);
  white-space: nowrap;
}

.tooltip.is-on {
  opacity: 1;
  transform: none;
}

.tooltip kbd {
  color: inherit;
  border-color: currentColor;
  opacity: 0.6;
}

/* ---------- library ---------- */

.library {
  height: 100%;
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
}

.lib {
  overflow: auto;
  padding: 40px clamp(16px, 4vw, 56px) 90px;
}

.lib-section {
  max-width: 1320px;
  margin: 0 auto 60px;
}

.lib-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 20px;
}

/* A guest can start with one interest, without choosing a tool first. */
.lib-hello {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  grid-template-areas: 'greet shelf' 'note note';
  align-items: center;
  gap: 28px 56px;
  margin: 8px 0 36px;
}
.lib-hello > .lib-greet { grid-area: greet; }
.lib-hello > .today { grid-area: shelf; }
.lib-hello > .lib-guest { grid-area: note; margin: 0; max-width: none; font-size: 13px; }
.lib-greet h1 {
  font: 650 clamp(38px, 4.4vw, 58px)/1.04 var(--font-display);
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.home-find {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 26px;
  padding: 6px 6px 6px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--glass-float, var(--bg-2));
}
.home-find:focus-within { outline: 2px solid var(--focus, var(--ink)); outline-offset: 3px; }
.home-find input {
  min-width: 0;
  width: 100%;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 400 16px/1.4 var(--font-ui);
}
.home-find input::placeholder { color: var(--ink-2); opacity: 1; }
.home-find input:focus-visible { outline: none; }
.home-find .btn { flex: 0 0 44px; width: 44px; padding: 0; border-radius: 11px; }
.home-kinds { display: flex; flex-wrap: wrap; gap: 0 17px; padding-top: 5px; }
.home-kinds a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
  text-underline-offset: 4px;
}
.home-kinds a:hover { color: var(--ink); text-decoration: underline; }
.home-kinds a:focus-visible, .today-more:focus-visible { outline: 2px solid var(--focus, var(--ink)); outline-offset: 3px; border-radius: 3px; }
.home-create { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; margin: 3px 0 0 -12px; }
.home-create .btn { min-height: 44px; padding-inline: 12px; }
.home-create > a { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2); font-size: 14px; text-underline-offset: 4px; }
.home-create > a:focus-visible { outline: 2px solid var(--focus, var(--ink)); outline-offset: 3px; }

/* Covers stand on one baseline; captions belong to the work, not to a box. */
.today { min-width: 0; display: grid; gap: 18px; }
.today-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.today-label { margin: 0; color: var(--ink); font: 600 18px/1.3 var(--font-display); letter-spacing: -0.015em; }
.today-date { color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.today-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.today-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.today-art { position: relative; display: block; width: 100%; aspect-ratio: 2/3; margin-bottom: 7px; transition: transform .25s var(--ease); }
.today-art > b {
  display: flex;
  align-items: flex-end;
  position: absolute;
  inset: 0;
  padding: 12px;
  overflow: hidden;
  overflow-wrap: anywhere;
  border-radius: 5px;
  background: linear-gradient(160deg, hsl(var(--hue, 220) 28% 31%), hsl(var(--hue, 220) 28% 16%));
  color: #fff;
  font: 600 15px/1.3 var(--font-display);
}
.today-art[data-aspect='square'] > b { top: auto; aspect-ratio: 1; }
.today-art.is-loaded > b { visibility: hidden; }
.today-art img {
  position: absolute;
  bottom: 0;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
  border-radius: 4px;
  box-shadow: 0 10px 16px -10px rgb(var(--shade, 0 0 0) / .5);
}
.today-title:hover .today-art { transform: translateY(-4px); }
.today-title:focus-visible { outline: 2px solid var(--focus, var(--ink)); outline-offset: 5px; border-radius: 5px; }
.today-name { font: 600 14px/1.35 var(--font-display); overflow-wrap: anywhere; }
.today-title > small { margin-top: auto; padding-top: 2px; color: var(--ink-2); font-size: 12px; line-height: 1.4; }
.today-placeholder { aspect-ratio: 2/3; margin-bottom: 60px; border-radius: 5px; background: color-mix(in srgb, var(--ink) 7%, transparent); }
.today-tail { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 14px; padding-top: 8px; border-top: 1px solid var(--line); }
.today-foot { margin: 0; color: var(--ink-2); font-size: 12px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.today-more { display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); font-size: 14px; text-underline-offset: 4px; }
@media (max-width: 1020px) {
  .lib-hello { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'greet' 'shelf' 'note'; gap: 28px; }
  .home-find { max-width: 600px; }
  .today-row { gap: 20px; }
  .today-art { max-height: 240px; }
  .today-art img { width: auto; max-width: 100%; }
  .today-name { font-size: 16px; }
}
@media (max-width: 560px) {
  .lib-hello { margin-top: 0; gap: 24px; }
  .lib-greet h1 { font-size: clamp(34px, 9.7vw, 42px); }
  .home-find { margin-top: 20px; }
  .home-kinds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
  .home-create { margin-top: 0; }
  .today { gap: 16px; }
  .today-row { display: flex; gap: 18px; overflow-x: auto; padding: 6px 5px 12px; margin: -6px -5px -12px; scroll-snap-type: x proximity; scrollbar-width: thin; }
  .today-title, .today-placeholder { flex: 0 0 116px; scroll-snap-align: start; }
  .today-title > small { font-size: 13px; }
  .today-art { height: 160px; aspect-ratio: auto; }
  .today-art img { width: 100%; }
  .today-name { font-size: 15px; }
  .today-label { font-size: 18px; }
  .today-tail { gap: 0 12px; }
  .today-foot { flex: 1 1 210px; }
}
@media (prefers-reduced-motion: reduce) { .today-art { transition: none; } }

/* ---------- what members ranked: lists on show ----------
   Each is the top of a real board (three tiers, a few covers to a tier), its name and who made it. */
.onshow-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.onshow-card {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 14px 14px 16px;
  border-radius: var(--r-panel, 24px);
  background: var(--glass-tray, var(--bg-2));
  box-shadow: inset 0 1px 0 var(--rim, transparent), inset 0 0 0 1px var(--rim-soft, var(--line));
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.3s var(--ease);
}

.onshow-card:hover {
  transform: translateY(-3px);
}

.onshow-card:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 3px;
}

.onshow-board {
  display: grid;
  gap: 6px;
}

.onshow-tier {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
}

.onshow-chip {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border-radius: 9px;
  font: 650 13px / 1 var(--font-display);
}

.onshow-row {
  display: flex;
  gap: 5px;
  height: 54px;
  overflow: hidden;
}

.onshow-cover {
  position: relative;
  flex: none;
  height: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  border-radius: 5px;
  background: linear-gradient(160deg, hsl(var(--hue, 220) 46% 30%), hsl(var(--hue, 220) 48% 14%));
}

.onshow-card[data-aspect='square'] .onshow-cover {
  aspect-ratio: 1;
}

.onshow-card[data-aspect='wide'] .onshow-cover {
  aspect-ratio: 16 / 9;
}

.onshow-cover b {
  display: block;
  padding: 8% 8% 0;
  color: #f2f4f2;
  font: 600 7.5px / 1.1 var(--font-display);
  overflow-wrap: anywhere;
}

.onshow-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s;
}

.onshow-cover img.is-loaded {
  opacity: 1;
}

.onshow-info {
  display: grid;
  gap: 6px;
  padding: 0 4px;
}

.onshow-info > b {
  font: 600 17px / 1.25 var(--font-display);
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.onshow-by {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
}

.onshow-by .profile-avatar {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  font-size: 11px;
}

.onshow-info small {
  color: var(--ink-3);
  font-size: 12.5px;
}

.onshow-off {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--glass-float, var(--bg-3));
  color: var(--ink-2);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.onshow-card:is(:hover, :focus-within) .onshow-off {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .onshow-card {
    transition: none;
  }
}

/* the foot of the home page: where the site's other pages are, said once and quietly */
.lib-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  margin-top: 28px;
  padding: 22px 0 6px;
  border-top: 1px solid var(--rim-soft, var(--line));
  color: var(--ink-3);
  font-size: 13.5px;
}

.lib-foot :is(a, .link-btn) {
  color: var(--ink-2);
  font: inherit;
  text-decoration: none;
}

.lib-foot :is(a, .link-btn):hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lib-foot > span {
  margin-right: auto;
}

.lib-lede {
  max-width: 60ch;
  margin: 16px 0 0;
  color: var(--ink-2);
  font-size: clamp(16px, 1.25vw, 18px);
  line-height: 1.5;
  text-wrap: pretty;
}

.lib-lede a {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  text-underline-offset: 3px;
}

/* said once to a guest, under the heading */
.lib-guest {
  max-width: 68ch;
  margin: -4px 0 14px;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.5;
}

.lib-guest a {
  color: var(--ink);
  font-weight: 600;
  text-underline-offset: 3px;
}

.lib-head h1 {
  font: 900 clamp(38px, 4.4vw, 58px)/0.95 var(--font-display);
}

.lib-head h2 {
  font: 850 clamp(28px, 3vw, 38px)/1 var(--font-display);
}

.lib-sub {
  flex-basis: 100%;
  color: var(--ink-2);
}

.lib-lists {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
}

.list-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: var(--r-3);
  background: var(--bg-2);
  border: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s var(--ease), border-color 0.2s;
}

.list-card:hover,
.list-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--line-2);
}

.mini-shelf {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  height: 160px;
  padding: 20px 20px 0;
  overflow: hidden;
}

.mini-cover {
  position: relative;
  flex: none;
  height: 112px;
  aspect-ratio: 2 / 3;
  border-radius: 2px;
  overflow: hidden;
  background: #0008;
}

.mini-shelf[data-aspect='square'] .mini-cover {
  aspect-ratio: 1;
  height: 92px;
}

.mini-shelf[data-aspect='wide'] .mini-cover {
  aspect-ratio: 16 / 9;
  height: 64px;
}

.mini-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.mini-cover.is-loaded img { opacity: 1; }
.mini-cover.is-loaded b { visibility: hidden; }

/* a title without a picture: its name, lettered on a quiet neutral tile */
.mini-cover b {
  display: -webkit-box;
  height: 100%;
  padding: 9% 9% 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  background: var(--cover-fallback);
  color: var(--ink);
  font: 650 10.5px / 1.12 var(--font-ui);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.mini-empty {
  align-self: center;
  margin: auto;
  color: var(--ink-3);
  font-size: 13px;
}

.list-card-body {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 16px 20px 18px;
}

.list-card h3 {
  font: 800 21px/1.15 var(--font-display);
  padding-right: 34px;
}

.list-meta {
  font-size: 13px;
  color: var(--ink-3);
}

.tier-dist {
  display: flex;
  gap: 2px;
  height: 6px;
  margin-top: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.tier-dist span {
  min-width: 0;
}

.dist-pool {
  background: var(--line-2);
}

.list-card > .btn {
  position: absolute;
  right: 10px;
  bottom: 54px;
  opacity: 0;
}

.list-card:hover > .btn,
.list-card:focus-within > .btn {
  opacity: 1;
}

.lib-empty {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 34px;
  border-radius: var(--r-3);
  border: 2px dashed var(--line-2);
  color: var(--ink-2);
  max-width: 640px;
}

.lib-empty-title {
  font: 850 26px/1.1 var(--font-display);
  color: var(--ink);
}

.lib-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  gap: 20px;
}

.tpl-card {
  display: grid;
  grid-template-rows: auto auto;
  padding: 0;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  background: var(--bg-2);
  overflow: hidden;
  transition: transform 0.2s var(--ease), border-color 0.2s;
}

/* (a link, so that the template's page can be reached and opened in a new tab; it reads as the card it is) */
a.tpl-card {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.tpl-card:hover,
.tpl-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--line-2);
}

.tpl-card.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.tpl-fan {
  --fan-center: 2;
  position: relative;
  container-type: inline-size;
  display: block;
  height: 176px;
  overflow: hidden;
}

.tpl-fan:has(> .tpl-cover:only-child) { --fan-center: 0; }
.tpl-fan:has(> .tpl-cover:nth-child(2):last-child) { --fan-center: 0.5; }
.tpl-fan:has(> .tpl-cover:nth-child(3):last-child) { --fan-center: 1; }
.tpl-fan:has(> .tpl-cover:nth-child(4):last-child) { --fan-center: 1.5; }

.tpl-cover {
  --fan-step: min(30px, 8cqw);
  --fan-angle: 6deg;
  --fan-lift: 0px;
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: min(78px, 26cqw);
  aspect-ratio: 2 / 3;
  border-radius: 3px;
  overflow: hidden;
  background: var(--bg-3);
  box-shadow: 0 10px 18px -6px rgba(0, 0, 0, 0.7);
  transform-origin: 50% 130%;
  transform: translateX(calc(-50% + (var(--i) - var(--fan-center)) * var(--fan-step))) rotate(calc((var(--i) - var(--fan-center)) * var(--fan-angle))) translateY(var(--fan-lift));
  transition: transform 0.3s var(--ease);
}

.tpl-card[data-aspect='square'] .tpl-cover {
  aspect-ratio: 1;
  width: min(86px, 32cqw);
}

.tpl-card[data-aspect='wide'] .tpl-cover {
  --fan-step: min(18px, 4.8cqw);
  --fan-angle: 7deg;
  aspect-ratio: 16 / 9;
  width: min(120px, 48cqw);
}

.tpl-card:hover .tpl-cover {
  --fan-step: min(38px, 8cqw);
  --fan-angle: 7deg;
  --fan-lift: -6px;
}

.tpl-card[data-aspect='wide']:hover .tpl-cover {
  --fan-step: min(23px, 6.1cqw);
  --fan-angle: 9deg;
}

.tpl-cover:nth-child(1),
.tpl-cover:nth-child(5) {
  z-index: 1;
}

.tpl-cover:nth-child(2),
.tpl-cover:nth-child(4) {
  z-index: 2;
}

.tpl-cover:nth-child(3) {
  z-index: 3;
}

.tpl-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s;
}

.tpl-cover.is-loaded img {
  opacity: 1;
}

.tpl-cover-text {
  position: absolute;
  inset: 6px;
  font: 800 11px/1.05 var(--font-label);
  text-transform: uppercase;
  color: var(--ink);
  overflow: hidden;
}

.tpl-body {
  display: grid;
  gap: 4px;
  padding: 14px 18px 17px;
}

.tpl-title {
  font: 850 20px/1.1 var(--font-display);
}

.tpl-meta {
  font-size: 13px;
  color: var(--ink-3);
}

@media (max-width: 560px) {
  /* Four samples show the first three; five show the middle three. */
  .tpl-fan:has(> .tpl-cover:nth-child(4):last-child) { --fan-center: 1; }
  .tpl-fan:has(> .tpl-cover:nth-child(4):last-child) > .tpl-cover:nth-child(4),
  .tpl-fan:has(> .tpl-cover:nth-child(5)) > .tpl-cover:first-child,
  .tpl-cover:nth-child(n + 5) { display: none; }
}

.missing {
  display: grid;
  place-content: center;
  justify-items: start;
  gap: 12px;
  height: 100%;
  padding: 24px;
}

.missing h1 {
  font: 650 44px/1.05 var(--font-display);
  letter-spacing: -0.035em;
}

.missing p {
  color: var(--ink-2);
}

/* ---------- quick rank deck ---------- */

.deck {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--deck-bg);
  overflow: hidden;
  animation: deck-in 0.22s var(--ease);
}

@keyframes deck-in {
  from {
    opacity: 0;
  }
}

.deck-glow {
  position: absolute;
  inset: -25%;
  background: center / cover no-repeat;
  filter: blur(90px) saturate(1.5);
  opacity: 0.32;
  transition: background-image 0.4s;
  pointer-events: none;
}

.deck-head,
.deck-body,
.deck-foot {
  position: relative;
}

.deck-head {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 22px;
}

.deck-progress {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 8px;
  max-width: 440px;
}

.deck-progress-text {
  font: 800 18px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.deck-bar {
  height: 4px;
  border-radius: 2px;
  background: color-mix(in srgb, transparent, var(--ink) 16%);
  overflow: hidden;
}

.deck-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
  transition: transform 0.3s var(--ease);
}

.deck-filter {
  min-width: 0;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--ink-3);
}

.deck-head > .btn {
  flex-shrink: 0;
  margin-left: auto;
}

.deck-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  padding: 0 32px 0 22px;
  min-height: 0;
}

/* The stage is measured, and the cover is cut to what is left of it once the
   caption has its lines: a long name can never push the card over the tiers. */
.deck-stage {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  min-height: 0;
  container-type: size;
}

/* the cards are a picture: a tap that lands on one is never kept from a tier */
.deck-card {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  pointer-events: none;
  transform-origin: 50% 0;
  transition: transform 0.25s var(--ease), opacity 0.25s;
}

/* the room a cover may take: as tall as the window allows, never wider than the stage */
.deck-seat {
  display: flex;
  flex: 0 1 min(60vh, 640px);
  justify-content: center;
  width: 100%;
  min-height: 0;
  container-type: size;
}

@supports (width: 1cqw) {
  .deck-seat {
    flex-basis: min(60vh, 640px, 100cqw / var(--r), 960px / var(--r));
  }
}

.deck-card[data-depth='1'] {
  transform: translateY(-20px) scale(0.93);
  opacity: 0.4;
}

.deck-card[data-depth='2'] {
  transform: translateY(-38px) scale(0.86);
  opacity: 0.18;
}

.deck-card:not([data-depth='0']) .deck-caption {
  visibility: hidden;
}

.deck-frame {
  position: relative;
  flex: none;
  height: 100%;
  height: 100cqh;
  aspect-ratio: var(--r);
  border-radius: var(--tile-r);
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 60px -18px rgba(0, 0, 0, 0.8);
}

.deck-bg {
  position: absolute;
  inset: -10%;
  width: 120%;
  max-width: none;
  height: 120%;
  object-fit: cover;
  filter: blur(26px) brightness(0.5);
}

.deck-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.deck-textcover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12%;
  overflow: hidden;
  font: 900 clamp(22px, 9cqh, 54px)/1 var(--font-label);
  text-transform: uppercase;
  text-align: center;
  overflow-wrap: anywhere;
  background: hsl(var(--hue, 220) 30% 24%);
  color: #f2f4f2;
}

.deck-caption {
  flex: none;
  max-width: min(640px, 100%);
  text-align: center;
}

.deck-name {
  font: 850 clamp(24px, 3vw, 38px)/1.08 var(--font-display);
}

/* a card that is its own name: the caption does not say it twice */
.deck-card.is-lettered .deck-name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.deck-card.is-lettered .deck-meta {
  margin-top: 0;
}

.deck-meta {
  margin-top: 6px;
  color: var(--ink-2);
}

.deck-n {
  margin-left: 8px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.deck-rail {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding: 8px 4px;
}

/* beside the cover the tiers, Skip and Undo are one column */
.deck-tiers,
.deck-aside {
  display: contents;
}

.deck-undo {
  order: 1;
}

.deck-tier {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-width: 190px;
  padding: 12px 14px;
  border: 0;
  border-radius: var(--r-2);
  background: var(--tc);
  color: var(--tc-ink);
  text-align: left;
  transition: transform 0.12s, box-shadow 0.12s;
}

.deck-tier:hover {
  transform: translateX(-4px);
  box-shadow: 0 8px 18px -8px rgba(0, 0, 0, 0.6);
}

.deck-tier:disabled {
  opacity: 0.38;
  pointer-events: none;
}

.deck-tier-label {
  font: 900 28px/1 var(--font-label);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deck-tier-count {
  font-size: 13px;
  font-weight: 700;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.deck-tier kbd {
  color: inherit;
  border-color: currentColor;
  opacity: 0.6;
}

.deck-skip {
  --tc: color-mix(in srgb, transparent, var(--ink) 10%);
  --tc-ink: var(--ink);
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.deck-skip .deck-tier-label {
  font-size: 18px;
}

.deck-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 24px;
  padding: 16px;
  color: var(--ink-3);
  font-size: 13px;
}

.deck-foot span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.deck-done {
  display: grid;
  place-self: center;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.deck-done h2 {
  font: 900 clamp(32px, 4vw, 52px)/1 var(--font-display);
}

.deck-done p {
  color: var(--ink-2);
}

.deck-done-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- narrow windows ---------- */

@media (max-width: 1100px) {
  .ed-top .btn-label {
    display: none;
  }

  .ed-top .btn:has(.btn-label) {
    width: var(--btn-h);
    padding: 0;
  }

  .ed-top .btn kbd {
    display: none;
  }

  .ed-top .tb-right .btn.primary:has(.btn-label) {
    width: auto;
    padding: 0 14px;
  }

  .ed-top .tb-right .btn.primary .btn-label {
    display: inline;
  }

  .list-title {
    max-width: 30vw;
  }
}

@media (max-width: 560px) {
  .lib-top .btn-label {
    display: none;
  }

  .lib-top .btn:has(.btn-count) {
    position: relative;
  }

  .lib-top .btn-count {
    position: absolute;
    top: 3px;
    right: 0;
    min-width: 17px;
    height: 17px;
    margin: 0;
    padding: 0 4px;
    font-size: 10.5px;
  }

  .lib-top .btn:has(.btn-label) {
    width: var(--btn-h);
    padding: 0;
  }

  /* a guest's way in keeps its word; joining is offered under the heading */
  .lib-top .btn.lib-entry .btn-label {
    display: inline;
  }

  .lib-top .btn.lib-entry:has(.btn-label) {
    width: auto;
    padding: 0 14px;
  }

  .lib-top .btn.lib-join {
    display: none;
  }

  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
    padding-right: 22px;
    mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent);
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: none;
  }

  .selbar .btn-label {
    display: none;
  }

  .ed-top .tb-right .btn.primary .btn-label {
    display: none;
  }

  .ed-top .tb-right .btn.primary:has(.btn-label) {
    width: var(--btn-h);
    padding: 0;
  }

  .tb-group {
    display: none;
  }

  .topbar {
    gap: 6px;
    padding: 0 8px 0 4px;
  }

  .tb-left,
  .tb-right {
    gap: 2px;
  }

  /* the list title gets the width; the theme moves into the ⋯ menu */
  .ed-top .tb-left {
    flex: 1;
  }

  .ed-top { gap: 6px; padding-right: 8px; }
  .ed-top .tb-left > .btn { flex: none; }
  .ed-top .tb-right { flex: none; gap: 2px; }
  .ed-top .title-wrap { flex: 1; }
  .ed-top .list-title { width: 100%; min-width: 0; }

  .title-wrap {
    min-width: 0;
  }

  .list-title {
    max-width: 100%;
    font-size: 17px;
  }

  .tb-theme {
    display: none;
  }

  /* tiers stack: the label becomes a strip above its covers */
  .tier {
    grid-template-columns: minmax(0, 1fr);
  }

  .talker {
    grid-row: 1;
    flex-direction: row;
    align-items: center;
    align-self: start;
    justify-self: start;
    gap: 10px;
    min-height: 0;
    margin: 0 0 4px;
    padding: 6px 12px 6px 10px;
  }

  .tier-drop {
    grid-row: 2;
    grid-column: 1;
    padding: 10px 6px;
  }

  .talker-more {
    position: static;
    opacity: 0.8;
  }

  .board {
    padding: 14px 12px 90px;
  }
}

@media (max-width: 820px) {
  .ed-main {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) min(44vh, 420px);
  }

  .splitter {
    display: none;
  }

  .cart {
    border-top: 1px solid var(--line-2);
  }

  .board {
    padding: 18px 16px 90px;
  }

  .selbar {
    left: 50%;
    bottom: calc(min(44vh, 420px) + 12px);
    max-width: calc(100% - 24px);
  }

  .tb-group.zoom,
  .save-status {
    display: none;
  }

  .export,
  .edit {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- quick rank under a thumb ---------- */

/* A phone, a tablet held upright, a short window: the tiers are keys, not a
   list. Each is as large as a thumb, names its tier and counts what it holds;
   the keyboard's hints step away, and Undo and Skip sit under the keys. */
@media (orientation: portrait) and (max-width: 1100px), (max-width: 820px), (max-height: 520px) {
  .deck-head {
    gap: 12px;
    padding: 10px 10px 4px 16px;
  }

  .deck-foot,
  .deck kbd {
    display: none;
  }

  :root[data-theme] .deck .deck-card {
    gap: 10px;
  }

  .deck-card[data-depth='1'] {
    transform: translateY(-11px) scale(0.94);
  }

  .deck-card[data-depth='2'] {
    transform: translateY(-21px) scale(0.88);
  }

  :root[data-theme] .deck .deck-name {
    display: -webkit-box;
    overflow: hidden;
    font-size: 20px;
    line-height: 1.14;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .deck-meta {
    margin-top: 4px;
    font-size: 13px;
  }

  :root[data-theme] .deck .deck-rail {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    gap: 8px;
    overflow: visible;
  }

  .deck-tiers {
    display: grid;
    gap: 6px;
  }

  .deck-aside {
    display: flex;
    justify-content: space-between;
    gap: 8px;
  }

  :root[data-theme] .deck .deck-tiers .deck-tier {
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    justify-items: center;
    gap: 5px;
    min-width: 0;
    height: 60px;
    padding: 4px;
    border-radius: 16px;
    text-align: center;
  }

  :root[data-theme] .deck .deck-tiers .deck-tier-label {
    max-width: 100%;
    font-size: 22px;
  }

  /* a tier with a word for a name: the word is set small, on two lines at most */
  :root[data-theme] .deck .deck-tiers .deck-tier[data-long] .deck-tier-label {
    display: -webkit-box;
    font-size: 12.5px;
    line-height: 1.1;
    letter-spacing: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  :root[data-theme] .deck .deck-tiers .deck-tier-count {
    font-size: 11px;
    line-height: 1;
  }

  :root[data-theme] .deck .deck-aside .deck-tier {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    order: 0;
    min-width: 0;
    height: 44px;
    padding: 0 18px;
    border-radius: 999px;
  }

  :root[data-theme] .deck .deck-aside .deck-tier-label {
    font-size: 15px;
  }

  /* a finger leaves its hover behind: the key answers the press and nothing else */
  :root[data-theme] .deck .deck-tier:is(:hover, :focus-visible) {
    transform: none;
  }

  :root[data-theme] .deck .deck-tier:active {
    transform: scale(0.95);
  }
}

/* upright: the cover above, the keys in one row at the foot of the screen */
@media (orientation: portrait) and (max-width: 1100px), (max-width: 820px) and (min-height: 521px) {
  .deck-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 0;
    padding: 0 14px;
  }

  .deck-stage {
    padding-top: 22px;
  }

  /* the cover takes what the screen has: its width, or the height left to it */
  @supports (width: 1cqw) {
    .deck-seat {
      flex-basis: min(100cqw / var(--r), 720px);
    }
  }

  :root[data-theme] .deck .deck-rail {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
  }

  .deck-tiers {
    grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  }
}

/* on its side, or in a short window: the keys in two columns beside the cover */
@media (orientation: landscape) and (max-height: 520px) {
  .deck-body {
    gap: 18px;
    padding: 0 16px 10px;
  }

  .deck-stage {
    padding-top: 14px;
  }

  :root[data-theme] .deck .deck-name {
    font-size: 17px;
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }

  :root[data-theme] .deck .deck-rail {
    width: 216px;
    padding: 0;
  }

  .deck-tiers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  :root[data-theme] .deck .deck-tiers .deck-tier {
    height: 48px;
    gap: 3px;
  }

  :root[data-theme] .deck .deck-aside .deck-tier {
    flex: 1 1 0;
    height: 40px;
    padding: 0 10px;
  }
}

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

/* ---------- dwell ring and the large view ---------- */

.dwell-ring {
  position: fixed;
  z-index: 190;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  animation: ring-in 0.18s var(--ease);
}

.dwell-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  fill: none;
  stroke-width: 3;
}

.dwell-ring .track {
  stroke: rgba(255, 255, 255, 0.18);
}

.dwell-ring .fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 69.2;
  stroke-dashoffset: 69.2;
  animation: ring-fill var(--fill, 1s) linear forwards;
}

@keyframes ring-fill {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes ring-in {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

.spotlight {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px) saturate(1.1);
  cursor: zoom-out;
  animation: spot-in 0.25s var(--ease);
}

.spotlight.is-leaving {
  animation: spot-out 0.2s forwards;
}

/* opened to stay it holds the focus itself, the whole screen: no ring round that */
.spotlight:focus {
  outline: none;
}

@keyframes spot-in {
  from {
    opacity: 0;
  }
}

@keyframes spot-out {
  to {
    opacity: 0;
  }
}

.spot-card {
  display: flex;
  align-items: flex-end;
  gap: 32px;
  margin: 0;
  max-width: min(1200px, 100%);
}

.spot-media {
  position: relative;
  flex: none;
  height: min(78vh, 760px);
  max-width: 62vw;
  overflow: hidden;
  border-radius: var(--tile-r);
  background: #000;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.spot-bg {
  position: absolute;
  inset: -10%;
  width: 120%;
  max-width: none;
  height: 120%;
  object-fit: cover;
  filter: blur(34px) brightness(0.5);
}

.spot-img {
  position: relative;
  height: 100%;
  width: auto;
  max-width: 62vw;
  object-fit: contain;
}

/* The cover leans after the pointer (panels/spotlight.js says where the
   pointer is: --tx and --ty run from -1 to 1 across the cover, --lean from 0
   to 1). At rest it is a flat picture with no layer of its own. Leaning, it
   also draws back a little: the edge that comes forward would otherwise
   reach over the panel it lies on. */
.spot-media {
  --tilt: 8deg;
}

/* a wide picture turns less: its edges travel further for the same angle */
.spot-card.is-wide .spot-media {
  --tilt: 4.5deg;
}

.spot-media.is-leaning {
  transform: perspective(1800px) scale(calc(1 - var(--lean, 0) * 0.03)) rotateX(calc(var(--ty, 0) * -1 * var(--tilt))) rotateY(calc(var(--tx, 0) * var(--tilt)));
  will-change: transform;
}

/* the light it catches: on the edge that comes forward, more of it the further it leans */
.spot-glare {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(farthest-corner at calc(50% - var(--tx, 0) * 42%) calc(50% - var(--ty, 0) * 42%), rgb(255 255 255 / 0.17), rgb(255 255 255 / 0.05) 34%, transparent 62%);
  mix-blend-mode: screen;
}

.spot-media.is-leaning .spot-glare {
  opacity: var(--lean, 0);
}

.spot-text {
  display: grid;
  place-items: center;
  height: 100%;
  aspect-ratio: 2 / 3;
  padding: 12%;
  font: 900 clamp(28px, 4vw, 56px)/1 var(--font-label);
  text-transform: uppercase;
  text-align: center;
  background: var(--bg-3);
}

.spot-caption {
  flex: 0 1 380px;
  min-width: 250px;
  max-width: 380px;
  padding-bottom: 6px;
  color: var(--ink);
  cursor: default;
}

.spot-caption > .btn {
  margin-top: 10px;
}

/* a wide picture (a landscape box, a screenshot): it takes the card's width
   and the caption goes under it, instead of being squeezed beside it */
.spot-card.is-wide {
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  width: fit-content;
  max-width: min(1040px, 100%);
}

.spot-card.is-wide .spot-media {
  height: auto;
  max-width: 100%;
}

/* as large as the window allows, whatever the file's own size (--ar is the
   picture's width over its height, set when it loads) */
.spot-card.is-wide .spot-img {
  display: block;
  width: min(100vw - 80px, 1012px, min(60vh, 620px) * var(--ar, 1.5));
  height: auto;
  max-width: none;
}

/* the caption takes the picture's width; it never makes the card wider */
.spot-card.is-wide .spot-caption {
  flex: none;
  width: 0;
  min-width: 100%;
  max-width: none;
  padding: 0 10px;
}

.spot-name {
  font: 850 clamp(28px, 3.2vw, 46px)/1.04 var(--font-display);
  text-wrap: balance;
}

.spot-facts {
  margin-top: 12px;
  font-size: 17px;
  color: var(--ink-2);
}

/* screenshots of a game: small pictures under the caption; one of them takes the cover's place */
.spot-shots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
}

.spot-shot {
  flex: none;
  width: 84px;
  aspect-ratio: 16 / 9;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: var(--bg-3);
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.18s, transform 0.18s;
}

.spot-shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.spot-shot:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.spot-shot[aria-pressed='true'] {
  opacity: 1;
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.spot-shot:focus-visible {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 2px;
}

.spot-shots small {
  flex-basis: 100%;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 11.5px;
}

/* the original name, under a title shown in the reader's language */
.spot-original {
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 15px;
}

/* a paragraph about the work (paintings, landmarks): a readable measure, and
   it scrolls in place instead of pushing the card past a short window */
.spot-about {
  max-height: min(30vh, 260px);
  margin-top: 14px;
  padding-right: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.55;
  text-wrap: pretty;
}

.spot-about a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.spot-about a .i {
  width: 13px;
  height: 13px;
  margin-left: 3px;
  vertical-align: -2px;
}

.spot-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.spot-genres span {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-size: 13px;
  color: var(--ink-2);
}

.spot-where {
  margin-top: 16px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.spot-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.spot-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-1);
  border: 1px solid var(--line-2);
  color: var(--ink);
  font-weight: 650;
  font-size: 14px;
  text-decoration: none;
}

.spot-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.spot-links .i {
  width: 15px;
  height: 15px;
}

[data-theme='snap'] .spot-media {
  border-radius: 22px;
  box-shadow: 0 30px 110px -10px rgb(var(--dc, 60 60 60) / 0.9), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* a phone: the picture takes the card's width and the words stand under it,
   in sight without scrolling; a card taller than the screen can be scrolled */
@media (max-width: 820px) {
  .spotlight {
    align-items: safe center;
    overflow-y: auto;
    padding: 14px;
  }

  :root[data-theme] .spot-card {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    width: 100%;
    max-width: 460px;
  }

  .spot-media {
    height: auto;
    max-width: 100%;
  }

  .spot-card:not(.is-wide) .spot-img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 58vh;
  }

  .spot-card.is-wide .spot-img {
    width: 100%;
  }

  .spot-text {
    width: 100%;
    height: auto;
  }

  :root[data-theme] .spot-caption {
    flex: none;
    align-self: stretch;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0 6px;
  }
}

/* ---------- add items on a phone ---------- */

@media (max-width: 560px) {
  /* three results to a row, not one that fills the screen */
  .wiki-results {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 8px;
  }

  /* where to search and the genres are one line each, swept sideways: the results get the screen */
  :root[data-theme] :is(.src-chips, .genre-browse) {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-right: 22px;
    mask-image: linear-gradient(90deg, #000 calc(100% - 30px), transparent);
  }

  :root[data-theme] :is(.src-chips, .genre-browse)::-webkit-scrollbar {
    display: none;
  }

  :root[data-theme] :is(.src-chips, .genre-browse) > * {
    flex: none;
  }
}

/* ---------- landing effects and theme changes ---------- */

.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 170;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-new(root) {
  animation: theme-reveal 0.75s cubic-bezier(0.65, 0, 0.35, 1);
}

@keyframes theme-reveal {
  from {
    clip-path: circle(0 at var(--vt-x, 50%) var(--vt-y, 0));
  }
  to {
    clip-path: circle(150vmax at var(--vt-x, 50%) var(--vt-y, 0));
  }
}

/* ---------- a page on its way ----------
   One language for every wait: light that runs. Along the top of the window
   while a view is fetched (js/busy.js), under the mark before the app has
   arrived (the splash), and across the blank shapes of what is coming
   (js/skeleton.js). Each waits a moment before it shows, so what arrives at
   once is not announced. */

.busy-line {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  /* room for the light's own glow under the line */
  height: 14px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.busy-line.is-on {
  opacity: 1;
}

.busy-line i {
  position: absolute;
  top: 0;
  left: 0;
  width: 34%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent) 35%, var(--accent) 65%, transparent);
  box-shadow: 0 0 12px 1px color-mix(in srgb, var(--accent) 55%, transparent);
  animation: busy-run 1.3s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

/* (on a light ground a glow of dark ink is a smudge) */
[data-appearance='light'] .busy-line i {
  box-shadow: none;
}

/* from before the left edge to past the right one (the light is a third of the line wide) */
@keyframes busy-run {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(310%);
  }
}

@keyframes busy-breathe {
  from {
    opacity: 0.25;
  }
  to {
    opacity: 0.9;
  }
}

html[data-busy] {
  cursor: progress;
}

/* the shape of what is coming: blank, and one light passing over all of it */
.sk {
  display: block;
  border-radius: 8px;
}

.sk-line {
  height: 13px;
  border-radius: 999px;
}

.sk-line + .sk-line {
  margin-top: 10px;
}

.sk-thin {
  height: 9px;
}

/* a card that waits answers nothing */
.is-skeleton {
  pointer-events: none;
}

.sk,
.is-skeleton :is(.mini-cover, .tpl-cover) {
  background-color: color-mix(in srgb, var(--ink) 9%, transparent);
  /* the light stands still in the window while the shapes show the part of it that is over them: one sweep
     across the page, not a blink in every block (where a shape is turned or the browser does not hold a
     background to the window, each has the sweep to itself, at the same moment) */
  background-image: linear-gradient(100deg, transparent 42%, color-mix(in srgb, var(--ink) 12%, transparent) 50%, transparent 58%);
  background-size: 220vw 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  box-shadow: none;
  animation: sk-pass 1.9s linear infinite;
}

@keyframes sk-pass {
  from {
    background-position: -120vw 0;
  }
  to {
    background-position: 0 0;
  }
}

/* (a moment's patience first: a page that is there at once shows no placeholders) */
.is-skeleton,
.sk-wait {
  animation: sk-arrive 0.35s var(--ease) 0.12s both;
}

@keyframes sk-arrive {
  from {
    opacity: 0;
  }
}

/* a member's page: the picture's place as the page draws it, then the name */
.sk-avatar {
  flex: none;
  width: 100px;
  height: 100px;
  border-radius: 28px;
}

.sk-wait .profile-identity .sk-line:first-child {
  height: 30px;
  margin: 6px 0 18px;
}

.social-section-head > .sk-line {
  height: 18px;
}

.sk-tiles {
  display: flex;
  gap: 14px;
  overflow: hidden;
}

.sk-tile {
  flex: none;
  width: 112px;
  aspect-ratio: 2 / 3;
}

@media (max-width: 640px) {
  .sk-avatar {
    width: 72px;
    height: 72px;
    border-radius: 20px;
  }

  .sk-tile {
    width: 84px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .busy-line i {
    left: 0;
    width: 100%;
    transform: none;
    animation: busy-breathe 1.4s ease-in-out infinite alternate;
  }

  .sk,
  .is-skeleton :is(.mini-cover, .tpl-cover) {
    background-image: none;
    animation: none;
  }
}

/* ---------- splash: what holds the screen until the app does ----------
   The mark and a line of light; once a session TierMaker turns around into
   rekaMreiT over it. It goes when the first view has put its frame up. If
   the scripts are long in coming it says so and offers to load again; it
   never leaves an empty page behind.
   What it looks like while it waits is drawn by the page itself
   (index.html, in the head): those rules must work before this sheet has
   come. Here: the name turning round, and how it leaves. */

#splash.is-done {
  opacity: 0;
  visibility: hidden;
}

/* The name and the little board arrive as one identity. */
#splash.is-intro .splash-wait {
  position: absolute;
  top: calc(50% - 150px);
  left: 50%;
  translate: -50% 0;
  display: grid;
  opacity: 1;
  animation: none;
}

#splash.is-intro .splash-line { visibility: hidden; }
#splash.is-intro .splash-mark { width: 76px; height: 76px; }
.splash-mark rect { transform-box: fill-box; transform-origin: center; }

.splash-word {
  position: relative;
  display: flex;
  font: 900 clamp(48px, 9vw, 120px)/1 var(--font-display);
  color: var(--ink);
  perspective: 600px;
}

.splash-word span {
  display: inline-block;
  transform-style: preserve-3d;
  backface-visibility: visible;
}

.splash-word span.is-cap {
  transition: color 0.4s ease 0.2s;
}

.splash-word.is-turned span.is-cap {
  color: var(--accent);
}

.splash-sub {
  position: absolute;
  bottom: 14vh;
  left: 0;
  right: 0;
  text-align: center;
  font: italic 17px/1.4 var(--font-ui);
  letter-spacing: 0.02em;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity 0.5s ease 0.6s;
}

#splash.is-turned .splash-sub {
  visibility: visible;
  opacity: 1;
}

/* under the name once it has turned, if the page is still not there */
#splash > .splash-foot {
  position: absolute;
  left: 50%;
  bottom: calc(14vh + 52px);
  margin-left: -66px;
  opacity: 0;
}

#splash.is-turned > .splash-foot {
  visibility: visible;
  animation: splash-arrive 0.5s var(--ease) 1.4s forwards;
}

.splash-late {
  font-family: var(--font-ui);
}

.splash-late a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- genre chips: filter the cart, browse the library ---------- */

.tag-row {
  display: flex;
  gap: 6px;
  margin: 0 -16px -4px;
  padding: 2px 16px 4px;
  overflow-x: auto;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 22px), transparent);
}

.tag-row::-webkit-scrollbar {
  display: none;
}

.tag-row[hidden] {
  display: none;
}

.tag-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-3);
  color: var(--ink-2, var(--ink));
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}

.tag-chip small {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.tag-chip:hover {
  border-color: var(--line-2);
  color: var(--ink);
}

.tag-chip:active {
  transform: scale(0.96);
}

.tag-chip[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

.tag-chip[aria-pressed='true'] small {
  color: inherit;
  opacity: 0.75;
}

.tag-clear {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-3);
}

.tag-clear:hover {
  color: var(--ink);
  background: var(--bg-3);
}

.tag-clear .i {
  width: 16px;
  height: 16px;
}

/* ---------- add items: one search, many sources ---------- */

.add-search {
  display: grid;
  gap: 12px;
}

.src-chips,
.genre-browse {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.genre-browse[hidden] {
  display: none;
}

.genre-browse .tag-chip {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

.src-label {
  margin-right: 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

.src-chip {
  height: 36px;
  padding: 0 14px 0 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-3) radial-gradient(circle at 15px 50%, var(--ink-3) 0 3.5px, transparent 4px);
  color: var(--ink-3);
  font-size: 13.5px;
  font-weight: 650;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.src-chip:hover {
  color: var(--ink);
  border-color: var(--line-2);
}

.src-chip[aria-pressed='true'],
.src-chip.is-on {
  color: var(--ink);
  border-color: var(--accent);
  background: var(--bg-3) radial-gradient(circle at 15px 50%, var(--accent) 0 4.5px, transparent 5px);
}

.src-results {
  display: grid;
  gap: 22px;
}

.src-section .wiki-results {
  margin-top: 10px;
}

.src-section.is-empty .wiki-results {
  display: none;
}

.src-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 15px;
  font-weight: 750;
}

.src-head small {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
}

.src-section.is-empty .src-head {
  opacity: 0.6;
}

.wiki-thumb.has-bg {
  background: radial-gradient(120% 85% at 50% 15%, color-mix(in oklab, var(--tile-bg) 62%, #fff) 0%, var(--tile-bg) 52%, color-mix(in oklab, var(--tile-bg) 60%, #000) 100%);
}

.wiki-thumb.has-bg img {
  object-fit: contain;
  object-position: 50% 100%;
}

.wiki-thumb {
  display: grid;
}

.wiki-noimg {
  place-self: center;
  padding: 12px;
  font-size: 14px;
  line-height: 1.2;
  text-align: center;
  color: var(--ink-3);
}

.wiki-card[data-aspect='square'] .wiki-thumb {
  aspect-ratio: 1;
}

.wiki-card[data-aspect='wide'] .wiki-thumb {
  aspect-ratio: 16 / 9;
}

.wiki-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.wiki-tags i {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-2);
  font-style: normal;
  font-size: 11px;
  font-weight: 650;
  color: var(--ink-3);
}

/* ---------- legends: a gold edge, a slow foil sheen, a crowned landing ---------- */

.foil {
  display: none;
}

.item.is-legend .foil {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

/* a band of light, parked off the cover until it is pointed at */
.item.is-legend .foil::before {
  content: '';
  position: absolute;
  inset: -10% -70%;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(255, 246, 214, 0.5) 47%,
    rgba(255, 210, 110, 0.32) 50%,
    rgba(170, 225, 255, 0.28) 53%,
    transparent 60%
  );
  mix-blend-mode: screen;
  transform: translateX(-62%);
}

/* light runs across the gilding once when the cover is pointed at */
.item.is-legend:hover .foil::before {
  animation: foil-sweep 1.1s cubic-bezier(0.45, 0, 0.2, 1);
}

@keyframes foil-sweep {
  to {
    transform: translateX(62%);
  }
}

/* the mark of a legend: a gilded edge, light catching on its corners */
.item.is-legend .foil::after {
  content: '';
  position: absolute;
  inset: 0;
  padding: 2.5px;
  border-radius: inherit;
  background: linear-gradient(135deg, #fff1bd 0%, #e2b13c 22%, #9c6b14 48%, #f3d57c 70%, #b8862b 100%);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.item.is-legend .cov {
  box-shadow: 0 0 0 1px rgba(60, 40, 0, 0.45);
}

.item.is-crowned .cov {
  animation: crowned 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes crowned {
  0% {
    transform: none;
  }
  25% {
    transform: scale(1.14) rotate(-1.5deg);
  }
  55% {
    transform: scale(0.98);
  }
  100% {
    transform: none;
  }
}

.legend-ribbon {
  position: fixed;
  z-index: 450;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px 9px;
  border-radius: 10px;
  background: linear-gradient(135deg, #fff3c4, #e0ae3a 50%, #a8761a);
  color: #2e1d02;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  pointer-events: none;
  animation: legend-ribbon 2.1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.legend-ribbon b {
  font: 900 13px/1 var(--font-display);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.legend-ribbon span {
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 650;
}

@keyframes legend-ribbon {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.7);
  }
  14% {
    opacity: 1;
    transform: translateY(0) scale(1.06);
  }
  22% {
    transform: none;
  }
  78% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
    transform: translateY(-14px);
  }
}

/* edit dialog: a legend sits in slowly turning rays of light, centred on the
   cover itself (a square, so the turn stays round) */
.edit-dialog.is-legend .edit-preview {
  position: relative;
  isolation: isolate;
  /* equal room above and below, so the whole halo shows and the cover sits in its middle */
  padding-block: 44px;
}

/* the turning square of rays reaches past the dialog's sides at its corners
   (masked to nothing there): no sideways scroll for that on a phone */
.edit-dialog.is-legend .dialog-body {
  overflow-x: hidden;
}

.edit-dialog.is-legend .edit-preview::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  width: 300px;
  aspect-ratio: 1;
  translate: -50% -50%;
  background:
    radial-gradient(closest-side, rgba(255, 206, 96, 0.5), rgba(255, 206, 96, 0) 62%),
    repeating-conic-gradient(from 0deg, rgba(240, 180, 60, 0) 0deg 6deg, rgba(240, 180, 60, 0.5) 10deg, rgba(240, 180, 60, 0) 14deg 20deg);
  mask-image: radial-gradient(closest-side, #000 28%, transparent 100%);
  animation: legend-rays 26s linear infinite;
  pointer-events: none;
}

@keyframes legend-rays {
  to {
    transform: rotate(1turn);
  }
}

.edit-legend,
.spot-legend {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.edit-legend {
  justify-content: center;
  margin-top: 10px;
}

.edit-legend i,
.spot-legend i {
  font-style: normal;
  color: #e3b23c;
}

.edit-legend b,
.spot-legend b {
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.edit-legend span,
.spot-legend span {
  color: var(--ink-3);
}

.spot-legend {
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.spot-card.is-legend .spot-media::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 246, 214, 0.35) 48%, rgba(170, 225, 255, 0.2) 53%, transparent 60%) 0 0 / 300% 100% no-repeat;
  mix-blend-mode: screen;
  /* one pass as the view opens, then one about every twenty seconds */
  animation: spot-foil 20s ease-in-out infinite;
}

@keyframes spot-foil {
  0% {
    background-position: 100% 0;
  }
  9%,
  100% {
    background-position: 0% 0;
  }
}

/* a legend in the hand: its foil runs across as the cover is turned, instead
   of passing by itself */
.spot-card.is-legend .spot-media.is-leaning::after {
  animation: none;
  background-position: calc(50% + var(--tx, 0) * 22%) 0;
  /* (with the light the cover already catches, the whole of it would wash the picture out) */
  opacity: calc(var(--lean, 0) * 0.5);
}

@media (prefers-reduced-motion: reduce) {
  .item.is-legend .foil::before,
  .edit-dialog.is-legend .edit-preview::before,
  .spot-card.is-legend .spot-media::after {
    animation: none;
  }
}

/* new list: what the list is about */
.cat-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* the room label on a list card shows only where a theme asks for it */
.card-room {
  display: none;
}

/* the category inside the meta line (Aurora) */
.meta-room {
  display: none;
}

/* a short form: it keeps the width of its fields, however wide the window */
.dialog.new-list-dialog {
  width: min(720px, calc(100vw - 32px));
}

.new-list-dialog .dialog-body {
  max-height: calc(100vh - 180px);
  overflow: auto;
}

/* ---------- finding a list on the home page (every theme) ---------- */

.lib-search {
  flex: 1 1 280px;
  max-width: 460px;
  height: var(--btn-h);
  margin-left: auto;
  padding-left: 12px;
  gap: 8px;
}

.lib-search > .i {
  flex: none;
  color: var(--ink-3);
}

.lib-head:has(.lib-search) {
  align-items: center;
}

.lib-count {
  margin-left: 14px;
  font: 600 15px/1 var(--font-ui);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--ink-3);
  vertical-align: middle;
}

.list-card[hidden],
.tpl-card[hidden],
.lib-nomatch[hidden],
.lib-nomatch-tpl[hidden] {
  display: none;
}

.lib-nomatch {
  display: grid;
  justify-items: start;
  gap: 10px;
  max-width: 640px;
  padding: 30px 34px;
  border-radius: var(--r-3);
  border: 2px dashed var(--line-2);
  color: var(--ink-2);
}

.lib-nomatch-tpl {
  color: var(--ink-3);
}

@media (max-width: 560px) {
  .lib-search {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
}

/* ---------- feedback ---------- */

.feedback-form .cat-pick .tag-chip .i {
  width: 16px;
  height: 16px;
}

.feedback-form textarea {
  min-height: 150px;
  resize: vertical;
}

.feedback-send {
  display: flex;
  align-items: center;
  gap: 14px;
}

.feedback-inbox {
  display: grid;
  gap: 14px;
}

.feedback-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.feedback-note {
  display: grid;
  gap: 8px;
  padding: 16px 18px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  background: var(--bg-3);
}

.feedback-note.is-done {
  opacity: 0.55;
}

.feedback-note header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 12px;
}

.feedback-kind {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
}

.feedback-note[data-kind='bug'] .feedback-kind {
  background: var(--danger);
  color: #1a0b08;
}

.feedback-note[data-kind='idea'] .feedback-kind {
  background: var(--ok);
  color: #0c1a10;
}

.feedback-who {
  font-size: 13px;
  color: var(--ink-3);
}

.feedback-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.feedback-ctx {
  font-size: 12px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.feedback-actions {
  display: flex;
  gap: 6px;
  margin-left: -10px;
}

.feedback-empty {
  display: grid;
  gap: 6px;
  padding: 26px 4px;
  color: var(--ink-2);
}

/* buttons hidden by script stay hidden whatever their display style */
.btn[hidden] {
  display: none;
}

/* a pairing: two cut-out characters side by side, a small × between them */
.cov.is-pair img {
  width: 64%;
  object-fit: contain;
  object-position: 50% 100%;
}

.cov.is-pair img.pair-a {
  left: -4%;
  right: auto;
}

.cov.is-pair img.pair-b {
  left: auto;
  right: -4%;
  opacity: 1;
  transform: scaleX(-1);
  z-index: 1;
}

.cov.is-pair .pair-x {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 6%;
  translate: -50% 0;
  font: 800 calc(var(--tw) * var(--k, 1) * 0.16) / 1 var(--font-label);
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.cov.is-pair.fit-contain::before {
  display: none;
}

/* ---------- the dropdown ----------
   Every <select class="field"> wears the same closed look: the app's own
   chevron (two strokes drawn in the text colour, so it follows every theme and
   both appearances), never the system's arrow. A page's color-scheme follows
   its palette (:root here is dark; theme-aurora.css says otherwise in the
   light appearance). Browsers that let the page draw
   the list that opens (appearance: base-select) draw it like the app's menus;
   elsewhere the system's list appears, in the page's colour scheme. */
select.field {
  appearance: none;
  -webkit-appearance: none;
  padding-inline-end: 34px;
  background-image:
    linear-gradient(to top right, transparent calc(50% - 0.6px), color-mix(in srgb, currentColor 62%, transparent) calc(50% - 0.6px) calc(50% + 0.6px), transparent calc(50% + 0.6px)),
    linear-gradient(to bottom right, transparent calc(50% - 0.6px), color-mix(in srgb, currentColor 62%, transparent) calc(50% - 0.6px) calc(50% + 0.6px), transparent calc(50% + 0.6px));
  background-repeat: no-repeat;
  background-size: 5px 5px;
  background-position: right 17px center, right 12px center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s;
}

select.field:dir(rtl) {
  background-position: left 12px center, left 17px center;
}

select.field:hover:not(:disabled, :focus) {
  border-color: color-mix(in srgb, var(--ink) 42%, transparent);
}

select.field:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* the small one: beside a search field, or inside a card */
select.field.is-compact {
  width: auto;
  height: 36px;
  padding: 0 30px 0 12px;
  border-radius: 999px;
  font-size: 13.5px;
}

select.field.is-compact:dir(rtl) {
  padding: 0 12px 0 30px;
}

/* a finger needs the full height */
@media (pointer: coarse) {
  select.field.is-compact {
    height: 44px;
  }
}

/* the list a <select> opens, where the page may draw it */
@supports (appearance: base-select) {
  select.field,
  select.field::picker(select) {
    appearance: base-select;
  }

  select.field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-inline-end: 12px;
    background-image: none;
  }

  select.field.is-compact,
  select.field.is-compact:dir(rtl) {
    padding-inline: 12px;
  }

  select.field selectedcontent {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-align: start;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  select.field::picker-icon {
    flex: none;
    content: '';
    width: 14px;
    height: 14px;
    background: currentColor;
    opacity: 0.6;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: rotate 0.2s;
  }

  select.field:open::picker-icon {
    rotate: 180deg;
  }

  select.field::picker(select) {
    box-sizing: border-box;
    min-width: anchor-size(width);
    max-width: min(92vw, 420px);
    max-height: min(60vh, 360px);
    margin-block: 6px;
    padding: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--ink) 30%, transparent) transparent;
    border: 1px solid var(--line-2);
    border-radius: var(--r-2);
    background: var(--menu-bg, var(--bg-2));
    color: var(--ink);
    box-shadow: var(--shadow-2);
  }

  select.field option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 14.5px;
    font-weight: 550;
    letter-spacing: 0;
    text-transform: none;
    color: var(--ink);
    cursor: pointer;
  }

  select.field option:is(:hover, :focus-visible):not(:disabled) {
    background: color-mix(in srgb, var(--ink) 10%, transparent);
    outline: 0;
  }

  select.field option:checked {
    font-weight: 750;
  }

  select.field option:disabled {
    color: var(--ink-3);
    opacity: 0.7;
    cursor: default;
  }

  select.field optgroup,
  select.field optgroup > legend {
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  select.field optgroup > legend {
    padding: 10px 12px 4px;
  }

  select.field option::checkmark {
    order: 1;
    margin-left: auto;
    content: '';
    width: 16px;
    height: 16px;
    background: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  }
}

/* ---------- a tick box of the app's own ----------
   The input is kept for the keyboard and unseen; the box beside it fills and
   its tick is drawn, stroke by stroke, when it is set (public/js/ui.js, tick). */

label:has(> .tick-input) {
  position: relative;
}

.tick-input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.tick-box {
  display: grid;
  flex: none;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 36%, transparent);
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.tick-box svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--bg);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* the tick is one stroke of about fourteen units: hidden, it is all gap */
  stroke-dasharray: 15;
  stroke-dashoffset: 15;
  transition: stroke-dashoffset 0.16s ease;
}

label:hover > .tick-box {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 62%, transparent);
}

.tick-input:checked + .tick-box {
  background: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
  animation: tick-set 0.36s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.tick-input:checked + .tick-box svg {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.28s cubic-bezier(0.6, 0, 0.2, 1) 0.08s;
}

.tick-input:focus-visible + .tick-box {
  outline: 2px solid var(--focus, var(--ink));
  outline-offset: 3px;
}

.tick-input:disabled + .tick-box {
  opacity: 0.45;
}

@keyframes tick-set {
  0% { transform: scale(0.82); }
  55% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .tick-input:checked + .tick-box {
    animation: none;
  }

  .tick-box svg,
  .tick-input:checked + .tick-box svg {
    transition: none;
  }
}

/* the site's mark before its name: three rows of a tier list (public/js/brand.js) */
.wordmark-mark {
  display: inline-block;
  height: 1.5em;
  margin-right: 0.34em;
  color: var(--ink);
  vertical-align: -0.42em;
}

.wordmark-mark svg {
  display: block;
  width: auto;
  height: 100%;
}
