/* I Have Crayon studio, /create/ (ihavecrayon#3). Loaded on that page only, after library.css. */
.studio { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
.st-tools { display: flex; flex-direction: column; gap: 14px; }
[data-mode-panel][hidden] { display: none; }
.st-box { background: var(--paper); border: 1px solid var(--line); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.st-box h2 { margin: 0; font-family: "Archivo Narrow", sans-serif; text-transform: uppercase; font-size: 15px; letter-spacing: 0.04em; color: var(--ink-2); }
.st-tabs { display: grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--ink); }
.st-tabs button { font: inherit; font-weight: 800; font-size: 16px; text-transform: uppercase; min-height: 48px; border: 0; background: var(--paper); color: var(--ink); cursor: pointer; }
.st-tabs button[aria-selected="true"] { background: var(--ink); color: #fff; }
.st-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.st-row .btn { font-size: 13px; padding: 8px 6px; }
.btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.btn:disabled { opacity: 0.4; cursor: default; }
.st-stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; }
.st-stamp { aspect-ratio: 1; padding: 4px; border: 2px solid var(--line); background: #fff; cursor: pointer; }
.st-stamp canvas { display: block; width: 100%; height: auto; }
.st-stamp[aria-pressed="true"] { border-color: var(--ink); background: #fff6cf; }
.st-palette { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.st-swatch { aspect-ratio: 1; min-height: 32px; border: 2px solid rgba(20, 33, 61, 0.25); border-radius: 50%; cursor: pointer; padding: 0; }
.st-swatch[aria-pressed="true"] { border: 3px solid var(--ink); box-shadow: 0 0 0 2px #fff inset; }
.st-field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); }
.st-field input[type=text], .st-field select { font: inherit; font-size: 17px; color: var(--ink); padding: 10px 12px; border: 2px solid var(--ink); background: #fff; border-radius: 0; }
.st-field input[type=range] { width: 100%; accent-color: var(--ink); }
.st-inline { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink-2); }
.st-inline input[type=color] { width: 48px; height: 36px; border: 2px solid var(--ink); padding: 0; background: #fff; }
.st-hint { margin: 0; font-size: 14px; color: var(--ink-2); min-height: 1.5em; }

.st-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.st-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.st-bar .btn { padding: 8px 12px; font-size: 13px; min-height: 40px; }
.st-bar .spacer { flex: 1; }
.st-zoom { display: inline-flex; align-items: center; gap: 4px; }
.st-zoom span { min-width: 48px; text-align: center; font-size: 14px; font-weight: 600; }
.st-scroll { background: #e3e7ee; border: 1px solid var(--line); overflow: auto; padding: 14px; max-height: calc(100vh - 120px); }
.st-stage { --z: 1; position: relative; margin: 0 auto; aspect-ratio: 1275 / 1650; background: #fff; box-shadow: 0 2px 10px rgba(20, 33, 61, 0.18);
  width: calc(min(100%, (100vh - 190px) * 0.7727) * var(--z)); min-width: min(100%, 280px); }
.st-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#st-preview { touch-action: none; cursor: crosshair; }
.st-stage[data-tool="hand"] #st-preview { touch-action: auto; cursor: grab; }
.st-stage[data-tool="fill"] #st-preview { cursor: cell; }

.st-start { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 12px; padding: 8%; background: rgba(255, 255, 255, 0.94); z-index: 2; }
.st-start[hidden] { display: none; }
.st-start h2 { margin: 0 0 6px; font-weight: 800; font-size: clamp(22px, 3vw, 32px); line-height: 1.15; }
.st-start p { margin: 0 0 6px; color: var(--ink-2); }
.st-start .btn { font-size: 15px; padding: 14px 12px; justify-content: flex-start; gap: 10px; text-align: left; }
.st-start .btn small { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink-2); }
.st-start .btn.primary small { color: var(--ink); }

.st-dlg { border: 2px solid var(--ink); padding: 0; max-width: min(760px, calc(100vw - 24px)); width: 100%; background: var(--paper); color: var(--ink); }
.st-dlg::backdrop { background: rgba(20, 33, 61, 0.55); }
.st-dlg .in { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 40px); overflow: auto; }
.st-dlg header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.st-dlg h2 { margin: 0; font-weight: 800; font-size: 24px; }
.st-dlg .close { font: inherit; font-size: 26px; line-height: 1; border: 0; background: none; cursor: pointer; min-width: 44px; min-height: 44px; color: var(--ink); }
.st-dlg p { margin: 0; color: #2c3550; }
.st-photo-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: start; }
#st-photo-preview { width: 100%; height: auto; aspect-ratio: 1275 / 1650; background: #fff; border: 1px solid var(--line); }
.st-lib-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.st-pick { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 6px; cursor: pointer; font: inherit; font-size: 13px; text-align: left; color: var(--ink); }
.st-pick:hover { border-color: var(--ink); }
.st-pick img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.st-lib-form { display: flex; }
.st-lib-form input { flex: 1; min-width: 0; font: inherit; padding: 10px 12px; border: 2px solid var(--ink); border-right: 0; border-radius: 0; }
.st-share-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 16px; align-items: start; }
#st-share-img { width: 100%; height: auto; border: 1px solid var(--line); }
.st-share-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.st-share-links .btn { font-size: 13px; }
.st-print { display: none; }

@media (max-width: 900px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .st-main { order: -1; }
  .st-scroll { max-height: none; padding: 8px; }
  .st-stage { width: calc(100% * var(--z)); }
}
@media (max-width: 560px) {
  .st-photo-grid, .st-share-grid { grid-template-columns: minmax(0, 1fr); }
  .st-start { padding: 6%; gap: 8px; }
  .st-start .btn small { display: none; }
}
@media print {
  .studio-page { padding: 0 !important; }
  .studio-page > .item.st-print { display: block !important; }
  #st-print-img { display: block; width: 100%; height: 9.6in; object-fit: contain; }
}
