/* Act 1: Recap Screenshot Surgery — Archival Desk Mat & Tactile Tools */

.surgery-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 0 22px;
}

.header-copy h1 {
  font-size: clamp(32px, 4.4vw, 48px);
  line-height: 1.06;
  margin-top: 4px;
}

.header-copy h1 em {
  font-style: italic;
  color: var(--wax);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn-upload-hero {
  min-height: 46px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 750;
  box-shadow: 0 8px 22px rgba(194, 65, 12, 0.28), 0 1px 3px rgba(24, 24, 27, 0.14);
}

.btn-upload-hero:hover:not(:disabled) {
  box-shadow: 0 10px 26px rgba(194, 65, 12, 0.36), 0 2px 6px rgba(24, 24, 27, 0.16);
}

/* Receipt restoration notice */
.receipt-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  margin-bottom: 20px;
  background: #FFFDF8;
  border: 1.5px solid rgba(21, 128, 61, 0.35);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 20px rgba(21, 128, 61, 0.08);
}

.receipt-banner[hidden] {
  display: none;
}

.receipt-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13.5px;
  color: var(--muted);
}

.receipt-banner-text strong {
  color: var(--present);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Main Two-Column Workbench */
.workbench {
  display: grid;
  grid-template-columns: minmax(330px, 412px) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

.mat-column {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Heirloom Archival Desk Mat Frame */
.desk-mat-frame {
  padding: 16px;
  background: linear-gradient(180deg, #FBF8F0 0%, #F4ECDD 100%);
  border: 1.5px solid var(--border-strong);
  position: relative;
}

/* Subtle drafting corner crop ticks */
.desk-mat-frame::before,
.desk-mat-frame::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 19px;
  pointer-events: none;
}

.desk-mat-frame::before {
  border: 1px dashed rgba(120, 53, 15, 0.14);
}

.mat-frame-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.mat-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.mat-source-badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The 9:16 Interactive Surgery Stage */
.mat-stage {
  --u: 0.34px;
  position: relative;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  border-radius: 14px;
  overflow: hidden;
  background: #110D2B;
  border: 1.5px solid rgba(24, 24, 27, 0.24);
  box-shadow: 0 12px 30px rgba(24, 24, 27, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.mat-stage:focus-visible {
  outline: 3px solid var(--terracotta);
  outline-offset: 3px;
}

.mat-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
}

/* Dropzone overlay */
.mat-drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(246, 242, 233, 0.92);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.mat-stage.is-file-over .mat-drop-overlay {
  opacity: 1;
}

.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 22px;
  border-radius: 16px;
  border: 2px dashed var(--terracotta);
  background: var(--surface);
  text-align: center;
  color: var(--ink);
  box-shadow: var(--shadow-card);
}

.drop-icon {
  font-size: 28px;
  color: var(--terracotta);
  line-height: 1;
}

.drop-card strong {
  font-family: var(--font-display);
  font-size: 18px;
}

.drop-card span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

/* Gentle prompt chip when mat has zero stickers placed yet */
.mat-hint-chip {
  position: absolute;
  left: 50%;
  bottom: calc(248 * var(--u));
  transform: translateX(-50%);
  width: 84%;
  z-index: 12;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.92);
  color: var(--ink);
  border: 1px solid rgba(24, 24, 27, 0.18);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  line-height: 1.35;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.mat-hint-chip[hidden] {
  display: none;
}

/* Archival Bottom Stamp on the 9:16 Stage (sits above IG Stories / TikTok bottom 160px safe zone) */
.mat-footer-stamp {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(236 * var(--u));
  padding-bottom: calc(156 * var(--u));
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(16 * var(--u));
  background: linear-gradient(180deg, rgba(16, 13, 28, 0) 0%, rgba(16, 13, 28, 0.78) 16%, rgba(16, 13, 28, 0.92) 100%);
  border-top: 1px solid rgba(255, 253, 248, 0.16);
  color: rgba(255, 253, 248, 0.94);
  font-family: var(--font-mono);
  font-size: calc(24 * var(--u));
  font-weight: 700;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.stamp-ticks {
  opacity: 0.5;
  font-size: calc(22 * var(--u));
}

/* ---------- Draggable Sticker Layer ---------- */
.mat-stickers {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.sticker {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: calc(960 * var(--u));
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  outline: none;
  transition: filter 0.16s ease;
}

.sticker[hidden] {
  display: none;
}

.sticker-future { z-index: 21; }
.sticker-present { z-index: 22; }
.sticker-past { z-index: 23; }

.sticker.is-selected {
  filter: drop-shadow(0 0 calc(10 * var(--u)) rgba(255, 253, 248, 0.85));
}

.sticker.is-dragging {
  cursor: grabbing;
  z-index: 35;
  filter: drop-shadow(0 calc(20 * var(--u)) calc(28 * var(--u)) rgba(0, 0, 0, 0.42));
}

.sticker:focus-visible {
  outline: 2px dashed #FFFDF8;
  outline-offset: 4px;
  border-radius: 12px;
}

/* Archival Sticker Tag Pills (Past Keep Line & Present Now Line) */
.sticker-pill {
  margin-top: calc(16 * var(--u));
  width: max-content;
  max-width: calc(496 * var(--u));
  min-width: calc(230 * var(--u));
  padding: calc(16 * var(--u)) calc(26 * var(--u)) calc(18 * var(--u));
  border-radius: calc(20 * var(--u));
  background: rgba(255, 253, 248, 0.96);
  color: #18181B;
  border: calc(3 * var(--u)) solid rgba(24, 24, 27, 0.16);
  box-shadow:
    0 0 0 calc(12 * var(--u)) rgba(255, 253, 248, 0.46),
    0 calc(12 * var(--u)) calc(28 * var(--u)) rgba(17, 13, 43, 0.36);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(5 * var(--u));
  text-align: center;
  transition: background 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.sticker-pill[hidden] {
  display: none;
}

.pill-micro {
  font-family: var(--font-mono);
  font-size: calc(20 * var(--u));
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sticker-pill-past .pill-micro { color: #B91C1C; }
.sticker-pill-present .pill-micro { color: #15803D; }

.pill-copy {
  font-family: var(--font-display);
  font-size: calc(34 * var(--u));
  font-weight: 600;
  line-height: 1.24;
  word-break: break-word;
}

/* Contrast Halo OFF state */
.mat-stage.halo-off .sticker-pill {
  background: rgba(18, 16, 30, 0.72);
  color: #FFFDF8;
  border-color: rgba(255, 253, 248, 0.28);
  box-shadow: 0 calc(10 * var(--u)) calc(24 * var(--u)) rgba(0, 0, 0, 0.35);
}

.mat-stage.halo-off .sticker-pill-past .pill-micro { color: #FCA5A5; }
.mat-stage.halo-off .sticker-pill-present .pill-micro { color: #86EFAC; }

.mat-stage.halo-off .wax-halo,
.mat-stage.halo-off .pulse-halo {
  opacity: 0;
}

.mat-stage.halo-off .tape-strip {
  filter: drop-shadow(0 calc(10 * var(--u)) calc(18 * var(--u)) rgba(0, 0, 0, 0.34));
}

/* ---------- PAST: Crimson Embossed Wax Seal ---------- */
.wax-seal-wrap {
  position: relative;
  width: calc(218 * var(--u));
  height: calc(218 * var(--u));
  display: flex;
  align-items: center;
  justify-content: center;
}

.wax-halo {
  position: absolute;
  inset: calc(-20 * var(--u));
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 253, 248, 0.88) 44%, rgba(255, 253, 248, 0.42) 68%, rgba(255, 253, 248, 0) 82%);
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.wax-seal-svg {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 calc(12 * var(--u)) calc(20 * var(--u)) rgba(24, 10, 10, 0.46));
}

.sticker-past.just-stamped .wax-seal-wrap {
  animation: waxStampImpact 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes waxStampImpact {
  0% { transform: scale(1.32) rotate(-9deg); }
  55% { transform: scale(0.94) rotate(2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ---------- PRESENT: Emerald Live BPM Pulse Badge ---------- */
.pulse-badge-wrap {
  --bpm: 74;
  position: relative;
  width: calc(202 * var(--u));
  height: calc(202 * var(--u));
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-halo {
  position: absolute;
  inset: calc(-24 * var(--u));
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 253, 248, 0.90) 44%, rgba(255, 253, 248, 0.40) 70%, rgba(255, 253, 248, 0) 84%);
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.pulse-wave {
  position: absolute;
  inset: calc(-6 * var(--u));
  border-radius: 50%;
  border: calc(6 * var(--u)) solid rgba(34, 197, 94, 0.65);
  box-shadow: 0 0 calc(22 * var(--u)) rgba(34, 197, 94, 0.45);
  animation: liveHeartbeat calc(60s / var(--bpm)) ease-out infinite;
  pointer-events: none;
}

@keyframes liveHeartbeat {
  0% { transform: scale(0.92); opacity: 0.92; }
  70% { transform: scale(1.22); opacity: 0.08; }
  100% { transform: scale(1.25); opacity: 0; }
}

.pulse-medallion {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #22C55E 0%, #15803D 52%, #14532D 100%);
  border: calc(6 * var(--u)) solid #DCFCE7;
  box-shadow:
    inset 0 0 0 calc(7 * var(--u)) rgba(187, 247, 208, 0.30),
    0 calc(12 * var(--u)) calc(24 * var(--u)) rgba(10, 28, 16, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #FFFDF8;
}

.pulse-ecg {
  width: calc(96 * var(--u));
  height: calc(24 * var(--u));
  margin-bottom: calc(2 * var(--u));
}

.pulse-bpm-num {
  font-family: var(--font-mono);
  font-size: calc(60 * var(--u));
  font-weight: 800;
  line-height: 0.96;
  letter-spacing: -0.03em;
}

.pulse-bpm-unit {
  font-family: var(--font-mono);
  font-size: calc(22 * var(--u));
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #DCFCE7;
  margin-top: calc(4 * var(--u));
}

.sticker-present.just-pulsed .pulse-medallion {
  animation: pulsePop 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pulsePop {
  0% { transform: scale(1.2); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* ---------- FUTURE: Opaque Paper Masking Tape ---------- */
.tape-rotator {
  transform: rotate(-4deg);
  transition: transform 0.08s linear;
}

.tape-strip {
  position: relative;
  width: calc(790 * var(--u));
  min-height: calc(154 * var(--u));
  display: flex;
  align-items: center;
  justify-content: center;
  filter:
    drop-shadow(0 0 calc(10 * var(--u)) rgba(255, 253, 248, 0.56))
    drop-shadow(0 calc(12 * var(--u)) calc(22 * var(--u)) rgba(17, 13, 43, 0.40));
  transition: filter 0.18s ease;
}

.tape-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.tape-content {
  position: relative;
  z-index: 2;
  width: 84%;
  padding: calc(16 * var(--u)) calc(14 * var(--u)) calc(18 * var(--u));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(4 * var(--u));
  text-align: center;
}

.tape-kicker {
  font-family: var(--font-mono);
  font-size: calc(19 * var(--u));
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #92400E;
}

.tape-text {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: calc(38 * var(--u));
  line-height: 1.18;
  color: #1C1917;
  word-break: break-word;
}

.sticker-future.just-taped .tape-strip {
  animation: tapeSlap 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tapeSlap {
  0% { transform: scaleX(1.1) scaleY(0.86); opacity: 0.85; }
  60% { transform: scaleX(0.98) scaleY(1.03); opacity: 1; }
  100% { transform: scale(1); }
}

/* ---------- Desk Mat Toolbar (below 9:16 stage) ---------- */
.mat-toolbar {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mat-upload-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mat-upload-row .btn {
  width: 100%;
  padding-left: 10px;
  padding-right: 10px;
  font-size: 12.5px;
}

.mat-guard-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.halo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.halo-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.halo-switch {
  position: relative;
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: rgba(24, 24, 27, 0.22);
  transition: background 0.16s ease;
  flex-shrink: 0;
}

.halo-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #FFFDF8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.24);
  transition: transform 0.16s ease;
}

.halo-toggle input:checked + .halo-switch {
  background: var(--present);
}

.halo-toggle input:checked + .halo-switch::after {
  transform: translateX(17px);
}

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

.halo-label {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.halo-label strong {
  font-size: 12.5px;
  color: var(--ink);
}

.halo-label small {
  font-size: 11px;
  color: var(--muted);
}

.privacy-chip {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--present);
  background: var(--present-soft);
  border: 1px solid rgba(21, 128, 61, 0.24);
  padding: 4px 8px;
  border-radius: 999px;
}

/* ---------- RIGHT: Editor Column & Act Cards ---------- */
.editor-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Drawer Tabs: hidden on desktop, visible on mobile <= 900px */
.drawer-tabs {
  display: none;
}

.act-card {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.act-card.is-highlighted {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lift);
}

.act-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.act-head h2 {
  font-size: 22px;
  margin-top: 6px;
  line-height: 1.15;
}

.act-desc {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.btn-wax {
  background: var(--wax);
  color: #FFFDF8;
  border-color: var(--wax);
}

.btn-wax:hover:not(:disabled) {
  background: #991B1B;
}

.btn-tape,
#btn-toggle-future.btn-tape {
  background: #B45309;
  color: #FFFFFF;
  border-color: #92400E;
}

.btn-tape:hover:not(:disabled),
#btn-toggle-future.btn-tape:hover:not(:disabled) {
  background: #92400E;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.field-label-row label {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-soft);
}

.char-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.char-count.is-near {
  color: var(--terracotta);
  font-weight: 700;
}

/* ---------- 4-Tap BPM Thumb Pad ---------- */
.bpm-workbench {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 16px;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.bpm-pad {
  position: relative;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease;
}

.bpm-pad:active,
.bpm-pad.is-pressed {
  transform: scale(0.94);
}

.bpm-pad:focus-visible {
  outline: 3px solid var(--present);
  outline-offset: 4px;
}

.bpm-ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.bpm-ring-track {
  fill: none;
  stroke: rgba(21, 128, 61, 0.16);
  stroke-width: 8;
}

.bpm-ring-progress {
  fill: none;
  stroke: var(--present);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 439.82;
  stroke-dashoffset: 439.82;
  transition: stroke-dashoffset 0.16s ease;
}

.bpm-ripple {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 2px solid var(--present);
  opacity: 0;
  pointer-events: none;
}

.bpm-ripple.is-rippling {
  animation: padRipple 420ms ease-out;
}

@keyframes padRipple {
  0% { transform: scale(0.86); opacity: 0.8; }
  100% { transform: scale(1.36); opacity: 0; }
}

.bpm-pad-inner {
  position: relative;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  background-color: #15803D;
  background-image: radial-gradient(circle at 32% 28%, #15803D 0%, #15803D 62%, #14532D 100%);
  box-shadow:
    0 8px 20px rgba(21, 128, 61, 0.30),
    inset 0 2px 3px rgba(255, 255, 255, 0.28);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.bpm-pad-main {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.bpm-pad-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #FFFFFF;
  background-color: #15803D;
  padding: 1px 5px;
  border-radius: 999px;
  margin-top: 2px;
}

.bpm-status {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.bpm-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.beat-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(21, 128, 61, 0.16);
  border: 1.5px solid rgba(21, 128, 61, 0.34);
  transition: transform 0.14s ease, background 0.14s ease;
}

.beat-dot.is-lit {
  background: var(--present);
  border-color: var(--present);
  transform: scale(1.14);
  box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.18);
}

.bpm-readout {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bpm-readout strong {
  font-size: 14.5px;
  color: var(--ink);
  line-height: 1.3;
}

.bpm-readout span {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Angle Slider ---------- */
.angle-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.angle-row label {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-soft);
}

.angle-row input[type="range"] {
  width: 100%;
  accent-color: #B45309;
  cursor: pointer;
}

.angle-output {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  min-width: 42px;
  text-align: right;
  color: var(--past);
}

/* ---------- Output Bench ---------- */
.output-card {
  background: linear-gradient(180deg, #FFFDF8 0%, #FAF5E8 100%);
  border-color: var(--border-strong);
}

.completion-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  color: var(--ink);
}

.completion-pill.is-complete {
  background: var(--present-soft);
  border-color: rgba(21, 128, 61, 0.4);
  color: var(--present);
}

.output-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-export-main {
  width: 100%;
  min-height: 50px;
  font-size: 15.5px;
}

.output-secondary-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.output-secondary-row .btn {
  width: 100%;
  font-size: 13.5px;
  padding: 10px 12px;
}

.output-footnote {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}

.output-footnote code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: rgba(24, 24, 27, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
}

/* ---------- Responsive Mobile Bottom-Drawer Flow (390x844 etc.) ---------- */
@media (max-width: 900px) {
  .workbench {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mat-column {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .desk-mat-frame {
    padding: 10px 12px;
  }

  .mat-stage {
    width: auto;
    height: min(44vh, 390px);
    max-width: min(240px, 64vw);
    margin-inline: auto;
  }

  .drawer-tabs {
    position: sticky;
    top: 8px;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 6px;
    background: rgba(255, 253, 248, 0.96);
    backdrop-filter: blur(8px);
    border: 1.5px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
  }

  .drawer-tab {
    min-height: 44px;
    padding: 6px 6px;
    border-radius: 11px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .drawer-tab.active {
    background: var(--ink);
    color: #FFFDF8;
  }

  .tab-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .dot-wax { background: var(--wax); }
  .dot-present { background: var(--present); }
  .dot-future { background: #D97706; }
  .dot-ink { background: var(--muted); }
  .drawer-tab.active .dot-ink { background: #FFFDF8; }

  .tab-check {
    font-size: 11px;
    font-weight: 800;
    color: #86EFAC;
  }
  .drawer-tab:not(.active) .tab-check {
    color: var(--present);
  }

  /* Only show the selected drawer panel on mobile so keyboards never crowd the mat */
  .editor-column .act-card {
    display: none;
  }
  .editor-column .act-card.is-active-tab {
    display: flex;
  }

  .bpm-workbench {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }

  .bpm-status {
    align-items: center;
  }

  .output-secondary-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .header-actions {
    width: 100%;
  }
  .header-actions .btn-upload-hero {
    flex: 1 1 100%;
    width: 100%;
  }
  .header-actions .btn-sm {
    flex: 1 1 auto;
  }
}

@media (max-width: 480px) {
  .surgery-header {
    padding: 0 0 12px;
    gap: 10px;
  }
  .surgery-header .lead {
    font-size: 14px;
    line-height: 1.4;
    margin-top: 6px;
  }
  .desk-mat-frame {
    padding: 12px;
  }
  .mat-upload-row {
    grid-template-columns: 1fr;
  }
  .act-card {
    padding: 16px;
  }
}
