/* The Hearth — green on graph paper, gold where light falls. */
@font-face { font-family: 'Alegreya'; src: url(fonts/alegreya-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url(fonts/alegreya-latin-400-italic.woff2) format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url(fonts/alegreya-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url(fonts/alegreya-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Alegreya Sans SC'; src: url(fonts/alegreya-sans-sc-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Alegreya Sans SC'; src: url(fonts/alegreya-sans-sc-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url(fonts/ibm-plex-mono-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'IBM Plex Mono'; src: url(fonts/ibm-plex-mono-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --paper: #FBFCF7;
  --paper-2: #F2F7EE;
  --grid: rgba(60, 110, 150, 0.10);
  --grid-fine: rgba(60, 110, 150, 0.045);
  --ink: #0F2A17;
  --ink-2: #33503A;
  --ink-3: #5E7A63;
  --member: #93CE7C;
  --tie: #AAD995;
  --stone: #6CB75A;
  --stone-ink: #143B1D;
  --infill: #EEF7E8;
  --gold: #C9A23A;
  --gold-hi: #F4DC86;
  --rule: #D5E3CF;
  --danger: #A33A2A;
  --night: #0B1A10;
  --serif: 'Alegreya', Georgia, 'Times New Roman', serif;
  --caps: 'Alegreya Sans SC', 'Gill Sans', 'Trebuchet MS', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--serif);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--ink); border-radius: 2px;
  background: var(--ink); color: var(--paper);
  font-family: var(--caps); font-weight: 700; font-size: 13px; letter-spacing: 0.08em;
}
.btn:hover { background: var(--ink-2); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: transparent; }
.btn.ghost:hover { background: var(--paper-2); }
.btn.ghost[aria-pressed="false"] { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.btn.small { min-height: 32px; padding: 0 12px; font-size: 12px; }
.link { border: 0; background: none; padding: 0; color: var(--ink-3); font-family: var(--caps); font-size: 12px; letter-spacing: 0.06em; }
.link:hover { color: var(--danger); }

/* ---------- login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
}
.login-card {
  width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px;
  padding: 36px 32px; background: var(--paper); border: 1px solid var(--rule);
}
.login-mark { width: 56px; height: 56px; color: var(--stone); margin-bottom: 4px; }
.login-card h1 { margin: 0 0 14px; font-weight: 500; font-size: 36px; line-height: 1; }
.login-card label { font-family: var(--caps); font-weight: 700; font-size: 12px; letter-spacing: 0.1em; color: var(--ink-2); }
.login-card input { height: 44px; padding: 0 12px; border: 1px solid var(--ink-3); border-radius: 2px; background: #fff; }
.login-card button { height: 44px; margin-top: 6px; border: 0; border-radius: 2px; background: var(--ink); color: var(--paper); font-family: var(--caps); font-weight: 700; letter-spacing: 0.1em; }
.login-error { min-height: 1.4em; margin: 0; color: var(--danger); font-size: 14px; }

/* ---------- app shell ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 52px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--rule); background: var(--paper);
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand-name { font-weight: 500; font-size: 22px; }
.brand-house { font-family: var(--caps); font-weight: 500; font-size: 13px; letter-spacing: 0.1em; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-actions { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }

.main { flex: 1; min-height: 0; display: flex; }

/* ---------- the house ---------- */
.stage-wrap {
  position: relative; flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 18px 24px 12px;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    linear-gradient(var(--grid-fine) 1px, transparent 1px), linear-gradient(90deg, var(--grid-fine) 1px, transparent 1px);
  background-size: 40px 40px, 40px 40px, 8px 8px, 8px 8px;
  overflow: hidden;
}
.stage {
  position: relative; container-type: inline-size;
  /* aspect-ratio and size are set from the template in app.js */
}
.stage-hint { margin: 10px 0 0; font-size: 14px; color: var(--ink-3); text-align: center; max-width: 60ch; }

.m { position: absolute; pointer-events: none; }
.m.member { background: var(--member); }
.m.tie { background: var(--tie); }
.m.infill { background: var(--infill); }
.m.rafters { background: var(--member); }
.m.oculus { border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--gold-hi), var(--gold) 70%, #A9832A); }

/* every element is a button: press to draw, drop a card to file it */
.el {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.25cqw; padding: 0.4cqw; border: 0; border-radius: 0; background: transparent; text-align: center;
  color: var(--ink); transition: background-color 0.25s, box-shadow 0.35s, transform 0.12s;
}
.el .nm { font-family: var(--caps); font-weight: 700; font-size: max(7px, 0.74cqw); line-height: 1.05; letter-spacing: 0.08em; color: var(--stone-ink); }
.el .ph { font-family: var(--serif); font-weight: 500; font-size: max(10px, 1.12cqw); line-height: 1.08; }
.el .ct {
  position: absolute; top: 0.3cqw; right: 0.35cqw; min-width: 1.5cqw; padding: 0 0.3cqw;
  font-family: var(--mono); font-size: max(8px, 0.72cqw); line-height: 1.4cqw; color: var(--stone-ink);
  background: rgba(255,255,255,0.55); border-radius: 0.7cqw;
}
.el .ct:empty { display: none; }
.hide-names .el .nm, .compact .el.stone .nm, .compact .el.rafter .nm { display: none; }
.compact .el .ph { font-size: max(8.5px, 1.12cqw); }
.compact .el.stone { padding: 1px; }
.compact .el .ct { display: none; }

.el.stone { background: var(--stone); }
.el.stone:hover { background: #7DC46A; }
.el.beam .ph, .el.rafter .ph { font-size: max(11px, 1.3cqw); }
.el.rafter { transform-origin: 50% 50%; }
.el.gable .ph { font-size: max(13px, 1.9cqw); }
.el.gable .yr { font-family: var(--serif); font-weight: 700; font-size: max(17px, 2.5cqw); line-height: 1; letter-spacing: 0.06em; color: #1F5B2B; }
.el.chamber .ph { font-family: var(--caps); font-weight: 700; font-size: max(11px, 1.5cqw); letter-spacing: 0.18em; color: #2F6B34; }
.el.chamber .nm { font-weight: 500; color: var(--ink-3); }
.el.vault .ph { font-style: italic; font-weight: 400; font-size: max(11px, 1.45cqw); line-height: 1.25; max-width: 24cqw; }
.el.footing .ph { font-weight: 400; font-size: max(10px, 1.3cqw); letter-spacing: 1.1em; margin-right: -1.1em; }
.el.chamber:hover, .el.vault:hover, .el.gable:hover, .el.footing:hover { background: rgba(108,183,90,0.10); }
.el.beam:hover, .el.rafter:hover { background: rgba(255,255,255,0.22); }

.el.struck { transform: scale(0.97); }
.el.lit { box-shadow: 0 0 0 0.25cqw var(--gold), 0 0 2.4cqw 0.4cqw rgba(201,162,58,0.55); z-index: 3; }
.el.lit-soft { box-shadow: 0 0 0 0.18cqw rgba(201,162,58,0.75), 0 0 1.6cqw rgba(201,162,58,0.35); z-index: 2; }
.el.drop-over { box-shadow: 0 0 0 0.3cqw var(--ink), 0 0 0 0.6cqw var(--gold-hi); z-index: 4; }
.el.selected::after { content: ""; position: absolute; left: 20%; right: 20%; bottom: -0.55cqw; height: 0.25cqw; background: var(--ink); }

/* the hearth holds the drawn card */
.el.hearth {
  padding: 0; background: #F5FAF1; outline: 0.15cqw solid var(--stone); outline-offset: -0.15cqw;
  overflow: visible;
}
.el.hearth .hearth-label { display: flex; flex-direction: column; align-items: center; gap: 0.4cqw; padding: 1cqw; }
.el.hearth .ph { font-weight: 700; font-size: max(17px, 2.6cqw); line-height: 1; color: #1F5B2B; }
.el.hearth .hint { font-family: var(--serif); font-style: italic; font-size: max(10px, 1.05cqw); color: var(--ink-3); max-width: 22cqw; }
.el.hearth.has-card { background: transparent; outline-color: transparent; }
.hearth-card {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
}
.hearth-card .hc {
  position: relative; background: #fff; box-shadow: 0 0.4cqw 1.6cqw rgba(15,42,23,0.28), 0 0 0 0.08cqw rgba(15,42,23,0.15);
  overflow: hidden; animation: land 0.55s cubic-bezier(.2,.9,.25,1.05);
}
.hearth-card img { position: absolute; left: 50%; top: 50%; display: block; max-width: none; }
.hearth-tag {
  position: absolute; left: 50%; bottom: -2.4cqw; transform: translateX(-50%); white-space: nowrap;
  font-family: var(--caps); font-weight: 700; font-size: max(9px, 0.8cqw); letter-spacing: 0.1em; color: var(--ink-3);
}
@keyframes land {
  0%   { transform: translateY(-7cqw) rotate(-7deg) scale(0.78); opacity: 0; }
  55%  { transform: translateY(0.5cqw) rotate(1.6deg) scale(1.045); opacity: 1; }
  76%  { transform: translateY(-0.15cqw) rotate(-0.7deg) scale(0.99); }
  100% { transform: none; opacity: 1; }
}
.hearth-card .hc.holo::after, .f-card.holo .f-foil { display: block; }
.hearth-card .hc.holo::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: 0.3;
  background: linear-gradient(115deg, #ff8ab8, #ffd98a, #a8f59a, #8ae4ff, #b99aff, #ff8ab8, #ffd98a, #a8f59a);
  background-size: 300% 300%; animation: foil-drift 9s ease-in-out infinite alternate;
}
@keyframes foil-drift { from { background-position: 0% 30%; } to { background-position: 100% 70%; } }

/* jambs and walls: words up the member, between its stones */
.el.jamb, .el.wall { padding: 0; }
.el.jamb:hover, .el.wall:hover { background: rgba(255,255,255,0.28); }
.el .vw {
  position: absolute; left: 50%; writing-mode: vertical-rl; transform: translate(-50%, -50%) rotate(180deg);
  white-space: nowrap; letter-spacing: 0.05em;
}
.el.wall .vw { font-size: max(11px, 1.3cqw); }
.drag-mini {
  position: fixed; left: -400px; top: 0; overflow: hidden; background: #fff;
  box-shadow: 0 6px 16px rgba(15,42,23,0.35); transform: rotate(-3deg);
}
.drag-mini img { position: absolute; left: 50%; top: 50%; max-width: none; }

/* ---------- library ---------- */
.library {
  flex: none; width: 360px; display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--rule); background: var(--paper);
}
.lib-head { flex: none; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px 12px; border-bottom: 1px solid var(--rule); }
.lib-title { display: flex; align-items: baseline; justify-content: space-between; }
.lib-title h2 { margin: 0; font-weight: 500; font-size: 22px; }
.lib-count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.search { height: 38px; padding: 0 12px; border: 1px solid var(--rule); border-radius: 2px; background: #fff; }
.search:focus { border-color: var(--ink-3); outline: none; }
.seg { display: flex; border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; }
.seg-btn {
  flex: 1; min-height: 32px; border: 0; background: transparent; font-family: var(--caps); font-weight: 700;
  font-size: 12px; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg-btn:disabled { color: var(--ink-3); cursor: default; }

.lib-grid {
  flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 20px;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 12px; align-content: start;
}
.lib-empty { grid-column: 1 / -1; margin: 12px 0; color: var(--ink-3); font-style: italic; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 5px; padding: 0; border: 0; background: none; text-align: left;
  cursor: grab;
}
.tile:active { cursor: grabbing; }
.tile .thumb {
  position: relative; width: 100%; aspect-ratio: 1 / 1; display: grid; place-items: center;
  background: var(--paper-2); overflow: hidden;
}
.tile .thumb .tc { position: relative; overflow: hidden; background: #fff; box-shadow: 0 1px 3px rgba(15,42,23,0.25); }
.tile .thumb img { position: absolute; left: 50%; top: 50%; display: block; max-width: none; }
.tile:hover .thumb { background: #E5EFDF; }
.tile .meta { display: flex; justify-content: space-between; gap: 4px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.tile .pips { display: flex; gap: 2px; align-items: center; }
.tile .pip { width: 6px; height: 6px; background: var(--stone); }
.tile.dragging { opacity: 0.4; }
.tile.current .thumb { outline: 2px solid var(--gold); outline-offset: 2px; }

.lib-foot { flex: none; padding: 12px 16px 16px; border-top: 1px solid var(--rule); }
.drop {
  display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 1.5px dashed var(--ink-3); border-radius: 2px;
  text-align: center; cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--ink); background: var(--paper-2); }
.drop-main { font-family: var(--caps); font-weight: 700; font-size: 14px; letter-spacing: 0.08em; }
.drop-sub { font-size: 13px; color: var(--ink-3); }
.drop.busy { pointer-events: none; opacity: 0.6; }

/* ---------- focus: one card, close up ---------- */
.focus { position: fixed; inset: 0; z-index: 50; background: var(--night); color: #E9F2E4; }
.swirl { position: absolute; inset: 0; width: 100%; height: 100%; }
.crt {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.11) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}
.focus-body { position: relative; height: 100%; display: flex; }
.focus-stage {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 28px; perspective: 1600px;
}
.f-float { transform-style: preserve-3d; }
.f-float.arrive { animation: arrive 0.85s cubic-bezier(.2,.8,.3,1) both, breathe 7s ease-in-out 0.85s infinite; }
@keyframes arrive {
  0%   { transform: translateY(60px) rotate(-9deg) scale(0.55); opacity: 0; }
  50%  { transform: translateY(-6px) rotate(2.2deg) scale(1.05); opacity: 1; }
  72%  { transform: translateY(2px) rotate(-0.9deg) scale(0.985); }
  100% { transform: none; opacity: 1; }
}
@keyframes breathe { 0%, 100% { transform: none; } 50% { transform: translateY(-7px) rotate(0.6deg); } }
.f-card-tilt { transition: transform 0.25s ease-out; transform-style: preserve-3d; }
.f-card { position: relative; transform-style: preserve-3d; transition: transform 0.7s cubic-bezier(.3,.8,.25,1); }
.f-card.flipped { transform: rotateY(180deg); }
.f-face {
  position: absolute; left: 50%; top: 50%; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: #fff; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.08);
}
.f-back { transform: rotateY(180deg); }
.f-face img { position: absolute; left: 50%; top: 50%; display: block; max-width: none; transition: transform 0.45s ease, opacity 0.25s; }
.f-face img.loading, .f-face img:not([src]) { opacity: 0; }
/* holographic foil: a rainbow that slides as the card tilts, with a fine etched grain */
.f-foil {
  display: none; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply; opacity: 0.26;
  background:
    repeating-linear-gradient(62deg, rgba(255,255,255,0.0) 0 3px, rgba(255,255,255,0.18) 3px 4px),
    linear-gradient(115deg, #ff8ab8 0%, #ffd98a 12%, #a8f59a 25%, #8ae4ff 37%, #b99aff 50%, #ff8ab8 62%, #ffd98a 75%, #a8f59a 87%, #8ae4ff 100%);
  background-size: 100% 100%, 320% 320%;
  background-position: 0 0, var(--fx, 40%) var(--fy, 40%);
  transition: background-position 0.2s ease-out;
}
.f-card.holo .f-shine { mix-blend-mode: overlay; background: radial-gradient(circle at var(--sx, 30%) var(--sy, 20%), rgba(255,255,255,0.8), rgba(255,255,255,0.15) 30%, transparent 60%); }
.f-shine {
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light;
  background: radial-gradient(circle at var(--sx, 30%) var(--sy, 20%), rgba(255,255,255,0.55), transparent 55%);
}
.f-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.pill {
  min-height: 40px; padding: 0 18px; border: 1px solid rgba(233,242,228,0.35); border-radius: 20px;
  background: rgba(11,26,16,0.55); color: #E9F2E4; font-family: var(--caps); font-weight: 700; font-size: 13px; letter-spacing: 0.1em;
  backdrop-filter: blur(6px);
}
.pill:hover { border-color: var(--gold-hi); color: var(--gold-hi); }
.pill.tick { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.pill.tick input { width: 15px; height: 15px; margin: 0; accent-color: var(--gold); }
.pill.tick:has(input:checked) { border-color: var(--gold-hi); color: var(--gold-hi); }
.back {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px 0 10px;
  border: 1px solid var(--ink); border-radius: 2px; background: var(--ink); color: var(--paper);
  font-family: var(--caps); font-weight: 700; font-size: 13px; letter-spacing: 0.08em;
}
.back:hover { background: var(--ink-2); }

.f-panel {
  flex: none; width: 380px; overflow-y: auto; padding: 22px 22px 40px; display: flex; flex-direction: column; gap: 22px;
  background: var(--paper); color: var(--ink); box-shadow: -20px 0 60px rgba(0,0,0,0.35);
}
.f-sec { display: flex; flex-direction: column; gap: 10px; }
.f-sec h3 { margin: 0; font-family: var(--caps); font-weight: 700; font-size: 13px; letter-spacing: 0.12em; color: #2F6B34; padding-bottom: 7px; border-bottom: 1px solid var(--ink); }
.f-sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--ink); padding-bottom: 7px; }
.f-sec-head h3 { border: 0; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .none { color: var(--ink-3); font-style: italic; font-size: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: var(--stone); color: var(--stone-ink);
  font-size: 14px; line-height: 1.2;
}
.chip b { font-family: var(--caps); font-weight: 700; font-size: 11px; letter-spacing: 0.06em; }
.chip button { width: 22px; height: 22px; border: 0; background: rgba(255,255,255,0.35); color: var(--stone-ink); font-size: 14px; line-height: 1; }
.chip button:hover { background: #fff; }
.f-select { height: 38px; padding: 0 8px; border: 1px solid var(--rule); border-radius: 2px; background: #fff; }
.f-text { width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 2px; background: #fff; resize: vertical; font-size: 15px; line-height: 1.45; }
.f-text:focus { outline: none; border-color: var(--ink-3); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.status[data-s="running"], .status[data-s="queued"] { color: #8A6A12; }
.status[data-s="failed"] { color: var(--danger); }

.rec .rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #E05A43; }
.rec[aria-pressed="true"] { background: #7A2416; border-color: #7A2416; }
.rec[aria-pressed="true"] .rec-dot { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.entries { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.entry { display: flex; flex-direction: column; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; }
.entry-time { font-family: var(--mono); font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.entry-text { margin: 0; white-space: pre-wrap; }
.entry-text:empty { display: none; }
.entry-audio { width: 100%; height: 36px; }
.entry-transcript { display: flex; flex-direction: column; gap: 3px; }
.entry-tx { margin: 0; white-space: pre-wrap; font-style: italic; color: var(--ink-2); border-radius: 2px; }
.entry-tx[contenteditable="true"] { font-style: normal; outline: 1px solid var(--ink-3); outline-offset: 4px; background: #fff; }
.entry-tx:empty::before { content: "No transcript yet. Click to type one."; color: var(--ink-3); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 80; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(560px, calc(100% - 32px)); padding: 11px 16px; background: var(--ink); color: var(--paper);
  font-size: 15px; box-shadow: 0 10px 30px rgba(15,42,23,0.3); transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- narrow screens ---------- */
@media (max-width: 900px) {
  .main { flex-direction: column; overflow-y: auto; }
  .stage-wrap { flex: none; padding: 16px; }
  .library { width: auto; border-left: 0; border-top: 1px solid var(--rule); }
  .lib-grid { overflow: visible; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .focus-body { flex-direction: column; overflow-y: auto; }
  .focus-stage { flex: none; min-height: 70vh; }
  .f-panel { width: auto; overflow: visible; }
  .bar .btn.ghost { padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* jambs and walls glow beneath their stones, never over them */
.el.jamb.lit, .el.jamb.lit-soft, .el.jamb.drop-over, .el.wall.lit, .el.wall.lit-soft, .el.wall.drop-over { z-index: auto; }
.el.jamb .ct, .el.wall .ct { right: auto; left: 50%; transform: translateX(-50%); }
.el.jamb .ct { top: 7%; }
.el.wall .ct { top: 3%; }

/* ---------- chords, scores and spreads ---------- */
.main { position: relative; }
.play-panel {
  position: absolute; top: 8px; right: 376px; z-index: 30; width: min(860px, calc(100% - 400px));
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px;
  padding: 20px 22px 22px; background: var(--paper); border: 1px solid var(--ink);
  box-shadow: 0 18px 50px rgba(15,42,23,0.22);
}
.pp-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pp-col h3 { margin: 0; padding-bottom: 7px; border-bottom: 1px solid var(--ink); font-family: var(--caps); font-weight: 700; font-size: 13px; letter-spacing: 0.12em; color: #2F6B34; }
.pp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 52vh; overflow-y: auto; }
.pp-list li { display: flex; align-items: stretch; }
.pp-item {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 7px 8px; border: 0; background: none; text-align: left;
}
.pp-item:hover { background: var(--paper-2); }
.pp-name { font-weight: 500; font-size: 16px; line-height: 1.2; }
.pp-about { font-size: 13px; line-height: 1.3; color: var(--ink-3); }
.pp-del { flex: none; border: 0; background: none; padding: 0 8px; color: var(--ink-3); font-family: var(--caps); font-size: 12px; }
.pp-del:hover, .pp-del[data-armed="1"] { color: var(--danger); }
.pp-none { padding: 7px 8px; font-style: italic; font-size: 14px; color: var(--ink-3); }
.pp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.pp-tempo { display: inline-flex; align-items: center; gap: 6px; font-family: var(--caps); font-weight: 700; font-size: 12px; letter-spacing: 0.08em; color: var(--ink-2); }
.pp-tempo select { height: 30px; border: 1px solid var(--rule); border-radius: 2px; background: #fff; font-family: var(--serif); font-size: 14px; letter-spacing: 0; }

.spread {
  flex: none; width: min(100%, 1100px); margin-top: 10px; padding: 10px 12px 12px;
  background: rgba(251,252,247,0.94); border: 1px solid var(--rule); box-shadow: 0 6px 24px rgba(15,42,23,0.08);
}
.spread-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.spread-title { font-weight: 500; font-size: 18px; }
.spread-meta { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.spread-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.spread-name { height: 32px; width: 220px; max-width: 40vw; padding: 0 10px; border: 1px solid var(--rule); border-radius: 2px; background: #fff; font-size: 14px; }
.spread-row { list-style: none; margin: 0; padding: 2px 0 4px; display: flex; gap: 10px; overflow-x: auto; }
.sp-step { flex: none; display: flex; align-items: flex-start; gap: 5px; animation: sp-in 0.5s cubic-bezier(.2,.9,.25,1.05); }
.sp-step.chord .sp-cards { padding: 3px; border: 1px solid rgba(201,162,58,0.7); }
.sp-num { font-family: var(--mono); font-size: 10px; color: var(--ink-3); padding-top: 2px; }
.sp-cards { display: flex; gap: 4px; }
.sp-card { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 72px; padding: 0; border: 0; background: none; }
.sp-thumb { width: 72px; height: 72px; display: grid; place-items: center; background: var(--paper-2); color: var(--ink-3); }
.sp-thumb .tc { position: relative; overflow: hidden; background: #fff; box-shadow: 0 1px 3px rgba(15,42,23,0.25); }
.sp-thumb img { position: absolute; left: 50%; top: 50%; display: block; max-width: none; }
button.sp-card:hover .sp-thumb { background: #E5EFDF; }
.sp-el { width: 100%; font-family: var(--caps); font-weight: 700; font-size: 10px; letter-spacing: 0.04em; line-height: 1.15; text-align: center; color: var(--ink-2); }
.sp-card.empty .sp-el { color: var(--ink-3); font-weight: 500; }
@keyframes sp-in { from { transform: translateY(10px) scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }

.compose {
  flex: none; width: min(100%, 1100px); margin-bottom: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px;
  background: var(--ink); color: var(--paper);
}
.compose-top { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.compose-title { font-family: var(--caps); font-weight: 700; font-size: 14px; letter-spacing: 0.12em; color: var(--gold-hi); }
.compose-help { font-size: 14px; color: #C9D9C3; }
.compose-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; counter-reset: st; }
.compose-steps li { flex: none; padding: 3px 9px; border: 1px solid rgba(244,220,134,0.45); font-size: 14px; white-space: nowrap; counter-increment: st; }
.compose-steps li::before { content: counter(st) "  "; font-family: var(--mono); font-size: 11px; color: var(--gold-hi); }
.compose-steps li.empty { border-style: dashed; color: #C9D9C3; font-style: italic; }
.compose-steps li.empty::before { content: ""; }
.compose-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.compose-name { height: 32px; flex: 1; min-width: 160px; max-width: 320px; padding: 0 10px; border: 0; border-radius: 2px; background: var(--paper); color: var(--ink); font-size: 14px; }
.compose .btn { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.compose .btn.ghost { background: transparent; color: var(--paper); border-color: transparent; }
.compose .btn.ghost:hover { background: rgba(255,255,255,0.1); }
.stage.composing .el { cursor: copy; }
@media (max-width: 900px) {
  .play-panel { right: 8px; left: 8px; width: auto; grid-template-columns: 1fr; }
}

/* ---------- import ---------- */
.drop { cursor: default; gap: 6px; }
.drop-picks { display: flex; justify-content: center; gap: 6px; margin-top: 4px; }
.queue { margin: 0 0 10px; font-size: 13px; line-height: 1.35; color: var(--ink-2); }
.queue .link { font-size: 12px; color: #2F6B34; text-decoration: underline; }
.import { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px; background: rgba(11,26,16,0.55); }
.im-box {
  width: min(980px, 100%); max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; gap: 12px;
  padding: 20px 22px; background: var(--paper); border: 1px solid var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,0.35);
}
.im-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.im-head h2 { margin: 0; font-weight: 500; font-size: 26px; }
.im-opts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.im-opts label { display: flex; flex-direction: column; gap: 4px; font-family: var(--caps); font-weight: 700; font-size: 12px; letter-spacing: 0.08em; color: var(--ink-2); min-width: 0; }
.im-opts select { height: 36px; padding: 0 8px; border: 1px solid var(--rule); border-radius: 2px; background: #fff; font-family: var(--serif); font-size: 15px; letter-spacing: 0; font-weight: 400; color: var(--ink); min-width: 0; }
.im-summary { margin: 0; font-size: 14px; color: var(--ink-3); }
.im-pairs { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 120px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px; align-content: start; border-top: 1px solid var(--rule); padding-top: 10px; }
.im-pair { display: grid; grid-template-columns: 22px 1fr 1fr; grid-template-rows: auto auto; gap: 4px 6px; padding: 6px; background: var(--paper-2); }
.im-pair figure { margin: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.im-pair img { width: 100%; height: 88px; object-fit: contain; background: #fff; box-shadow: 0 1px 2px rgba(15,42,23,0.2); }
.im-pair figure.none::before { content: ""; display: block; height: 88px; border: 1px dashed var(--ink-3); opacity: 0.5; }
.im-pair figcaption { font-family: var(--mono); font-size: 10px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.im-num { font-family: var(--mono); font-size: 10px; color: var(--ink-3); padding-top: 2px; }
.im-tools { grid-column: 2 / -1; display: flex; gap: 12px; align-items: center; min-height: 18px; }
.im-status { margin-right: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.im-pair.done { background: #E3F1DC; } .im-pair.done .im-status { color: #2F6B34; }
.im-pair.dupe { opacity: 0.6; }
.im-pair.failed { background: #F6E4DF; } .im-pair.failed .im-status { color: var(--danger); }
.im-pair.working .im-status { color: #8A6A12; }
.im-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.im-progress { margin-right: auto; display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.im-track { flex: 1; max-width: 360px; height: 6px; background: var(--rule); }
.im-track i { display: block; height: 100%; width: 0; background: var(--stone); transition: width 0.3s; }
#im-prog { font-family: var(--mono); font-size: 12px; color: var(--ink-2); white-space: nowrap; }
@media (max-width: 900px) { .im-opts { grid-template-columns: 1fr; } }

/* ---------- review ---------- */
.badge { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: var(--ink); font-family: var(--mono); font-size: 11px; line-height: 18px; letter-spacing: 0; }
.badge:empty { display: none; }
.el.due:not(.lit):not(.lit-soft) { animation: due 3.2s ease-in-out infinite; }
@keyframes due { 0%, 100% { box-shadow: 0 0 0 0 rgba(201,162,58,0); } 50% { box-shadow: 0 0 0 0.22cqw rgba(201,162,58,0.75), 0 0 1.4cqw rgba(201,162,58,0.35); } }

.review {
  position: fixed; inset: 0; z-index: 55; display: flex; flex-direction: column;
  background-color: var(--paper);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
}
.rv-bar { flex: none; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 16px 0 20px; border-bottom: 1px solid var(--rule); background: var(--paper); flex-wrap: wrap; }
.rv-title { font-weight: 500; font-size: 22px; }
.rv-count { font-family: var(--mono); font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.rv-track { flex: 1; min-width: 80px; max-width: 420px; height: 4px; background: var(--rule); }
.rv-track i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.4s; }
.rv-set { display: inline-flex; align-items: center; gap: 6px; font-family: var(--caps); font-weight: 700; font-size: 12px; letter-spacing: 0.08em; color: var(--ink-2); }
.rv-set select { height: 30px; border: 1px solid var(--rule); border-radius: 2px; background: #fff; font-family: var(--serif); font-size: 14px; }
.rv-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 32px; padding: 24px 32px 8px; }
.rv-main.empty { grid-template-columns: 1fr; }
.rv-main.empty .rv-a { display: none; }
.rv-q { min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.rv-kind { margin: 0; font-family: var(--caps); font-weight: 700; font-size: 13px; letter-spacing: 0.12em; color: #2F6B34; }
.rv-prompt { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 500; text-wrap: balance; }
.rv-card { flex: 1; min-height: 160px; display: flex; align-items: center; justify-content: center; }
.rv-face { position: relative; overflow: hidden; background: #fff; box-shadow: 0 14px 40px rgba(15,42,23,0.22), 0 0 0 1px rgba(15,42,23,0.08); animation: arrive 0.6s cubic-bezier(.2,.8,.3,1) both; }
.rv-face img { position: absolute; left: 50%; top: 50%; max-width: none; }
.rv-where { margin: 0; min-height: 1.4em; font-size: 15px; color: var(--ink-2); }
.rv-done { margin: 0; font-size: 18px; max-width: 52ch; color: var(--ink-2); }
.rv-a { min-height: 0; display: flex; align-items: center; justify-content: center; }
.rv-opts { width: 100%; max-height: 100%; display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rv-opts.n5, .rv-opts.n6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.rv-opt { position: relative; padding: 0; border: 0; background: none; }
.rv-thumb { width: 100%; aspect-ratio: 1.25; display: grid; place-items: center; background: var(--paper-2); transition: background 0.2s, box-shadow 0.25s, opacity 0.3s; }
.rv-thumb .tc { position: relative; overflow: hidden; background: #fff; box-shadow: 0 2px 8px rgba(15,42,23,0.22); }
.rv-thumb img { position: absolute; left: 50%; top: 50%; max-width: none; }
.rv-thumb.solo { max-width: 560px; }
.rv-opt:hover .rv-thumb { background: #E5EFDF; }
.rv-key { position: absolute; top: 6px; left: 8px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.rv-opt.right .rv-thumb { box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(201,162,58,0.5); background: #F6EFD6; }
.rv-opt.wrong .rv-thumb { box-shadow: 0 0 0 3px var(--danger); }
.rv-opt.dim .rv-thumb { opacity: 0.35; }
.rv-opt:disabled { cursor: default; }
.mini-house { flex: none; }
.mini-house .el { cursor: pointer; }
.mini-house .el.pick { box-shadow: 0 0 0 0.3cqw var(--ink), 0 0 0 0.55cqw var(--gold-hi); z-index: 4; }
.mini-house .el.hit { box-shadow: 0 0 0 0.3cqw var(--gold), 0 0 2cqw rgba(201,162,58,0.6); z-index: 4; }
.mini-house .el.miss { outline: 0.3cqw dashed var(--gold); outline-offset: 0.2cqw; z-index: 4; }
.mini-house .el.wrong { box-shadow: 0 0 0 0.3cqw var(--danger); z-index: 4; }
.mini-house .el.jamb.pick, .mini-house .el.wall.pick, .mini-house .el.jamb.hit, .mini-house .el.wall.hit,
.mini-house .el.jamb.wrong, .mini-house .el.wall.wrong, .mini-house .el.jamb.miss, .mini-house .el.wall.miss { z-index: auto; }
.rv-foot { flex: none; min-height: 92px; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 10px 24px 22px; flex-wrap: wrap; }
.rv-hint { margin: 0; font-style: italic; color: var(--ink-3); }
.rv-verdict { margin: 0; font-size: 18px; }
.rv-verdict.ok { color: #2F6B34; }
.rv-verdict.no { color: var(--danger); }
.rv-rates { display: flex; gap: 8px; }
.rv-rate {
  position: relative; min-width: 104px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 9px 14px 8px;
  border: 1px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink);
}
.rv-rate:hover { background: var(--paper-2); }
.rv-rate.def { background: var(--ink); color: var(--paper); }
.rv-r { font-family: var(--caps); font-weight: 700; font-size: 14px; letter-spacing: 0.08em; }
.rv-in { font-family: var(--mono); font-size: 11px; opacity: 0.75; }
.rv-k { position: absolute; top: 3px; right: 6px; font-family: var(--mono); font-size: 9px; opacity: 0.5; }
.rv-rate.g1 { border-color: var(--danger); }
.rv-rate.g1.def { background: var(--danger); border-color: var(--danger); }
@media (max-width: 900px) {
  .rv-main { grid-template-columns: 1fr; overflow-y: auto; padding: 16px; }
  .rv-card { min-height: 220px; }
}
