:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #22394a;
  background: #dedad5;
  --navy: #213b4d;
  --paper: #fffefa;
  --red: #ba352d;
}
* { box-sizing: border-box }
body { margin: 0; min-height: 100svh }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; cursor: pointer }
button:focus-visible, .surface:focus-visible { outline: 3px solid #2467af; outline-offset: 3px }
.controls button:focus-visible { outline-color: white; outline-offset: 1px }
[disabled] { cursor: default }
.desk {
  width: min(calc(100% - 24px), 555px);
  margin: auto;
  padding: max(14px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom));
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.mast { display: grid; justify-items: center; gap: 8px; margin: 0 0 13px }
.brand { font-size: clamp(37px, 9.8vw, 54px); font-weight: 900; letter-spacing: -.065em; line-height: 1.03; padding-right: .065em }
.levels { display: flex; background: #d1cdc7; padding: 2px; border-radius: 10px; gap: 1px }
.levels button { min-height: 32px; border: 0; background: transparent; border-radius: 8px; padding: 0 16px; font-size: 13px; font-weight: 700 }
.levels button[aria-pressed=true] { background: #f8f6f2; box-shadow: 0 1px 2px #22394a20 }
.pad { background: var(--paper); border: 1px solid #c0bab2; border-radius: 15px; box-shadow: 0 1px 1px #3d3a3615; padding: 0 7px }
.folio { display: flex; align-items: center; justify-content: space-between; min-height: 35px; gap: 12px; padding: 5px 7px 1px }
.folio h1 { margin: 0; font-size: 14px; font-weight: 750; overflow-wrap: anywhere }
#folio-no { font-size: 11px; font-variant-numeric: tabular-nums; color: #625f5a; white-space: nowrap }
.surface { position: relative; touch-action: none; user-select: none; cursor: crosshair; width: min(100%, max(232px, calc(100svh - 285px))); margin: 0 auto; aspect-ratio: 1; display: block }
.surface svg, .surface canvas { position: absolute; inset: 0; width: 100%; height: 100% }
.surface canvas { pointer-events: none }
.caption { display: flex; align-items: center; gap: 13px; min-height: 30px; padding: 0 7px 6px; white-space: nowrap; color: #565c60; font-size: 11px; font-weight: 650 }
.caption span { display: flex; align-items: center; gap: 6px }
.caption b { width: 8px; height: 8px; border-radius: 100%; display: inline-block; background: #2e689f }
.caption b.finish { width: 0; height: 0; border: 0; border-left: 7px solid #2e689f; border-top: 4px solid transparent; border-bottom: 4px solid transparent; background: none; border-radius: 0 }
.caption-instruction { margin-left: auto }
.controls {
  margin-top: clamp(12px, 2.7vh, 24px);
  background: var(--navy);
  color: white;
  border-radius: 17px;
  display: grid;
  gap: 10px;
  padding: 11px 13px 12px;
}
.pens { display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; justify-items: center }
.pen, .iconbtn { border: 0; background: transparent; display: grid; place-items: center; padding: 0; border-radius: 9px; width: 48px; height: 45px }
.pen::before { content: ""; display: block; width: 37px; height: 37px; background: var(--swatch); border-radius: 8px }
.pen[aria-pressed=true]::before { outline: 2px solid white; outline-offset: 2px }
.actions { display: grid; grid-template-columns: 44px 1px 44px 1fr; align-items: center; gap: 8px }
.iconbtn { width: 44px }
.tool-divider { width: 1px; height: 29px; background: #ffffff55 }
.iconbtn svg, .next svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.iconbtn:disabled { opacity: .42 }
.next { border: none; background: var(--red); color: #fff; min-height: 47px; border-radius: 11px; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 0 9px; font-weight: 780; font-size: 16px }
.next:active { background: #a52c25 }
@media (min-height: 740px) and (max-width: 600px) {
  .controls { margin-top: auto }
  .pad { margin-bottom: 17px }
  .mast { margin-top: 13px; margin-bottom: 16px }
}
@media (min-width: 650px) {
  .desk { min-height: 0; padding-top: 24px }
  .mast { gap: 10px; margin-bottom: 17px }
  .controls { padding: 13px 20px 15px; gap: 13px }
  .actions { grid-template-columns: 48px 1px 48px 1fr; gap: 12px }
}
@media (max-width: 355px) {
  .desk { width: calc(100% - 20px); padding-top: 10px }
  .mast { gap: 6px; margin-bottom: 9px }
  .brand { font-size: 34px }
  .controls { margin-top: 10px }
}
@media (max-height: 565px) and (orientation: landscape) {
  .desk { width: min(calc(100% - 26px), 460px) }
  .surface { width: min(100%, 355px) }
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap }
/* On tall phones keep sheet and tray together rather than stretching their gap. */
@media (min-height: 740px) and (max-width: 600px) {
  .desk { justify-content: center }
  .controls { margin-top: 17px }
  .pad { margin-bottom: 0 }
  .mast { margin-top: 0; margin-bottom: 16px }
}
/* The tray sits beside the board in tablet landscape so both stay visible. */
@media (min-width: 800px) and (orientation: landscape) {
  .desk { width: min(calc(100% - 44px), 840px); display: grid; grid-template-columns: minmax(0,1fr) 217px; column-gap: 16px }
  .mast { grid-column: 1 / -1 }
  .surface { width: min(100%, max(310px, calc(100svh - 210px))) }
  .controls { align-self: end; margin-top: 0; padding: 12px 11px }
  .actions { grid-template-columns: 33px 1px 33px 1fr; gap: 3px }
  .iconbtn { width: 33px }
  .next { gap: 4px; font-size: 13px; padding-inline: 6px }
  .next svg { width: 16px; height: 16px }
}
@media (max-height: 620px) and (orientation: portrait) {
  .surface { width: min(100%, max(218px, calc(100svh - 302px))) }
  .controls { gap: 6px; padding-block: 8px 9px }
  .desk { padding-bottom: 8px }
}
