/* Acefont: a card-table look. Ivory paper, black and card red, serif headings, fonts dealt as playing cards. */

:root {
  --ink: #151417;
  --ink-2: #2a272e;
  --paper: #f6f1e7;
  --card: #fffdf8;
  --line: #e3d9c5;
  --muted: #6f6758;
  --red: #c4122f;
  --red-dk: #9a0d24;
  --gold: #c99a3a;
  --gold-lt: #f4e6c0;
  --c: #151417;
  --c-soft: #efe8da;
  --suit: "♠";
  --r: 12px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Category colours, each with its own suit */
.hue-0 { --c: #151417; --c-soft: #ece6da; --suit: "♠"; }
.hue-1 { --c: #c4122f; --c-soft: #f8e1e4; --suit: "♥"; }
.hue-2 { --c: #1f6a4f; --c-soft: #dfeee7; --suit: "♣"; }
.hue-3 { --c: #b5761c; --c-soft: #f6ead3; --suit: "♦"; }
.hue-4 { --c: #2b3f86; --c-soft: #e2e7f5; --suit: "♠"; }
.hue-5 { --c: #c4122f; --c-soft: #f8e1e4; --suit: "♦"; }
.hue-6 { --c: #1f6a4f; --c-soft: #dfeee7; --suit: "♣"; }
.hue-7 { --c: #7a2a6b; --c-soft: #f1e1ee; --suit: "♥"; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

body { margin: 0; font: 15px/1.5 var(--sans); color: var(--ink); background: var(--paper); }

h1, h2, h3 { line-height: 1.15; margin: 0; overflow-wrap: anywhere; font-family: var(--serif); }
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }
p { margin: 0 0 .6em; }
button, input, select { font: inherit; color: inherit; }

.wrap { max-width: 1360px; margin: 0 auto; padding: 0 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 6px; background: var(--red); color: #fff; padding: 6px 12px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 6px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header: black table edge ---------- */

.top { background: var(--ink); color: var(--paper); }
.bar { display: flex; align-items: center; gap: 22px; height: 64px; }

.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; flex: 0 0 auto; }
.logo-card {
  position: relative; display: grid; place-items: center; width: 30px; height: 40px;
  background: #fff; border-radius: 5px; box-shadow: 0 0 0 2px var(--gold), 3px 3px 0 2px #000;
  transform: rotate(-6deg); transition: transform .2s;
}
.logo:hover .logo-card { transform: rotate(4deg) translateY(-2px); }
.logo-a { font: 700 22px/1 var(--serif); color: var(--red); }
.logo-pip { position: absolute; right: 3px; bottom: 1px; font-size: 9px; line-height: 1; color: var(--ink); }
.logo-text { font: 700 1.75rem/1 var(--serif); letter-spacing: -.01em; color: var(--paper); }
.logo-text i { font-weight: 400; color: var(--gold); }

.nav { display: flex; gap: 4px; flex: 0 0 auto; }
.nav a {
  padding: 6px 10px; text-decoration: none; font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(246, 241, 231, .78); border-bottom: 2px solid transparent;
}
.nav a:hover { color: #fff; border-bottom-color: var(--gold); }

.search { flex: 1 1 220px; display: flex; min-width: 0; max-width: 380px; margin-left: auto; background: var(--ink-2); border: 1px solid #3a3640; border-radius: 8px; overflow: hidden; }
.search:focus-within { border-color: var(--gold); }
.search input { flex: 1; min-width: 0; border: 0; padding: 8px 12px; background: transparent; color: var(--paper); outline: none; }
.search input::placeholder { color: #9b94a3; }
.search button { border: 0; background: transparent; color: var(--gold); padding: 0 12px; cursor: pointer; display: grid; place-items: center; }
.search button:hover { color: #fff; }
kbd { font: 600 .75rem ui-monospace, Consolas, monospace; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; background: #fff; color: var(--muted); }

.az { background: var(--card); border-bottom: 3px double var(--line); color: var(--ink); }
.az-row { display: flex; justify-content: space-between; gap: 2px; overflow-x: auto; scrollbar-width: none; padding-top: 4px; padding-bottom: 4px; }
.az a { flex: 1 0 auto; min-width: 24px; text-align: center; padding: 2px 0; border-radius: 4px; font: 600 1.02rem/1.4 var(--serif); text-decoration: none; color: var(--muted); }
.az a:hover { color: var(--red); background: var(--gold-lt); }

/* ---------- Preview bar: red, sticks to the top ---------- */

.pvbar { position: sticky; top: 0; z-index: 20; background: var(--red); color: #fff; padding: 8px 0; box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .35); }
.pvbar-row { display: flex; align-items: center; gap: 10px; }
.pvbar-label { font: italic 600 1.1rem/1 var(--serif); flex: 0 0 auto; }
.pvbar input[type=text], .tryrow input[type=text] {
  flex: 1; min-width: 0; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.pvbar input[type=text] { border-color: transparent; font-size: 1rem; }
input[type=color] { width: 36px; height: 36px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; flex: 0 0 auto; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 5px; }
input[type=color]::-moz-color-swatch { border: 0; border-radius: 5px; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 8px; padding: 6px 12px; font-weight: 700; cursor: pointer; flex: 0 0 auto; }
.pvbar .btn-ghost:hover, .pvbar .btn-ghost[aria-pressed=true] { background: #fff; color: var(--red); border-color: #fff; }
.views { display: flex; flex: 0 0 auto; }
.views .btn-ghost:first-child { border-radius: 8px 0 0 8px; }
.views .btn-ghost:last-child { border-radius: 0 8px 8px 0; border-left: 0; }

main { padding-top: 22px; padding-bottom: 48px; min-height: 60vh; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-block; background: var(--red); color: #fff; text-decoration: none; text-align: center;
  font-weight: 800; letter-spacing: .02em; padding: 10px 22px; border-radius: 8px; border: 0;
  box-shadow: 0 3px 0 var(--red-dk); transition: transform .1s, box-shadow .1s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--red-dk); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--red-dk); }

/* ---------- Page heading ---------- */

.head { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.head h1 { font-size: 2.1rem; font-weight: 700; letter-spacing: -.01em; }
.head h1::before { content: var(--suit); color: var(--c); font-size: .7em; margin-right: .35em; vertical-align: .08em; }
.count { color: var(--muted); margin: 0 0 4px; font-style: italic; font-family: var(--serif); font-size: 1.02rem; }
.sorts { display: flex; align-items: center; gap: 4px; margin-left: auto; color: var(--muted); font-size: .85rem; }
.sorts > span { margin-right: 4px; text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; font-weight: 700; }
.sort { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); text-decoration: none; font-weight: 700; color: var(--ink); }
.sort:hover { border-color: var(--ink); }
.sort.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.intro { color: var(--muted); max-width: 820px; margin: -4px 0 16px; font-size: .97rem; }
.intro p:last-child { margin-bottom: 0; }

.sec-row { display: flex; align-items: baseline; gap: 14px; margin: 30px 0 12px; }
.sec { font-size: 1.55rem; font-weight: 700; }
.sec::after { content: ""; }
.more { font-weight: 700; color: var(--red); text-decoration: none; font-size: .9rem; }
.more:hover { text-decoration: underline; }

/* ---------- Font cards, dealt like playing cards ---------- */

.flist { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.fc {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  box-shadow: 0 1px 0 #e8dfcc, 0 8px 18px -12px rgba(40, 30, 10, .45);
  transition: transform .15s, box-shadow .15s;
}
.fc::before {
  content: var(--suit); position: absolute; top: 7px; left: 10px; font: 700 .9rem/1 var(--serif); color: var(--c);
}
.fc:hover { transform: translateY(-3px) rotate(-.4deg); box-shadow: 0 1px 0 #e8dfcc, 0 16px 26px -14px rgba(40, 30, 10, .55); border-color: #cfc1a4; }
.fc:nth-child(even):hover { transform: translateY(-3px) rotate(.4deg); }
.fc-pv { grid-column: 1 / -1; display: block; padding: 22px 16px 8px; }
.fc-pv img { width: 100%; aspect-ratio: 700 / 180; object-fit: contain; }
.fc-meta { min-width: 0; padding: 8px 4px 10px 14px; border-top: 1px dashed var(--line); }
.fc-name, .fc-sub { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-name { font: 700 1.08rem/1.3 var(--serif); text-decoration: none; }
.fc-name:hover { color: var(--red); }
/* The whole card opens the font page; the other links stay clickable above it. */
.fc-name::after { content: ""; position: absolute; inset: 0; border-radius: var(--r); }
.fc-sub { font-size: .8rem; color: var(--muted); }
.fc-sub a, .fc-dl { position: relative; z-index: 1; }
.fc-sub a { text-decoration: none; }
.fc-sub a:hover { text-decoration: underline; color: var(--ink); }
.fc-dls { display: none; color: var(--muted); font-size: .82rem; white-space: nowrap; }
.fc-dl {
  display: grid; place-items: center; width: 34px; height: 34px; margin: 0 12px 0 4px; border-radius: 50%;
  text-decoration: none; font-size: 1rem; font-weight: 800; color: var(--red); border: 1.5px solid var(--red);
}
.fc-dl:hover { background: var(--red); color: #fff; }

/* List layout: a neat column of rows */
.view-rows .flist.switch { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--card); box-shadow: 0 8px 18px -14px rgba(40, 30, 10, .45); }
.view-rows .switch .fc { grid-template-columns: 230px minmax(0, 1fr) 70px 58px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.view-rows .switch .fc:hover, .view-rows .switch .fc:nth-child(even):hover { transform: none; box-shadow: none; background: var(--gold-lt); }
.view-rows .switch .fc:last-child { border-bottom: 0; }
.view-rows .switch .fc::before { top: 50%; left: 12px; transform: translateY(-50%); }
.view-rows .switch .fc-pv { grid-column: 2; grid-row: 1; padding: 6px 12px; }
.view-rows .switch .fc-pv img { width: auto; height: 52px; max-width: 100%; aspect-ratio: auto; object-position: left center; }
.view-rows .switch .fc-meta { grid-column: 1; grid-row: 1; border: 0; padding: 6px 10px 6px 32px; align-self: stretch; display: grid; align-content: center; }
.view-rows .switch .fc-dls { display: block; grid-column: 3; grid-row: 1; text-align: right; }
.view-rows .switch .fc-dl { grid-column: 4; grid-row: 1; }

/* ---------- Pager ---------- */

.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 5px; margin-top: 28px; }
.pg { min-width: 36px; text-align: center; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); text-decoration: none; font: 600 1rem/1.2 var(--serif); }
a.pg:hover { border-color: var(--ink); }
.pg-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pg-gap { padding: 0 3px; color: var(--muted); }

.empty { text-align: center; padding: 44px 16px; background: var(--card); border: 1px dashed #cfc1a4; border-radius: var(--r); }
.empty h1 { font-size: 1.8rem; margin-bottom: 8px; }

/* ---------- Home ---------- */

.hero { padding: 10px 0 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.lead { font-size: clamp(1.8rem, 3.6vw, 2.9rem); font-weight: 700; letter-spacing: -.015em; margin: 0 0 6px; }
.lead b { color: var(--red); }
.lead i { font-weight: 400; }
.promise { color: var(--muted); margin: 0; max-width: 760px; font-size: 1.02rem; }

/* Categories: tiles with a coloured top edge */
.cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.cat { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: var(--r); padding: 12px 14px; }
.cat h2, .cat h3 { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.cat h2::before, .cat h3::before { content: var(--suit); color: var(--c); font-size: .8em; margin-right: .3em; }
.cat h2 a, .cat h3 a { text-decoration: none; }
.cat h2 a:hover, .cat h3 a:hover, .cat li a:hover { color: var(--red); }
.cat ul { list-style: none; margin: 0; padding: 0; }
.cat.inline ul { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.cat li { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.cat li a { text-decoration: none; color: #40392e; font-size: .92rem; }
.cat li span { color: var(--muted); font-size: .8rem; }

/* Designers */
.people { list-style: none; margin: 0; padding: 0; columns: 5 210px; column-gap: 22px; }
.people li { break-inside: avoid; border-bottom: 1px dotted var(--line); }
.people a { display: flex; justify-content: space-between; gap: 8px; padding: 4px 4px; text-decoration: none; }
.people a:hover { color: var(--red); }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--serif); font-size: 1.02rem; }
.howmany { color: var(--muted); font-size: .8rem; }

/* ---------- Font page: one long page ---------- */

.fhead {
  position: relative; display: flex; align-items: flex-end; flex-wrap: wrap; gap: 14px 28px;
  background: var(--ink); color: var(--paper); border-radius: 16px; padding: 26px 30px 24px; margin-bottom: 14px; overflow: hidden;
}
.fhead::after {
  content: var(--suit); position: absolute; right: 22px; top: -36px; font: 700 190px/1 var(--serif);
  color: rgba(255, 255, 255, .05); pointer-events: none;
}
.fhead-main { flex: 1 1 340px; min-width: 0; position: relative; }
.kicker { margin: 0 0 4px; font-size: .72rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.fhead h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); font-weight: 700; letter-spacing: -.015em; }
.fsub { margin: 8px 0 0; color: rgba(246, 241, 231, .75); }
.fsub a { color: #fff; }
.fhead-dl { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 0 0 auto; position: relative; }
.fhead-dl .btn { font-size: 1.1rem; padding: 12px 34px; }
.fhead-dl .note { margin: 0; color: rgba(246, 241, 231, .65); }

/* "On this page" links, kept in view while scrolling */
.jump {
  position: sticky; top: 0; z-index: 15; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  background: var(--paper); padding: 8px 0; margin-bottom: 10px; border-bottom: 1px solid var(--line);
}
.jump a { padding: 5px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); text-decoration: none; font-weight: 700; font-size: .88rem; }
.jump a:hover { border-color: var(--ink); }
.jump a span { color: var(--muted); font-weight: 600; }
.jump .nf { display: none; }
.font-ready .jump .nf { display: inline-block; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.col-main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.part { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 22px; scroll-margin-top: 64px; }
.part-h { font-size: 1.45rem; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.part-h span { color: var(--ink); font-size: .8em; margin-right: .2em; }
#characters .part-h span, #about .part-h span { color: var(--red); }
.panel { position: sticky; top: 64px; background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--red); border-radius: var(--r); padding: 14px 18px; min-width: 0; scroll-margin-top: 64px; }
.panel h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 10px; }

.tryrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; padding: 10px; background: var(--paper); border-radius: 10px; }
.tryrow input[type=text] { flex: 1 1 220px; }
.tryrow input[type=range] { flex: 0 1 160px; min-width: 90px; accent-color: var(--red); }
.tryrow .btn-ghost { color: var(--ink); border-color: var(--line); background: #fff; }
.tryrow .btn-ghost:hover { border-color: var(--ink); }
.size-out { flex: 0 0 3.4em; color: var(--muted); font-variant-numeric: tabular-nums; }
.stage { padding: 8px 0; overflow: hidden; }
.stage img { margin: 0 auto; width: 100%; aspect-ratio: 700 / 180; object-fit: contain; }
.font-ready .stage { display: none; }

.note { font-size: .88rem; color: var(--muted); margin: 8px 0 0; }
.note.first { margin: 0 0 10px; }
.fine { font-size: .8rem; color: var(--muted); margin: 8px 0 0; overflow-wrap: anywhere; }
.specs { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; }
.specs dt, .specs dd { padding: 6px 0; border-bottom: 1px dotted var(--line); }
.specs dt { color: var(--muted); padding-right: 14px; font-size: .88rem; }
.specs dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.prose { overflow-wrap: anywhere; }
.prose p { max-width: 70ch; }

/* Live samples drawn with the font file (loaded by app.js as "AFFSample") */
.sample { font-family: "AFFSample", sans-serif; font-weight: normal; font-style: normal; }
.live, .needs-font { display: none; }
.font-ready .live { display: block; }
.font-ready .needs-font { display: block; }

.tester { font-size: 72px; line-height: 1.2; padding: 6px 0 12px; overflow: hidden; overflow-wrap: anywhere; min-height: 1.2em; }
.wf-row { display: flex; align-items: baseline; gap: 12px; padding: 4px 0; border-top: 1px dotted var(--line); }
.wf-size { flex: 0 0 22px; font-size: .72rem; color: var(--muted); text-align: right; }
.wf-row .sample { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; line-height: 1.3; }
.s48 { font-size: 48px; } .s32 { font-size: 32px; } .s24 { font-size: 24px; } .s16 { font-size: 16px; } .s12 { font-size: 12px; }
.para { font-size: 20px; line-height: 1.5; margin: 12px 0 0; padding-top: 12px; border-top: 1px dotted var(--line); overflow-wrap: anywhere; }

.glyphs { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 5px; }
.glyphs button {
  display: grid; place-items: center; height: 50px; padding: 0; font-size: 24px; line-height: 1; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: 7px; cursor: copy; transition: transform .1s;
}
.glyphs button:hover { background: var(--gold-lt); border-color: var(--gold); transform: translateY(-2px); }
.glyphs button.copied { background: var(--red); border-color: var(--red); color: #fff; }
.copy-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 12px); z-index: 60;
  background: var(--ink); color: var(--paper); font-weight: 700; padding: 9px 18px; border-radius: 10px; border: 1px solid var(--gold);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .25); opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.copy-toast.on { opacity: 1; transform: translate(-50%, 0); }
.copy-toast b { font-family: AFFSample, var(--serif); font-size: 1.25em; margin: 0 2px; color: #fff; }
.glyphs h3.blk { grid-column: 1 / -1; font: 700 .72rem/1.2 var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: .12em; margin: 12px 0 2px; }
.glyphs h3.blk:first-child { margin-top: 0; }

.lang-lead { margin: 0 0 8px; font-weight: 700; }
.langs { list-style: none; margin: 0 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 5px; }
.langs li { background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 2px 11px; font-weight: 600; font-size: .86rem; }
.chars { font-weight: 700; color: var(--ink); letter-spacing: .08em; }
.sub { font: 700 1.1rem/1.2 var(--serif); margin: 18px 0 8px; }
.cover { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-width: 660px; }
.cover li { display: grid; grid-template-columns: minmax(0, 13em) minmax(60px, 1fr) auto; gap: 12px; align-items: center; font-size: .9rem; }
.cover-name { font-weight: 600; overflow-wrap: anywhere; }
.cover-num { font-size: .8rem; color: var(--muted); white-space: nowrap; text-align: right; min-width: 6.5em; }
.cover-wide { grid-column: 2 / -1; text-align: left; }
.cover progress { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--paper); color: var(--red); }
.cover progress::-webkit-progress-bar { background: var(--paper); }
.cover progress::-webkit-progress-value { background: var(--red); }
.cover progress::-moz-progress-bar { background: var(--red); }

/* ---------- Test backgrounds (picker in app.js, choice set on <html> by view.js) ---------- */

.bgpick { position: relative; flex: 0 0 auto; }
.bgpick-btn { display: inline-flex; align-items: center; gap: 7px; }
.sw {
  display: inline-block; flex: 0 0 auto; width: 26px; height: 18px; border-radius: 4px; border: 1px solid rgba(0, 0, 0, .25);
  background: var(--card) center / cover no-repeat;
}
.bgpick-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30; width: 300px; max-width: calc(100vw - 24px);
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.bgpick-panel[hidden] { display: none; }
.tryrow .bgpick-panel { right: auto; left: 0; }
.bgopt {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid transparent; border-radius: 7px;
  background: none; text-align: left; font-weight: 600; font-size: .88rem; cursor: pointer;
}
.bgopt:hover { background: var(--paper); }
.bgopt[aria-pressed=true] { border-color: var(--red); background: var(--paper); }
.bgopt .sw { width: 34px; height: 22px; }
.sw-plain { background: linear-gradient(135deg, var(--card) 46%, var(--red) 46% 54%, var(--card) 54%); }

/* The pictures and ink colour of each theme */
[data-bg=notebook]  { --theme-img: url(bg/notebook.jpg);  --theme-bg: #fbf9f1; }
[data-bg=kraft]     { --theme-img: url(bg/kraft.jpg);     --theme-bg: #bc925f; }
[data-bg=sunset]    { --theme-img: url(bg/sunset.jpg);    --theme-bg: #ffb28e; }
[data-bg=wood]      { --theme-img: url(bg/wood.jpg);      --theme-bg: #4a2e1c; --theme-ink: #fff3dc; }
[data-bg=chalk]     { --theme-img: url(bg/chalk.jpg);     --theme-bg: #24302a; --theme-ink: #f4f4ee; }
[data-bg=blueprint] { --theme-img: url(bg/blueprint.jpg); --theme-bg: #1f4e8c; --theme-ink: #ffffff; }
[data-bg=neon]      { --theme-img: url(bg/neon.jpg);      --theme-bg: #1c1424; --theme-ink: #fff4fb; }
.sw-notebook, [data-bg=notebook] .bgpick-btn .sw   { background-image: url(bg/notebook-thumb.jpg); }
.sw-kraft, [data-bg=kraft] .bgpick-btn .sw         { background-image: url(bg/kraft-thumb.jpg); }
.sw-sunset, [data-bg=sunset] .bgpick-btn .sw       { background-image: url(bg/sunset-thumb.jpg); }
.sw-wood, [data-bg=wood] .bgpick-btn .sw           { background-image: url(bg/wood-thumb.jpg); }
.sw-chalk, [data-bg=chalk] .bgpick-btn .sw         { background-image: url(bg/chalk-thumb.jpg); }
.sw-blueprint, [data-bg=blueprint] .bgpick-btn .sw { background-image: url(bg/blueprint-thumb.jpg); }
.sw-neon, [data-bg=neon] .bgpick-btn .sw           { background-image: url(bg/neon-thumb.jpg); }

/* Where the background shows: card previews, the live samples and the fallback picture */
[data-bg] .fc-pv, [data-bg] .live, [data-bg] .stage {
  background: var(--theme-bg) var(--theme-img) center / cover no-repeat; border-radius: 8px; isolation: isolate;
}
[data-bg] .fc-pv { margin: 24px 10px 2px; padding: 10px 8px; }
[data-bg] .live, [data-bg] .stage { padding: 14px 18px; }
.view-rows[data-bg] .switch .fc-pv { margin: 6px 8px; padding: 4px 10px; }
[data-bg] .live .sample { color: var(--theme-ink, inherit); }
[data-bg] .wf-row, [data-bg] .para { border-top-color: rgba(127, 127, 127, .35); }
[data-bg-mode=dark] .wf-size { color: var(--theme-ink); opacity: .7; }
[data-bg=neon] .live .sample { text-shadow: 0 0 6px #ff4fd8, 0 0 20px rgba(255, 79, 216, .55); }

/* Stored pictures (dark ink, transparent or white background) adapt without redrawing:
   on light themes the white disappears, on dark themes the ink turns light. */
[data-bg-mode=light] .fc-pv img, [data-bg-mode=light] .stage img { mix-blend-mode: multiply; }
[data-bg-mode=dark] .fc-pv img, [data-bg-mode=dark] .stage img { filter: grayscale(1) invert(1) brightness(1.2); mix-blend-mode: screen; }
/* A colour the visitor picked: those pictures come from preview.php in that colour already. */
.ink-custom[data-bg-mode=dark] .fc-pv img, .ink-custom[data-bg-mode=dark] .stage img { filter: none; mix-blend-mode: normal; }

/* ---------- Footer ---------- */

.foot { background: var(--ink); color: rgba(246, 241, 231, .7); padding: 20px 0; font-size: .88rem; }
.foot-row { display: flex; justify-content: space-between; align-items: center; gap: 8px 24px; flex-wrap: wrap; }
.foot p { margin: 0; }
.foot-logo { font: 700 1.25rem/1 var(--serif); color: var(--paper); margin-right: 10px; }
.foot-logo i { font-weight: 400; color: var(--gold); }
.foot-links { display: flex; gap: 16px; flex-wrap: wrap; }
.foot-links a { text-decoration: none; color: var(--paper); }
.foot-links a:hover { color: var(--gold); }

/* ---------- Small screens ---------- */

@media (max-width: 1000px) {
  .cols { grid-template-columns: 1fr; }
  .panel { position: static; }
  .bar { flex-wrap: wrap; height: auto; padding-top: 14px; padding-bottom: 10px; gap: 10px 14px; }
  .search { order: 2; max-width: none; flex: 1 1 100%; margin-left: 0; }
  .nav { margin-left: auto; overflow-x: auto; }
  .view-rows .switch .fc { grid-template-columns: 170px minmax(0, 1fr) 56px; }
  .view-rows .switch .fc-dls { display: none; }
  .view-rows .switch .fc-dl { grid-column: 3; }
}

@media (max-width: 640px) {
  .wrap { padding-left: 12px; padding-right: 12px; }
  .nav { order: 3; flex: 1 1 100%; margin: 0; }
  .nav a { padding: 4px 6px; letter-spacing: .06em; }
  .pvbar-label, kbd, .pvbar #pv-clear, .pvbar .bgpick-label { display: none; }
  .pvbar .bgpick-btn { padding: 6px 8px; }
  .pvbar-row { position: relative; }
  .pvbar .bgpick { position: static; }
  .pvbar .bgpick-panel { left: 0; right: 0; width: auto; max-width: none; }
  .flist { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cat { padding: 10px 11px; }
  .cat h2, .cat h3 { font-size: 1.1rem; }
  .fc-pv { padding: 22px 8px 6px; }
  .fc-meta { padding-left: 10px; }
  .fc-dl { margin-right: 8px; width: 30px; height: 30px; }
  .view-rows .switch .fc { grid-template-columns: minmax(0, 1fr) 50px; }
  .view-rows .switch .fc::before { top: 14px; transform: none; }
  .view-rows .switch .fc-pv { grid-column: 1; grid-row: 2; padding: 0 10px 6px 32px; }
  .view-rows .switch .fc-pv img { height: 40px; }
  .view-rows .switch .fc-dl { grid-column: 2; grid-row: 1 / 3; }
  .sorts { margin-left: 0; }
  .head h1 { font-size: 1.7rem; }
  .fhead { padding: 20px 18px; }
  .fhead-dl { flex: 1 1 100%; align-items: stretch; }
  .part { padding: 14px 14px; }
  .jump { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .jump a { flex: 0 0 auto; }
  .tester { font-size: 44px; }
  .s48 { font-size: 34px; } .s32 { font-size: 26px; }
  .cover li { grid-template-columns: minmax(0, 1fr) auto; }
  .cover progress { grid-column: 1 / -1; grid-row: 2; }
  .cover-wide { grid-column: 2; text-align: right; }
}
