@font-face {
  font-family: "General Sans";
  src: url("./fonts/general-sans-semibold.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: Satoshi;
  src: url("./fonts/satoshi-regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Satoshi;
  src: url("./fonts/satoshi-medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ground: #f4f3ef;
  --ink: #111;
  --muted: #61615d;
  --line: #d0cec6;
  --accent: #0f2c24;
  --panel: #f9f8f4;
  --gutter: clamp(16px, 3.6vw, 56px);
  --display: "General Sans", Arial, sans-serif;
  font-family: Satoshi, Arial, sans-serif;
  color: var(--ink);
  background: var(--ground);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
button, a { color: inherit; }
:focus-visible { outline: 2px solid #2f50ff; outline-offset: 3px; }
.shell { width: min(100% - 2 * var(--gutter), 1376px); margin-inline: auto; }
.skip { position: absolute; z-index: 5; padding: 10px; background: var(--ink); color: var(--ground); }
.skip:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
.masthead { border-bottom: 1px solid var(--line); }
.nav { display: flex; justify-content: space-between; align-items: center; min-height: 62px; gap: 16px; }
.brand { font: 600 1.25rem/1 var(--display); letter-spacing: -.045em; text-decoration: none; }
.portfolio, .stage-label, .field-label, .field > label:not(.check), .field > div > label {
  font-size: .76rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.portfolio { padding-block: 10px; text-decoration: none; }
.portfolio:hover, .brand:hover, .quiet:hover, footer a:hover { text-decoration: underline; text-underline-offset: 4px; }
.intro { padding: clamp(34px, 5vw, 66px) 0 clamp(24px, 4vw, 44px); }
h1 {
  font: 600 clamp(2.55rem, 8vw, 7.2rem)/.95 var(--display);
  letter-spacing: -.067em;
  margin: 0;
}
.intro p { margin: 16px 0 0; color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.2rem); line-height: 1.45; }

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 1fr) minmax(0, 2.5fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "modes preview" "editor preview";
  border: 1px solid var(--line);
}
.modes { grid-area: modes; display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); background: var(--panel); }
.modes button {
  padding: 13px 8px;
  min-height: 46px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-weight: 500;
  color: var(--muted);
}
.modes button + button { border-left: 1px solid var(--line); }
.modes button:hover { background: #ecece4; }
.modes button[aria-pressed=true] { color: var(--accent); border-bottom-color: var(--accent); background: #e7ebe2; }
.editor { grid-area: editor; display: flex; flex-direction: column; min-width: 0; background: var(--panel); }
.controls { padding: 0 18px 5px; }
.field { padding: 13px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.file-field { border-bottom: 1px solid var(--line); }
.field-head, .sliders label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
label, .field-label { display: block; font-size: .88rem; font-weight: 500; margin-bottom: 6px; }
.field-head label { margin: 0; }
.quiet { min-height: 30px; padding: 2px 0; color: var(--accent); border: 0; background: none; font-size: .84rem; font-weight: 500; }
.upload { width: 100%; min-height: 40px; padding: 8px; margin-top: 4px; background: transparent; border: 1px dashed #92998b; font-size: .91rem; font-weight: 500; color: var(--accent); }
.upload:hover { background: #e7ebe2; }
.upload span { margin-right: 4px; }
.filename, .error { font-size: .81rem; margin: 7px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.error { color: #982d24; }
.material { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.material button { padding: 5px 1px; min-height: 51px; border: 1px solid var(--line); background: transparent; font-size: .76rem; font-weight: 500; }
.material button:hover { background: #eeeee8; }
.material button[aria-pressed=true] { border-color: var(--accent); background: #e7ebe2; color: var(--accent); }
.material i { display: block; width: 18px; height: 15px; margin: 0 auto 4px; border: 1px solid #28203340; }
.rainbow { background: linear-gradient(125deg,#d39aff,#aacdff,#9dedda,#fbf4a2,#ffacd7); }
.prism { background: repeating-conic-gradient(from 30deg,#c3e9ff 0 60deg,#d2bafa 60deg 120deg,#eecee9 120deg 180deg); background-size: 9px 11px; }
.chrome { background: linear-gradient(145deg,#7e8392,#fff,#9fa7b9,#f9faff); }
.matte { background: #f8f3dd; }
select, input[type=text] { width: 100%; border: 1px solid var(--line); border-radius: 0; background: var(--ground); color: var(--ink); padding: 8px; min-height: 37px; font-size: .9rem; }
select { appearance: none; padding-right: 21px; background-image: linear-gradient(45deg,transparent 50%,var(--accent) 50%),linear-gradient(135deg,var(--accent) 50%,transparent 50%); background-position: calc(100% - 13px) 16px,calc(100% - 9px) 16px; background-size: 4px 4px; background-repeat: no-repeat; }
input[type=range], input[type=checkbox] { accent-color: var(--accent); }
input[type=range] { display: block; width: 100%; margin: 0 0 9px; height: 17px; }
input[type=range]:last-child { margin-bottom: 0; }
input[type=range]:disabled { opacity: .4; }
.sliders label { margin-bottom: 3px; }
output { font-variant-numeric: tabular-nums; font-size: .79rem; color: var(--muted); text-transform: none; letter-spacing: 0; }
.check, .sliders .check { display: flex; justify-content: flex-start; align-items: center; gap: 7px; margin: 8px 0 0; cursor: pointer; }
.check input { margin: 0; width: 15px; height: 15px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.caption-row { grid-template-columns: minmax(0, 1fr) 70px; }
.export { margin-top: auto; padding: 13px 18px 11px; border-top: 1px solid var(--line); text-align: center; }
.export button { background: var(--accent); color: white; border: 1px solid var(--accent); border-radius: 0; min-height: 43px; width: 100%; font-weight: 500; }
.export button:hover { background: #254438; }
.export button:disabled { opacity: .6; cursor: wait; }
.export small { display: block; color: var(--muted); font-size: .78rem; margin-top: 5px; }

.preview { grid-area: preview; min-width: 0; min-height: 560px; display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.stage {
  --stage-base: #eae9e1;
  --stage-line: #4b514117;
  --stage-light: #f9f8ee;
  --stage-text: #363a32;
  --stage-label: #f5f4eced;
  --stage-shadow: #24282035;
  min-height: 510px;
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  overflow: hidden;
  color: var(--stage-text);
  background-color: var(--stage-base);
  background-image: linear-gradient(var(--stage-line) 1px,transparent 1px),linear-gradient(90deg,var(--stage-line) 1px,transparent 1px),radial-gradient(ellipse at 50% 46%,var(--stage-light),transparent 74%);
  background-size: 24px 24px,24px 24px,100% 100%;
  background-position: center;
  perspective: 900px;
}
.stage[data-surface=lavender] { --stage-base: #e4dfed; --stage-line: #3b275716; --stage-light: #f7f2fc; --stage-label: #f8f3fded; }
.stage[data-surface=ink] { --stage-base: #191a19; --stage-line: #fff1; --stage-light: #31352f; --stage-label: #232822ed; --stage-text: #e8e9e2; --stage-shadow: #0008; }
.stage.dragover::after { content: "Drop image to upload"; position: absolute; inset: 10px; display: grid; place-items: center; background: #eef1e9f5; border: 2px dashed var(--accent); color: var(--accent); font-weight: 500; z-index: 2; pointer-events: none; }
.stage-label, #stage-hint { position: absolute; z-index: 1; padding: 6px 9px; background: var(--stage-label); }
.stage-label { top: 15px; left: 17px; }
#canvas-wrap { width: min(92%, 560px); max-width: 100%; line-height: 0; transform: rotateX(var(--rx,0deg)) rotateY(var(--ry,0deg)) rotateZ(var(--rz,-5deg)); transition: transform .16s ease-out; }
#art { width: 100%; height: auto; filter: drop-shadow(0 12px 12px var(--stage-shadow)) drop-shadow(0 2px 2px var(--stage-shadow)); touch-action: pan-y; }
body[data-mode=stamp] #art { cursor: grab; touch-action: none; }
body[data-mode=stamp] #art:active { cursor: grabbing; }
#stage-hint { bottom: 0; margin: 0 0 11px; font-size: .83rem; text-align: center; pointer-events: none; }
.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 16px; border-top: 1px solid var(--line); background: var(--panel); }
.surfaces { display: flex; align-items: center; gap: 6px; font-size: .84rem; }
.surfaces > span { margin-right: 3px; color: var(--muted); }
.surfaces button { display: grid; place-items: center; background: none; border: 1px solid transparent; border-radius: 50%; width: 28px; height: 28px; padding: 0; }
.surfaces button::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 1px solid #76746d; background: #ded8e9; }
.surfaces button[data-surface=paper]::after { background: #e5e2d6; }
.surfaces button[data-surface=ink]::after { background: #232623; }
.surfaces button:hover, .surfaces button[aria-pressed=true] { border-color: var(--accent); }
footer { display: flex; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; padding: 15px 0 25px; color: var(--muted); font-size: .83rem; }
footer a { text-underline-offset: 3px; }

@media (max-width: 680px) {
  .nav { min-height: 52px; }
  .intro { padding: 30px 0 23px; }
  .intro p { margin-top: 10px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "modes" "preview" "editor"; }
  .preview { min-height: 0; border-left: 0; border-bottom: 1px solid var(--line); }
  .stage { min-height: 0; height: min(89vw, 430px); flex: auto; }
  #canvas-wrap { width: min(87%, 380px); }
  .stage-label { top: 9px; left: 9px; }
  #stage-hint { margin-bottom: 6px; }
  .stage-bar { padding: 5px 11px; }
  .controls { padding-inline: 13px; }
  .export { position: sticky; bottom: 0; z-index: 2; background: var(--panel); padding-inline: 13px; }
  select, input[type=text] { font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  #canvas-wrap { transition: none; transform: none !important; }
}
