/* Tarot Study. Modern, quiet, card art is the only strong color. */

:root {
  --bg: #f4f1ec;
  --bg-2: #ebe6de;
  --bg-3: #e2dcd2;
  --ink: #1c1916;
  --ink-2: #463f39;
  --muted: #847a70;
  --faint: #b9b0a5;
  --rule: #d8d0c4;
  --accent-base: #9a4a26;
  --accent: var(--accent-base);
  --accent-soft: color-mix(in srgb, var(--accent-base) 13%, var(--bg));
  --home: #231c17;
  --home-2: #2d241e;
  --home-ink: #eee6da;
  --home-muted: #95897c;
  --radius: 14px;
  --head-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.25 0 0 0 0 0.2 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Type: Newsreader for names and reading, Inter for interface, IBM Plex Mono for small labels */
:root {
  --f-display: "Newsreader", "Noto Serif TC", Georgia, serif;
  --f-body: "Newsreader", "Noto Serif TC", Georgia, serif;
  --f-ui: "Inter", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --display-weight: 400;
  --body-size: 18px;
}
/* Simplified Chinese: use the SC serif so characters don't mix with the TC font */
html[lang="zh-Hans"] {
  --f-display: "Newsreader", "Noto Serif SC", Georgia, serif;
  --f-body: "Newsreader", "Noto Serif SC", Georgia, serif;
  --f-ui: "Inter", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg) var(--noise);
  color: var(--ink);
  font: 400 var(--body-size)/1.65 var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; outline: none; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
kbd {
  font: 500 11px/1 var(--f-mono);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 5px;
  color: var(--muted);
  background: var(--bg);
}
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 8px; z-index: 100; background: var(--bg); padding: 8px 12px; }

.label {
  font: 500 11px/1.2 var(--f-mono);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------------------------------------------------------- header */

.site-head {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--head-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* own transition layer, so named elements (card art, gallery) animate under it, not over it */
  view-transition-name: site-head;
}
.site-head::after {
  content: "";
  position: absolute;
  left: 28px; right: 28px; bottom: 0;
  height: 1px;
  background: var(--rule);
}
.brand {
  font: var(--display-weight) 24px/1 var(--f-display);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -.01em;
}
.nav { display: flex; align-items: center; gap: 2px; margin: 0 auto; }
.nav-sep { flex: none; width: 1px; height: 18px; margin: 0 8px; background: var(--rule); }
.nav-link {
  font: 500 14px/1 var(--f-ui);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--ink-2);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.nav-link:hover, .nav-trigger[aria-expanded="true"] { background: var(--bg-2); color: var(--ink); }
.nav-link.is-current { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); border-radius: 0; }
.nav-trigger[aria-expanded="true"].is-current { border-radius: 999px; box-shadow: none; }
.nav-link:focus-visible { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink-2); border-radius: 999px; }

.head-tools { display: flex; align-items: center; gap: 10px; }
.mode {
  display: inline-flex;
  background: var(--bg-2);
  border-radius: 999px;
  padding: 3px;
}
.mode button {
  font: 500 13px/1 var(--f-ui);
  padding: 9px 14px;
  border-radius: 999px;
  color: var(--muted);
  min-height: 36px;
  transition: background .2s, color .2s;
}
.mode button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.random-btn {
  font: 500 13px/1 var(--f-ui);
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  color: var(--ink-2);
  white-space: nowrap;
}
.random-btn:hover:not(:disabled) { background: var(--bg-2); color: var(--ink); }
.random-btn:disabled { color: var(--muted); opacity: .45; cursor: default; }
.search-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
}
.search-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 1.7; stroke-linecap: round; }
.search-btn:hover { background: var(--bg-2); }

/* mega menu */
.mega {
  position: absolute;
  top: calc(var(--head-h) + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(880px, calc(100vw - 32px));
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(40, 28, 18, .35);
  padding: 22px 24px 24px;
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 24px;
}
.mega[hidden] { display: none; }
/* invisible bridge over the gap under the header, so moving the mouse down keeps the menu open */
.mega::before { content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 14px; }
.mega-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; }
.mega-title { font: var(--display-weight) 28px/1 var(--f-display); }
.mega-blurb { margin: 10px 0 0; max-width: 520px; font: 400 14.5px/1.4 var(--f-ui); color: var(--muted); text-wrap: pretty; }
.mega-cols { display: grid; gap: 0 18px; align-content: start; }
.mega-cols.major { grid-template-columns: repeat(3, 1fr); }
.mega-cols.suit { grid-template-columns: repeat(2, 1fr); }
.mega-fool { grid-column: 1 / -1; margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.mega-col { display: flex; flex-direction: column; }
.mega-stage { padding: 6px 10px 12px 18px; min-height: calc(2.5em + 18px); font: 400 14.5px/1.25 var(--f-ui); color: var(--muted); text-wrap: balance; }
.mega-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  font: 400 14.5px/1.25 var(--f-ui);
  min-height: 38px;
}
.mega-item .n { font: 500 11.5px/1 var(--f-mono); color: var(--muted); width: 22px; flex: none; text-align: right; }
.mega-item.unstudied { color: var(--faint); }
.mega-item.unstudied .n { color: var(--faint); }
.mega-item:hover, .mega-item:focus-visible { background: var(--bg-2); color: var(--ink); }
.mega-item.is-current { background: var(--ink); color: var(--bg); }
.mega-item.is-current .n { color: var(--faint); }
.mega-preview {
  align-self: start;
  aspect-ratio: 1084 / 1895;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2);
}
.mega-preview img { width: 100%; height: 100%; object-fit: cover; }
.mega-legend { grid-column: 1 / -1; display: flex; gap: 16px; }

/* ---------------------------------------------------------------- home */

.home { padding: 20px 16px 8px; }
.home-panel {
  max-width: 1320px;
  margin: 0 auto;
  background: var(--home) var(--noise);
  color: var(--home-ink);
  border-radius: 20px;
  padding: 40px 40px 56px;
}
.home-top {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: center;
  padding-bottom: 22px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(238, 230, 218, .12);
}
.home .label { color: var(--home-muted); }
.prog { position: relative; align-items: center; padding-bottom: 30px; margin-bottom: 10px; }
.prog-toggle { position: absolute; top: -4px; right: 0; width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; opacity: .55; transition: opacity .15s, background .15s; }
.prog-toggle:hover, .prog-toggle:focus-visible { opacity: 1; background: rgba(238, 230, 218, .08); }
.prog-toggle .chev { width: 13px; height: 13px; stroke: var(--home-ink); transform: rotate(180deg); }
.prog-toggle:focus-visible { outline-color: var(--home-ink); }
.prog-mini { display: none; }
.prog.collapsed { padding-bottom: 14px; }
.prog.collapsed .prog-toggle { top: -8px; }
.prog.collapsed .prog-toggle .chev { transform: none; }
.prog.collapsed .prog-big, .prog.collapsed .prog-sub, .prog.collapsed .prog-body { display: none; }
.prog.collapsed .prog-mini { display: inline; color: var(--home-ink); }
.prog-head { display: flex; flex-direction: column; gap: 8px; }
.prog-big { display: flex; align-items: baseline; gap: 8px; font: var(--display-weight) 64px/.95 var(--f-display); letter-spacing: -.02em; color: var(--home-ink); }
.prog-big span { font-size: 26px; color: var(--home-muted); letter-spacing: 0; }
.prog-sub { font: 400 12.5px/1.2 var(--f-mono); color: var(--home-ink); opacity: .75; }
.prog-body { display: grid; gap: 9px; max-width: 560px; }
/* overall bar and stage rows share columns: name · bar · count */
.home-progress { font: 400 12px/1 var(--f-mono); color: var(--home-muted); }
.prog-total, .stage { display: grid; grid-template-columns: 104px minmax(0, 1fr) 36px; gap: 14px; align-items: center; font: 400 12.5px/1 var(--f-mono); color: var(--home-ink); }
.prog-total { padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px dashed rgba(238, 230, 218, .14); }
.prog-total .stage-name { font-weight: 500; }
.prog-total .bar { height: 10px; border-radius: 999px; background: rgba(238, 230, 218, .12); position: relative; overflow: hidden; }
.prog-total .bar i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--home-ink); }
.prog-total .stage-n { font-weight: 500; }
.stages { display: grid; gap: 9px; }
.stage-name { text-align: right; opacity: .85; }
.stage-n { text-align: right; }
.stage-track { display: flex; justify-content: center; height: 7px; border-radius: 999px; background: rgba(238, 230, 218, .07); }
.stage-track i { background: var(--home-ink); opacity: .6; border-radius: 999px; }
.group {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  padding: 26px 0;
  border-top: 1px solid rgba(238, 230, 218, .08);
}
.group:first-of-type { border-top: 0; }
.group-side { display: flex; flex-direction: column; gap: 14px; }
.group-name { font: var(--display-weight) 30px/1 var(--f-display); }
.group-count { font: 400 12px/1 var(--f-mono); color: var(--home-muted); }
.group-side .tile { width: calc((100% - 0px)); max-width: 118px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 18px 16px; }

.tile {
  position: relative;
  display: block;
  aspect-ratio: 1084 / 1895;
  border-radius: 6px;
  text-decoration: none;
  z-index: 1;
  transition: transform .28s var(--ease), z-index 0s .28s;
  -webkit-tap-highlight-color: transparent;
}
.tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 6px;
  filter: grayscale(.85) brightness(.4) contrast(.95);
  transition: filter .28s var(--ease), box-shadow .28s var(--ease);
}
.tile.studied img { filter: grayscale(.5) brightness(.64); }
.tile .ink {
  position: absolute;
  top: 7px; right: 7px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--home-ink);
  box-shadow: 0 0 0 2px rgba(35, 28, 23, .6);
  opacity: .9;
}
.tile .cap {
  position: absolute;
  left: 50%; top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
  white-space: nowrap;
  font: 500 12px/1 var(--f-ui);
  color: var(--home-ink);
  background: rgba(20, 16, 13, .85);
  padding: 6px 9px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s var(--ease);
}
.tile .cap b { font: 500 11px/1 var(--f-mono); color: var(--home-muted); margin-right: 6px; }
.tile:hover, .tile:focus-visible, .tile.is-active {
  transform: translateY(-8px) scale(1.14);
  z-index: 10;
  transition: transform .28s var(--ease), z-index 0s;
}
.tile:hover img, .tile:focus-visible img, .tile.is-active img {
  filter: none;
  box-shadow: 0 22px 44px -10px rgba(0, 0, 0, .7), 0 4px 12px rgba(0, 0, 0, .35);
}
.tile:hover .cap, .tile:focus-visible .cap, .tile.is-active .cap { opacity: 1; transform: translateX(-50%) translateY(0); }
.tile:focus-visible { outline-color: var(--home-ink); }

/* ---------------------------------------------------------------- card page */

.card-page { max-width: 1320px; margin: 0 auto; padding: 28px 28px 20px; }
.card-grid {
  display: grid;
  grid-template-columns: var(--art, 36%) minmax(0, 1fr);
  gap: 0 44px;
  align-items: start;
}
.art { position: sticky; top: calc(var(--head-h) + 20px); margin: 0; }
.art img {
  width: 100%;
  border-radius: 10px;
  cursor: zoom-in;
  box-shadow: 0 18px 40px -22px rgba(40, 28, 18, .5);
  view-transition-name: card-art;
}
.art-cap { margin-top: 10px; display: flex; justify-content: space-between; }
.sizebar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.sizebar button {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  font: 400 18px/1 var(--f-ui);
  color: var(--ink-2);
  flex: none;
}
.sizebar button:hover { background: var(--bg-2); }
.sizebar input[type="range"] {
  flex: 1;
  min-width: 0;
  height: 34px;
  margin: 0;
  accent-color: var(--ink);
  cursor: ew-resize;
  background: transparent;
}

.card-head { display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; padding-bottom: 20px; border-bottom: 1px solid var(--rule); }
.card-meta { display: flex; gap: 14px; align-items: center; }
.card-name {
  grid-column: 1;
  font: var(--display-weight) clamp(40px, 5vw, 64px)/1 var(--f-display);
  letter-spacing: -.02em;
  margin: 4px 0 0;
}
.element { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.element svg { width: 34px; height: 34px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; }
.card-tools { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 4px; }
.text-btn { font: 500 12px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 0; }
.text-btn:hover { color: var(--ink); }
.text-btn + .text-btn { margin-left: 16px; }

.sec { border-bottom: 1px solid var(--rule); }
.sec-head {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 12px 0;
  text-align: left;
}
button.sec-head:hover .sec-title { color: var(--accent); }
.sec-idx { font: 500 11px/1 var(--f-mono); color: var(--faint); }
.sec-title { font: 500 15px/1.2 var(--f-ui); transition: color .15s; }
.sec-title small { font: 400 12px/1 var(--f-ui); color: var(--muted); margin-left: 8px; }
.chev { width: 16px; height: 16px; stroke: var(--ink-2); fill: none; stroke-width: 1.6; transition: transform .3s var(--ease); }
.sec.open .chev { transform: rotate(180deg); }
.sec.empty .sec-head { color: var(--faint); cursor: default; }
.sec.empty .sec-title, .sec.empty .sec-title small { color: var(--faint); }
.sec.empty .sec-title::after { content: "no notes yet"; font: 400 12px/1 var(--f-ui); margin-left: 10px; }
.sec-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .36s var(--ease); }
.sec.open .sec-body { grid-template-rows: 1fr; }
.sec-inner { overflow: hidden; min-height: 0; }
.sec-content { padding: 0 0 22px 34px; opacity: 0; transform: translateY(-4px); transition: opacity .3s .05s, transform .36s var(--ease); }
.sec.open .sec-content { opacity: 1; transform: none; }
.sec.fixed .sec-head { cursor: default; }

.sec-content p { margin: 0 0 12px; }
.sec-content ul { margin: 0 0 12px; padding-left: 20px; }
.sec-content li { margin: 4px 0; }
.sec-content p.lead { margin-bottom: 2px; }
.sec-content li::marker { color: var(--faint); }
.sec-content a { color: var(--accent); text-underline-offset: 3px; }
.sec-content s { color: var(--muted); }
.keyword {
  font: var(--display-weight) clamp(24px, 2.6vw, 32px)/1.2 var(--f-display);
  letter-spacing: -.01em;
  margin: 0;
}
.keyword.tentative { color: var(--ink-2); font-style: italic; }
.keyword-note { display: block; margin-top: 6px; }
.entry { display: grid; grid-template-columns: 1fr; gap: 2px; }  /* date on its own line above the text */
.entry + .entry { margin-top: 18px; }
.date { font: 500 12px/1.9 var(--f-mono); color: var(--muted); }
main:focus-visible, main:focus { outline: none; }
.sub-label { font: 500 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: block; margin: 4px 0 8px; }
.note-source { font-size: .9em; color: var(--muted); margin-top: 6px; }
.ref { display: grid; grid-template-columns: 110px 1fr; gap: 0 12px; padding: 8px 0; border-top: 1px dashed var(--rule); }
.ref:first-child { border-top: 0; }
.ref .label { padding-top: 5px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px 14px 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  font: 500 14px/1 var(--f-ui);
  margin: 0 6px 6px 0;
}
.chip:hover { background: var(--bg-2); }
.chip .n { font: 500 11px/1 var(--f-mono); color: var(--muted); }

/* diagram */
.diagram-wrap { overflow-x: auto; padding: 6px 2px 12px; margin-left: -2px; }
.diagram { position: relative; }
.diagram svg { position: absolute; inset: 0; overflow: visible; }
.diagram path { fill: none; stroke: var(--ink-2); stroke-width: 1.3; stroke-linecap: round; }
.diagram circle { fill: var(--ink-2); }
.dnode {
  position: absolute;
  max-width: var(--dmax, 220px);
  font: 400 14.5px/1.35 var(--f-body);
  color: var(--ink);
  padding: 2px 0;
}
.dnode.root { font: var(--display-weight) 20px/1.2 var(--f-display); }
.diagram.measuring .dnode { position: static; display: inline-block; }
.diagram.animate path { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw .5s var(--ease) forwards; animation-delay: var(--d); }
.diagram.animate .dnode, .diagram.animate circle { opacity: 0; animation: appear .4s var(--ease) forwards; animation-delay: var(--d); }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* blocks below the card */
.block { margin-top: 44px; border-top: 1px solid var(--ink); }
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 64px;
  text-align: left;
}
.block-title { font: var(--display-weight) 32px/1 var(--f-display); letter-spacing: -.01em; }
.block-title .label { margin-left: 12px; vertical-align: middle; }
.block .sec-content { padding-left: 0; }

.gallery-strip { display: flex; flex-wrap: wrap; gap: 16px; }
/* every image shares one height and keeps its own proportions, so nothing is cropped */
.gitem { --gh: 325px; max-width: 100%; text-align: left; display: flex; flex-direction: column; gap: 8px; }
.gitem .gimg {
  height: var(--gh);
  aspect-ratio: 400 / 678; /* until the image loads and reports its own (see app.js) */
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-2);
  display: grid;
  place-items: center;
  outline: 2px solid transparent;
  outline-offset: -2px;
  transition: outline-color .2s;
}
/* Safari: keep the image out of the tile's size, or its natural width (900px) stretches the tile */
.gitem { align-items: flex-start; }
.gitem .gimg { position: relative; min-width: 0; }
.gitem .gimg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.gitem .gcap { width: 0; min-width: 100%; }
.gitem:hover .gimg { outline-color: var(--ink); }
.gitem .gcap { font: 500 13px/1.3 var(--f-ui); }
.gitem .gcap small { display: block; font: 400 12px/1.3 var(--f-ui); color: var(--muted); }
.gitem .gcap .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); margin-left: 6px; vertical-align: middle; }
.noimg { font: 400 12px/1.3 var(--f-mono); color: var(--faint); padding: 8px; text-align: center; }
.gallery-feature { display: grid; grid-template-columns: min(var(--gart, 340px), 70%) minmax(0, 1fr); gap: 32px; margin-bottom: 26px; }
.gallery-feature .gimg { display: block; width: 100%; aspect-ratio: auto; border-radius: 10px; overflow: hidden; background: var(--bg-2); cursor: pointer; }
.gallery-feature .gimg img { width: 100%; height: auto; }
.gallery-feature .gimg .noimg { aspect-ratio: 400 / 678; display: grid; place-items: center; }
.gnotes h3 { font: var(--display-weight) 30px/1.1 var(--f-display); margin: 0 0 4px; }
.gnotes .label { display: block; margin-bottom: 18px; }
.gnote-body { cursor: text; border-radius: 8px; margin: -6px -10px; padding: 6px 10px; transition: background .15s; }
.gnote-body:hover { background: var(--bg-2); }
.gnote-empty {
  display: block; width: 100%; min-height: 84px; text-align: left; cursor: text;
  border: 1px solid var(--rule); border-radius: 10px; background: transparent;
  padding: 12px 14px; font: 400 17px/1.6 var(--f-body); color: var(--faint);
  transition: border-color .15s;
}
.gnote-empty:hover { border-color: var(--accent); }
.gnote-body[hidden], .gnote-empty[hidden] { display: none !important; }
.seg { margin-bottom: 14px; }
.seg-label { font: 500 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-right: 10px; }
.seg .date { margin-right: 10px; }
.seg p:first-of-type { display: inline; }
.seg p { margin: 0 0 10px; }
.seg ul { margin: 8px 0 10px; padding-left: 20px; }
.gallery-rest .gitem { --gh: 224px; }
.gallery-rest .gcap { font-size: 12px; }
/* upload button after the last tile, centred on the image height (not the caption) */
.gadd { height: var(--gh, 325px); display: grid; place-items: center; padding: 0 4px; }
.gallery-rest .gadd { --gh: 224px; }
.gadd .icon-btn { width: 36px; height: 36px; border-radius: 50%; color: var(--muted); }
.gadd .icon-btn svg { width: 16px; height: 16px; }
.gallery-empty { align-items: center; }
.gallery-empty .gadd { height: auto; }
/* images saved to one card (not a deck) */
.gitem .gcap .gtag { display: inline-block; margin-left: 6px; padding: 2px 6px; border-radius: 999px; border: 1px solid var(--rule); font: 500 10px/1.2 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); vertical-align: 1px; }
.gnotes .label a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.gsaved-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; margin-top: 18px; padding-top: 6px; border-top: 1px dashed var(--rule); }
.gsaved-tools .text-btn + .text-btn { margin-left: 0; }
.gsaved-tools .text-btn:hover { color: var(--ink); }
.gsaved-tools .gs-ask { font: 400 14px/1.4 var(--f-ui); color: var(--ink-2); }
.gsaved-tools .gs-yes { color: var(--accent); }
.gdeck-form { margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--rule); max-width: 420px; }
.gdeck-form .field input { font: 400 15px/1.3 var(--f-ui); color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: 9px; padding: 10px 12px; min-height: 42px; }
.gdeck-form .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gdeck-actions { display: flex; gap: 10px; }


.compare-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px 8px; }
.compare-grid {
  display: grid;
  gap: 32px;
}
.cmp-col.is-self .cmp-top img { box-shadow: 0 0 0 2px var(--ink); }
.pill[disabled] { opacity: .45; cursor: default; }
.block-title .label:empty { display: none; }
.cmp-col { min-width: 0; }
.cmp-top { display: grid; grid-template-columns: 144px 1fr; gap: 16px; align-items: start; margin-bottom: 18px; }
.cmp-top img { border-radius: 8px; }
.cmp-name { font: var(--display-weight) 28px/1.05 var(--f-display); margin: 6px 0 6px; text-decoration: none; display: block; }
.sec-content a.cmp-name { color: var(--ink); }
.sec-content a.cmp-name:hover { color: var(--accent); }
.cmp-note { margin: 0 0 16px; padding-left: 12px; border-left: 2px solid var(--accent); }
.cmp-part { border-top: 1px solid var(--rule); padding: 12px 0 4px; }
.cmp-part > .label { display: block; margin-bottom: 8px; }
.cmp-part.empty > .label::after { content: " (none)"; color: var(--faint); }
.cmp-part .keyword { font-size: 24px; }
.cmp-empty {
  border: 1px dashed var(--faint);
  border-radius: var(--radius);
  min-height: 260px;
  display: grid;
  place-items: center;
  width: 100%;
  color: var(--muted);
  font: 500 15px/1.4 var(--f-ui);
}
.cmp-empty.narrow { padding: 0 6px; font-size: 13px; }
.cmp-empty.narrow .label { display: block; margin-top: 6px; font-size: 10px; letter-spacing: .05em; }
.cmp-empty.narrow b { display: block; font: 300 34px/1 var(--f-ui); }
.cmp-empty:hover { border-color: var(--ink); color: var(--ink); }
.cmp-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 10px; font: 500 13px/1 var(--f-ui); min-height: 40px; }
.switch i { width: 34px; height: 20px; border-radius: 999px; background: var(--faint); position: relative; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.switch[aria-pressed="true"] i { background: var(--ink); }
.switch[aria-pressed="true"] i::after { transform: translateX(14px); }
.pill { font: 500 13px/1 var(--f-ui); border: 1px solid var(--rule); border-radius: 999px; padding: 10px 14px; min-height: 40px; }
.pill:hover { background: var(--bg-2); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; }
.pager a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  transition: background .2s;
}
.pager a:hover { background: var(--bg-2); }
.pager a.next { text-align: right; align-items: flex-end; }
.pager .pname { font: var(--display-weight) 24px/1.1 var(--f-display); }

/* ---------------------------------------------------------------- method */

.method { max-width: 760px; margin: 0 auto; padding: 48px 28px; }
.method h1 { font: var(--display-weight) clamp(44px, 6vw, 72px)/1 var(--f-display); margin: 8px 0 32px; letter-spacing: -.02em; }
.method h2, .method h3, .method h4 { font: var(--display-weight) 28px/1.15 var(--f-display); margin: 36px 0 10px; }
.method-body { padding-top: 0; }
/* a blank line in the note reads as a full empty line, like Obsidian */
.method-body p, .method-body ul { margin-bottom: 1.65em; }
.method-body p.lead { margin-bottom: 2px; }

/* ---------------------------------------------------------------- journal */

.journal {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 28px 20px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0 56px;
  align-items: start;
}
.journal.side-closed { grid-template-columns: 132px minmax(0, 1fr); }
.jside { position: sticky; top: calc(var(--head-h) + 20px); max-height: calc(100vh - var(--head-h) - 40px); display: flex; flex-direction: column; }
.jside-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--ink);
  text-align: left;
}
.jside-toggle:hover .label { color: var(--ink); }
.jside-toggle .chev { transform: rotate(180deg); }
.side-closed .jside-toggle .chev { transform: rotate(-90deg); }
.jside-scroll { overflow: hidden auto; margin: 0 -10px; padding: 4px 10px 12px; }
.side-closed .jside-scroll { display: none; }
.jlist-group { padding-top: 18px; }
.jlist-group > .label { display: block; margin-bottom: 6px; }
.jlist-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  font: 400 14px/1.35 var(--f-ui);
  color: var(--ink-2);
  text-decoration: none;
}
.jlist-item:hover { background: var(--bg-2); color: var(--ink); }
.jlist-item.is-current { background: var(--bg-2); color: var(--ink); font-weight: 500; }
.jlist-item .date { line-height: 1.35; }

.jentry { max-width: 820px; }
.jentry .card-head { grid-template-columns: 1fr; }
.jentry .card-name { font-size: clamp(34px, 4vw, 52px); line-height: 1.05; }
.jlink { text-decoration: none; }
.jlink:hover { color: var(--accent); }
.reading { padding-top: 26px; scroll-margin-top: calc(var(--head-h) + 8px); }
.reading + .reading { margin-top: 56px; border-top: 1px solid var(--ink); }
.reading-meta { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.spread {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  --gap: 30px;
  gap: 28px var(--gap);
  margin: 22px 0 10px;
  padding: 30px 24px 26px;
  border-radius: var(--radius);
  /* a wooden table: warm light falling on it, plank seams, grain, then the wood itself */
  --home-ink: #fbf3e6;
  --home-muted: #e6ddd0;
  --home-2: #5a544c;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='280'%3E%3Cfilter id='g' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.006 .19' numOctaves='4' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .13 0 0 0 0 .11 0 0 0 0 .09 1.9 0 0 0 -.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
  background:
    radial-gradient(ellipse 90% 75% at 50% 38%, rgba(255, 244, 228, .14), transparent 70%),
    repeating-linear-gradient(to bottom, transparent 0 138px, rgba(28, 24, 20, .42) 138px 139px, rgba(255, 246, 232, .09) 139px 140px),
    var(--grain),
    #736c63;
  box-shadow: inset 0 0 60px rgba(30, 25, 20, .35);
}
.spread-card {
  position: relative;
  flex: 0 1 calc((100% - var(--gap) * (var(--n) - 1)) / var(--n));
  max-width: 168px;
  min-width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: var(--home-ink);
}
.spread-card img, .spread-card .noimg {
  width: 100%;
  border-radius: 7px;
  box-shadow: 0 1px 2px rgba(24, 19, 14, .3), 0 5px 10px -6px rgba(24, 19, 14, .5);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .28s var(--ease), box-shadow .28s var(--ease);
}
.spread-card .noimg { aspect-ratio: .58; display: grid; place-items: center; padding: 8px; background: var(--home-2); font: 400 13px/1.3 var(--f-ui); }
/* picked up a little: the card rises, its shadow stays on the table, so it drops further below the card and spreads */
.spread-card:hover img, .spread-card:focus-visible img {
  transform: translateY(-6px) rotate(var(--tilt, 0deg));
  box-shadow: 0 7px 5px -3px rgba(24, 19, 14, .16), 0 15px 18px -7px rgba(24, 19, 14, .42);
}
.spread-card:focus-visible { outline-color: var(--home-ink); }
.spread-pos { font: 500 11px/1 var(--f-mono); color: var(--home-muted); margin-top: 14px; }
.spread-label {
  font: 500 14px/1.3 var(--f-ui);
  margin-top: 6px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
}
.spread-name { font: 400 12px/1.3 var(--f-ui); color: var(--home-muted); margin-top: 4px; }
/* on a card page: the readings this card was drawn in */
.drawn-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
  padding: 12px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  text-decoration: none;
}
.drawn-row + .drawn-row { border-top: 1px solid var(--rule); border-radius: 0; }
.drawn-row:hover { background: var(--bg-2); }
.drawn-row:hover .drawn-title { color: var(--accent); }
.sec-content a.drawn-row { color: var(--ink); }
.drawn-row .label { text-align: right; line-height: 1.5; }
/* deck pill colours: one pastel per deck (--h hue, --s how saturated). A deck not listed here falls back to orange. */
.deck-pill {
  --h: 28;
  --s: 1;
  display: inline-block;
  margin-left: 8px;
  padding: 3px 9px;
  border: 1px solid hsl(var(--h) calc(75% * var(--s)) 76%);
  border-radius: 999px;
  background: hsl(var(--h) calc(85% * var(--s)) 94%);
  font: 500 10px/1.2 var(--f-mono);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: hsl(var(--h) calc(50% * var(--s)) 40%);
  white-space: nowrap;
  vertical-align: 2px;
}
.deck-pill[data-deck="ct"] { --h: 28; }             /* Curious Travels: orange */
.deck-pill[data-deck="tv"] { --h: 242; }            /* Terra Volatile: purple-ish blue */
.deck-pill[data-deck="po"] { --h: 58; --s: .55; }   /* Pagan Otherworlds: brownish green */
.drawn-row:has(.label:empty) .drawn-title { grid-column: 2 / -1; }
.jentry .sec-content { font-size: var(--body-size); }
.jentry .sec-content p { margin-bottom: 1em; }
.jentry .sec-content p.lead { margin-bottom: 2px; }
.jentry .sec-content ol { margin: 0 0 12px; padding-left: 22px; }
.jentry .sec-content mark { background: var(--accent-soft); color: inherit; padding: 0 2px; border-radius: 3px; }
.jentry .sec:last-child { border-bottom: 0; }
/* the header tools act on card pages only; Study / Reference only changes card pages */
body:not([data-view="home"]):not([data-view="card"]) .random-btn,
body:not([data-view="home"]):not([data-view="card"]) .mode { visibility: hidden; }

@media (max-width: 900px) {
  .journal, .journal.side-closed { grid-template-columns: 1fr; padding: 20px 16px; }
  .jside { position: static; max-height: none; margin-bottom: 20px; }
  .jside-scroll { max-height: 40vh; }
  .side-closed .jside-toggle .chev { transform: none; }
  .drawn-row { grid-template-columns: 44px minmax(0, 1fr); gap: 2px 12px; }
  .drawn-row .label { grid-column: 2; text-align: left; }
  .spread { --gap: 18px; gap: 22px var(--gap); padding: 22px 14px 20px; }
  .spread-card { min-width: 84px; }
  body:not([data-view="home"]):not([data-view="card"]) .random-btn,
  body:not([data-view="home"]):not([data-view="card"]) .mode { display: none; }
}

/* ---------------------------------------------------------------- search */

.search {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(28, 22, 18, .32);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh 16px 16px;
}
.search[hidden] { display: none; }
.search-box {
  width: min(560px, 100%);
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px -20px rgba(20, 14, 10, .5);
  overflow: hidden;
  animation: pop .18s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.search-top { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--rule); }
.search-mode { font: 500 11px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
#search-input { flex: 1; border: 0; background: none; font: 400 19px/1.3 var(--f-ui); color: var(--ink); outline: none; min-width: 0; padding: 6px 0; }
#search-input::placeholder { color: var(--faint); }
.search-list { list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow: auto; }
.search-list li {
  display: grid;
  grid-template-columns: 34px 44px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  min-height: 52px;
}
.search-list li[aria-selected="true"] { background: var(--bg-2); }
.search-list img { width: 34px; border-radius: 3px; aspect-ratio: 1084 / 1895; object-fit: cover; }
.search-list .n { font: 500 12px/1 var(--f-mono); color: var(--muted); }
.search-list .nm { font: 500 15px/1.2 var(--f-ui); }
.search-list .st { font: 400 11px/1 var(--f-mono); color: var(--faint); }
.search-list .none { display: block; color: var(--muted); font: 400 14px/1.4 var(--f-ui); padding: 14px 10px; cursor: default; }

/* ---------------------------------------------------------------- zoom */

.zoom {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(22, 17, 14, .94);
  overflow: hidden;
  touch-action: none;
  cursor: zoom-out;
  view-transition-name: zoom-bg;
}
.zoom[hidden] { display: none; }
.zoom img {
  position: absolute;
  left: 0; top: 0;
  max-width: none;
  border-radius: 8px;
  transform-origin: 0 0;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  view-transition-name: none;
}
.zoom img.dragging { cursor: grabbing; }
.zoom-hint {
  position: absolute;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  font: 400 12px/1 var(--f-mono);
  color: rgba(238, 230, 218, .6);
  pointer-events: none;
}
.zoom.fallback-in { animation: fade-in .25s var(--ease); }
@keyframes fade-in { from { opacity: 0; } }

/* ---------------------------------------------------------------- view transitions */

::view-transition-group(*) { animation-duration: .42s; animation-timing-function: var(--ease); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .25s; }
::view-transition-old(card-art), ::view-transition-new(card-art) { height: 100%; object-fit: cover; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; transition-delay: 0ms !important; }
  .tile:hover, .tile:focus-visible, .tile.is-active { transform: none; }
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1200px) {
  .site-head { gap: 12px; padding: 0 16px; }
  .site-head::after { left: 16px; right: 16px; }
  .brand { font-size: 20px; }
  .nav-link { padding: 10px 7px; font-size: 13.5px; }
  .mode button { padding: 9px 11px; }
  .random-btn { padding: 0 11px; }
  .home-top, .group { grid-template-columns: 160px 1fr; gap: 24px; }
  .home-panel { padding: 32px 28px 44px; }
  .grid { gap: 14px 12px; }
}
@media (max-width: 1010px) {
  .brand { font-size: 17px; }
  .nav-sep { margin: 0 4px; }
}
@media (max-width: 900px) {
  .nav-link { padding: 10px 5px; }
  .mode button { padding: 9px 11px; }
  .random-btn { padding: 0 11px; }
  .search-btn kbd { display: none; }
  .card-page { padding: 20px 16px; }
  .card-grid { gap: 0 24px; }
  .compare-grid { gap: 20px; }
  .cmp-top { grid-template-columns: 1fr; }
  .cmp-top img { max-width: 210px; }
}
/* the nav drops to its own row under the title once the header no longer fits on one line */
@media (max-width: 1060px) {
  :root { --head-h: 108px; }
  .site-head { flex-wrap: wrap; height: auto; padding: 8px 16px; gap: 6px; }
  .head-tools { margin-left: auto; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
}
@media (max-width: 760px) {
  .home { padding: 12px 8px; overflow-x: clip; } /* hover captions on edge tiles would widen the page */
  .home-panel { padding: 24px 16px 32px; border-radius: 14px; }
  .home-top, .group { grid-template-columns: 1fr; gap: 14px; }
  .prog { gap: 20px; }
  .prog-big { font-size: 52px; }
  .prog-total, .stage { grid-template-columns: 92px minmax(0, 1fr) 30px; gap: 10px; font-size: 12px; }
  .group-side { flex-direction: row; align-items: end; justify-content: space-between; }
  .group-side .tile { width: 72px; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .card-grid { grid-template-columns: 1fr; }
  .art { position: static; width: var(--art-m, 60%); margin: 0 auto 20px; }
  .gallery-feature { grid-template-columns: 1fr; }
  .gallery-feature .gart { max-width: min(100%, var(--gart, 340px)); }
  .ref { grid-template-columns: 1fr; }
  .mega { grid-template-columns: 1fr; top: calc(var(--head-h) + 8px); max-height: calc(100vh - var(--head-h) - 16px); overflow: auto; }
  .mega-preview { display: none; }
  .mega-cols.major { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- decks */

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 44px 32px; padding-top: 30px; }
.decks-note { margin: 0; font: 400 12px/1.6 var(--f-mono); color: var(--home-muted); }
.deck-grid + .decks-note { margin-top: 48px; padding-top: 16px; border-top: 1px solid color-mix(in srgb, var(--home-muted) 30%, transparent); }
.deck-source { margin-top: 8px; font: 400 12px/1.4 var(--f-mono); color: var(--home-muted); }
.deck-source a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.deck-source a:hover { color: var(--accent); }
.deck { display: flex; flex-direction: column; gap: 6px; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.deck-tile {
  position: relative;
  z-index: 1;
  /* as tall as the narrowest deck; each cover keeps its own shape and sits on the bottom edge */
  display: flex;
  align-items: flex-end;
  aspect-ratio: var(--tall, .6);
  margin-bottom: 10px;
  transform-origin: 50% 100%;
  transition: transform .28s var(--ease), z-index 0s .28s;
}
.deck-tile img {
  width: 100%; height: auto;
  aspect-ratio: var(--r, .6);
  object-fit: cover;
  border-radius: 8px;
  filter: grayscale(.5) brightness(.64);
  transition: filter .28s var(--ease), box-shadow .28s var(--ease);
}
.deck:hover .deck-tile, .deck:focus-visible .deck-tile {
  transform: translateY(-8px) scale(1.06);
  z-index: 10;
  transition: transform .28s var(--ease), z-index 0s;
}
.deck:hover .deck-tile img, .deck:focus-visible .deck-tile img {
  filter: none;
  box-shadow: 0 22px 44px -10px rgba(0, 0, 0, .7), 0 4px 12px rgba(0, 0, 0, .35);
}
.deck:focus-visible { outline-color: var(--home-ink); }
.deck-name { font: var(--display-weight) 22px/1.15 var(--f-display); color: var(--home-ink); }
.deck-year { font: 400 12px/1 var(--f-mono); color: var(--home-muted); }

/* one deck: other decks on top, then the gallery */
.deck-page .home-top { align-items: start; }
.deck-title { font: var(--display-weight) 30px/1.05 var(--f-display); margin: 12px 0 10px; }
.deck-switch { display: flex; gap: 16px clamp(8px, 1.4vw, 18px); margin-top: 14px; }
.deck.small { flex: 0 1 78px; min-width: 0; gap: 4px; overflow-wrap: anywhere; }
.deck.small .deck-tile { margin-bottom: 6px; }
.deck.small .deck-tile img { border-radius: 5px; }
.deck.small:hover .deck-tile, .deck.small:focus-visible .deck-tile { transform: translateY(-4px) scale(1.1); }
.deck.small .deck-name { font: 500 12px/1.25 var(--f-ui); }
.deck.small .deck-year { font-size: 11px; }
.deck-page .tile { aspect-ratio: var(--ratio); width: 100%; cursor: zoom-in; }
.deck-page .tile img { filter: none; }

.zoom-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(238, 230, 218, .12);
  transition: background .2s;
}
.zoom-close:hover { background: rgba(238, 230, 218, .24); }
.zoom-close svg { width: 20px; height: 20px; fill: none; stroke: var(--home-ink); stroke-width: 1.7; stroke-linecap: round; }
.zoom-close:focus-visible { outline-color: var(--home-ink); }

/* previous / next card, deck gallery only */
.zoom-nav {
  position: absolute;
  top: 50%;
  width: 52px; height: 52px;
  margin-top: -26px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: rgba(238, 230, 218, .12);
  opacity: .7;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}
.zoom.has-nav .zoom-nav { display: grid; }
.zoom-nav.prev { left: 16px; }
.zoom-nav.next { right: 16px; }
.zoom-nav:hover, .zoom-nav:focus-visible { background: rgba(238, 230, 218, .24); opacity: 1; }
.zoom-nav svg { width: 22px; height: 22px; fill: none; stroke: var(--home-ink); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.zoom-nav:focus-visible { outline-color: var(--home-ink); }

@media (prefers-reduced-motion: reduce) {
  .deck:hover .deck-tile, .deck:focus-visible .deck-tile { transform: none; }
}
@media (max-width: 760px) {
  .deck-grid { grid-template-columns: repeat(2, 1fr); gap: 28px 16px; padding-top: 20px; }
  .deck-name { font-size: 18px; }
  .deck-switch { flex-wrap: wrap; gap: 14px 12px; }
  .deck.small { flex: 0 0 62px; }
  .zoom-nav { width: 44px; height: 44px; margin-top: -22px; }
  .zoom-nav.prev { left: 8px; }
  .zoom-nav.next { right: 8px; }
}

/* ================================================================ demo additions */

/* ---------------------------------------------------------------- dark theme */

:root[data-theme="dark"] {
  --bg: #171412;
  --bg-2: #231e1a;
  --bg-3: #2d2722;
  --ink: #ece4d8;
  --ink-2: #cdc2b4;
  --muted: #9a8e81;
  --faint: #62584e;
  --rule: #352e28;
  --accent: color-mix(in srgb, var(--accent-base) 55%, #f4e6d8);
  --accent-soft: color-mix(in srgb, var(--accent-base) 30%, var(--bg));
  --home: #0f0d0b;
  --home-2: #1c1714;
  color-scheme: dark;
}
:root[data-theme="dark"] .mega,
:root[data-theme="dark"] .search-box,
:root[data-theme="dark"] .profile-menu,
:root[data-theme="dark"] .modal-box { box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8); }
.switch[aria-pressed="true"] i::after { background: var(--bg); }

/* ---------------------------------------------------------------- profile */

.profile { position: relative; }
.profile-btn { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; }
.avatar {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-base);
  color: #fbf4ea;
  font: 600 13px/1 var(--f-ui);
  letter-spacing: .02em;
  transition: box-shadow .2s;
}
.profile-btn:hover .avatar, .profile-btn[aria-expanded="true"] .avatar { box-shadow: 0 0 0 3px var(--bg), 0 0 0 4.5px var(--rule); }
.avatar.big { width: 42px; height: 42px; font-size: 15px; }
.avatar svg { width: 58%; height: 58%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: 248px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(40, 28, 18, .35);
  animation: pop .16s var(--ease);
}
.profile-menu[hidden] { display: none; }
.pm-head { display: flex; align-items: center; gap: 12px; padding: 10px 10px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--rule); }
.pm-name { font: 500 15px/1.2 var(--f-ui); }
.pm-email { font: 400 12.5px/1.3 var(--f-ui); color: var(--muted); }
.pm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border-radius: 8px;
  font: 400 14.5px/1.2 var(--f-ui);
  color: var(--ink);
  text-decoration: none;
  text-align: left;
}
.pm-item:hover, .pm-item:focus-visible { background: var(--bg-2); }
.pm-item svg { width: 18px; height: 18px; fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.pm-sub { margin-left: auto; font: 500 10.5px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pm-sep { height: 1px; background: var(--rule); margin: 6px 4px; }

/* ---------------------------------------------------------------- editable sections */

.sec { position: relative; }
.sec.empty.editable .sec-head { cursor: pointer; }
.sec.empty .sec-title::after { content: "no notes yet"; }
.sec.empty.editable .sec-title::after { content: "click to add"; }
.sec.empty.editable .sec-head:hover .sec-title,
.sec.empty.editable .sec-head:hover .sec-title::after { color: var(--accent); }
.sec.empty.editing .sec-title::after { content: ""; }
.sec.empty.editable.open .sec-content { padding-top: 2px; }

.sec.editable [data-edit] {
  position: relative;
  cursor: text;
  border-radius: 8px;
  margin: -6px -10px;
  padding: 6px 10px;
  transition: background .15s;
}
.sec.editable [data-edit] + [data-edit] { margin-top: 12px; }
.sec.editable [data-edit]:hover { background: var(--bg-2); }
.sec.editable .ref[data-edit] { border-top: 0; margin-top: 2px; }
.sec.editable .ref[data-edit] + .ref { border-top: 1px dashed var(--rule); }
.entry.nodate { display: block; }
.date.meta { display: block; font-size: 11.5px; color: var(--muted); opacity: .85; }
.entry-body > :last-child { margin-bottom: 0; }

.add-entry, .add-field-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  font: 500 13px/1 var(--f-ui);
  color: var(--muted);
  border: 1px dashed var(--faint);
  min-height: 34px;
}
.add-entry b, .add-field-btn b { font: 400 16px/1 var(--f-ui); }
.add-entry:hover, .add-field-btn:hover, .add-field-btn[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.sec.editing .add-entry { display: none; }

.add-field { position: relative; padding: 18px 0 4px 34px; }
.add-field-btn { margin-top: 0; }
.af-pop {
  position: absolute;
  left: 34px; top: calc(100% + 4px);
  z-index: 20;
  width: 290px;
  padding: 10px 8px 8px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px -20px rgba(40, 28, 18, .35);
  animation: pop .16s var(--ease);
}
.af-pop[hidden] { display: none; }
.af-pop > .label { display: block; padding: 2px 10px 8px; }
.af-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border-radius: 8px;
  font: 400 14.5px/1.2 var(--f-ui);
  text-align: left;
}
.af-item:hover:not(:disabled) { background: var(--bg-2); }
.af-item:disabled { color: var(--faint); cursor: default; }
.af-on { font: 500 10.5px/1 var(--f-mono); letter-spacing: .06em; text-transform: uppercase; }
.af-note { margin: 8px 10px 4px; padding-top: 10px; border-top: 1px solid var(--rule); font: 400 12.5px/1.45 var(--f-ui); color: var(--muted); }
.af-note a { color: var(--accent); text-underline-offset: 3px; }

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

[data-edit][hidden], .editable-title[hidden] { display: none !important; }

.editor {
  margin: 2px 0 4px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
  overflow: hidden;
}
.editor + [data-edit], [data-edit] + .editor { margin-top: 12px; }
.editor.nudge { animation: nudge .35s; }
@keyframes nudge { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.ed-input {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 400 17px/1.6 var(--f-body);
  padding: 12px 14px 6px;
  outline: none;
  resize: none;
  min-height: 48px;
}
textarea.ed-input { min-height: 84px; overflow: hidden; }
.ed-input::placeholder { color: var(--faint); }
.ed-mono { font: 400 14px/1.65 var(--f-mono); white-space: pre; overflow-x: auto; }
.editor[data-kind="line"] .ed-input { font: var(--display-weight) 22px/1.3 var(--f-display); }
.ed-rich { min-height: 84px; }
.ed-rich:empty::before { content: attr(data-placeholder); color: var(--faint); }
.ed-rich p { margin: 0 0 10px; }
.ed-rich ul, .ed-rich ol { margin: 0 0 10px; padding-left: 22px; }
.ed-tools { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--rule); background: var(--bg-2); }
.ed-tools button {
  width: 34px; height: 32px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font: 500 15px/1 var(--f-body);
  color: var(--ink-2);
}
.ed-tools button:hover { background: var(--bg-3); color: var(--ink); }
.ed-tools svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.ed-tools svg circle { fill: currentColor; stroke: none; }
.ed-tools svg text { fill: currentColor; stroke: none; font-family: var(--f-mono); }
.ed-tsep { width: 1px; height: 18px; background: var(--rule); margin: 0 4px; }
.ed-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 8px 14px; }
.ed-hint { font: 400 11.5px/1.4 var(--f-mono); color: var(--muted); }
.ed-actions { display: flex; gap: 6px; flex: none; }
.ed-btn {
  width: 34px; height: 32px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  background: var(--bg);
}
.ed-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ed-save { background: var(--accent-base); border-color: var(--accent-base); color: #fbf4ea; }
.ed-save:hover { filter: brightness(1.1); }
.ed-discard { color: var(--ink-2); }
.ed-discard:hover { background: var(--bg-2); color: var(--ink); }

/* ---------------------------------------------------------------- diagram picker */

.dpick { position: absolute; top: 10px; right: 30px; z-index: 5; }
.dpick-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font: 500 12.5px/1 var(--f-ui);
  color: var(--ink-2);
  background: var(--bg);
}
.dpick-btn:hover, .dpick-btn[aria-expanded="true"] { background: var(--bg-2); color: var(--ink); }
.dpick-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.dpick-btn .chev { width: 12px; height: 12px; }
.dpick-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.dpick-menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  list-style: none;
  margin: 0;
  padding: 6px;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 12px;
  box-shadow: 0 24px 60px -20px rgba(40, 28, 18, .35);
  animation: pop .16s var(--ease);
}
.dpick-menu[hidden] { display: none; }
.dpick-menu button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 7px;
  font: 400 14px/1.2 var(--f-ui);
  text-align: left;
}
.dpick-menu button:hover { background: var(--bg-2); }
.dpick-menu button[aria-selected="true"] { font-weight: 600; }
.dpick-menu button[aria-selected="true"]::after { content: "✓"; color: var(--accent); }
.diagram-soon {
  border: 1px dashed var(--faint);
  border-radius: 10px;
  padding: 26px 22px;
  text-align: center;
  color: var(--muted);
}
.diagram-soon p { margin: 8px auto 0; max-width: 360px; font: 400 14px/1.5 var(--f-ui); }

/* ---------------------------------------------------------------- journal additions */

.jside-top { display: flex; align-items: flex-end; gap: 10px; border-bottom: 1px solid var(--ink); }
.jside-top .jside-toggle { border-bottom: 0; flex: 1; }
.jnew {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
  padding: 6px 11px 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  font: 500 12.5px/1 var(--f-ui);
  color: var(--ink-2);
}
.jnew b { font: 400 15px/1 var(--f-ui); }
.jnew:hover { background: var(--bg-2); color: var(--ink); }
.side-closed .jnew { display: none; }
.editable-title { cursor: text; border-radius: 8px; margin-left: -8px; margin-right: -8px; padding: 0 8px; transition: background .15s; }
.editable-title:hover { background: var(--bg-2); }
.card-head .editor { grid-column: 1 / -1; margin-top: 6px; }
.spread-empty { justify-content: center; align-items: center; min-height: 120px; color: var(--home-muted); font: 400 14px/1.4 var(--f-ui); }
.jentry .card-head { grid-template-columns: 1fr auto; align-items: center; }
.jentry .card-head .card-name { grid-column: 1 / -1; }
.jedit-btn { grid-column: 2; grid-row: 1; padding: 6px 0; text-decoration: none; }

/* journal edit page */
.jedit .card-head { padding-bottom: 18px; }
.jedit-title {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  padding: 4px 12px;
  margin-left: -13px;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: var(--display-weight) clamp(30px, 3.6vw, 46px)/1.15 var(--f-display);
  letter-spacing: -.02em;
  width: calc(100% + 13px);
}
.jedit-title::placeholder { color: var(--faint); }
.jedit-date, .jedit-deck { display: flex; align-items: center; gap: 12px; }
.jedit-date { grid-column: 1 / -1; margin-top: 6px; }
.jedit-date .set-input, .jedit-deck .set-input { width: auto; }
.jedit-deck { margin-bottom: 12px; }
.jedit .sec-head { min-height: 48px; }
.jbox {
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.jbox:focus-within, .jedit-title:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.jbox .ed-input { padding: 12px 14px; }
.jedit-foot {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 10px;
  padding: 14px 0 18px;
  border-top: 1px solid var(--rule);
  background: var(--bg);
}
.jedit-actions { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.jedit-actions .pill { min-width: 96px; }
.jdel-btn { display: inline-flex; align-items: center; gap: 6px; color: #b2442c; }
.jdel-btn:hover { color: #8f3420; }
.jdel-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.jdel-confirm { display: flex; align-items: center; gap: 12px 18px; flex: 1; flex-wrap: wrap; font: 400 14px/1.4 var(--f-ui); color: var(--ink-2); }
.jdel-confirm[hidden] { display: none; }
.jdel-confirm b { font-weight: 500; color: var(--ink); }
.jedit-foot.is-confirming > .jdel-btn, .jedit-foot.is-confirming > .ed-hint, .jedit-foot.is-confirming > .jedit-actions { display: none; }

/* ---------------------------------------------------------------- settings */

.settings-layout { display: grid; grid-template-columns: 168px minmax(0, 820px); justify-content: center; gap: 0 44px; padding: 0 28px; }
.settings { max-width: 820px; margin: 0 auto; padding: 36px 0 40px; width: 100%; }
.set-nav { position: sticky; top: calc(var(--head-h) + 28px); align-self: start; margin-top: 44px; display: flex; flex-direction: column; gap: 2px; }
.set-nav .label { padding: 0 12px 10px; }
.set-nav-link { text-align: left; font: 500 14px/1.2 var(--f-ui); color: var(--muted); padding: 9px 12px; border-radius: 8px; min-height: 38px; }
.set-nav-link:hover { background: var(--bg-2); color: var(--ink); }
.set-nav-link.is-current { background: var(--bg-2); color: var(--ink); box-shadow: inset 2px 0 0 var(--ink); border-radius: 0 8px 8px 0; }
.set-nav-danger { margin-top: 10px; border-top: 1px solid var(--rule); border-radius: 0 0 8px 8px; padding-top: 14px; color: #b2442c; }
.set-nav-danger:hover, .set-nav-danger.is-current { color: #b2442c; background: color-mix(in srgb, #b2442c 8%, var(--bg)); }
.set-nav-danger.is-current { box-shadow: inset 2px 0 0 #b2442c; }
.settings-head { padding-bottom: 18px; border-bottom: 1px solid var(--ink); }
.settings-head h1 { font: var(--display-weight) clamp(40px, 5vw, 60px)/1 var(--f-display); letter-spacing: -.02em; margin: 6px 0 0; }
.set-sec { padding: 30px 0 34px; border-bottom: 1px solid var(--rule); scroll-margin-top: calc(var(--head-h) + 12px); }
.set-sec h2 { font: var(--display-weight) 28px/1.1 var(--f-display); margin: 0 0 16px; }
.set-note { font: 400 14px/1.5 var(--f-ui); color: var(--muted); margin: -6px 0 18px; max-width: 560px; }
.set-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  align-items: center;
  gap: 8px 24px;
  min-height: 56px;
  padding: 8px 0;
  font: 400 15px/1.3 var(--f-ui);
}
.set-row + .set-row { border-top: 1px dashed var(--rule); }
.set-row label, .set-key { font: 500 14.5px/1.3 var(--f-ui); color: var(--ink-2); }
.set-static { color: var(--muted); }
.set-email { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; min-width: 0; }
.set-email .set-static { overflow-wrap: anywhere; }
.set-email .text-btn + .text-btn, .set-email .pill + .text-btn { margin-left: 0; }
.set-email .set-input { flex: 1 1 220px; width: auto; max-width: 340px; }
.set-input {
  font: 400 15px/1.3 var(--f-ui);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 9px;
  padding: 10px 12px;
  min-height: 42px;
  width: min(100%, 340px);
}
.set-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
/* our own chevron, inset from the edge (the browser's sits tight against the border) */
select.set-input, .up-deck {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  /* same line chevron as the rest of the site; a mid grey that reads in light and dark */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 6 8 10.5 12.5 6' fill='none' stroke='%238f8478' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-size: 16px 16px;
  background-repeat: no-repeat;
}
.seg { display: inline-flex; background: var(--bg-2); border-radius: 999px; padding: 3px; justify-self: start; }
.seg button { font: 500 13px/1 var(--f-ui); padding: 9px 16px; border-radius: 999px; color: var(--muted); min-height: 36px; }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.swatches { display: flex; gap: 12px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; background: var(--sw); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--sw); }

.ed-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ed-keys { margin-top: 18px; grid-template-columns: 180px auto 1fr; }
.ed-keys-note { font-size: 13.5px; }
.ed-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.ed-option:hover { border-color: var(--faint); }
.ed-option[aria-checked="true"] { border-color: var(--ink); }
.ed-opt-demo {
  display: block;
  width: 100%;
  min-height: 74px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-2);
  font: 400 15px/1.5 var(--f-body);
  color: var(--ink-2);
}
.ed-opt-demo.mono { font: 400 13px/1.7 var(--f-mono); }
.ed-opt-bar { display: flex; gap: 12px; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); font: 500 13px/1 var(--f-ui); color: var(--muted); }
.ed-opt-name { font: 500 15px/1.2 var(--f-ui); }
.ed-opt-sub { font: 400 13px/1.4 var(--f-ui); color: var(--muted); }

.set-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.set-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto minmax(40px, auto);
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  background: var(--bg);
}
.set-item.dragging { position: relative; z-index: 2; box-shadow: 0 10px 30px -12px rgba(40, 28, 18, .45); border-radius: 10px; }
.set-item-name { font: 500 15px/1.3 var(--f-ui); }
.set-item-name small { display: block; font: 400 12.5px/1.3 var(--f-ui); color: var(--muted); }
.tag { font: 500 10.5px/1 var(--f-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 5px 8px; border-radius: 999px; background: var(--bg-2); }
.tag-preset { color: var(--accent); background: var(--accent-soft); }
.drag-handle { width: 36px; height: 40px; display: grid; place-items: center; color: var(--faint); cursor: grab; touch-action: none; }
.drag-handle:hover { color: var(--ink-2); }
.dragging .drag-handle { cursor: grabbing; }
.drag-handle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.set-item .switch { min-height: 40px; padding: 0 2px; }
/* card fields: one switch per mode, under labelled columns */
.field-item, .field-head { grid-template-columns: 36px minmax(0, 1fr) 66px 76px 76px 44px; }
.field-item .tag { justify-self: center; }
.field-head { display: grid; align-items: end; gap: 12px; padding-bottom: 8px; font: 500 10.5px/1.35 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.fh-mode { text-align: center; }
.mode-switch { display: flex; justify-content: center; }
.field-del { justify-self: end; height: 36px; min-width: 36px; padding: 0 9px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font: 500 12.5px/1 var(--f-ui); white-space: nowrap; }
.field-del svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.field-del span { display: none; }
.field-del:hover { color: #b2442c; background: color-mix(in srgb, #b2442c 10%, var(--bg)); }
.field-del.confirm { color: #fff; background: #b2442c; }
.field-del.confirm span { display: inline; }
.deck-main-note { margin: -4px 0 16px; }
.add-custom { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.add-custom .set-input { flex: 1 1 240px; width: auto; }
.pill b { font-weight: 400; margin-right: 2px; }
.pill.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill.solid:hover { background: var(--ink-2); }

.dtype-default { display: flex; align-items: center; gap: 8px; margin-top: 6px; font: 400 12.5px/1 var(--f-ui); color: var(--muted); }
.dtype-default { max-width: 100%; }
.dtype-default .set-input { width: auto; min-width: 0; flex: 0 1 auto; min-height: 32px; padding: 5px 8px; font-size: 13px; }

.jf-head { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; padding: 0 92px 8px 0; font: 500 10.5px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.jf-head .jf-inputs span { padding-left: 2px; }
.jf-inputs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 8px; min-width: 0; }
.jf-item .set-input { width: 100%; min-height: 38px; padding: 8px 10px; font-size: 14px; }
.jf-item .jf-ph { color: var(--muted); }
.jf-item .jf-ph:focus { color: var(--ink); }

.stage-row label small { display: block; margin-top: 3px; font: 400 12.5px/1.3 var(--f-ui); color: var(--muted); }
.stage-field { display: flex; align-items: center; gap: 12px; }
.stage-field .set-input { flex: 1; width: auto; max-width: 340px; }
.stage-count { font: 400 12px/1 var(--f-mono); color: var(--muted); white-space: nowrap; }
.stage-count.near { color: #b2442c; }

.danger-zone { border-bottom: 0; }
.danger-zone h2 { color: #b2442c; }
.danger-box { border: 1px solid color-mix(in srgb, #b2442c 45%, var(--rule)); border-radius: var(--radius); padding: 18px 20px; }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.danger-title { font: 500 15px/1.3 var(--f-ui); }
.danger-row p { margin: 4px 0 0; font: 400 13.5px/1.5 var(--f-ui); color: var(--muted); max-width: 480px; }
.danger-export { margin-top: 16px; padding: 14px 16px; border-radius: 10px; background: var(--bg-2); display: flex; align-items: center; justify-content: space-between; gap: 12px 18px; flex-wrap: wrap; }
.danger-export p { margin: 0; flex: 1 1 300px; font: 400 13.5px/1.5 var(--f-ui); color: var(--ink-2); }
.danger-export p b { font-weight: 500; color: var(--ink); }
.danger-export .pill { background: var(--bg); white-space: nowrap; }
.export-row { grid-template-columns: minmax(0, 1fr) auto; }
.export-row .set-key small { display: block; margin-top: 3px; font: 400 12.5px/1.3 var(--f-ui); color: var(--muted); }
.export-row .pill { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; justify-self: start; }
.export-row .pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.export-row .pill small { font: 400 11px/1 var(--f-mono); color: var(--muted); }
.danger-btn { color: #b2442c; border-color: color-mix(in srgb, #b2442c 50%, var(--rule)); white-space: nowrap; }
.danger-btn:hover { background: color-mix(in srgb, #b2442c 10%, var(--bg)); }
.danger-btn[hidden], .danger-confirm[hidden] { display: none; }
.danger-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--rule); font: 400 14px/1.3 var(--f-ui); }
.danger-confirm .set-input { width: 180px; font-family: var(--f-mono); }
.danger-actions { display: flex; gap: 10px; margin-left: auto; }
.danger-solid { background: #b2442c; border-color: #b2442c; color: #fff; }
.danger-solid:disabled { opacity: .4; cursor: not-allowed; }

.deck-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.deck-main { display: flex; align-items: center; gap: 14px; flex: 1 1 320px; }
.deck-main .set-input { flex: 1; }
.deck-actions { display: flex; justify-content: flex-end; align-items: flex-end; gap: 8px; margin: 0 0 10px; }
.deck-actions .set-note { flex: 1; margin: 0 auto 0 0; padding-right: 16px; }
.deck-actions .icon-btn { flex: none; }
.icon-btn { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--rule); display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.deck-table { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.dt-row { grid-template-columns: minmax(0, 1fr) 64px 92px 72px 44px; padding: 6px 6px 6px 14px; }
.dt-row:last-child { border-bottom: 0; }
.dt-headrow { display: grid; align-items: center; gap: 12px; min-height: 40px; background: var(--bg-2); border-bottom: 1px solid var(--rule); font: 500 10.5px/1 var(--f-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.dt-name { display: flex; align-items: center; gap: 12px; font: 500 15px/1.25 var(--f-ui); min-width: 0; text-align: left; color: var(--ink); }
.dt-row[data-id] { cursor: pointer; }
.dt-row[data-id]:hover { background: var(--bg-2); }
.dt-row[data-id]:hover .dt-name > span { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.set-sub { font: 500 14.5px/1.3 var(--f-ui); color: var(--ink-2); margin: 26px 0 10px; }
.deck-shelf { border-style: dashed; background: color-mix(in srgb, var(--bg-2) 45%, var(--bg)); }
.deck-shelf .dt-row img { opacity: .55; }
.deck-shelf .dt-check { visibility: hidden; }
.dt-empty { margin: 0; padding: 22px 16px; text-align: center; font: 400 13.5px/1.4 var(--f-ui); color: var(--muted); }
.dt-empty:not(:only-child) { display: none; }
.deck-shelf .dt-row:nth-last-child(2) { border-bottom: 0; }
.dt-name img { width: 30px; height: 50px; object-fit: cover; border-radius: 4px; flex: none; }
.dt-name small { display: block; font: 400 12.5px/1.3 var(--f-ui); color: var(--muted); }
.dt-num { text-align: right; font: 400 13px/1 var(--f-mono); color: var(--ink-2); }
.dt-headrow .dt-num { color: var(--muted); }
.dt-check { text-align: center; }
.dt-headrow .dt-check { line-height: 1.3; }
.dt-check input { width: 18px; height: 18px; accent-color: var(--accent-base); cursor: pointer; }
/* remove-deck trashcan: lid lifts, a ✓ / ✕ panel slides out to the left */
.dt-del { --red: #b2442c; --ez: cubic-bezier(.32, .72, 0, 1); position: relative; justify-self: end; width: 36px; height: 36px; z-index: 1; }
.dt-del-box { position: absolute; top: 0; right: 0; height: 36px; width: 36px; border-radius: 10px; background: transparent; transition: width .62s var(--ez), background-color .3s var(--ez); }
.dt-del[data-state="open"] .dt-del-box { width: 118px; background: color-mix(in srgb, var(--red) 9%, var(--bg)); }
.dt-del-btn { position: absolute; top: 0; right: 0; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--red); transition: transform .2s var(--ez), background-color .2s; }
.dt-del-btn:hover { background: color-mix(in srgb, var(--red) 12%, var(--bg)); }
.dt-del[data-state="open"] .dt-del-btn:hover { background: transparent; }
.dt-del-btn:active { transform: scale(.94); }
.dt-del-btn svg { grid-area: 1 / 1; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; overflow: visible; transition: opacity .22s var(--ez), transform .22s var(--ez); }
.dt-bin-lid { transform-box: view-box; transform-origin: 3px 6px; transition: transform .6s cubic-bezier(.34, 1.1, .64, 1); }
.dt-del[data-state="open"] .dt-bin-lid { transform: rotate(-35deg); }
.dt-del-btn.settle .dt-bin { animation: dt-settle .45s var(--ez); }
@keyframes dt-settle { 40% { transform: scale(.86); } }
.dt-done { opacity: 0; transform: scale(.6); stroke-width: 2.5; }
.dt-done path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.dt-del[data-status="deleted"] .dt-bin { opacity: 0; transform: scale(.6); }
.dt-del[data-status="deleted"] .dt-done { opacity: 1; transform: none; }
.dt-del[data-status="deleted"] .dt-done path { stroke-dashoffset: 0; transition: stroke-dashoffset .45s var(--ez) .1s; }
.dt-del-panel { position: absolute; top: 0; right: 41px; height: 36px; width: 74px; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--bg-2); opacity: 0; transform: translateX(6px); pointer-events: none; transition: opacity .3s var(--ez), transform .3s var(--ez); }
.dt-del-panel::after { content: ""; position: absolute; right: -5px; top: 50%; width: 6px; height: 10px; transform: translateY(-50%); background: inherit; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.dt-del[data-state="open"] .dt-del-panel { opacity: 1; transform: none; pointer-events: auto; transition: opacity .44s var(--ez) .14s, transform .44s var(--ez) .14s; }
.dt-del-c { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); background: var(--bg); box-shadow: 0 .5px 1px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.1), inset 0 .5px 0 rgba(255,255,255,.6); opacity: 0; transform: scale(.9); transition: opacity .3s var(--ez), transform .3s var(--ez), background-color .2s; }
.dt-del-c:hover { background: color-mix(in srgb, var(--bg) 70%, #fff); }
.dt-del-c svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.dt-del-yes { color: var(--red); }
.dt-del[data-state="open"] .dt-del-c { opacity: 1; transform: scale(1); transition: opacity .44s var(--ez) .21s, transform .44s var(--ez) .21s, background-color .2s; }
.dt-del[data-state="open"] .dt-del-c + .dt-del-c { transition-delay: .28s, .28s, 0s; }
.dt-del[data-state="open"] .dt-del-c:active { transform: scale(.84); transition: transform .18s cubic-bezier(.3, 1.6, .5, 1); }
.dt-row.leaving { min-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; opacity: 0; transition: height .32s var(--ez), padding .32s var(--ez), opacity .25s; }
.dt-del.pop, .dt-row .drag-handle.pop { animation: dt-pop .32s var(--ez); }
@keyframes dt-pop { from { opacity: 0; transform: scale(.7); } }
@media (prefers-reduced-motion: reduce) {
  .dt-del *, .dt-del *::after, .dt-del.pop, .dt-row .drag-handle.pop, .dt-del-btn.settle .dt-bin { transition: none !important; animation: none !important; }
}

.changelog { max-width: 720px; padding-left: 28px; padding-right: 28px; }
.cl-intro { margin: 12px 0 0; font: 400 15px/1.5 var(--f-ui); color: var(--muted); }
.cl-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.cl-v { font: 500 12px/1 var(--f-mono); color: var(--ink); }
.cl-meta .date { margin-left: auto; }
.cl-release h2 { margin-bottom: 12px; }
.cl-list { margin: 0; padding-left: 20px; font: 400 15px/1.6 var(--f-ui); color: var(--ink-2); }
.cl-list li + li { margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 999px; background: var(--ink); color: var(--bg); font: 500 13.5px/1.3 var(--f-ui); box-shadow: 0 12px 30px -12px rgba(20, 14, 10, .5); }
.toast[hidden] { display: none; }

/* ---------------------------------------------------------------- upload dialog */

.modal { position: fixed; inset: 0; z-index: 85; background: rgba(28, 22, 18, .36); display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--bg); border-radius: var(--radius); padding: 24px; box-shadow: 0 30px 80px -20px rgba(20, 14, 10, .5); animation: pop .18s var(--ease); }
.modal-box h2 { font: var(--display-weight) 30px/1.1 var(--f-display); margin: 0 0 8px; }
.modal-note { font: 400 14px/1.5 var(--f-ui); color: var(--muted); margin: 0 0 18px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field input { font: 400 15px/1.3 var(--f-ui); color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: 9px; padding: 10px 12px; min-height: 42px; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px; border: 1.5px dashed var(--faint); border-radius: 12px; text-align: center; font: 500 14px/1.4 var(--f-ui); color: var(--ink-2); }
.up-drop { width: 100%; cursor: pointer; background: transparent; transition: border-color .15s, background .15s; }
.up-drop:hover, .up-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.up-items { display: grid; gap: 12px; margin-top: 14px; }
.up-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.up-item img { width: 64px; height: 96px; object-fit: cover; border-radius: 6px; background: var(--bg-2); }
.up-item .field { margin: 0; }
.up-item-x { width: 32px; height: 32px; border-radius: 50%; color: var(--muted); }
.up-item-x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.up-switch { margin: 16px 0 0; font: 400 13px/1.4 var(--f-ui); color: var(--muted); }
.up-switch .text-btn { font: inherit; letter-spacing: normal; text-transform: none; padding: 0; text-decoration: underline; text-underline-offset: 3px; color: var(--ink-2); }
.pill[disabled] { opacity: .45; cursor: default; }
.dropzone svg { width: 28px; height: 28px; fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.name-guide { margin-top: 12px; padding: 14px 16px; border-radius: 12px; background: var(--bg-2); font: 400 13.5px/1.5 var(--f-ui); color: var(--ink-2); }
.name-guide p { margin: 0 0 10px; }
.name-guide dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0 0 10px; }
.name-guide dt { font-weight: 500; color: var(--ink); }
.name-guide dd { margin: 0; color: var(--muted); }
.name-guide code { display: inline-block; font: 400 12px/1.5 var(--f-mono); color: var(--ink-2); background: var(--bg); border-radius: 5px; padding: 1px 6px; margin: 4px 4px 0 0; }
.name-guide .label { margin: 0; font-size: 10.5px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* upload window */
.upload-box { width: min(780px, 100%); padding-bottom: 0; }
.upload-box .modal-actions { position: sticky; bottom: 0; margin: 20px -24px 0; padding: 14px 24px; background: var(--bg); border-top: 1px solid var(--rule); }
.up-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 0 14px; }
.up-deck { font: 400 15px/1.3 var(--f-ui); color: var(--ink); background: var(--bg); border: 1px solid var(--rule); border-radius: 9px; padding: 10px 12px; min-height: 42px; max-width: 420px; cursor: pointer; }
.up-deck:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.up-have { margin: -4px 0 14px; }
.up-gallery { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; margin: -2px 0 14px; }
.up-gallery .switch { color: var(--ink); }
.up-gallery-note { font: 400 13px/1.4 var(--f-ui); color: var(--muted); }
.up-bulk, .up-pick { margin-top: 16px; border: 1px solid var(--rule); border-radius: 12px; }
.up-pick-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; font: 500 14.5px/1.3 var(--f-ui); color: var(--ink); }
.up-pick-head > span:first-child { flex: 1; }
.up-pick-head small { display: block; margin-top: 2px; font: 400 13px/1.4 var(--f-ui); color: var(--muted); }
.up-pick-head .chev, .up-group-head .chev { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.6; transition: transform .2s var(--ease); }
.up-pick-head[aria-expanded="false"] .chev, .up-group-head[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.up-pick-body { padding: 0 16px 16px; }
.up-pick-body[hidden] { display: none; }
.up-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 4px 0 10px; border-bottom: 1px solid var(--rule); }
.up-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.up-chip { font: 500 12.5px/1 var(--f-ui); padding: 7px 12px; min-height: 32px; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); }
.up-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.up-group-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 0 8px; font: 500 13.5px/1 var(--f-ui); color: var(--ink); text-align: left; }
.up-group-head .label { margin-left: auto; }
.up-group + .up-group { border-top: 1px dashed var(--rule); }
.up-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; padding-bottom: 12px; }
.up-grid[hidden] { display: none; }
.up-card { aspect-ratio: 7 / 12; border-radius: 6px; border: 1px dashed var(--faint); background: var(--bg-2); display: grid; place-items: center; padding: 4px 3px; overflow: hidden; font: 400 10.5px/1.25 var(--f-ui); color: var(--muted); text-align: center; hyphens: auto; -webkit-hyphens: auto; }
.up-card:hover, .up-card:focus-visible { border-style: solid; border-color: var(--ink); color: var(--ink); }
.up-card img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
.up-card.picked, .up-card.have { padding: 0; border-style: solid; border-color: var(--rule); }
.up-card.have img { opacity: .4; }
.up-card.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.upload-box { position: relative; }
.up-card img { transition: opacity .28s cubic-bezier(.32, .72, 0, 1), transform .28s cubic-bezier(.32, .72, 0, 1); }
.up-card.popped { border-style: solid; border-color: var(--ink); }
.up-card.clearing img { opacity: 0; transform: scale(.88); }

/* Replace / Remove pill at the pointer */
.up-pop { --red: #b2442c; --ez: cubic-bezier(.32, .72, 0, 1); position: absolute; z-index: 6; display: flex; align-items: center; gap: 12px; height: 46px; padding: 0 6px; border-radius: 16px;
  background: var(--bg); box-shadow: 0 0 0 1px var(--rule), 0 14px 32px -12px rgba(20, 14, 10, .45);
  transform-origin: var(--ox, 46px) 50%; animation: up-pop-in .42s var(--ez); }
@keyframes up-pop-in { from { opacity: 0; transform: scale(.55); } }
.up-pop.leaving { opacity: 0; transform: scale(.8); transition: opacity .22s var(--ez), transform .22s var(--ez); pointer-events: none; }
.up-pop-c { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; transition: transform .2s var(--ez), background-color .2s, opacity .3s var(--ez); }
.up-pop-c:active { transform: scale(.92); }
.up-pop-c svg { grid-area: 1 / 1; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; overflow: visible; transition: opacity .22s var(--ez), transform .22s var(--ez); }
.up-pop-up { color: var(--ink-2); animation: up-pop-l .44s var(--ez) .04s backwards; }
.up-pop-up:hover { background: var(--bg-2); color: var(--ink); }
.up-pop-bin { color: var(--red); animation: up-pop-r .44s var(--ez) .1s backwards; }
.up-pop-bin:hover, .up-pop[data-state="confirm"] .up-pop-bin { background: color-mix(in srgb, var(--red) 11%, var(--bg)); }
@keyframes up-pop-l { from { opacity: 0; transform: translateX(14px) scale(.8); } }
@keyframes up-pop-r { from { opacity: 0; transform: translateX(-14px) scale(.8); } }
.up-pop[data-state="confirm"] .up-pop-up { opacity: .35; }
.up-pop[data-state="confirm"] .dt-bin-lid { transform: rotate(-35deg); }
.up-pop-bin.settle .dt-bin { animation: dt-settle .45s var(--ez); }
.up-pop[data-status="deleted"] .dt-bin { opacity: 0; transform: scale(.6); }
.up-pop[data-status="deleted"] .dt-done { opacity: 1; transform: none; }
.up-pop[data-status="deleted"] .dt-done path { stroke-dashoffset: 0; transition: stroke-dashoffset .45s var(--ez) .1s; }
.up-pop[data-status="deleted"] .up-pop-up { opacity: .35; }
.up-pop-panel { width: 0; margin-left: -12px; height: 36px; overflow: hidden; flex: none; transition: width .62s var(--ez), margin .62s var(--ez); }
.up-pop[data-state="confirm"] .up-pop-panel { width: 82px; margin-left: -2px; }
.up-pop-inner { position: relative; width: 74px; height: 36px; margin-left: 8px; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--bg-2);
  opacity: 0; transform: translateX(-6px); transition: opacity .3s var(--ez), transform .3s var(--ez); }
.up-pop-inner::before { content: ""; position: absolute; left: -5px; top: 50%; width: 6px; height: 10px; transform: translateY(-50%); background: inherit; clip-path: polygon(100% 0, 0 50%, 100% 100%); }
.up-pop[data-state="confirm"] .up-pop-inner { opacity: 1; transform: none; transition: opacity .44s var(--ez) .14s, transform .44s var(--ez) .14s; }
.up-pop .dt-del-c { opacity: 0; transform: scale(.9); }
.up-pop[data-state="confirm"] .dt-del-c { opacity: 1; transform: scale(1); transition: opacity .44s var(--ez) .21s, transform .44s var(--ez) .21s, background-color .2s; }
.up-pop[data-state="confirm"] .dt-del-c + .dt-del-c { transition-delay: .28s, .28s, 0s; }
.up-pop[data-state="confirm"] .dt-del-c:active { transform: scale(.84); transition: transform .18s cubic-bezier(.3, 1.6, .5, 1); }
/* crumple: a removed card balls up and tumbles away (built and driven in JS) */
.crumple { position: fixed; z-index: 90; pointer-events: none; }
.crumple-fall, .crumple-crush, .crumple-sheet { position: absolute; inset: 0; }
.crumple-sheet { border-radius: 6px; overflow: hidden; background: var(--bg-2); }
.crumple-sheet img { width: 100%; height: 100%; object-fit: cover; display: block; }
.crumple-sheet svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.crumple-facets { opacity: 0; }
.crumple-facets .lit { fill: rgba(255, 250, 240, .5); }
.crumple-facets .shade { fill: rgba(60, 42, 28, .3); }
.crumple-facets .soft { opacity: .55; }
.crumple-folds path { fill: none; stroke: rgba(60, 42, 28, .45); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
@media (prefers-reduced-motion: reduce) {
  .up-pop, .up-pop *, .up-pop *::before, .up-card img { transition: none !important; animation: none !important; }
}
@media (max-width: 560px) {
  .up-row { grid-template-columns: 1fr; }
  .up-grid { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
}

/* ---------------------------------------------------------------- responsive (demo additions) */

@media (max-width: 1080px) {
  .settings-layout { grid-template-columns: minmax(0, 820px); padding: 0 28px; }
  .set-nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; margin: 0 -28px; padding: 8px 28px; top: var(--head-h); z-index: 5; background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); }
  .set-nav::-webkit-scrollbar { display: none; }
  .set-nav .label { display: none; }
  .set-nav-link { white-space: nowrap; border-radius: 999px; }
  .set-nav-link.is-current { box-shadow: none; border-radius: 999px; background: var(--ink); color: var(--bg); }
  .set-nav-danger { margin: 0 0 0 6px; border-top: 0; padding-top: 9px; border-radius: 999px; }
  .set-nav-danger.is-current { box-shadow: none; background: #b2442c; color: #fff; }
  .set-sec { scroll-margin-top: calc(var(--head-h) + 66px); }
}
@media (max-width: 760px) {
  .settings-layout { padding: 0 16px; }
  .set-nav { margin: 0 -16px; padding: 8px 16px; }
  .settings { padding: 24px 0 32px; }
  .jf-inputs { grid-template-columns: 1fr; }
  .field-item, .field-head { grid-template-columns: 28px minmax(0, 1fr) 64px 64px 36px; gap: 8px; }
  .field-item .tag, .field-head > :nth-child(3) { display: none; }
  .jf-item { grid-template-columns: 28px minmax(0, 1fr) auto minmax(36px, auto); gap: 8px; }
  .jf-item .tag { display: none; }
  .jf-head { display: none; }
  .danger-row { flex-direction: column; align-items: flex-start; }
  .danger-confirm .set-input { width: 100%; }
  .stage-field .set-input { max-width: none; }
  .set-row { grid-template-columns: 1fr; gap: 8px; padding: 12px 0; }
  .set-input { width: 100%; }
  .ed-options { grid-template-columns: 1fr; }
  .dt-row { grid-template-columns: minmax(0, 1fr) 40px 60px 44px; gap: 8px; }
  .dt-row > :nth-child(3) { display: none; }
  .dt-name img { display: none; }
  .ed-hint { display: none; }
  .ed-foot { justify-content: flex-end; }
  .dpick { right: 28px; }
  .dpick-btn span { display: none; }
  .add-field { padding-left: 0; }
  .af-pop { left: 0; width: min(290px, calc(100vw - 32px)); }
  .sec-content { padding-left: 0; }
  .profile-menu { right: -4px; }
}
@media (max-width: 560px) {
  .random-btn { display: none; }
  .mode button { padding: 9px 10px; font-size: 12.5px; }
  .head-tools { gap: 6px; }
  .search-btn { padding: 0 11px; }
  .brand { font-size: 17px; }
}
@media (max-width: 760px) {
  .changelog { padding: 24px 16px 32px; }
}

/* Settings > Card system: confirmation under the choice */
.sys-note { margin: 2px 0 0 204px; max-width: 520px; font: 400 14px/1.5 var(--f-ui); color: var(--muted); }
.sys-note p { margin: 0 0 6px; }
.sys-note .sys-remind { color: var(--accent); }
.sys-note .text-btn { font: inherit; letter-spacing: normal; text-transform: none; padding: 0; text-decoration: underline; text-underline-offset: 3px; color: inherit; }
@media (max-width: 760px) { .sys-note { margin-left: 0; } }

/* journal edit: live card preview and required fields */
.jedit-preview .spread { margin: 14px 0 0; }
.jedit-preview .spread-empty { min-height: 90px; }
.jedit-missed { margin: 8px 2px 0; font: 400 13px/1.4 var(--f-ui); color: var(--muted, var(--ink-2)); }
.jedit-title.is-missing, .jbox.is-missing { border-color: #b2442c; box-shadow: 0 0 0 3px color-mix(in srgb, #b2442c 18%, transparent); }
/* the preview sits inside a section, whose links are accent-colored; keep the table's own cream */
.sec-content a.spread-card { color: var(--home-ink); }

/* Keyword (2 column): upright left, reversed right */
.kw-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.kw-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kw-col + .kw-col { border-left: 1px solid var(--rule); padding-left: 24px; }
.kw-none { color: var(--faint); }
.editor[data-kind="pair"] .ed-input { font: var(--display-weight) 22px/1.3 var(--f-display); width: 100%; }
@media (max-width: 520px) { .kw-pair { gap: 14px; } .kw-col + .kw-col { padding-left: 14px; } }
.set-item .switch:disabled { opacity: .4; cursor: not-allowed; }
.up-system { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; margin: 2px 0 14px; }
.up-system > .label { margin: 0; }
.up-system .seg button { padding: 8px 14px; min-height: 32px; }
.up-system .seg { margin: 0; }

/* ---------------------------------------------------------- decks as notebooks: systems, deck notes, switching */

/* Thoth pip title under the card name, and in menus */
.card-sub { grid-column: 1; margin: 2px 0 0; font: italic 400 20px/1.2 var(--f-display); color: var(--ink-2); }
.mega-sub { margin-left: 6px; font: 400 12px/1 var(--f-ui); color: var(--muted); }
.mega-item.is-current .mega-sub { color: var(--faint); }
/* the main deck doesn't have this card */
.art-none { display: grid; place-items: center; aspect-ratio: 400 / 678; border: 1px dashed var(--rule); border-radius: 8px; }
/* a past reading's card named in its own deck's system, with the main deck's name beside it */
.spread-alt { display: block; font-size: 11px; color: var(--muted); }

/* gallery tile: the deck's chosen fields above its deck note */
.gfield { margin-bottom: 18px; }
.gnotes .gfield .label, .gnotes .gnote-label { margin-bottom: 8px; }
.gfield .keyword { margin: 0; }
.gtree ul { margin: 4px 0; padding-left: 18px; }

/* checkbox chips (gallery tile fields, copy fields) */
.check { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px 7px 10px; border: 1px solid var(--rule); border-radius: 999px;
  font: 400 13.5px/1.2 var(--f-ui); color: var(--ink-2); cursor: pointer; }
.check:has(input:checked) { border-color: var(--ink); color: var(--ink); background: var(--bg-2); }
.check input { accent-color: var(--ink); margin: 0; }
.tile-picks, .sw-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.tile-set .set-key small { display: block; margin-top: 3px; font: 400 12.5px/1.3 var(--f-ui); color: var(--muted); }

/* switch main deck dialog */
.switch-box { width: min(560px, 100%); }
.sw-remind { font: 400 14px/1.5 var(--f-ui); color: var(--ink-2); background: var(--bg-2); border-radius: 10px; padding: 12px 14px; margin: 0 0 18px; }
.sw-sec { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
.sw-sec legend { font: 500 15px/1.35 var(--f-ui); color: var(--ink); padding: 0; margin-bottom: 6px; }
.sw-help { font: 400 13.5px/1.45 var(--f-ui); color: var(--muted); margin: 0 0 10px; }
.sw-opts { display: grid; gap: 8px; margin-bottom: 10px; }
.sw-opts.sw-row { grid-template-columns: repeat(2, max-content); }
.sw-opt { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 10px; cursor: pointer;
  font: 400 14.5px/1.3 var(--f-ui); color: var(--ink); }
.sw-opt:has(input:checked) { border-color: var(--ink); background: var(--bg-2); }
.sw-opt input { accent-color: var(--ink); margin: 2px 0 0; flex: none; }
.sw-opt small { display: block; margin-top: 3px; font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.sw-warn { font: 500 13.5px/1.45 var(--f-ui); color: #b2442c; margin: 0; }
.sw-safe { font: 400 13.5px/1.45 var(--f-ui); color: var(--muted); margin: 0; }
.sw-warn[hidden], .sw-safe[hidden], .sw-checks[hidden] { display: none; }

/* upload window: system tag locked once a deck has notes */
.seg.is-locked button { cursor: not-allowed; }
.seg.is-locked button:not([aria-checked="true"]) { opacity: .45; }

/* profile menu: quick switch between decks with notes */
.pm-label { display: block; padding: 6px 10px 4px; }
.pm-deck span { display: flex; flex-direction: column; gap: 2px; }
.pm-deck small { font: 400 12px/1.2 var(--f-ui); color: var(--muted); }
.pm-deck svg { margin-left: auto; }

/* Chinese interface: CSS-only hints (the rest is translated by js/i18n.js) */
html[lang="zh-Hans"] .sec.empty .sec-title::after { content: "还没有笔记"; }
html[lang="zh-Hans"] .sec.empty.editable .sec-title::after { content: "点击添加"; }
html[lang="zh-Hans"] .cmp-part.empty > .label::after { content: "（无）"; }
html[lang="zh-Hant"] .sec.empty .sec-title::after { content: "還沒有筆記"; }
html[lang="zh-Hant"] .sec.empty.editable .sec-title::after { content: "點擊新增"; }
html[lang="zh-Hant"] .cmp-part.empty > .label::after { content: "（無）"; }

/* ------------------------------------------------------------ give feedback */
.fb-box h2 { font: 600 19px/1.2 var(--f-ui); margin: 0 0 16px; }
.fb-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.fb-kind { font: 500 13px/1 var(--f-ui); padding: 8px 12px; border-radius: 8px; background: var(--bg-2); color: var(--ink-2); }
.fb-kind:hover { background: var(--bg-3); color: var(--ink); }
.fb-kind[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.fb-msg { border: 1px solid var(--rule); border-radius: 10px; background: var(--bg-2); padding: 12px 12px 8px; transition: border-color .15s, box-shadow .15s; }
.fb-msg:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fb-msg textarea { display: block; width: 100%; min-height: 104px; resize: vertical; border: 0; background: transparent; padding: 0; font: 400 15px/1.45 var(--f-ui); color: var(--ink); }
.fb-msg textarea:focus { outline: none; }
.fb-msg textarea::placeholder, .fb-email::placeholder { color: var(--muted); }
.fb-attach { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 4px; font: 400 13px/1 var(--f-ui); color: var(--ink-2); border-radius: 6px; }
.fb-attach:hover { color: var(--ink); }
.fb-attach svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fb-files { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.fb-files li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 8px; background: var(--bg); font: 400 13px/1.3 var(--f-ui); color: var(--ink-2); }
.fb-files li span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-files li small { color: var(--muted); flex: none; }
.fb-files li button { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; }
.fb-files li button:hover { background: var(--bg-2); color: var(--ink); }
.fb-files li svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.fb-email { display: block; width: 100%; margin-top: 12px; font: 400 15px/1.3 var(--f-ui); color: var(--ink); background: var(--bg-2); border: 1px solid var(--rule); border-radius: 10px; padding: 11px 12px; min-height: 44px; }
.fb-email:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fb-error { margin: 12px 0 0; font: 400 13px/1.45 var(--f-ui); color: #b2442c; }
