/* Tablet: one sheet of paper, a row of tools, one button. */
body.draw {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  background:
    radial-gradient(120% 90% at 50% 40%, #1d1a4f 0%, var(--ink) 60%) fixed;
}

.studio {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: max(10px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

.bar { display: flex; align-items: baseline; gap: 18px; padding: 2px 4px 10px; }
.brand { margin: 0; font: 400 26px/1 var(--display); letter-spacing: .005em; }
.bar-hint { margin: 0; color: var(--mist); font-size: 15px; }

.paper-box { position: relative; min-height: 0; display: grid; place-items: center; }
.paper {
  position: relative;
  background: var(--paper);
  border-radius: 6px;
  box-shadow: 0 22px 60px rgba(4, 3, 20, .55), 0 2px 0 rgba(255, 255, 255, .08) inset;
}
.paper canvas { width: 100%; height: 100%; border-radius: inherit; touch-action: none; }
.paper-empty {
  position: absolute; inset: 0; margin: 0;
  display: grid; place-items: center;
  font-size: clamp(40px, 6vw, 72px); color: rgba(42, 40, 64, .28);
  pointer-events: none; transition: opacity .4s;
}
.paper.has-ink .paper-empty { opacity: 0; }

/* ---- tools ---- */
.tools { display: flex; align-items: center; gap: 10px; padding: 12px 4px 2px; }
.sep { width: 1px; height: 30px; background: var(--ink-3); margin: 0 4px; }
.swatches, .sizes { display: flex; gap: 8px; }

.swatch {
  width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  background: var(--c);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .18) inset;
  transition: transform .12s;
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--gold); transform: scale(1.06); }

.size {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center;
}
.size span { width: var(--d); height: var(--d); border-radius: 50%; background: var(--paper); }
.size[aria-checked="true"] { background: var(--ink-2); box-shadow: 0 0 0 2px var(--gold) inset; }

.tool {
  width: 48px; height: 48px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--paper);
}
.tool svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool[aria-pressed="true"] { background: var(--gold); color: var(--ink); }
.tool:disabled { opacity: .3; cursor: default; }
.done { margin-left: auto; min-width: 150px; font-size: 1.15rem; }

/* ---- sheet: name + style ---- */
.sheet {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 20px;
  background: rgba(9, 8, 28, .72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade .2s ease-out;
}
.sheet-card {
  width: min(940px, 100%);
  max-height: 100%; overflow: auto;
  display: grid; grid-template-columns: 1fr 1.2fr; gap: 30px; align-items: start;
  padding: 28px; border-radius: 22px; background: var(--ink-2);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  animation: rise .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet-preview {
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--paper);
  transform: rotate(-1.5deg); box-shadow: 0 14px 36px rgba(0, 0, 0, .45); margin-top: 6px;
}
.sheet h2 { margin: 0 0 10px; font: 400 26px/1.1 var(--display); }
.sheet h2 + .styles { margin-top: 0; }
.name {
  width: 100%; height: 56px; margin-bottom: 22px; padding: 0 16px;
  border-radius: 12px; border: 2px solid var(--ink-3); background: var(--ink);
  font-size: 1.2rem; outline: none; -webkit-user-select: text; user-select: text;
}
.name:focus { border-color: var(--majorelle); }
.name::placeholder { color: rgba(201, 198, 232, .55); }
.styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.style {
  min-height: 64px; padding: 8px 10px; border-radius: 14px;
  border: 2px solid var(--ink-3); background: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 500; font-size: 1rem; text-align: center;
}
.style .em { font-size: 1.35rem; }
.style[aria-checked="true"] { border-color: var(--gold); background: rgba(233, 185, 73, .12); }
.sheet-error { margin: 14px 0 0; color: #ff8a9a; font-weight: 500; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }

/* ---- after sending ---- */
.after {
  position: fixed; inset: 0; z-index: 20;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 44px; align-items: center;
  padding: max(28px, env(safe-area-inset-top)) 44px 28px;
  background: radial-gradient(110% 90% at 30% 45%, #221e5c 0%, var(--ink) 65%);
  animation: fade .3s ease-out;
}
.after-pic {
  position: relative; aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden;
  background: var(--paper); box-shadow: 0 26px 70px rgba(0, 0, 0, .55);
}
.after-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.after-art { opacity: 0; transform: scale(1.04); transition: opacity 1.2s ease, transform 2.4s ease; }
.after-pic.painted .after-art { opacity: 1; transform: none; }
.after-pic.working::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 43%, rgba(233, 185, 73, .38) 50%, transparent 57%);
  background-size: 300% 100%;
  animation: sweep 2.6s cubic-bezier(.5, 0, .5, 1) infinite;
  mix-blend-mode: multiply;
}
.after-head { margin: 0 0 6px; font: 400 clamp(40px, 5vw, 64px)/1 var(--display); text-wrap: balance; }
.after-line { margin: 0; font-size: clamp(28px, 3vw, 38px); line-height: 1.1; color: var(--gold); }
.after-caption { margin: 14px 0 0; color: var(--mist); font-size: 18px; line-height: 1.45; max-width: 36ch; }
.take { display: flex; align-items: center; gap: 16px; margin-top: 20px; }
.take-qr { width: 132px; height: 132px; padding: 9px; border-radius: 12px; background: var(--paper); }
.take-qr svg { width: 100%; height: 100%; display: block; }
.take p { margin: 0; font-size: 30px; color: var(--paper); max-width: 8em; line-height: 1; }
.after-actions { display: flex; gap: 12px; margin-top: 28px; }

/* ---- notices ---- */
.notice {
  position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; text-align: center; padding: 40px;
  background: var(--ink);
}
.notice h1 { margin: 0 0 12px; font: 400 40px/1.1 var(--display); }
.notice p { margin: 0 auto; color: var(--mist); font-size: 18px; max-width: 34ch; }

.turn {
  position: fixed; inset: 0; z-index: 40; display: none; place-content: center; justify-items: center; gap: 18px;
  background: var(--ink); text-align: center;
}
.turn svg { width: 84px; fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linecap: round; }
.turn p { margin: 0; font: 400 30px/1.15 var(--display); max-width: 12em; }
@media (orientation: portrait) { .turn { display: grid; } }

/* Small landscape screens (phones): tighter chrome */
@media (max-height: 560px) {
  .bar { display: none; }
  .swatch { width: 32px; height: 32px; }
  .tools { gap: 6px; }
  .size, .tool { width: 40px; height: 40px; }
  .after { grid-template-columns: 1fr 1fr; gap: 24px; padding: 18px 24px; }
}
@media (max-width: 1000px) { .bar-hint { display: none; } }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); } }
@keyframes sweep { from { background-position: 125% 0; } to { background-position: -125% 0; } }
