*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; color-scheme: dark; }
body { margin: 0; min-width: 0; }
p, h1, h2, h3, figure, fieldset { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #c98954; outline-offset: 4px; }
a { color: inherit; text-decoration: none; }
svg { display: block; flex: none; }
img { display: block; max-width: 100%; }

:root {
  --cocoa: #2a201a; --deep: #201813; --paper: #f1e5cf; --ink: #382b22;
  --ivory: #f7e9ce; --muted: #cfbda5; --olive: #596344; --olive-light: #c4caa0;
  --copper: #d4a46b; --soft-rule: #5b4736; --serif: Georgia, 'Times New Roman', serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
body {
  background: radial-gradient(ellipse at 82% 12%, #483323 0, transparent 47rem), var(--cocoa);
  color: var(--ivory); font-family: var(--sans); font-size: 1rem; line-height: 1.55;
}
body::before {
  position: fixed; z-index: -1; inset: 0; pointer-events: none; content: "";
  background: url('./assets/grain.png') repeat; opacity: .34;
}
.shell { width: min(100% - 5rem, 72rem); margin-inline: auto; }
.skip-link { position: absolute; top: .7rem; left: .7rem; z-index: 5; padding: .55rem 1rem; background: var(--paper); color: var(--ink); transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.top { border-bottom: 1px solid #604d3c; }
.top-inner { min-height: 4.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wordmark { display: inline-flex; align-items: center; gap: .55rem; font: 2rem/1 var(--serif); letter-spacing: -.055em; }
.brand-dot { color: var(--copper); margin-left: -.43rem; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; color: var(--copper); border: 1px solid #796044; border-radius: 50%; }
.brand-mark svg { width: 1.55rem; height: 1.55rem; }
.top-link { font-size: .9rem; color: var(--muted); padding: .65rem .3rem; }
.top-link:hover { color: var(--ivory); }
.intro { display: grid; grid-template-columns: minmax(0, 1.13fr) minmax(0, .87fr); align-items: center; gap: 1.7rem; padding-block: 3rem 3.15rem; position: relative; }
.intro-copy { position: relative; z-index: 1; }
.eyebrow { color: var(--copper); font-size: .875rem; font-weight: 620; letter-spacing: .2em; display: flex; align-items: center; gap: .65rem; margin-bottom: .85rem; }
.eyebrow span { display: block; width: 1.25rem; height: 1px; background: var(--copper); }
h1 { color: var(--ivory); font: normal clamp(3.25rem, 6vw, 5.65rem)/.95 var(--serif); letter-spacing: -.077em; margin-left: -.045em; }
h1 em { color: var(--olive-light); font-weight: 400; }
.intro-description { color: #e2cdb2; margin: 1.35rem 0 1.5rem; font-size: clamp(1rem, 1.4vw, 1.13rem); }
.intro-actions { display: flex; flex-wrap: wrap; gap: .65rem; }
.button { display: inline-flex; min-height: 3rem; gap: .55rem; align-items: center; justify-content: center; padding: .65rem 1.15rem; border: 1px solid transparent; border-radius: .5rem; font-size: 1rem; font-weight: 650; transition: background .18s, border-color .18s, color .18s; }
.button svg, .text-button svg, .small-button svg, .icon-button svg, .privacy-note svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linejoin: round; stroke-linecap: round; }
.button-olive { color: #fff4dd; background: var(--olive); border-color: #737b56; }
.button-olive:hover:not(:disabled) { background: #66714d; }
.button-outline { background: #2c211a80; border-color: #87684a; color: #f1dcc0; }
.button-outline:hover { background: #483426; }
.privacy-note { display: flex; gap: .42rem; align-items: center; color: var(--muted); margin-top: 1rem; font-size: .875rem; }
.privacy-note svg { color: var(--copper); flex: none; width: 1rem; }
.sample-art { position: relative; height: clamp(16rem, 32vw, 23rem); width: min(100%, 29rem); justify-self: end; isolation: isolate; }
.art-paper {
  position: absolute; width: 43%; top: 10%; padding: .65rem .65rem .5rem; background: #e9d7b7;
  background-image: url('./assets/grain.png'); color: #564133; border-radius: .23rem;
  box-shadow: 0 .95rem 2rem #140e0978, inset 0 0 0 1px #f7e3bd80; text-align: center;
}
.art-paper img { width: 100%; aspect-ratio: 4 / 5; height: auto; object-fit: contain; display: block; }
.art-original { left: 7%; transform: rotate(-11deg); z-index: 1; }
.art-original img { background: #f1e7d5; }
.art-outline { right: 8%; top: 15%; transform: rotate(9deg); z-index: 2; background-color: #f1e3c7; }
.art-outline img { background: #f9eed8; }
.art-tape { position: absolute; z-index: 1; top: -.45rem; width: 40%; height: 1.1rem; left: 30%; background: #b387569a; border: 1px solid #ecd3a63d; transform: rotate(-5deg); }
.art-original figcaption { text-align: left; padding-left: .3rem; }
.art-outline .art-tape { transform: rotate(9deg); background: #92916c9c; }
.art-paper figcaption, .art-caption { display: block; padding-top: .5rem; font: italic .96rem var(--serif); }
.art-loop { position: absolute; z-index: -1; border: 1px solid #d0a37470; border-radius: 50%; }
.art-loop-one { inset: 14% 2% 13% 2%; transform: rotate(-22deg); }
.art-loop-two { inset: 20% 3% 12% 8%; transform: rotate(-28deg); border-color: #f1c48b32; }
.footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-top: 1px solid var(--soft-rule); padding-block: 1.5rem max(1.5rem, env(safe-area-inset-bottom)); color: var(--muted); font-size: .875rem; }
.footer span:first-child { font: 1.4rem var(--serif); color: var(--ivory); }

.studio { color-scheme: light; margin-bottom: 2.15rem; scroll-margin-top: 1.1rem; border-top: 1px solid #66503d; padding-top: 1.3rem; }
.studio:focus { outline: none; }
.studio-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .95rem; }
.studio-heading button { flex-shrink: 0; white-space: nowrap; }
.studio h2 { font: clamp(1.8rem, 3.2vw, 2.6rem)/1.07 var(--serif); letter-spacing: -.04em; }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; padding: .25rem .3rem; background: none; border: 0; color: var(--copper); font-size: .875rem; font-weight: 650; }
.text-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: .2em; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(17.5rem, 20.5rem); gap: 1rem; align-items: start; }
.preview-panel { min-width: 0; border-radius: .7rem; background: #33271f; border: 1px solid #785f48; padding: .75rem; box-shadow: 0 1rem 2rem #160d0945; }
.preview-toolbar, .preview-footer { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.preview-toolbar { padding: 0 .2rem .65rem; }
.preview-title { font-size: .9rem; font-weight: 630; }
.toolbar-actions { display: flex; align-items: center; gap: .4rem; }
.small-button, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; background: transparent; min-height: 2.75rem; padding: .33rem .65rem; border: 1px solid #856b53; border-radius: .38rem; color: inherit; font-size: .875rem; font-weight: 630; }
.icon-button { padding: .33rem; min-width: 2.75rem; }
.small-button:hover:not(:disabled), .icon-button:hover:not(:disabled), .icon-button[aria-pressed="true"] { background: #9c7b5438; }
.preview-area {
  min-height: 26rem; width: 100%; display: grid; place-items: center; padding: 1.65rem; overflow: hidden;
  background-color: #cbb597; background-image: url('./assets/grain.png'), radial-gradient(ellipse at center, #e6d3b3, #c5ad8d);
  border: 1px solid #604832; border-radius: .34rem;
}
.drawing-paper {
  display: grid; place-items: center; position: relative; min-width: 0; width: min(100%, 18.4rem);
  aspect-ratio: 4/5; background: #f9efd9; box-shadow: 0 .45rem 1.3rem #513d2765;
}
.drawing-paper.is-checkered { background: repeating-conic-gradient(#dbcdb7 0% 25%, #f7eedf 0% 50%) 0 0 / 1.1rem 1.1rem; }
.drawing-paper > canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.empty-preview { position: relative; text-align: center; color: var(--ink); padding: .7rem; }
.empty-preview p { margin-top: .55rem; font: 1.35rem var(--serif); }
.empty-mark { display: inline-grid; place-items: center; border-radius: 50%; border: 1px solid #af9473; width: 3.1rem; height: 3.1rem; color: #675440; }
.empty-mark svg { width: 2rem; height: 2rem; }
.empty-action { color: #586143; }
.preview-footer { margin-top: .55rem; color: #dfcbb3; font-size: .875rem; padding-inline: .2rem; }
#file-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#size-label { white-space: nowrap; }
.settings {
  padding: 1.1rem; border: 1px solid #c0a37d; border-radius: .7rem; color: var(--ink); background: var(--paper) url('./assets/grain.png');
  box-shadow: 0 .75rem 1.75rem #120b0750; min-width: 0;
}
.settings h3 { font: 1.55rem/1.13 var(--serif); letter-spacing: -.03em; margin-bottom: 1.05rem; }
.modes, .camera-settings { border: 0; padding: 0; min-inline-size: 0; }
.modes legend, .camera-settings legend { padding: 0; font-size: .875rem; font-weight: 680; margin-bottom: .35rem; }
.mode-buttons { display: grid; grid-template-columns: .91fr .97fr 1.2fr; gap: .2rem; padding: .22rem; background: #d6c5aa8c; border: 1px solid #bba88d; border-radius: .42rem; }
.mode-buttons button { min-height: 2.5rem; border: 1px solid transparent; border-radius: .3rem; padding: .3rem .1rem; background: transparent; color: #47372b; font-size: .875rem; font-weight: 650; }
.mode-buttons button[aria-pressed="true"] { background: #f8ecd4; border-color: #b9a17b; box-shadow: 0 1px 2px #ad947655; }
.mode-buttons button:hover:not(:disabled) { color: #202719; }
.settings-controls { display: grid; gap: .55rem; padding-top: .9rem; }
.range-field { display: grid; gap: .15rem; font-size: .9rem; font-weight: 610; }
.range-field > span { display: flex; justify-content: space-between; gap: .4rem; }
.range-field output { color: #5d4d3d; font-weight: 490; font-variant-numeric: tabular-nums; }
input[type="range"] { margin: 0; width: 100%; height: 1.75rem; accent-color: #596344; }
.check-field { display: flex; align-items: center; gap: .6rem; min-height: 2.4rem; font-size: .875rem; font-weight: 600; }
.check-field input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: #596344; }
.settings-bottom { display: grid; gap: .12rem; margin-top: .65rem; padding-top: .85rem; border-top: 1px solid #bda988; }
.download-button { width: 100%; }
.original-button { color: #586143; }
.status { display: block; margin-top: .65rem; min-height: 1.5em; color: var(--muted); font-size: .875rem; }
.status[data-tone="error"] { color: #ffd2b9; }
.preview-area.is-camera { padding: 0; display: block; min-height: 0; background: #17120e; }
.camera-view { position: relative; width: 100%; height: 28rem; height: clamp(24rem, 60dvh, 36rem); overflow: hidden; touch-action: none; }
.camera-view video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.camera-view canvas { position: absolute; width: min(45%, 55vh); height: auto; max-height: 94%; object-fit: contain; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.camera-guide { pointer-events: none; position: absolute; inset: 9%; border: 1px dashed #fff5d494; border-radius: .2rem; }
.camera-badge { position: absolute; pointer-events: none; left: 50%; transform: translateX(-50%); bottom: .75rem; width: max-content; max-width: calc(100% - 1.5rem); background: #241912e8; color: #fbefd9; border-radius: .3rem; padding: .25rem .55rem; font-size: .875rem; text-align: center; }
.camera-settings { margin-top: .85rem; display: grid; gap: .5rem; }
.field-help { color: #5b4b3e; font-size: .875rem; }
.camera-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.camera-actions button[aria-pressed="true"] { border-color: #485139; background: #596344; color: #fff4dd; }
:root.is-processing #canvas, :root.is-processing #camera-canvas { opacity: .65; }

@media (max-width: 62rem) {
  .shell { width: min(100% - 3rem, 72rem); }
  .intro { padding-block: 2.35rem; gap: .75rem; }
}
@media (max-width: 47rem) {
  .shell { width: min(100% - 1.75rem, 40rem); }
  .intro { grid-template-columns: 1fr; gap: .55rem; padding-block: 2rem 1.1rem; }
  .sample-art { justify-self: center; width: min(100%, 22rem); height: min(19rem, 68vw); }
  .art-paper { width: 39%; }
  .art-original { left: 15%; }
  .art-outline { right: 14%; }
  .art-loop-one { inset: 15% 5% 12% 5%; }
  .art-loop-two { inset: 15% 5% 12% 10%; }
  .workspace { grid-template-columns: 1fr; gap: .75rem; }
  .preview-area { min-height: 0; padding: .85rem; }
  .drawing-paper { width: min(100%, 16rem); }
  .top-inner { min-height: 3.8rem; }
  .intro-actions .button { padding-inline: .7rem; font-size: .875rem; }
  .studio-heading { align-items: center; }
  .settings { padding: 1.05rem; }
  .wide-only { display: none; }
}
@media (max-width: 23rem) {
  .shell { width: calc(100% - 1.25rem); }
  h1 { font-size: clamp(2.8rem, 15vw, 3.4rem); }
  .button { padding-inline: .7rem; }
  .studio-heading button { flex-shrink: 0; white-space: nowrap; }
.studio h2 { font-size: 1.6rem; }
  .studio-heading { gap: .4rem; }
  .preview-panel { padding: .55rem; }
  .art-paper { padding: .38rem .38rem .4rem; }
  .art-paper figcaption, .art-caption { font-size: .85rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
