:root {
  --bg: #f3ead9;
  --bg-deep: #d7dfcf;
  --cloth: #f1e7d6;
  --cloth-check: rgba(57, 93, 138, 0.09);
  --paper: #fbf4e7;
  --paper-deep: #f0e2c8;
  --paper-shadow: #cab28d;
  --moss: #6d816b;
  --moss-deep: #4f6558;
  --wicker: #c9ab7b;
  --wood: #b98c59;
  --wood-deep: #906843;
  --ink: #324038;
  --ink-soft: #5e6a60;
  --indigo: #355c92;
  --indigo-soft: #6c8cb6;
  --sage: #dde3d0;
  --cream: #fff9f0;
  --tape: #f0dcc4;
  --line: rgba(76, 95, 78, 0.16);
  --line-strong: rgba(53, 92, 146, 0.28);
  --warning: #a4693f;
  --danger: #b85c52;
  --ok: #5f8b65;
  --shadow-soft: 0 16px 44px rgba(86, 66, 42, 0.14);
  --shadow-panel: 0 22px 70px rgba(96, 75, 46, 0.16);
  --shadow-stage: 0 28px 80px rgba(50, 63, 51, 0.22);
  --hole-size: 22px;
  --impact-shadow-size: 18px;
  --punch-accent-glow: rgba(58, 101, 170, 0.08);
  --punch-color-shift: 0deg;
  --punch-color-sat: 1;
  --punch-color-bright: 1;
  --scroll-drift-a: 0px;
  --scroll-drift-b: 0px;
  --scroll-drift-c: 0px;
  --scroll-drift-d: 0px;
  --scroll-drift-e: 0px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Sans 3", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 251, 245, 0.92), transparent 28rem),
    radial-gradient(circle at 88% 14%, rgba(119, 151, 110, 0.22), transparent 22rem),
    linear-gradient(180deg, #f5efdf 0%, #eadfca 48%, #dfe5d6 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -5;
}

body::before {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.18) 0 2px, transparent 2px 38px),
    repeating-linear-gradient(90deg, rgba(56, 94, 139, 0.08) 0 2px, transparent 2px 38px);
  opacity: 0.55;
}

body::after {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 28%),
    radial-gradient(circle at 50% 0%, rgba(255, 247, 232, 0.76), transparent 42%);
  z-index: -4;
}

.desk-aura,
.paper-speckles {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.desk-aura {
  z-index: -3;
}

.desk-aura::before {
  content: "";
  position: absolute;
  border-radius: 999px;
  filter: blur(72px);
}

.desk-aura-indigo::before {
  width: 26rem;
  height: 26rem;
  left: -6rem;
  top: 16%;
  background: rgba(53, 92, 146, 0.14);
}

.desk-aura-moss::before {
  width: 22rem;
  height: 22rem;
  right: -2rem;
  bottom: 12%;
  background: rgba(98, 134, 91, 0.18);
}

.paper-speckles {
  z-index: -2;
  opacity: 0.18;
  background-image: radial-gradient(circle, rgba(105, 83, 48, 0.7) 0 1px, transparent 1px);
  background-size: 12px 12px;
  mix-blend-mode: multiply;
}

a {
  color: inherit;
}

button,
textarea {
  font: inherit;
}

.page {
  width: min(1380px, calc(100% - 1.4rem));
  margin: 0 auto;
  padding: 1.1rem 0 2.8rem;
}

.masthead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.9rem;
  padding: 0.75rem 1.15rem;
  border-radius: 999px;
  border: 1px solid rgba(75, 88, 68, 0.15);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(244, 233, 213, 0.92)),
    var(--paper);
  box-shadow: 0 10px 28px rgba(90, 68, 42, 0.1);
  color: var(--ink);
  text-decoration: none;
  font-family: "Patrick Hand", cursive;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
}

.masthead-copy {
  max-width: 28rem;
  padding: 0.2rem 0.2rem 0 0;
  text-align: right;
}

.masthead-kicker {
  margin: 0;
  font-family: "Patrick Hand", cursive;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--indigo);
}

.masthead-note {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.45;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(18rem, 0.95fr) minmax(0, 1.5fr) minmax(18rem, 1fr);
  gap: 1rem 0.4rem;
  align-items: start;
  position: relative;
  isolation: isolate;
}

.studio-rail {
  display: grid;
  gap: 1.1rem;
  margin-top: 2.1rem;
  margin-left: -0.45rem;
  transform: translate3d(0, var(--scroll-drift-c), 0);
  position: relative;
  z-index: 2;
}

.panel-card {
  position: relative;
  border: 1px solid rgba(90, 86, 63, 0.14);
  border-radius: 2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.22)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0)),
    var(--paper);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  will-change: transform;
  animation: paper-appear 720ms cubic-bezier(0.2, 0.78, 0.24, 1) both;
}

.panel-card::before {
  content: "";
  position: absolute;
  left: 1rem;
  right: 1rem;
  top: 0.9rem;
  height: 0.45rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(53, 92, 146, 0), rgba(53, 92, 146, 0.18), rgba(53, 92, 146, 0));
  opacity: 0.6;
  pointer-events: none;
}

.maker-note,
.stage-panel,
.studio-panel,
.library-panel {
  padding: 1.35rem;
}

.maker-note {
  margin-right: -0.55rem;
  transform: translate3d(-0.08rem, calc(1.35rem + var(--scroll-drift-a)), 0) rotate(-0.85deg);
  animation-delay: 100ms;
  z-index: 1;
}

.stage-panel {
  margin-left: -0.15rem;
  margin-right: -0.15rem;
  transform: translate3d(0, calc(0.12rem + var(--scroll-drift-b)), 0) rotate(0.18deg);
  animation-delay: 180ms;
  z-index: 6;
}

.studio-panel {
  transform: translate3d(-0.18rem, calc(-0.15rem + var(--scroll-drift-d)), 0) rotate(0.7deg);
  animation-delay: 260ms;
  z-index: 2;
}

.library-panel {
  transform: translate3d(0.18rem, calc(0.55rem + var(--scroll-drift-e)), 0) rotate(-0.62deg);
  animation-delay: 340ms;
  z-index: 1;
}

.eyebrow {
  margin: 0;
  font-family: "Patrick Hand", cursive;
  font-size: 1rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--indigo);
}

.maker-note h1,
.panel-heading h2,
.studio-panel h2,
.library-panel h2 {
  margin: 0.5rem 0 0;
  font-family: "Cormorant Garamond", serif;
  font-weight: 600;
  line-height: 0.94;
  letter-spacing: -0.03em;
  color: #2d3c34;
}

.maker-note h1 {
  font-size: clamp(2.9rem, 4.6vw, 4.8rem);
  text-wrap: balance;
}

.panel-heading h2,
.studio-panel h2,
.library-panel h2 {
  font-size: clamp(2rem, 3vw, 3rem);
}

.lede {
  margin: 1rem 0 0;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.7;
}

.signal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.3rem;
}

.signal-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  width: fit-content;
  min-height: 3rem;
  padding: 0.78rem 1rem;
  border-radius: 1.25rem;
  border: 1px solid rgba(100, 119, 99, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(247, 238, 224, 0.98)),
    var(--paper);
  box-shadow: 0 10px 28px rgba(91, 72, 48, 0.08);
  color: var(--ink);
  font-family: "Patrick Hand", cursive;
  font-size: 1.02rem;
  line-height: 1.2;
}

.signal-pill-count {
  color: var(--indigo);
}

.signal-dot {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 0 0 0.45rem rgba(83, 118, 163, 0.14);
  flex: 0 0 auto;
}

.paper-notes {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.35rem;
}

.note-scrap {
  position: relative;
  padding: 1rem 1rem 0.95rem;
  border-radius: 1.4rem;
  border: 1px solid rgba(115, 124, 91, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(245, 233, 214, 0.98)),
    var(--paper);
  box-shadow: var(--shadow-soft);
  animation: paper-appear 820ms cubic-bezier(0.2, 0.78, 0.24, 1) both, paper-float 8.8s ease-in-out infinite;
}

.note-scrap:nth-child(1) {
  transform: rotate(-1deg);
  animation-delay: 220ms, 0s;
}

.note-scrap:nth-child(2) {
  transform: rotate(0.6deg);
  animation-delay: 300ms, 1.1s;
}

.note-scrap:nth-child(3) {
  transform: rotate(-0.4deg);
  animation-delay: 380ms, 2.1s;
}

.note-scrap::before {
  content: "";
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  width: 3.6rem;
  height: 0.95rem;
  border-radius: 0.25rem;
  background: rgba(240, 220, 196, 0.72);
  transform: rotate(6deg);
}

.note-scrap-title {
  margin: 0;
  font-family: "Patrick Hand", cursive;
  font-size: 1.08rem;
  color: var(--indigo);
}

.note-scrap p:last-child {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  line-height: 1.5;
}

.stage-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.16)),
    linear-gradient(135deg, rgba(100, 128, 97, 0.1), rgba(53, 92, 146, 0.04)),
    #f8f0df;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.95rem;
}

.stage-caption {
  max-width: 15rem;
  margin: 0.2rem 0 0;
  font-family: "Patrick Hand", cursive;
  font-size: 1.02rem;
  line-height: 1.25;
  color: var(--ink-soft);
  text-align: right;
}

.stage-frame {
  padding: 0.95rem;
  border-radius: 2rem;
  border: 1px solid rgba(127, 104, 71, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(90deg, rgba(164, 134, 96, 0.09) 0 12px, rgba(203, 172, 123, 0.14) 12px 24px),
    linear-gradient(180deg, #dcc29d, #c7a478);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36);
  position: relative;
  z-index: 2;
}

.stage {
  position: relative;
  min-height: 37rem;
  border-radius: 1.6rem;
  overflow: visible;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 18%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.08) 0 2px, rgba(255, 255, 255, 0) 2px 18px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 2px, rgba(255, 255, 255, 0) 2px 18px),
    radial-gradient(circle at 50% 10%, rgba(255, 245, 227, 0.32), transparent 28%),
    linear-gradient(180deg, #809378 0%, #6d826b 38%, #5a7166 100%);
  perspective: 1800px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  touch-action: none;
  --card-aspect: 1.6025641;
  --stage-width: 46rem;
  --stage-height: 37rem;
  --impact-x: 0.5;
  --impact-y: 0.5;
  --card-rotate-x: 0deg;
  --card-rotate-y: 0deg;
  --card-scale-x: 1;
  --card-scale-y: 1;
  --card-lift: 0;
  --card-flip: 0;
}

.stage[data-punch-size="small"] {
  --punch-accent-glow: rgba(58, 101, 170, 0.1);
  --punch-color-shift: 0deg;
  --punch-color-sat: 1;
  --punch-color-bright: 1;
}

.stage[data-punch-size="medium"] {
  --punch-accent-glow: rgba(79, 144, 83, 0.12);
  --punch-color-shift: 54deg;
  --punch-color-sat: 1.08;
  --punch-color-bright: 0.98;
}

.stage[data-punch-size="large"] {
  --punch-accent-glow: rgba(182, 78, 65, 0.13);
  --punch-color-shift: 132deg;
  --punch-color-sat: 1.12;
  --punch-color-bright: 0.98;
}

.stage::before,
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stage::before {
  background:
    radial-gradient(circle at 16% 18%, rgba(255, 255, 255, 0.12), transparent 20%),
    radial-gradient(circle at 82% 22%, rgba(53, 92, 146, 0.12), transparent 18%),
    radial-gradient(circle at 72% 88%, rgba(224, 230, 210, 0.2), transparent 16%);
  opacity: 0.9;
}

.stage::after {
  inset: 1rem;
  border-radius: 1.25rem;
  border: 1px solid rgba(252, 249, 242, 0.14);
}

.stage-floor {
  position: absolute;
  inset: auto 7% 7% 7%;
  height: 28%;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(71, 92, 79, 0.28) 0 18%, rgba(47, 65, 55, 0.18) 36%, rgba(47, 65, 55, 0) 72%);
  filter: blur(18px);
  transform: translateZ(-120px);
}

.card-rig {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(
    calc(var(--stage-width) * 0.92),
    46rem,
    calc(var(--stage-height) * 0.85 * var(--card-aspect))
  );
  max-height: calc(var(--stage-height) * 0.85);
  aspect-ratio: 5 / 3.12;
  transform-style: preserve-3d;
  transform-origin: calc(var(--impact-x) * 100%) calc(var(--impact-y) * 100%);
  transform:
    translate(-50%, -50%)
    translateY(calc(var(--card-lift) * -1px))
    rotateX(var(--card-rotate-x))
    rotateY(var(--card-rotate-y))
    scaleX(var(--card-scale-x))
    scaleY(var(--card-scale-y));
  transition: transform 640ms cubic-bezier(0.22, 0.78, 0.24, 1);
  z-index: 10;
}

.card-shadow {
  position: absolute;
  inset: 11% 4% -13%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(66, 65, 46, 0.36), transparent 72%);
  transform: translateZ(-88px) scale(0.98);
  filter: blur(30px);
  opacity: 0.72;
}

.card-body {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateY(calc(var(--card-flip) * 180deg)) translateZ(10px);
  cursor: none;
  outline: none;
  transition: transform 760ms cubic-bezier(0.22, 0.78, 0.24, 1);
}

.card-body:focus-visible .card-face {
  box-shadow:
    0 0 0 4px rgba(53, 92, 146, 0.2),
    0 18px 42px rgba(79, 62, 39, 0.18);
}

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 1.7rem;
  overflow: hidden;
  backface-visibility: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    0 18px 42px rgba(79, 62, 39, 0.18);
}

.card-face-front {
  transform: translateZ(11px);
  border: 1px solid rgba(248, 241, 230, 0.66);
}

.card-face-back {
  transform: rotateY(180deg) translateZ(11px);
  border: 1px solid rgba(152, 164, 141, 0.38);
}

.card-face::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -4px 0 rgba(110, 89, 58, 0.12);
}

.card-art {
  display: block;
  width: 100%;
  height: 100%;
}

.front-panel {
  fill: rgba(53, 92, 146, 0.94);
}

.front-label {
  fill: rgba(243, 247, 252, 0.72);
}

.front-botanical,
.front-botanical-soft {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.front-botanical {
  stroke: rgba(247, 250, 253, 0.92);
  stroke-width: 16;
}

.front-botanical-soft {
  stroke: rgba(232, 241, 250, 0.8);
  stroke-width: 12;
}

.front-sun {
  fill: rgba(250, 246, 234, 0.18);
  stroke: rgba(248, 242, 229, 0.7);
  stroke-width: 8;
}

.face-rule {
  fill: none;
  stroke: rgba(89, 89, 66, 0.24);
  stroke-linecap: round;
  stroke-width: 10;
}

.face-rule-soft {
  stroke-width: 8;
  opacity: 0.64;
}

.back-note-line {
  fill: none;
  stroke: rgba(90, 110, 124, 0.3);
  stroke-linecap: round;
  stroke-width: 8;
}

.back-stamp {
  fill: rgba(73, 101, 137, 0.16);
  stroke: rgba(67, 91, 123, 0.28);
  stroke-width: 7;
}

.back-seal {
  fill: rgba(53, 92, 146, 0.12);
  stroke: rgba(53, 92, 146, 0.22);
  stroke-width: 7;
}

.stage.is-flipped {
  --card-flip: 1;
}

.stage.is-flipped .card-shadow {
  opacity: 0.62;
}

.punch-hole-proxy {
  position: absolute;
  width: var(--hole-size);
  height: var(--hole-size);
  border-radius: 50%;
}

.punch-preview-group {
  opacity: 0.88;
}

.punch-anchor {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(6.5rem, 12vw, 8rem);
  height: clamp(9.8rem, 18vw, 11.8rem);
  transform: translate(-50%, -50%);
  transform-style: preserve-3d;
  pointer-events: none;
}

.punch-top-assembly {
  z-index: 14;
  isolation: isolate;
}

.punch-bottom-assembly {
  z-index: 6;
}

.punch-guide {
  position: absolute;
  left: 50%;
  top: 28%;
  bottom: 28%;
  width: 0.12rem;
  transform: translateX(-50%);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 249, 238, 0), rgba(255, 249, 238, 0.58) 20%, rgba(213, 189, 157, 0.22) 50%, rgba(255, 249, 238, 0.46) 80%, rgba(255, 249, 238, 0));
  box-shadow:
    0 0 0 1px rgba(255, 248, 236, 0.08),
    0 0 0.35rem rgba(109, 83, 55, 0.05);
  opacity: 0.12;
}

.punch-guide::before,
.punch-guide::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 0.36rem;
  height: 0.36rem;
  transform: translateX(-50%);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 250, 243, 0.72), rgba(214, 191, 160, 0.18) 62%, rgba(214, 191, 160, 0) 100%);
  box-shadow:
    0 0 0.45rem rgba(113, 84, 54, 0.06);
  opacity: 0.16;
}

.punch-guide::before {
  top: 0;
}

.punch-guide::after {
  bottom: 0;
}

.punch-top,
.punch-bottom {
  position: absolute;
  left: 50%;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  transform-style: preserve-3d;
  transition: transform 280ms cubic-bezier(0.22, 0.78, 0.24, 1), filter 220ms ease;
  will-change: transform;
}

.punch-top {
  top: 50%;
  transform:
    translate(-50%, calc(-50% - 1.12rem))
    scale(0.78, 0.72);
}

.punch-bottom {
  top: 50%;
  transform:
    translate(-50%, calc(-50% + 0.7rem))
    scale(0.22, 0.18);
  opacity: 0.14;
}

.punch-top-halo,
.punch-bottom-halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 96%;
  height: 62%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}

.punch-top-halo {
  background: radial-gradient(circle, var(--punch-accent-glow), rgba(79, 117, 169, 0) 72%);
  filter: blur(12px);
}

.punch-bottom-halo {
  width: 44%;
  height: 44%;
  background: radial-gradient(circle, rgba(67, 53, 39, 0.08), rgba(67, 53, 39, 0) 72%);
  filter: blur(8px);
}

.punch-graphic {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.punch-graphic-top {
  filter:
    hue-rotate(var(--punch-color-shift))
    saturate(var(--punch-color-sat))
    brightness(var(--punch-color-bright))
    drop-shadow(0 0.18rem 0.22rem rgba(255, 248, 233, 0.22))
    drop-shadow(0 0.52rem 0.72rem rgba(86, 61, 32, 0.18));
}

.punch-graphic-bottom {
  filter:
    hue-rotate(var(--punch-color-shift))
    saturate(calc(var(--punch-color-sat) * 0.92))
    brightness(var(--punch-color-bright))
    blur(0.4px)
    drop-shadow(0 0.16rem 0.28rem rgba(78, 58, 35, 0.06));
}

.punch-top-assembly::before,
.punch-top-assembly::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.punch-top-assembly::before {
  z-index: 0;
  width: var(--impact-shadow-size);
  height: var(--impact-shadow-size);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(24, 16, 11, 0.46), rgba(24, 16, 11, 0.22) 34%, rgba(24, 16, 11, 0) 72%);
  filter: blur(3px);
  top: calc(50% + 0.64rem);
  opacity: 0.9;
  transition:
    width 240ms cubic-bezier(0.42, 0, 0.88, 1),
    height 240ms cubic-bezier(0.42, 0, 0.88, 1),
    filter 220ms cubic-bezier(0.42, 0, 0.88, 1),
    opacity 220ms cubic-bezier(0.42, 0, 0.88, 1),
    background 220ms cubic-bezier(0.42, 0, 0.88, 1);
  will-change: width, height, filter, opacity;
}

.punch-top-assembly::after {
  content: none;
}

.stage[data-phase="aim"] .punch-top-assembly::before {
  width: calc(var(--impact-shadow-size) * 1.18);
  height: calc(var(--impact-shadow-size) * 1.18);
  background: radial-gradient(circle, rgba(24, 16, 11, 0.52), rgba(24, 16, 11, 0.22) 38%, rgba(24, 16, 11, 0) 74%);
  opacity: 0.94;
}

.stage[data-phase="clamp"] .punch-top-assembly::before {
  width: calc(var(--impact-shadow-size) * 2.72);
  height: calc(var(--impact-shadow-size) * 2.72);
  background: radial-gradient(circle, rgba(12, 8, 6, 0.86), rgba(12, 8, 6, 0.48) 46%, rgba(12, 8, 6, 0) 84%);
  filter: blur(3.6px);
  opacity: 1;
}

.stage[data-phase="recoil"] .punch-top-assembly::before {
  width: calc(var(--impact-shadow-size) * 1.42);
  height: calc(var(--impact-shadow-size) * 1.42);
  background: radial-gradient(circle, rgba(22, 15, 10, 0.44), rgba(22, 15, 10, 0.18) 40%, rgba(22, 15, 10, 0) 78%);
  filter: blur(3.5px);
  opacity: 0.92;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1rem;
}

.tool-row {
  display: flex;
  justify-content: flex-start;
  margin-top: 1rem;
}

.punch-size-slider {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 1.4rem;
  border: 1px solid rgba(103, 97, 74, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(245, 232, 209, 0.96)),
    var(--paper);
  box-shadow: 0 10px 22px rgba(94, 72, 43, 0.08);
}

.punch-size-track {
  position: relative;
  width: 100%;
  height: 2.8rem;
  display: flex;
  border-radius: 1rem;
  border: 1px solid rgba(111, 101, 73, 0.16);
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.punch-size-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.4rem;
  background: linear-gradient(135deg, rgba(79, 144, 83, 0.94), rgba(79, 144, 83, 0.76));
  box-shadow: 0 4px 12px rgba(79, 144, 83, 0.3);
  transition: left 200ms ease, background 200ms ease;
  pointer-events: none;
}

.punch-size-indicator[data-size="small"] {
  left: 0.3rem;
  background: linear-gradient(135deg, rgba(58, 101, 170, 0.94), rgba(58, 101, 170, 0.76));
  box-shadow: 0 4px 12px rgba(58, 101, 170, 0.3);
}

.punch-size-indicator[data-size="medium"] {
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  background: linear-gradient(135deg, rgba(79, 144, 83, 0.94), rgba(79, 144, 83, 0.76));
  box-shadow: 0 4px 12px rgba(79, 144, 83, 0.3);
}

.punch-size-indicator[data-size="large"] {
  right: 0.3rem;
  left: auto;
  background: linear-gradient(135deg, rgba(182, 78, 65, 0.94), rgba(182, 78, 65, 0.76));
  box-shadow: 0 4px 12px rgba(182, 78, 65, 0.3);
}

.punch-size-zone {
  flex: 1;
  min-height: 2.8rem;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0;
  position: relative;
  z-index: 1;
  transition: background 80ms ease;
}

.punch-size-zone:hover {
  background: rgba(0, 0, 0, 0.04);
}

.punch-size-zone:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: -1px;
}

.punch-size-zone:disabled {
  cursor: default;
  opacity: 0.4;
}

.punch-size-picker {
  display: none;
}

.punch-size-label {
  display: none;
}

.punch-size-button {
  display: none;
}

.control-button {
  --paper-tilt: 0deg;
  min-height: 3rem;
  padding: 0.74rem 1.1rem;
  border: 1px solid rgba(111, 101, 73, 0.18);
  border-radius: 1rem 1.1rem 0.92rem 1.06rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(244, 230, 206, 0.98)),
    var(--paper);
  color: var(--ink);
  box-shadow: 0 12px 26px rgba(94, 72, 43, 0.1);
  cursor: pointer;
  font-family: "Patrick Hand", cursive;
  font-size: 1.02rem;
  letter-spacing: 0.04em;
  transform: rotate(var(--paper-tilt));
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
  animation: paper-appear 620ms cubic-bezier(0.2, 0.78, 0.24, 1) both;
}

.control-button:nth-child(1) {
  --paper-tilt: -1deg;
  animation-delay: 420ms;
}

.control-button:nth-child(2) {
  --paper-tilt: 0.5deg;
  animation-delay: 470ms;
}

.control-button:nth-child(3) {
  --paper-tilt: -0.35deg;
  animation-delay: 520ms;
}

.control-button:nth-child(4) {
  --paper-tilt: 0.85deg;
  animation-delay: 570ms;
}

.control-button:hover,
.control-button:focus-visible,
.dock-close:hover,
.dock-close:focus-visible {
  transform: translateY(-2px) rotate(var(--paper-tilt, 0deg));
  border-color: var(--line-strong);
  box-shadow: 0 16px 30px rgba(84, 65, 40, 0.14);
}

.control-button:focus-visible,
.dock-close:focus-visible,
.dock-textarea:focus {
  outline: 2px solid rgba(53, 92, 146, 0.26);
  outline-offset: 2px;
}

.control-button-primary {
  background:
    linear-gradient(180deg, rgba(88, 123, 170, 0.86), rgba(54, 88, 133, 0.96)),
    var(--indigo);
  border-color: rgba(53, 92, 146, 0.28);
  color: #f8fbff;
}

.status-message {
  min-height: 1.5rem;
  margin: 0.95rem 0 0;
  color: var(--ink-soft);
  font-family: "Patrick Hand", cursive;
  font-size: 1.05rem;
  line-height: 1.3;
}

.status-message[data-tone="ok"] {
  color: var(--ok);
}

.status-message[data-tone="warn"] {
  color: var(--warning);
}

.status-message[data-tone="error"] {
  color: var(--danger);
}

.data-dock {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 1.6rem;
  border: 1px solid rgba(121, 122, 100, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(247, 239, 226, 0.98)),
    repeating-linear-gradient(180deg, transparent 0 1.85rem, rgba(92, 118, 149, 0.12) 1.85rem 1.96rem),
    var(--paper);
  box-shadow: var(--shadow-soft);
}

.data-dock-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
}

.dock-title,
.dock-hint,
.dock-field {
  margin: 0;
}

.dock-title,
.dock-field {
  font-family: "Patrick Hand", cursive;
  color: var(--indigo);
}

.dock-title {
  font-size: 1.08rem;
  letter-spacing: 0.05em;
}

.dock-hint {
  margin-top: 0.25rem;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1.5;
}

.dock-close {
  min-height: 2.65rem;
  padding: 0.72rem 1rem;
  border: 1px solid rgba(111, 101, 73, 0.16);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(245, 233, 210, 0.98)),
    var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-family: "Patrick Hand", cursive;
  font-size: 1rem;
  transform: rotate(0.4deg);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.dock-field {
  display: block;
  margin-top: 0.95rem;
  font-size: 1rem;
  letter-spacing: 0.05em;
}

.dock-textarea {
  width: 100%;
  min-height: 12rem;
  margin-top: 0.45rem;
  padding: 0.95rem 1rem;
  border: 1px solid rgba(106, 118, 93, 0.16);
  border-radius: 1.2rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(247, 238, 222, 0.98)),
    var(--cream);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  font-family: "Source Sans 3", sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
}

.dock-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.8rem;
}

.slug-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 18;
}

.paper-slug {
  position: absolute;
  width: calc(var(--hole-size) * 0.72);
  height: calc(var(--hole-size) * 0.72);
  border-radius: 46% 54% 58% 42% / 42% 48% 52% 58%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(242, 229, 203, 0.98)),
    linear-gradient(180deg, var(--cream), var(--paper));
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 18px rgba(69, 57, 40, 0.16);
  animation: slug-flit 720ms cubic-bezier(0.18, 0.74, 0.24, 1) forwards;
}

.studio-panel,
.library-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.14)),
    linear-gradient(135deg, rgba(127, 161, 124, 0.08), rgba(53, 92, 146, 0.03)),
    #f9f1e0;
}

.upload-grid {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.upload-slot {
  position: relative;
  padding: 1rem;
  border-radius: 1.5rem;
  border: 1px solid rgba(106, 119, 93, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(245, 235, 220, 0.98)),
    var(--paper);
  box-shadow: var(--shadow-soft);
  animation: paper-appear 760ms cubic-bezier(0.2, 0.78, 0.24, 1) both, paper-float 9.6s ease-in-out infinite;
}

.upload-slot:first-child {
  transform: translateX(-0.45rem) rotate(-1.15deg);
  animation-delay: 320ms, 0.8s;
}

.upload-slot:last-child {
  margin-top: -0.15rem;
  transform: translateX(0.6rem) rotate(0.95deg);
  animation-delay: 420ms, 1.7s;
}

.slot-tab {
  position: absolute;
  top: 0.85rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.45rem;
  padding: 0.12rem 0.62rem;
  border-radius: 999px;
  background: rgba(240, 220, 196, 0.88);
  color: var(--indigo);
  font-family: "Patrick Hand", cursive;
  font-size: 0.96rem;
  letter-spacing: 0.04em;
}

.slot-art {
  aspect-ratio: 4 / 2.45;
  border-radius: 1.15rem;
  border: 1px solid rgba(122, 132, 101, 0.15);
  background-color: var(--sage);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.slot-art-front {
  background:
    radial-gradient(circle at 28% 32%, rgba(249, 251, 253, 0.18), transparent 18%),
    linear-gradient(135deg, rgba(53, 92, 146, 0.98), rgba(74, 115, 166, 0.88)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
}

.slot-art-back {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    repeating-linear-gradient(180deg, transparent 0 1.55rem, rgba(89, 110, 124, 0.18) 1.55rem 1.66rem),
    linear-gradient(135deg, #dce1cd, #c7cfb8);
}

.upload-slot h3 {
  margin: 0.85rem 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.55rem;
  font-weight: 600;
  color: #344239;
}

.upload-slot p,
.mini-note {
  margin: 0.3rem 0 0;
  color: var(--ink-soft);
  line-height: 1.55;
}

.ghost-chip {
  min-height: 2.55rem;
  margin-top: 0.85rem;
  padding: 0.62rem 0.9rem;
  border: 1px dashed rgba(53, 92, 146, 0.28);
  border-radius: 999px;
  background: rgba(247, 250, 253, 0.78);
  color: var(--indigo);
  font-family: "Patrick Hand", cursive;
  font-size: 1rem;
  cursor: default;
}

.fan-stack {
  position: relative;
  min-height: 13rem;
  margin-top: 1rem;
  perspective: 1200px;
}

.stack-card {
  position: absolute;
  left: 50%;
  top: 0.9rem;
  width: min(100%, 15rem);
  aspect-ratio: 5 / 3.12;
  padding: 0.9rem;
  border-radius: 1.45rem;
  border: 1px solid rgba(96, 109, 89, 0.14);
  box-shadow: 0 18px 36px rgba(84, 67, 42, 0.14);
  transform-origin: center bottom;
  animation: paper-appear 820ms cubic-bezier(0.2, 0.78, 0.24, 1) both, stack-sway 10.5s ease-in-out infinite;
}

.stack-card::before {
  content: "";
  position: absolute;
  top: 0.75rem;
  left: 50%;
  width: 3.9rem;
  height: 0.95rem;
  border-radius: 0.25rem;
  background: rgba(240, 220, 196, 0.76);
  transform: translateX(-50%) rotate(-4deg);
}

.stack-card-one {
  transform: translateX(calc(-50% - 1.8rem)) rotate(-10deg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #456ea4, #2f537f);
  color: #f7fbff;
  animation-delay: 380ms, 0.3s;
}

.stack-card-two {
  transform: translateX(-50%) rotate(-2deg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #edf1e3, #d1d7c1);
  color: var(--ink);
  animation-delay: 470ms, 1.6s;
}

.stack-card-three {
  transform: translateX(calc(-50% + 2rem)) rotate(9deg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0)),
    linear-gradient(135deg, #f3e4ca, #ddc29d);
  color: var(--ink);
  animation-delay: 560ms, 2.8s;
}

.stack-card-label {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 0.95rem;
  font-family: "Patrick Hand", cursive;
  font-size: 1.08rem;
  letter-spacing: 0.04em;
}

.stage[data-phase="aim"] .punch-top-assembly .punch-top {
  transform:
    translate(-50%, calc(-50% - 1.02rem))
    scale(0.78, 0.72);
}

.stage[data-phase="aim"] .punch-bottom-assembly .punch-bottom {
  transform:
    translate(-50%, calc(-50% + 0.68rem))
    scale(0.22, 0.18);
}

.stage[data-phase="clamp"] .punch-top-assembly .punch-top {
  transform:
    translate(-50%, calc(-50% - 0.36rem))
    scale(0.8, 0.74);
  filter: saturate(1.04);
}

.stage[data-phase="clamp"] .punch-bottom-assembly .punch-bottom {
  transform:
    translate(-50%, calc(-50% + 0.32rem))
    scale(0.24, 0.2);
}

.stage[data-phase="recoil"] .punch-top-assembly .punch-top {
  transform:
    translate(-50%, calc(-50% - 0.72rem))
    scale(0.79, 0.73);
}

.stage[data-phase="recoil"] .punch-bottom-assembly .punch-bottom {
  transform:
    translate(-50%, calc(-50% + 0.5rem))
    scale(0.23, 0.19);
}

.stage.is-denied .punch-top-assembly,
.stage.is-denied .punch-bottom-assembly {
  animation: deny-jitter 280ms linear 1;
}

body.is-touch-mode .punch-anchor,
body.is-reduced-motion .punch-anchor {
  transition: left 180ms ease, top 180ms ease, transform 180ms ease;
}

body.is-reduced-motion .card-rig,
body.is-reduced-motion .punch-top,
body.is-reduced-motion .punch-bottom,
body.is-reduced-motion .card-body {
  transition-duration: 180ms;
}

@keyframes slug-flit {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45) rotate(0deg);
  }
  26% {
    opacity: 1;
    transform: translate(calc(-50% + var(--drift-x, 0px) * 0.34), calc(-50% - 1.1rem)) scale(1) rotate(10deg);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--drift-x, 0px)), calc(-50% + 2.2rem)) scale(0.72) rotate(124deg);
  }
}

@keyframes deny-jitter {
  0% { transform: translate(-50%, -50%) translateX(0); }
  30% { transform: translate(-50%, -50%) translateX(-5px); }
  60% { transform: translate(-50%, -50%) translateX(5px); }
  100% { transform: translate(-50%, -50%) translateX(0); }
}

@keyframes paper-appear {
  0% {
    opacity: 0;
    filter: blur(5px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes paper-float {
  0%, 100% {
    box-shadow: var(--shadow-soft);
  }
  50% {
    box-shadow: 0 22px 52px rgba(86, 66, 42, 0.18);
  }
}

@keyframes stack-sway {
  0%, 100% {
    box-shadow: 0 18px 36px rgba(84, 67, 42, 0.14);
  }
  50% {
    box-shadow: 0 24px 42px rgba(84, 67, 42, 0.2);
  }
}

.panel-heading-tight {
  margin-bottom: 0.65rem;
}

.stage-caption-left {
  text-align: left;
}

.library-copy,
.template-copy {
  margin-top: 0.7rem;
}

.card-frame-highlight {
  fill: none;
  stroke: rgba(255, 255, 255, 0.34);
  stroke-width: 5;
}

.saved-stack {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.1rem;
  perspective: 1200px;
}

.library-card,
.template-card {
  position: relative;
  display: grid;
  gap: 0.9rem;
  width: 100%;
  border: 1px solid rgba(103, 112, 84, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(245, 233, 212, 0.98)),
    var(--paper);
  box-shadow: 0 16px 34px rgba(84, 67, 42, 0.12);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.library-card {
  grid-template-columns: 6.2rem minmax(0, 1fr);
  align-items: center;
  padding: 0.85rem;
  border-radius: 1.45rem;
  transform:
    translateX(calc(var(--stack-order, 0) * 0.2rem))
    rotate(calc((var(--stack-order, 0) * 0.45deg) - 0.7deg));
}

.library-card:nth-child(even) {
  transform:
    translateX(calc(var(--stack-order, 0) * 0.16rem))
    rotate(calc((var(--stack-order, 0) * -0.28deg) + 0.45deg));
}

.library-card:hover,
.library-card:focus-visible,
.template-card:hover,
.template-card:focus-visible {
  transform: translateY(-2px) rotate(0deg);
  border-color: rgba(53, 92, 146, 0.24);
  box-shadow: 0 22px 40px rgba(84, 67, 42, 0.16);
  outline: none;
}

.library-card.is-active {
  border-color: rgba(53, 92, 146, 0.3);
  box-shadow:
    0 20px 40px rgba(84, 67, 42, 0.16),
    0 0 0 0.18rem rgba(53, 92, 146, 0.11);
}

.library-card-preview,
.template-preview {
  border-radius: 1rem;
  border: 1px solid rgba(117, 126, 98, 0.14);
  background:
    radial-gradient(circle at 24% 22%, rgba(255, 255, 255, 0.22), transparent 18%),
    linear-gradient(135deg, #e7dcc3, #cec2aa);
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.library-card-preview {
  aspect-ratio: 5 / 3.12;
}

.template-preview {
  width: 5.4rem;
  aspect-ratio: 5 / 3.12;
  flex: 0 0 auto;
}

.library-card-body,
.template-card-body {
  min-width: 0;
}

.library-card-title,
.template-card-title,
.pack-title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 0.96;
  color: #314036;
}

.library-card-meta,
.template-card-tags,
.pack-description,
.card-editor-meta,
.empty-note,
.panel-warning {
  margin: 0.28rem 0 0;
  color: var(--ink-soft);
  line-height: 1.45;
}

.library-card-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.7rem;
}

.library-card-count,
.library-card-badge,
.pack-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.8rem;
  padding: 0.18rem 0.72rem;
  border-radius: 999px;
  font-family: "Patrick Hand", cursive;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.library-card-count,
.pack-count {
  background: rgba(226, 216, 197, 0.84);
  color: var(--ink-soft);
}

.library-card-badge {
  background: rgba(53, 92, 146, 0.13);
  color: var(--indigo);
}

.card-editor {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 1.45rem;
  border: 1px solid rgba(102, 117, 88, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(246, 236, 217, 0.98)),
    var(--paper);
  box-shadow: var(--shadow-soft);
}

.card-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
}

.card-name-input {
  width: 100%;
  min-height: 3rem;
  margin-top: 0.4rem;
  padding: 0.78rem 0.95rem;
  border: 1px solid rgba(106, 118, 93, 0.16);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(247, 238, 223, 0.98)),
    var(--cream);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.54);
}

.card-name-input:focus {
  outline: 2px solid rgba(53, 92, 146, 0.22);
  outline-offset: 2px;
}

.ghost-chip-action {
  cursor: pointer;
}

.template-packs {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.template-pack {
  border-radius: 1.45rem;
  border: 1px solid rgba(104, 117, 88, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(244, 232, 211, 0.96)),
    var(--paper);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.pack-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  width: 100%;
  padding: 0.9rem 1rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.pack-toggle-copy {
  min-width: 0;
}

.pack-toggle[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.22);
}

.pack-body {
  display: grid;
  gap: 0.7rem;
  padding: 0 1rem 1rem;
}

.pack-body[hidden] {
  display: none;
}

.template-card {
  grid-template-columns: 4.9rem minmax(0, 1fr);
  align-items: center;
  padding: 0.65rem;
  border-radius: 1rem;
}

.template-card-tags {
  font-size: 0.88rem;
}

.template-card-title {
  font-size: 1.35rem;
}

.template-packs {
  max-height: min(56vh, 36rem);
  overflow-y: auto;
  padding-right: 0.4rem;
  margin-right: -0.18rem;
  align-content: start;
}

.template-packs::-webkit-scrollbar {
  width: 0.7rem;
}

.template-packs::-webkit-scrollbar-thumb {
  border: 0.18rem solid rgba(0, 0, 0, 0);
  border-radius: 999px;
  background: rgba(126, 122, 103, 0.34);
  background-clip: padding-box;
}

.template-packs::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.26);
  border-radius: 999px;
}

/* ── Pack shelf ──────────────────────────────────────────────── */

.pack-shelf-wrap {
  position: sticky;
  top: 0;
  z-index: 3;
  /* Paper background so card grid doesn't bleed through when scrolling */
  background: linear-gradient(180deg, rgba(247,241,230,1) 80%, rgba(247,241,230,0));
  padding-bottom: 0.5rem;
  margin-bottom: -0.5rem;
}

.pack-shelf {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  /* Padding creates room inside the scroll container so fanned cards
     (position:absolute within .pack-stack) don't hit the clip edges.
     .pack-stack is sized to fully contain the fan bounding box. */
  padding: 1.5rem 1rem 0.75rem;
}

.pack-shelf::-webkit-scrollbar { display: none; }

.shelf-arrow {
  position: absolute;
  top: calc(1.5rem + 3.25rem); /* vertically centred on the card stack */
  transform: translateY(-50%);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(90, 86, 63, 0.18);
  box-shadow: 0 2px 8px rgba(84, 67, 42, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #4a5240;
  z-index: 5;
  transition: transform 180ms ease, box-shadow 180ms ease;
  animation: arrow-nudge 1.4s ease-in-out infinite;
}

.shelf-arrow:hover { box-shadow: 0 4px 14px rgba(84, 67, 42, 0.2); }
.shelf-arrow-left  { left: -0.6rem; animation-name: arrow-nudge-left; }
.shelf-arrow-right { right: -0.6rem; }

@keyframes arrow-nudge      { 0%,100%{transform:translateY(-50%) translateX(0)} 50%{transform:translateY(-50%) translateX(2px)} }
@keyframes arrow-nudge-left { 0%,100%{transform:translateY(-50%) translateX(0)} 50%{transform:translateY(-50%) translateX(-2px)} }

/* ── Pack deck button ──────────────────────────────────────────── */

.pack-deck {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.4rem 0.35rem 0.5rem;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 1rem;
  cursor: pointer;
  text-align: center;
  transition: background 180ms ease, border-color 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.pack-deck:hover,
.pack-deck:focus-visible {
  background: rgba(94, 84, 64, 0.06);
  outline: none;
}

.pack-deck.is-open {
  background: rgba(53, 92, 146, 0.07);
  border-color: rgba(53, 92, 146, 0.2);
}

/* ── Stacked card visual ──────────────────────────────────────── */

.pack-stack {
  /* Oversized to fully contain the fan bounding box (20° rotation of 6.8×4.25rem
     card = ~7.85×6.32rem). Nothing overflows, so overflow:hidden parents don't clip. */
  position: relative;
  width: 8rem;
  height: 6.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pack-stack-card {
  position: absolute;
  /* Card centred inside the larger stack box */
  width: 6.8rem;
  height: 4.25rem;
  top: 1.175rem;
  left: 0.6rem;
  border-radius: 0.5rem;
  background-color: #ddd5c2;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 7px rgba(84, 67, 42, 0.22);
  transition: transform 280ms cubic-bezier(0.34, 1.3, 0.64, 1);
}

/* Closed: stacked deck with depth — back cards offset + darker */
.pack-stack-card:nth-child(1) {
  transform: translate(-4px, 5px) scale(0.91);
  z-index: 1;
  filter: brightness(0.7);
}
.pack-stack-card:nth-child(2) {
  transform: translate(-2px, 3px) scale(0.96);
  z-index: 2;
  filter: brightness(0.85);
}
.pack-stack-card:nth-child(3) {
  transform: translate(0, 0) scale(1);
  z-index: 3;
}

/* Open: rotation only — no translate, so fan stays within the oversized .pack-stack box */
.pack-deck.is-open .pack-stack-card:nth-child(1) {
  transform: rotate(-20deg) scale(0.95);
  filter: brightness(0.95);
}
.pack-deck.is-open .pack-stack-card:nth-child(2) {
  transform: translateY(-3px) scale(1);
  filter: brightness(1);
}
.pack-deck.is-open .pack-stack-card:nth-child(3) {
  transform: rotate(20deg) scale(0.95);
  filter: brightness(0.95);
}

.pack-deck-title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.2;
  color: #314036;
  max-width: 7rem;
}

.pack-deck-count {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  background: rgba(53, 92, 146, 0.85);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 6px rgba(50, 63, 51, 0.18);
}

/* ── Card fan grid ──────────────────────────────────────────────── */

.pack-fan {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  padding-bottom: 1rem;
}

.pack-fan-description {
  grid-column: 1 / -1;
  margin: 0 0 0.25rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.template-fan-card {
  display: flex;
  flex-direction: column;
  border-radius: 0.9rem;
  overflow: hidden;
  border: 1px solid rgba(103, 112, 84, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(245, 233, 212, 0.98));
  box-shadow: 0 8px 22px rgba(84, 67, 42, 0.1);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
  animation: fan-card-in 260ms cubic-bezier(0.34, 1.3, 0.64, 1) calc(var(--i, 0) * 45ms) both;
}

.template-fan-card:nth-child(odd)  { transform: rotate(-0.5deg); }
.template-fan-card:nth-child(even) { transform: rotate(0.5deg); }

.template-fan-card:hover,
.template-fan-card:focus-visible {
  transform: translateY(-3px) rotate(0deg) !important;
  box-shadow: 0 14px 30px rgba(84, 67, 42, 0.16);
  outline: none;
}

.template-fan-image {
  width: 100%;
  aspect-ratio: 5 / 3.12;
  max-height: 7rem;
  background-color: #ddd5c2;
  background-size: cover;
  background-position: center;
  flex: 0 0 auto;
}

.template-fan-title {
  margin: 0;
  padding: 0.5rem 0.65rem 0.6rem;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.1;
  color: #314036;
}

@keyframes fan-card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ──────────────────────────────────────────────────────────────── */

.empty-note {
  margin-top: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: 1.15rem;
  background: rgba(247, 241, 230, 0.8);
}

.panel-warning {
  margin-top: 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: 1rem;
  background: rgba(169, 105, 63, 0.1);
  color: var(--warning);
}

.stage-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(26rem, calc(100% - 2.6rem));
  padding: 1.2rem 1.25rem;
  border-radius: 1.55rem;
  border: 1px dashed rgba(250, 248, 240, 0.34);
  background: rgba(49, 67, 59, 0.28);
  box-shadow: 0 22px 40px rgba(29, 38, 34, 0.18);
  color: rgba(248, 245, 235, 0.92);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 22;
  backdrop-filter: blur(6px);
}

.stage-empty-title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2rem, 4vw, 2.5rem);
  line-height: 0.94;
}

.stage-empty-copy {
  margin: 0.55rem 0 0;
  font-size: 1rem;
  line-height: 1.55;
  color: rgba(242, 239, 230, 0.84);
}

.stage.is-empty .card-rig {
  opacity: 0.28;
  transform:
    translate(-50%, -50%)
    scale(0.96)
    rotateX(12deg)
    rotateY(-7deg);
}

.stage.is-empty .punch-top-assembly,
.stage.is-empty .punch-bottom-assembly {
  opacity: 0.2;
}

.stage.is-empty .card-body {
  cursor: default;
}

.stage.is-drop-target::after {
  border-color: rgba(248, 244, 232, 0.44);
  box-shadow: 0 0 0 0.4rem rgba(255, 247, 229, 0.14);
}

.stage.is-drop-target .stage-empty {
  transform: translate(-50%, -50%) scale(1.02);
  background: rgba(53, 92, 146, 0.34);
}

/* Legacy monolith media queries removed — layout now handled by
   the single @media (max-width: 1100px) mobile breakpoint below.

   Kept: a few resets that still apply at narrow desktop widths. */
@media (max-width: 1180px) {
  .stage-panel,
  .stage-frame {
    transform: none;
  }
}

/* Legacy monolith small-screen breakpoints removed (760px, 560px).
   All sub-desktop layouts are now handled by the single 1100px breakpoint. */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .paper-slug {
    display: none;
  }

  .note-scrap,
  .control-button,
  .dock-close,
  .stack-card,
  .upload-slot,
  .maker-note,
  .stage-panel,
  .studio-panel,
  .library-panel,
  .studio-rail {
    transform: none;
    animation: none;
  }

  .stage.is-denied .punch-top-assembly,
  .stage.is-denied .punch-bottom-assembly {
    animation-duration: 120ms;
  }
}

.auth-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 1.4rem;
  border: 1px solid rgba(102, 117, 88, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(246, 236, 217, 0.98)),
    var(--paper);
  box-shadow: var(--shadow-soft);
}

.auth-panel-head,
.auth-actions,
.unlock-section-head,
.unlock-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
}

.auth-panel-head {
  margin-bottom: 0.75rem;
}

.auth-badge-stack {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.auth-panel-copy,
.auth-status {
  margin: 0.24rem 0 0;
  color: var(--ink-soft);
  line-height: 1.4;
}

.auth-login-badge,
.auth-state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.8rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  background: rgba(53, 92, 146, 0.13);
  color: var(--indigo);
  font-family: "Patrick Hand", cursive;
}

.auth-login-badge {
  background: rgba(106, 119, 93, 0.12);
  color: #4d6244;
}

.auth-login-badge[data-login-state="signed-in"] {
  background: rgba(90, 146, 96, 0.18);
  color: #356143;
}

.auth-login-badge[data-login-state="signed-out"] {
  background: rgba(173, 122, 88, 0.16);
  color: #8b5b41;
}

.auth-email-input {
  margin-top: 0.25rem;
}

.auth-actions,
.unlock-actions {
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.art-upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.art-upload-card,
.unlock-section {
  padding: 0.85rem;
  border-radius: 1rem;
  border: 1px solid rgba(104, 117, 88, 0.14);
  background: rgba(255, 255, 255, 0.48);
}

.art-upload-title {
  margin: 0 0 0.45rem;
  font-family: "Patrick Hand", cursive;
  color: var(--indigo);
}

.art-upload-input {
  display: block;
  width: 100%;
  margin-bottom: 0.55rem;
}

.unlock-rail {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.unlock-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.unlock-chip {
  width: 100%;
  padding: 0.72rem 0.8rem;
  border: 1px solid rgba(106, 118, 93, 0.16);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(247, 238, 223, 0.98)),
    var(--cream);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.unlock-chip:hover,
.unlock-chip:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(53, 92, 146, 0.28);
  box-shadow: 0 12px 22px rgba(84, 65, 40, 0.12);
  outline: none;
}

.unlock-chip.is-selected {
  border-color: rgba(53, 92, 146, 0.34);
  box-shadow:
    0 12px 24px rgba(84, 65, 40, 0.12),
    inset 0 0 0 1px rgba(53, 92, 146, 0.12);
}

.unlock-chip.is-locked {
  cursor: default;
  opacity: 0.65;
}

.unlock-chip-title,
.unlock-chip-copy {
  display: block;
}

.unlock-chip-title {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.25rem;
  line-height: 1;
}

.unlock-chip-copy {
  margin-top: 0.18rem;
  color: var(--ink-soft);
  font-size: 0.92rem;
  line-height: 1.35;
}

.shape-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(3rem, 1fr));
  gap: 0.4rem;
}

.shape-chip {
  width: auto;
  height: 5rem;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shape-visual {
  display: block;
  width: 3rem;
  height: 3rem;
  color: var(--ink);
  filter: drop-shadow(0 2px 4px rgba(50, 64, 56, 0.1));
}

.card-highlight-stroke {
  fill: none;
  stroke-width: 22;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.card-highlight-fill {
  opacity: 0.18;
}

.card-stamp-mark {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 720px) {
  .art-upload-grid {
    grid-template-columns: 1fr;
  }
}

html,
body {
  height: 100%;
}

body {
  min-height: 100svh;
}

.page {
  width: min(1440px, calc(100% - 1rem));
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

.masthead {
  /* Mirror the workbench grid so nav tabs align above the sidebar */
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(20rem, 27vw, 25rem);
  gap: 0 1rem;
  align-items: end;
  margin-bottom: 0;
}

.masthead-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex: 1 1 auto;
  min-width: 0;
}

.masthead-actions {
  display: flex;
  align-items: stretch;
  gap: 0;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 0.8rem 0.8rem 0 0;
  background:
    linear-gradient(180deg, rgba(210, 170, 120, 0.15) 0%, transparent 40%),
    linear-gradient(180deg, var(--wood), var(--wood-deep));
  border: 1px solid rgba(100, 70, 30, 0.25);
  border-bottom: none;
}

/* Wood grain on desktop tab bar */
.masthead-actions::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0px, transparent 2px,
      rgba(40, 18, 0, 0.09) 2px, rgba(40, 18, 0, 0.07) 3px,
      transparent 3px, transparent 7px,
      rgba(55, 25, 0, 0.05) 7px, rgba(55, 25, 0, 0.04) 7.5px
    ),
    repeating-linear-gradient(
      178deg,
      transparent 0px, transparent 9px,
      rgba(35, 15, 0, 0.08) 9px, rgba(35, 15, 0, 0.06) 11px,
      transparent 11px, transparent 22px,
      rgba(50, 22, 0, 0.06) 22px, rgba(50, 22, 0, 0.04) 23.5px
    );
}

/* Wood knot accent */
.masthead-actions::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 14px 10px at 72% 50%,
      rgba(45, 18, 0, 0.22),
      rgba(55, 25, 0, 0.12) 40%,
      transparent 100%),
    radial-gradient(ellipse 24px 16px at 72% 50%,
      transparent 45%,
      rgba(50, 22, 0, 0.07) 58%,
      transparent 85%);
}

.sheet-dismiss {
  min-height: 2.85rem;
  padding: 0.72rem 1rem;
  border: 1px solid rgba(111, 101, 73, 0.16);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(245, 233, 210, 0.98)),
    var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 22px rgba(84, 65, 40, 0.09);
  cursor: pointer;
  font-family: "Patrick Hand", cursive;
  font-size: 1rem;
  letter-spacing: 0.04em;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease, color 180ms ease;
}

.sheet-dismiss:hover,
.sheet-dismiss:focus-visible {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 14px 28px rgba(84, 65, 40, 0.14);
  outline: none;
}

/* Desktop masthead nav buttons — connected tabs above sidebar panel.
   Inactive tabs look slightly recessed; the active tab shares the panel
   background so the dividing line vanishes and they read as one card. */
.shell-menu-button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 2.4rem;
  padding: 0.45rem 0.6rem 0.35rem;
  border: none;
  border-right: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 0;
  background: transparent;
  color: rgba(255, 248, 235, 0.75);
  box-shadow: none;
  cursor: pointer;
  font-family: "Source Sans 3", sans-serif;
  font-weight: 600;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  transition: color 160ms ease, background 160ms ease;
  position: relative;
  z-index: 1;
}

.shell-menu-button:last-child {
  border-right: none;
}

.shell-menu-icon {
  display: block;
  width: 18px;
  height: 18px;
  opacity: 0.75;
  transition: opacity 180ms ease;
}

.shell-menu-button:hover,
.shell-menu-button:focus-visible {
  color: rgba(255, 248, 235, 1);
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.shell-menu-button:hover .shell-menu-icon,
.shell-menu-button:focus-visible .shell-menu-icon {
  opacity: 1;
}

/* Active tab: paper background punches through the wood,
   connecting seamlessly to the sidebar panel below. */
.shell-menu-button.is-active {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.22)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0)),
    var(--paper);
  color: var(--ink);
  z-index: 2;
  border-right-color: rgba(90, 86, 63, 0.14);
}

.shell-menu-button.is-active .shell-menu-icon {
  opacity: 1;
}

/* Erase the panel's top border behind the active tab */
.shell-menu-button.is-active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.22)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0)),
    var(--paper);
}

/* mobile-nav active state moved below .mobile-nav-button base (see below line ~3200) */

.workbench {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(20rem, 27vw, 25rem);
  gap: 0 1rem;
  align-items: stretch;
}

/* Desktop sidebar — holds all switchable panels */
body[data-layout="desktop"] .sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* Desktop sidebar: hide the top highlight strip since tabs connect flush */
body[data-layout="desktop"] .sidebar > .tools-panel::before,
body[data-layout="desktop"] .sidebar > .shell-drawer::before {
  display: none;
}

/* Desktop: all sidebar panels hidden by default */
body[data-layout="desktop"] .sidebar > .tools-panel,
body[data-layout="desktop"] .sidebar > .shell-drawer {
  position: static;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  width: auto;
  height: auto;
  max-height: none;
  z-index: auto;
  flex: 1;
  min-height: 0;
  transform: none;
  margin: 0;
  animation: none;
  border-radius: 0 0 2rem 2rem;
  opacity: 1;
  pointer-events: auto;
  display: none;
  transition: none;
}

/* Desktop: tools panel shows by default when no overlay is active */
body[data-layout="desktop"][data-overlay="none"] .sidebar > .tools-panel {
  display: flex;
}

/* Desktop: show the selected overlay panel */
body[data-layout="desktop"][data-overlay="cards"] .sidebar > #cardsDrawer {
  display: flex;
}

body[data-layout="desktop"][data-overlay="starters"] .sidebar > #startersDrawer {
  display: flex;
}

body[data-layout="desktop"][data-overlay="profile"] .sidebar > #profileDrawer {
  display: flex;
}

/* Desktop: no scrim for sidebar switching */
body[data-layout="desktop"] .shell-scrim {
  display: none !important;
}

.stage-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  z-index: 4;
}

.stage-frame {
  min-height: 0;
}

.stage {
  min-height: auto;
  height: 100%;
}

.stage-hud {
  display: grid;
  gap: 0.8rem;
  margin-top: 0.75rem;
}

/* ---- Stage overlays: count bubble + flip button ---- */
.stage-frame {
  position: relative;
}

.count-bubble {
  position: absolute;
  top: 0.1rem;
  left: 0.1rem;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.82), rgba(247,240,224,0.96)),
    var(--paper);
  border: 1px solid rgba(53, 92, 146, 0.18);
  box-shadow: 0 4px 12px rgba(53, 92, 146, 0.12);
  color: var(--indigo);
  font-family: "Patrick Hand", cursive;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

.flip-overlay-btn {
  position: absolute;
  bottom: 0.1rem;
  left: 0.1rem;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid rgba(53, 92, 146, 0.2);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.78), rgba(247,240,224,0.94)),
    var(--paper);
  box-shadow: 0 4px 12px rgba(53, 92, 146, 0.1);
  color: var(--indigo);
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.flip-overlay-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(53, 92, 146, 0.18);
}

.flip-overlay-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.undo-overlay-btn {
  position: absolute;
  bottom: 0.1rem;
  right: 0.1rem;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 1px solid rgba(53, 92, 146, 0.2);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.78), rgba(247,240,224,0.94)),
    var(--paper);
  box-shadow: 0 4px 12px rgba(53, 92, 146, 0.1);
  color: var(--indigo);
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.undo-overlay-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(53, 92, 146, 0.18);
}

.undo-overlay-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---- Stage toolbar: one connected card ---- */
.stage-toolbar {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(90, 86, 63, 0.15);
  border-radius: 1rem;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.58), rgba(247,240,224,0.94)),
    var(--paper);
  box-shadow: 0 6px 18px rgba(84, 65, 40, 0.08);
  overflow: hidden;
}

/* Options area: pad content, no border */
.toolbar-options {
  display: flex;
  align-items: center;
  gap: 0;
  min-height: 3.2rem;
  padding: 0.35rem 0.65rem;
}

.toolbar-sep {
  width: 1px;
  height: 1.8rem;
  background: rgba(100, 119, 99, 0.2);
  margin: 0 0.5rem;
  flex-shrink: 0;
}

/* Tabs: flush bottom of card, divided by top border */
.toolbar-tabs {
  display: flex;
  border-top: 1px solid rgba(90, 86, 63, 0.12);
}

.toolbar-tab {
  flex: 1;
  padding: 0.5rem 0.4rem;
  border: none;
  border-right: 1px solid rgba(90, 86, 63, 0.12);
  /* slightly subdued — "behind" the active pane */
  background: rgba(0, 0, 0, 0.022);
  color: var(--ink-soft);
  font-family: "Patrick Hand", cursive;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.toolbar-tab:last-child {
  border-right: none;
}

/* Active tab: same background as card — visually "opens" into options pane.
   margin-top: -1px + border-top matching card bg erases the divider line
   at exactly this tab's position, creating a seamless connection. */
.toolbar-tab.is-active {
  background: transparent;
  color: var(--indigo);
  font-weight: 600;
  margin-top: -1px;
  border-top: 1px solid rgba(247, 240, 224, 0.97);
}

.toolbar-tab.is-empty {
  opacity: 0.45;
}

.toolbar-tab.is-empty.is-active {
  opacity: 0.65;
}

/* Size selector: sliding indicator bar */
.toolbar-size-slider {
  flex-shrink: 0;
  width: 7rem;
}

.toolbar-size-track {
  position: relative;
  width: 100%;
  height: 2.5rem;
  display: flex;
  align-items: center;
  border-radius: 0.75rem;
  background: rgba(53, 92, 146, 0.07);
  border: 1px solid rgba(53, 92, 146, 0.14);
}

.toolbar-size-indicator {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: calc(33.33% - 0.28rem);
  height: calc(100% - 0.28rem);
  border-radius: 0.55rem;
  pointer-events: none;
  z-index: 1;
  transition: left 200ms cubic-bezier(0.34, 1.2, 0.64, 1);
}

.toolbar-size-indicator[data-size="small"] {
  left: 0.14rem;
  background: linear-gradient(145deg, var(--indigo-soft), var(--indigo));
}

.toolbar-size-indicator[data-size="medium"] {
  left: calc(33.33% + 0.0rem);
  background: linear-gradient(145deg, var(--moss), var(--moss-deep));
}

.toolbar-size-indicator[data-size="large"] {
  left: calc(66.66% + 0.14rem);
  background: linear-gradient(145deg, var(--wood), var(--wood-deep));
}

.toolbar-size-zone {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 2;
}

.toolbar-size-zone:disabled {
  opacity: 0.4;
  cursor: default;
}

.size-label {
  position: relative;
  z-index: 3;
  font-family: "Patrick Hand", cursive;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  pointer-events: none;
  transition: color 200ms ease;
}

/* Label turns white when its zone is the active size */
.toolbar-size-track[data-selected="small"]  .toolbar-size-zone:nth-child(2) .size-label,
.toolbar-size-track[data-selected="medium"] .toolbar-size-zone:nth-child(3) .size-label,
.toolbar-size-track[data-selected="large"]  .toolbar-size-zone:nth-child(4) .size-label {
  color: rgba(255, 255, 255, 0.92);
}

/* Shape picker: scrollable row with fade + arrow overlays */
.shapes-row {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  /* edge fades — shown via can-scroll-* classes */
}

.shapes-row::before,
.shapes-row::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 150ms ease;
  z-index: 1;
}

.shapes-row::before {
  left: 0;
  background: linear-gradient(to right, rgba(247, 240, 222, 0.92), transparent);
}

.shapes-row::after {
  right: 0;
  background: linear-gradient(to left, rgba(247, 240, 222, 0.92), transparent);
}

.shapes-row.can-scroll-left::before  { opacity: 1; }
.shapes-row.can-scroll-right::after  { opacity: 1; }

.shapes-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid rgba(90, 86, 63, 0.18);
  background: rgba(247, 240, 222, 0.95);
  color: var(--ink-soft);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 4px rgba(84, 65, 40, 0.12);
  transition: background 100ms ease, color 100ms ease;
}

.shapes-arrow:hover {
  background: white;
  color: var(--indigo);
}

.shapes-arrow-left  { left: 0; }
.shapes-arrow-right { right: 0; }

.toolbar-shapes {
  display: flex;
  align-items: center;
  gap: 0.05rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-width: 0;
  padding: 0 0.1rem;
}

.toolbar-shapes::-webkit-scrollbar { display: none; }

.toolbar-shape-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.6rem;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background 120ms ease;
}

.toolbar-shape-btn.is-selected {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.7), rgba(247,240,224,0.88)),
    var(--paper);
  border-color: rgba(53, 92, 146, 0.22);
}

.toolbar-shape-btn:disabled { opacity: 0.38; }
.toolbar-shape-btn.is-locked { opacity: 0.35; cursor: default; }

/* Options scroll for highlights/stamps */
.toolbar-options-scroll {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}

.toolbar-options-scroll::-webkit-scrollbar { display: none; }

.toolbar-option-btn {
  flex-shrink: 0;
  padding: 0.38rem 0.8rem;
  border-radius: 0.6rem;
  border: 1px solid rgba(100, 119, 99, 0.2);
  background: transparent;
  color: var(--ink);
  font-family: "Patrick Hand", cursive;
  font-size: 0.9rem;
  cursor: pointer;
}

.toolbar-option-btn.is-selected {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.7), rgba(247,240,224,0.88)),
    var(--paper);
  border-color: rgba(53, 92, 146, 0.22);
  color: var(--indigo);
}

.toolbar-option-btn.toolbar-option-action {
  color: var(--indigo);
  border-color: rgba(53, 92, 146, 0.3);
}

.toolbar-option-btn:disabled { opacity: 0.4; }

.tools-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1.35rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.18)),
    linear-gradient(135deg, rgba(127, 161, 124, 0.08), rgba(53, 92, 146, 0.04)),
    #f9f1e0;
}

.tools-panel-head,
.shell-drawer-head,
.tool-section-head,
.utility-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.tools-panel-head {
  margin-bottom: 1rem;
}

.tool-section-label {
  margin: 0 0 0.5rem;
  font-family: "Patrick Hand", cursive;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.tools-panel-head h2,
.shell-drawer-head h2 {
  display: none;
}

.tools-panel-scroll,
.shell-drawer-scroll {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* prevent wide children from inflating the track */
  gap: 1rem;
  padding-right: 0.25rem;
  align-content: start;
  scrollbar-width: none; /* Firefox */
}

.tools-panel-scroll::-webkit-scrollbar,
.shell-drawer-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.tool-section,
.utility-section {
  padding: 1rem;
  border-radius: 1.5rem;
  border: 1px solid rgba(102, 117, 88, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(246, 236, 217, 0.98)),
    var(--paper);
  box-shadow: var(--shadow-soft);
}

.tool-section h3,
.utility-section h3 {
  margin: 0.42rem 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.75rem;
  line-height: 0.96;
  color: #314036;
}

.compact-unlock-rail {
  margin-top: 0.9rem;
}

.tool-control-row,
.utility-control-row {
  margin-top: 0.95rem;
}

.utility-control-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.utility-danger {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(248, 232, 224, 0.98)),
    var(--paper);
}

.utility-delete-button {
  margin-top: 0.95rem;
  border-color: rgba(184, 92, 82, 0.24);
  color: #8d433b;
}

.shell-scrim {
  position: fixed;
  inset: 0;
  border: 0;
  background: rgba(30, 30, 28, 0.28);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 20;
}

.shell-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(28rem, 85vw);
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  border-radius: 1.2rem 0 0 1.2rem;
  opacity: 0;
  pointer-events: none;
  transform: translate3d(100%, 0, 0);
  transition: transform 280ms ease, opacity 200ms ease;
}

.shell-drawer-head {
  margin-bottom: 1rem;
}

/* On desktop, tabs handle navigation — dismiss buttons hidden */
body[data-layout="desktop"] .sheet-dismiss {
  display: none;
}

body[data-layout="desktop"] {
  overflow: hidden;
}

body[data-layout="desktop"] .page {
  height: 100svh;
}

body[data-overlay-open="true"] .shell-scrim {
  display: block;
}

body[data-overlay-open="false"] .shell-scrim {
  display: none;
}

/* Wood drawer interior — all drawers, all breakpoints */
.shell-drawer.panel-card {
  background:
    linear-gradient(180deg, rgba(30, 15, 0, 0.18) 0%, transparent 12%),
    linear-gradient(90deg, rgba(30, 15, 0, 0.10) 0%, transparent 6%, transparent 94%, rgba(30, 15, 0, 0.10) 100%),
    linear-gradient(180deg, #c9a06a, #d4ad78 40%, #c19a62 100%);
  border: none;
  box-shadow:
    inset 4px 0 8px -2px rgba(30, 15, 0, 0.15),
    inset -4px 0 8px -2px rgba(30, 15, 0, 0.15),
    inset 0 6px 12px -4px rgba(20, 8, 0, 0.22);
  overflow: hidden;
  isolation: isolate;
}

.shell-drawer::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
  background:
    repeating-linear-gradient(
      180deg,
      transparent 0px, transparent 3px,
      rgba(50, 25, 0, 0.06) 3px, rgba(50, 25, 0, 0.04) 4px,
      transparent 4px, transparent 10px,
      rgba(40, 18, 0, 0.04) 10px, rgba(40, 18, 0, 0.03) 10.5px
    ),
    repeating-linear-gradient(
      178deg,
      transparent 0px, transparent 14px,
      rgba(35, 15, 0, 0.05) 14px, rgba(35, 15, 0, 0.04) 16px,
      transparent 16px, transparent 30px
    );
  opacity: 0.7;
}

.shell-drawer::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
  background:
    radial-gradient(ellipse 22px 16px at 28% 35%,
      rgba(50, 22, 0, 0.18), rgba(60, 28, 0, 0.10) 40%,
      rgba(70, 35, 5, 0.04) 70%, transparent 100%),
    radial-gradient(ellipse 34px 24px at 28% 35%,
      transparent 40%, rgba(50, 22, 0, 0.06) 58%, transparent 75%),
    radial-gradient(ellipse 14px 10px at 75% 65%,
      rgba(50, 22, 0, 0.14), rgba(60, 28, 0, 0.06) 50%, transparent 100%),
    radial-gradient(ellipse 24px 16px at 75% 65%,
      transparent 45%, rgba(50, 22, 0, 0.05) 60%, transparent 80%);
}

.shell-drawer > * {
  position: relative;
  z-index: 1;
}

.shell-drawer .eyebrow {
  color: #5a3a1e;
  font-weight: 700;
  font-size: 1.1rem;
}

.shell-drawer-head .eyebrow,
.tools-panel-head .eyebrow {
  font-weight: 700;
  font-size: 1.1rem;
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 0;
  padding-bottom: env(safe-area-inset-bottom);
  border-radius: 0;
  border: none;
  border-top: 2px solid rgba(100, 70, 30, 0.25);
  background:
    linear-gradient(180deg, rgba(210, 170, 120, 0.15) 0%, transparent 40%),
    linear-gradient(180deg, var(--wood), var(--wood-deep));
  box-shadow: 0 -4px 20px rgba(84, 55, 20, 0.25);
  isolation: isolate;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Wood grain texture — horizontal lines */
.mobile-nav::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    /* tight horizontal grain */
    repeating-linear-gradient(
      180deg,
      transparent 0px,
      transparent 2px,
      rgba(40, 18, 0, 0.09) 2px,
      rgba(40, 18, 0, 0.07) 3px,
      transparent 3px,
      transparent 7px,
      rgba(55, 25, 0, 0.05) 7px,
      rgba(55, 25, 0, 0.04) 7.5px
    ),
    /* medium horizontal bands */
    repeating-linear-gradient(
      178deg,
      transparent 0px,
      transparent 9px,
      rgba(35, 15, 0, 0.08) 9px,
      rgba(35, 15, 0, 0.06) 11px,
      transparent 11px,
      transparent 22px,
      rgba(50, 22, 0, 0.06) 22px,
      rgba(50, 22, 0, 0.04) 23.5px
    ),
    /* wide horizontal sweep */
    repeating-linear-gradient(
      182deg,
      transparent 0px,
      transparent 15px,
      rgba(30, 12, 0, 0.04) 15px,
      rgba(30, 12, 0, 0.06) 17px,
      rgba(30, 12, 0, 0.04) 19px,
      transparent 19px
    );
}

/* Wood knots — concentric rings */
.mobile-nav::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    /* knot 1 — left area: dark core + rings */
    radial-gradient(ellipse 16px 12px at 14% 50%,
      rgba(45, 18, 0, 0.28),
      rgba(55, 25, 0, 0.18) 35%,
      rgba(65, 30, 5, 0.08) 65%,
      transparent 100%),
    radial-gradient(ellipse 30px 22px at 14% 50%,
      transparent 40%,
      rgba(50, 22, 0, 0.10) 55%,
      rgba(50, 22, 0, 0.06) 65%,
      transparent 80%),
    /* grain warping around knot 1 */
    radial-gradient(ellipse 55px 8px at 14% 32%, rgba(40, 18, 0, 0.07), transparent),
    radial-gradient(ellipse 55px 8px at 14% 70%, rgba(40, 18, 0, 0.07), transparent),
    /* knot 2 — right of center: smaller */
    radial-gradient(ellipse 12px 10px at 66% 46%,
      rgba(45, 18, 0, 0.24),
      rgba(55, 25, 0, 0.14) 40%,
      rgba(65, 30, 5, 0.06) 70%,
      transparent 100%),
    radial-gradient(ellipse 22px 16px at 66% 46%,
      transparent 45%,
      rgba(50, 22, 0, 0.08) 58%,
      rgba(50, 22, 0, 0.04) 70%,
      transparent 85%),
    /* grain warping around knot 2 */
    radial-gradient(ellipse 40px 6px at 66% 30%, rgba(40, 18, 0, 0.06), transparent),
    radial-gradient(ellipse 40px 6px at 66% 64%, rgba(40, 18, 0, 0.06), transparent),
    /* knot 3 — far right: tiny accent */
    radial-gradient(ellipse 9px 7px at 90% 55%,
      rgba(45, 18, 0, 0.20),
      rgba(55, 25, 0, 0.10) 45%,
      transparent 100%),
    radial-gradient(ellipse 16px 11px at 90% 55%,
      transparent 50%,
      rgba(50, 22, 0, 0.06) 65%,
      transparent 85%);
}

/* Ensure buttons sit above the grain */
.mobile-nav > * {
  position: relative;
  z-index: 1;
}

.mobile-nav-button {
  min-height: 3.2rem;
  padding: 0.35rem 0.4rem 0.45rem;
  position: relative;
  font-weight: 400;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  border-radius: 0;
  border: 0;
  border-top: 2.5px solid transparent;
  background: transparent;
  color: rgba(255, 248, 235, 0.75);
  box-shadow: none;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.mobile-nav-button:hover,
.mobile-nav-button:focus-visible {
  transform: none;
  border-color: transparent;
  box-shadow: none;
  color: rgba(255, 248, 235, 1);
  background: rgba(255, 255, 255, 0.08);
}

.mobile-nav-button.is-active,
.mobile-nav-button[aria-current="page"] {
  color: #fff9f0;
  border-top: 2.5px solid var(--cream);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 60%);
}

.mobile-nav-icon {
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 1.3rem;
}

.mobile-nav-icon svg {
  display: block;
}

.mobile-nav-label {
  font-size: 0.68rem;
  font-family: "Source Sans 3", sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
}

.mobile-nav-profile {
  /* profile button same styling, no special overrides needed */
}

@media (max-width: 960px) {
  html,
  body {
    height: 100dvh;
    overflow: hidden;
  }

  body {
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
  }

  .page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .masthead,
  .masthead-primary,
  .tools-panel-head,
  .shell-drawer-head,
  .tool-section-head,
  .utility-section-head {
    flex-direction: column;
  }

  .masthead {
    display: none;
  }

  .masthead-copy,
  .stage-caption {
    text-align: left;
  }

  .masthead-actions {
    justify-content: stretch;
  }

  .masthead-actions > * {
    flex: 1 1 0;
  }

  .workbench {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: calc(3.35rem + env(safe-area-inset-bottom));
    isolation: auto;
  }

  /* On mobile, sidebar is invisible — drawers escape it via position:fixed */
  .sidebar {
    display: contents;
  }

  /* Hide stage panel heading on mobile — toolbar replaces it */
  .stage-panel-heading {
    display: none;
  }

  .stage-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0.75rem 0.75rem;
    overflow: hidden;
    border-radius: 0;
  }

  /* Stage frame: shrink mat border on mobile for more card space */
  .stage-frame {
    flex: none;
    padding: 0.5rem;
    border-radius: 1.4rem;
  }

  /* Move count bubble and buttons onto the mat border */
  .count-bubble {
    top: -0.15rem;
    left: -0.15rem;
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 0.4rem;
    font-size: 0.78rem;
  }

  .flip-overlay-btn {
    bottom: -0.15rem;
    left: -0.15rem;
    width: 2rem;
    height: 2rem;
    font-size: 0.9rem;
  }

  .undo-overlay-btn {
    bottom: -0.15rem;
    right: -0.15rem;
    left: auto;
    width: 2rem;
    height: 2rem;
  }

  /* Stage: fixed aspect ratio matching the card so the card never
     stretches or squishes when the viewport changes. */
  .stage {
    min-height: 0;
    aspect-ratio: 5 / 3.12;
    border-radius: 1rem;
  }

  /* Toolbar compact on mobile */
  .stage-toolbar {
    flex-shrink: 0;
    padding-top: 0.4rem;
  }

  /* Status message compact */
  .status-message {
    margin: 0.3rem 0 0;
    font-size: 0.85rem;
  }

  /* Drawer interior — wooden drawer look on mobile */
  #toolsPanel,
  .shell-drawer {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: calc(3.35rem + env(safe-area-inset-bottom) - 1px);
    width: auto;
    max-height: none;
    height: 60dvh;
    padding: 1.1rem 0.8rem 1rem;
    border-radius: 1rem 1rem 0 0;
    z-index: 40;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0, calc(100% + 1rem), 0);
    transition: transform 240ms ease, opacity 220ms ease;
    /* Drawer interior wood */
    border: none;
    background:
      /* inner shadow — top and sides */
      linear-gradient(180deg, rgba(30, 15, 0, 0.18) 0%, transparent 12%),
      linear-gradient(90deg, rgba(30, 15, 0, 0.10) 0%, transparent 6%, transparent 94%, rgba(30, 15, 0, 0.10) 100%),
      /* light wood bottom/floor */
      linear-gradient(180deg, #c9a06a, #d4ad78 40%, #c19a62 100%);
    box-shadow:
      inset 4px 0 8px -2px rgba(30, 15, 0, 0.15),
      inset -4px 0 8px -2px rgba(30, 15, 0, 0.15),
      inset 0 6px 12px -4px rgba(20, 8, 0, 0.22);
  }

  #toolsPanel {
    display: flex !important;
  }

  /* Horizontal grain on drawer floor */
  #toolsPanel::before,
  .shell-drawer::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    border-radius: 1rem 1rem 0 0;
    background:
      repeating-linear-gradient(
        180deg,
        transparent 0px,
        transparent 3px,
        rgba(50, 25, 0, 0.06) 3px,
        rgba(50, 25, 0, 0.04) 4px,
        transparent 4px,
        transparent 10px,
        rgba(40, 18, 0, 0.04) 10px,
        rgba(40, 18, 0, 0.03) 10.5px
      ),
      repeating-linear-gradient(
        178deg,
        transparent 0px,
        transparent 14px,
        rgba(35, 15, 0, 0.05) 14px,
        rgba(35, 15, 0, 0.04) 16px,
        transparent 16px,
        transparent 30px
      );
    opacity: 0.7;
  }

  /* Drawer knots */
  #toolsPanel::after,
  .shell-drawer::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    border-radius: 1rem 1rem 0 0;
    background:
      radial-gradient(ellipse 22px 16px at 28% 35%,
        rgba(50, 22, 0, 0.18),
        rgba(60, 28, 0, 0.10) 40%,
        rgba(70, 35, 5, 0.04) 70%,
        transparent 100%),
      radial-gradient(ellipse 34px 24px at 28% 35%,
        transparent 40%,
        rgba(50, 22, 0, 0.06) 58%,
        transparent 75%),
      radial-gradient(ellipse 14px 10px at 75% 65%,
        rgba(50, 22, 0, 0.14),
        rgba(60, 28, 0, 0.06) 50%,
        transparent 100%),
      radial-gradient(ellipse 24px 16px at 75% 65%,
        transparent 45%,
        rgba(50, 22, 0, 0.05) 60%,
        transparent 80%);
  }

  /* Drawer content sits above wood grain */
  #toolsPanel > *,
  .shell-drawer > * {
    position: relative;
    z-index: 1;
  }

  /* Override panel-card bg inside drawers — make it lighter paper on wood */
  .shell-drawer.panel-card,
  #toolsPanel.panel-card {
    background:
      linear-gradient(180deg, rgba(30, 15, 0, 0.18) 0%, transparent 12%),
      linear-gradient(90deg, rgba(30, 15, 0, 0.10) 0%, transparent 6%, transparent 94%, rgba(30, 15, 0, 0.10) 100%),
      linear-gradient(180deg, #c9a06a, #d4ad78 40%, #c19a62 100%);
    border: none;
    box-shadow:
      inset 4px 0 8px -2px rgba(30, 15, 0, 0.15),
      inset -4px 0 8px -2px rgba(30, 15, 0, 0.15),
      inset 0 6px 12px -4px rgba(20, 8, 0, 0.22);
  }

  /* Mobile drawer headers: × close button top-right */
  .shell-drawer-head,
  .tools-panel-head {
    flex-direction: row;
    align-items: center;
    margin-bottom: 0.4rem;
    position: relative;
  }

  .shell-drawer-head .sheet-dismiss,
  .tools-panel-head .sheet-dismiss {
    position: absolute;
    top: -0.4rem;
    right: -0.4rem;
    min-height: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border-radius: 999px;
    font-size: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(111, 101, 73, 0.16);
    background:
      linear-gradient(180deg, rgba(255,255,255,0.84), rgba(245,233,210,0.98)),
      var(--paper);
    box-shadow: 0 4px 10px rgba(84, 65, 40, 0.08);
  }

  .shell-drawer-head .sheet-dismiss::after,
  .tools-panel-head .sheet-dismiss::after {
    content: '\00d7';
    font-size: 0.85rem;
    color: var(--ink);
    font-family: system-ui, sans-serif;
    line-height: 1;
  }

  .shell-drawer-head .shell-drawer-kicker {
    color: #5a3a1e;
  }

  .shell-drawer-scroll,
  .tools-panel-scroll {
    padding-right: 0;
  }

  .mobile-nav {
    display: grid;
  }

  .masthead-actions {
    display: none;
  }

  body[data-layout="mobile"][data-mobile-tab="cards"] #cardsDrawer,
  body[data-layout="mobile"][data-mobile-tab="starters"] #startersDrawer,
  body[data-layout="mobile"][data-mobile-tab="tools"] #toolsPanel,
  body:has(.mobile-nav-button[aria-current="page"][data-mobile-tab="tools"]) #toolsPanel,
  body[data-layout="mobile"][data-mobile-tab="profile"] #profileDrawer {
    opacity: 1;
    pointer-events: auto;
    display: flex !important;
    transform: translate3d(0, 0, 0);
  }

  body[data-layout="mobile"][data-mobile-tab="cards"] .shell-scrim,
  body[data-layout="mobile"][data-mobile-tab="starters"] .shell-scrim,
  body[data-layout="mobile"][data-mobile-tab="tools"] .shell-scrim,
  body[data-layout="mobile"][data-mobile-tab="profile"] .shell-scrim {
    display: block;
  }

  body[data-layout="mobile"] .stage-panel {
    transform: none;
  }
}

/* Profile drawer placeholder */
.profile-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 2rem 1rem;
  text-align: center;
}

.profile-placeholder-text {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: #3a2210;
}

.profile-placeholder-sub {
  margin: 0;
  font-size: 0.9rem;
  color: #6a4e30;
  max-width: 22rem;
  line-height: 1.45;
}

@media (max-width: 640px) {
  .shell-menu-button,
  .sheet-dismiss,
  .control-button,
  .ghost-chip {
    font-size: 0.94rem;
  }

  .tool-control-row,
  .utility-control-row {
    grid-template-columns: 1fr;
  }

  .signal-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .shell-drawer,
  .tools-panel,
  .shell-menu-button,
  .mobile-nav-button,
  .sheet-dismiss {
    transition: none;
  }
}
