/* The paper crop and the final task share the original 940 × 1297 canvas. */
:root {
  --draw-card-ratio: 940 / 1297;
  /* Concentric with the drawn frame inside the card art: the frame sits
     ~32px/35px in from the face edge with a ~20px corner on the 940 × 1297
     canvas, so the container corner follows at 52px/55px (= 5.53% / 4.24%). */
  --card-face-radius: 5.53% / 4.24%;
}
.home-shell .card-stack { width: 262px; height: auto; aspect-ratio: var(--draw-card-ratio); }
.home-shell .front-card { padding: 0; }
.card-back-art { position: absolute; top: 50%; left: 0; width: 100%; height: auto; aspect-ratio: var(--draw-card-ratio); transform: translateY(-50%); display: block; overflow: hidden; border-radius: inherit; pointer-events: none; background: var(--surface); }
/* Remove the approved preview's exterior margin and shadow at display time.
   The original PNG stays intact; its card face occupies x78/y66/w940/h1297. */
.card-back-art img { position: absolute; display: block; max-width: none; width: 116.808510638%; height: auto; left: -8.29787234%; top: -5.088666153%; }
.dialog.draw-dialog {
  width: min(420px, calc(100vw - 32px), calc((100dvh - 32px) * 940 / 1297));
  max-width: none; max-height: none; height: auto; aspect-ratio: var(--draw-card-ratio);
  padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--ink);
  overflow: visible; box-shadow: none;
  animation: none;
}
.draw-dialog::backdrop { background: rgb(28 48 37 / .40); backdrop-filter: blur(7px); }
.draw-scene { position: relative; width: 100%; height: 100%; aspect-ratio: var(--draw-card-ratio); perspective: 1400px; container-type: inline-size; }
.draw-bounce-card { position: absolute; inset: 0; visibility: hidden; transform-origin: center; border-radius: var(--card-face-radius); }
.draw-flipper { position: absolute; inset: 0; transform-style: preserve-3d; }
.draw-choice { position: absolute; inset: 0; z-index: 2; display: block; width: 100%; height: 100%; padding: 0; border: 0; border-radius: inherit; background: transparent; color: var(--ink); outline-offset: 9px; }
.draw-choice:disabled { opacity: 1; }
.draw-choice:focus-visible { outline: 6px solid var(--lime); }
.draw-card-index { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); display: grid; place-items: center; width: 72px; height: 72px; border: 2px solid #cdd7bc; border-radius: 50%; background: var(--surface); font: 500 40px/1.2 'SFMono-Regular', Consolas, monospace; opacity: 0; transition: opacity .16s; }
.draw-scene[data-phase="choosing"] .draw-card-index { opacity: 1; }
.draw-bounce-card:has(.draw-choice:not(:disabled):hover) .draw-card-back { box-shadow: 0 0 0 6px var(--lime), 0 22px 54px rgb(18 44 32 / .24); }
.draw-prompt { position: fixed; top: 0; left: 50%; transform: translate(-50%, -100%); width: max-content; max-width: calc(100vw - 32px); padding: 12px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: center; pointer-events: none; }
.draw-prompt h2 { margin: 0; font-size: clamp(16px, 2vw, 20px); line-height: 1.5; font-weight: 550; }
.draw-card-back, .draw-card-front { position: absolute; inset: 0; border-radius: var(--card-face-radius); backface-visibility: hidden; -webkit-backface-visibility: hidden; border: 1px solid var(--line); box-shadow: 0 18px 44px rgb(18 44 32 / .16); }
.draw-card-back { background: var(--surface); border-color: #cdd7bc; overflow: hidden; }
.draw-card-back .card-art { position: absolute; inset: 0; min-height: 0; }
.draw-card-back .card-art::before { content: none; }
.draw-card-back .card-art > .card-back-art { position: absolute; }
.draw-card-front { transform: rotateY(180deg); display: flex; flex-direction: column; padding: 26px; background: var(--surface); gap: 22px; text-align: left; }
.draw-card-meta { min-height: 25px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding-right: 38px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.draw-card-meta span + span { border-left: 1px solid var(--line); padding-left: 12px; }
.draw-card-copy { min-height: 0; flex: 1; overflow: auto; scrollbar-width: thin; }
.draw-card-copy h2 { margin: 0; font-size: 28px; line-height: 1.4; letter-spacing: -.5px; font-weight: 650; text-wrap: pretty; }
.draw-card-context { margin: 16px 0 0; font-size: 16px; line-height: 1.7; color: var(--muted); }
.draw-card-goal { margin-top: 20px; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--soft-green); border-radius: 9px; }
.draw-card-goal > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.draw-card-goal p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--ink); }
.draw-card-bottom { flex-shrink: 0; }
.draw-card-duration { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0 0 12px; }
.draw-card-actions { display: grid; grid-template-columns: .85fr 1.15fr; gap: 10px; }
.draw-card-actions .btn { min-width: 0; min-height: 46px; padding: 10px 8px; gap: 6px; font-size: 15px; white-space: nowrap; }
.draw-card-actions .icon { width: 18px; height: 18px; flex-shrink: 0; }
.draw-dialog .draw-close { position: absolute; z-index: 20; top: 12px; right: 12px; width: 44px; height: 44px; min-height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); box-shadow: none; }
.draw-dialog .draw-close[hidden] { display: none !important; }
.draw-scene:focus { outline: none; }
.draw-close .icon { width: 20px; height: 20px; }
.draw-announcement { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.draw-scene[data-phase="loading"] .draw-selected-card { visibility: visible; transform: scale(.12); }
.draw-scene[data-phase="revealed"] .draw-selected-card { visibility: visible; transform: none; }
.draw-scene[data-phase="revealed"] .draw-bounce-card:not(.draw-selected-card) { visibility: hidden; pointer-events: none; }
.draw-scene[data-phase="revealed"] .draw-flipper { transform: rotateY(180deg); }
/* A failed motion dependency still provides a real, keyboard-accessible choice. */
.draw-scene.draw-static-choices { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px 12px; width: min(600px, calc(100vw - 32px), calc((100dvh - 160px) * 1.05)); height: auto; aspect-ratio: auto; }
.draw-static-choices .draw-bounce-card { position: relative; inset: auto; grid-column: span 2; aspect-ratio: var(--draw-card-ratio); visibility: visible; }
.draw-static-choices .draw-bounce-card:nth-child(4) { grid-column: 2 / span 2; }
.draw-static-choices .draw-bounce-card:nth-child(5) { grid-column: 4 / span 2; }
.draw-static-choices .draw-card-index { width: 22px; height: 22px; font-size: 12px; border-width: 1px; bottom: 8px; }
@media (min-width: 900px), (max-height: 500px) {
 .draw-scene.draw-static-choices { grid-template-columns: repeat(5, minmax(0, 1fr)); width: min(1000px, calc(100vw - 32px), calc((100dvh - 140px) * 3)); }
 .draw-static-choices .draw-bounce-card:nth-child(n) { grid-column: auto; }
}
@container (max-width: 370px) {
  .draw-card-front { padding: 20px; gap: 15px; }
  .draw-card-copy h2 { font-size: 24px; line-height: 1.35; }
  .draw-card-context { font-size: 15px; line-height: 1.6; margin-top: 12px; }
  .draw-card-goal { padding: 12px; margin-top: 14px; }
  .draw-card-goal p { font-size: 15px; line-height: 1.6; }
}
@container (max-width: 310px) {
  .draw-card-front { padding: 16px; gap: 10px; }
  .draw-card-meta { gap: 4px 8px; min-height: 30px; font-size: 11px; }
  .draw-card-meta span + span { padding-left: 8px; }
  .draw-card-copy h2 { font-size: 20px; line-height: 1.35; }
  .draw-card-context { font-size: 14px; line-height: 1.5; margin-top: 10px; }
  .draw-card-goal { padding: 10px; margin-top: 10px; }
  .draw-card-goal > span { font-size: 11px; margin-bottom: 4px; }
  .draw-card-goal p { font-size: 14px; line-height: 1.5; }
  .draw-card-duration { font-size: 11px; margin-bottom: 8px; }
  .draw-card-actions { gap: 8px; }
  .draw-card-actions .btn { min-height: 44px; padding: 8px 5px; font-size: 14px; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .draw-dialog, .draw-dialog * { animation: none !important; transition: none !important; }
}
