@font-face {
  font-family: KRA Interface;
  src: url(assets/fonts/DMSans-Regular.woff2) format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #f4f1ff;
  --muted: #bdb6cf;
  --paper: #101018;
  --surface: #1b1a26;
  --line: #393449;
  --accent: #c6a9ff;
  --accent-deep: #d4bfff;
  --accent-wash: #2b2240;
  --radius: 18px;
  font-family: "KRA Interface", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 60% 2%, #4a326b52, transparent 53%),
    radial-gradient(ellipse at 8% 36%, #26204455, transparent 45%),
    var(--paper);
}
button, input, select, textarea { font: inherit; }
button, select, input[type="range"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid #e0cbff;
  outline-offset: 3px;
}
button:disabled { opacity: .48; cursor: not-allowed; }
button { color: inherit; }
a { color: inherit; }

.top {
  min-height: 65px;
  padding: 10px clamp(18px, 5vw, 76px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: #111018;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; font-weight: 760; text-decoration: none; letter-spacing: -.02em; }
.brand-portrait { display: block; flex: none; width: 36px; height: 36px; filter: drop-shadow(0 0 7px #ae84ff65); }
.png-celebration {
  position: fixed; z-index: 20; inset: 0; display: grid; place-content: center;
  justify-items: center; gap: 12px; pointer-events: none;
  background: #0a081b60; color: #f4f1ff;
  font-size: .9rem; font-weight: 750; letter-spacing: .08em;
}
.png-celebration .brand-portrait { width: clamp(100px, 27vw, 154px); height: auto; }
.png-celebration span {
  padding: 6px 12px; border: 1px solid #746291; border-radius: 8px; background: #171324;
}

.mascot-smile { opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .png-celebration .brand-portrait { animation: mascot-turn 1.35s ease-in-out both; }
  .brand-portrait .smiling-eyes {
    transform-origin: 32px 33px;
  }
  .png-celebration .smiling-eyes { animation: mascot-wink 1.35s ease-in-out; }
  .brand > .brand-portrait .smiling-eyes {
    animation: mascot-idle-blink 5s ease-in-out infinite;
  }
  .png-celebration .mascot-smile { animation: mascot-smile 1.35s ease-in-out; }
  .png-celebration { animation: mascot-backdrop 1.6s ease both; }
  @keyframes mascot-turn {
    0% { transform: rotate(0deg) scale(1); }
    64%, 82% { transform: rotate(360deg) scale(1.24); }
    100% { transform: rotate(360deg) scale(1); }
  }
  @keyframes mascot-wink {
    0%, 64%, 82%, 100% { transform: scaleY(1); }
    71%, 75% { transform: scaleY(.2); }
  }
  @keyframes mascot-idle-blink {
    0%, 96%, 100% { scale: 1 1; }
    98% { scale: 1 .2; }
  }
  @keyframes mascot-smile {
    0%, 53%, 100% { opacity: 0; }
    65%, 84% { opacity: 1; }
  }
  @keyframes mascot-backdrop {
    0%, 100% { opacity: 0; }
    15%, 85% { opacity: 1; }
  }
}
.brand-wordmark {
  display: inline-flex; align-items: center; gap: .38em;
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(.8rem, 2.5vw, 1.06rem); font-weight: 750;
  letter-spacing: .055em; text-transform: uppercase; white-space: nowrap;
}
.brand-kra { color: #cbb4ff; letter-spacing: .1em; }
.brand-foto { color: #f4f1ff; }
.brand-chip {
  position: relative; isolation: isolate; margin-inline: .16em;
  padding: .34em .66em; color: #8df2dd;
  font-size: .78em; font-weight: 700; letter-spacing: .095em;
}
.brand-chip::before {
  content: ""; position: absolute; z-index: -1; inset: 0;
  clip-path: polygon(6px 0,100% 0,100% calc(100% - 6px),calc(100% - 6px) 100%,0 100%,0 6px);
  background: linear-gradient(135deg, #396b68, #214342 40%, #162f34);
}
.brand-chip::after {
  content: ""; position: absolute; inset: 24% -3px;
  border-inline: 3px dotted #8df2dd; opacity: .65; pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .upload > span { transition: transform .2s ease; }
  .upload:is(:hover,:focus-within) > span { transform: translateY(-4px) rotate(-9deg); }
}
.privacy {
  color: #dcd1f0; font-size: .72rem; font-weight: 650; text-align: right;
  padding: 5px 9px; border: 1px solid #443557; border-radius: 8px; background: #21192d;
}

main { max-width: 1340px; margin-inline: auto; padding: 0 clamp(14px, 3.8vw, 52px) 50px; }
.intro { padding: clamp(28px, 4.4vw, 57px) 0 clamp(24px, 3.4vw, 39px); }
.eyebrow {
  margin: 0 0 9px;
  color: var(--accent-deep);
  font-weight: 800;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: .70rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.intro h1 {
  font-family: "KRA Interface", "Segoe UI", system-ui, sans-serif;
  font-size: clamp(2.25rem, 5.2vw, 4.55rem);
  font-weight: 760;
  letter-spacing: -.065em;
  line-height: 1.02;
  margin: 0 0 13px;
  text-wrap: balance;
}
.intro > p:not(.eyebrow) { margin: 0; max-width: 57ch; color: var(--muted); line-height: 1.55; }
.studio { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(0, .82fr); gap: clamp(14px, 2vw, 26px); align-items: start; }
.panel {
  min-width: 0; background: linear-gradient(150deg, #211e2e, var(--surface) 64%); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 16px 32px #06050d6b, inset 0 1px 0 #ffffff08;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; flex-wrap: wrap; }
.panel-head h2, .controls h2 { margin: 0; font-size: 1.03rem; font-weight: 800; letter-spacing: -.02em; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: .79rem; }
.preview { position: sticky; top: 16px; overflow: hidden; }
.stage {
  position: relative;
  display: grid; place-items: center;
  min-height: clamp(240px, 34vw, 458px);
  margin: 0 14px;
  border: 1px solid #5b5169;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(90deg, #81769824 1px, transparent 1px) center / 21px 21px,
    linear-gradient(#81769824 1px, transparent 1px) center / 21px 21px,
    radial-gradient(ellipse at 50% 36%, #45404f, #2c2836 74%);
}
.stage canvas {
  display: block;
  width: min(calc(100% - 16px), 58vh, 540px);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  margin: 8px;
  border-radius: 7px;
  cursor: grab;
  touch-action: none;
}
.stage canvas:active { cursor: grabbing; }
.stage-foot { color: var(--muted); font-size: .79rem; line-height: 1.5; padding: 12px 20px 16px; }
.stage-foot p { margin: 0; }
.stage-foot strong { color: var(--ink); }
.tabs, .choices { display: flex; flex-wrap: wrap; gap: 7px; }
.tabs { padding: 4px; background: #13121c; border: 1px solid #373044; border-radius: 11px; }
.tabs button, .choices button, .secondary {
  border: 1px solid var(--line); border-radius: 9px;
  background: #201e2d;
  min-height: 38px; padding: 7px 12px;
  font-size: .8rem; font-weight: 690; transition: background .18s, border-color .18s, color .18s;
}
.tabs button { border-color: transparent; min-height: 34px; background: transparent; }
.tabs button:hover, .choices button:hover, .secondary:hover { border-color: #a88ac6; }
.tabs button[aria-selected="true"], .tabs button[aria-pressed="true"], .tabs button.active, .tabs button.is-active {
  background: #3b2b57; color: #f7f0ff; border-color: #6d568c;
}
.choices button[aria-pressed="true"], .choices button[aria-selected="true"], .choices button.active, .choices button.is-active {
  background: var(--accent-wash); color: #eadbff; border-color: #9879c7;
}
.controls { padding: clamp(15px, 2vw, 25px); }
.controls form { margin: 0; }
.controls .step { padding: 16px 0; border-top: 1px solid var(--line); min-width: 0; }
.controls > .step:first-child, .controls form > .step:first-child { padding-top: 0; border-top: 0; }
.step h2, .step h3, .step legend { margin: 0 0 9px; font-size: .89rem; font-weight: 790; }
.step p { margin: 6px 0 0; }
.step .eyebrow { margin: 0 0 5px; }
.step .choices + .choices { margin-top: 9px; }
.step .sliders { margin-top: 11px; }
#engraving-tools > label {
  display: block;
  font-size: .78rem;
  font-weight: 680;
  margin: 10px 0 4px;
}
.step fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.upload {
  min-height: 98px; position: relative; display: grid; place-content: center; gap: 4px;
  text-align: center; padding: 12px; background: linear-gradient(115deg, #2c2442, #221f33); color: #efe4ff;
  border: 1px dashed #8d72b7; border-radius: 12px; cursor: pointer; overflow: hidden;
  font-size: .86rem; font-weight: 740;
}
.upload:hover, .upload:focus-within, .upload.is-dragging { background: #3a2b50; border-color: var(--accent-deep); }
.upload:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload > span { color: var(--accent-deep); font-size: 1.14rem; line-height: 1; }
.upload small { color: #d1c4e4; font-size: .73rem; font-weight: 550; }
.upload input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.sliders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 13px; }
.sliders label { display: block; min-width: 0; color: var(--ink); font-size: .76rem; font-weight: 650; }
.sliders input[type="range"] { display: block; width: 100%; margin: 5px 0 0; min-height: 20px; accent-color: var(--accent); }
.controls input:not([type="range"],[type="file"],[type="checkbox"],[type="radio"]), .controls select, .controls textarea {
  width: 100%; border: 1px solid #57506a; border-radius: 9px;
  padding: 8px 10px; min-height: 38px; background: #16151f; color: var(--ink); font-size: .86rem;
}
.controls textarea { resize: vertical; min-height: 67px; }
.controls label + label:has(select) { margin-top: 6px; }
.controls output, .note { font-size: .75rem; color: var(--muted); line-height: 1.45; }
.note { margin: 6px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 13px; }
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 8px 17px;
  border: 1px solid var(--accent-deep); border-radius: 10px;
  background: var(--accent-deep); color: #211537; box-shadow: 0 0 15px #a776ff33; font-weight: 800; font-size: .83rem;
  text-decoration: none;
}
.primary:hover:not(:disabled) { background: #ece0ff; }
.actions .secondary { min-height: 44px; }
footer { margin: 20px auto 0; text-align: center; font-size: .74rem; color: var(--muted); }

@media (max-width: 850px) {
  .studio { grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); }
  .panel-head { padding-inline: 14px; }
  .stage { margin-inline: 10px; }
}
@media (max-width: 680px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
  .stage { min-height: 240px; }
  .stage canvas { width: min(calc(100% - 16px), 56vh, 410px); }
  .top { min-height: 58px; }
}
@media (max-width: 440px) {
  .top { flex-wrap: wrap; gap: 8px 12px; }
}
@media (max-width: 360px) {
  .panel-head { align-items: flex-start; }
  .sliders { grid-template-columns: 1fr; }
  .tabs button, .choices button { padding-inline: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
@font-face{font-family:AAVersoClassic;src:url(assets/fonts/AmarisEditorial-Regular.woff2) format("woff2")}
@font-face{font-family:AAVersoModern;src:url(assets/fonts/DMSans-Regular.woff2) format("woff2")}
@font-face{font-family:AAVersoCursive;src:url(assets/fonts/Allura-Regular.ttf) format("truetype")}
.intro h1 em { color: var(--accent-deep); font-style: normal; }

.export-options {
  display: grid; gap: .65rem; margin-block: 1rem; padding: .75rem;
  border: 1px solid var(--line); border-radius: 10px;
}
.export-options summary { cursor: pointer; }
.export-options[open] > :not(summary):not([hidden]) { display: block; margin-top: .55rem; }
.export-options select, dialog select, dialog input:not([type="range"]), dialog textarea {
  max-width: 100%; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem;
}
.export-options input[type="file"] { max-width: 100%; }
dialog {
  width: min(92vw, 720px); max-height: 90dvh; padding: clamp(14px, 4vw, 28px);
  color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: auto;
}
dialog::backdrop { background: #09070dbb; }
dialog > h2 { margin-top: 0; }
dialog > label { display: grid; gap: .3rem; margin-block: .65rem; }
dialog .actions { margin-block: .65rem; flex-wrap: wrap; }
dialog canvas { display: block; max-width: 100%; height: auto; margin: auto; }
#output-image { margin-bottom: 1rem; }
.retouch-view {
  background: repeating-conic-gradient(#ddd 0% 25%, #bbb 0% 50%) 50% / 18px 18px;
}
#retouch-view { max-height: 52dvh; width: auto; object-fit: contain; touch-action: none; cursor: crosshair; }
#piece-guide { cursor: crosshair; }
dialog > label { grid-template-columns: minmax(0, 1fr); }
dialog > label > :is(input, select, textarea) { width: 100%; min-width: 0; }
dialog .actions > * { max-width: 100%; }
#local-model { min-width: 0; max-width: 100%; }
