@font-face { font-family: "Strenuous"; src: url("assets/strenuous bl.ttf") format("truetype"); font-weight: 700 900; font-display: swap; }
@font-face { font-family: "Laca"; src: url("assets/Laca Regular.otf") format("opentype"); font-weight: 400 800; font-display: swap; }

:root {
  --orange: #ff5900;
  --purple: #6831ff;
  --turquoise: #00bdb7;
  --yellow: #f6bb00;
  --ink: #24242a;
  --soft: #6d6d72;
  --paper: #f2f3ef;
  --white: #fff;
  --line: #d8dad4;
  --display: "Strenuous", Impact, sans-serif;
  --body: "Laca", Arial, sans-serif;
  --ease: cubic-bezier(.16,1,.3,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; min-height: 100%; overscroll-behavior: none; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }

.app-shell { position: relative; display: grid; grid-template-rows: auto minmax(0,1fr); width: 100vw; min-height: 100dvh; height: 100dvh; overflow: hidden; }
.app-shell::before { content: ""; position: fixed; z-index: 10; pointer-events: none; inset: 0; border: 7px solid var(--orange); }

.app-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; min-height: clamp(5.5rem, 12vh, 8.5rem); padding: .8rem clamp(1.4rem, 3vw, 3.5rem); background: var(--orange); color: white; }
.brand-frame { width: min(15rem, 26vw); overflow: visible; }
.brand-frame img { display: block; width: 100%; height: auto; }
.header-copy { text-align: center; text-transform: uppercase; letter-spacing: .13em; }
.header-copy span { display: block; margin-bottom: .3rem; font-size: clamp(.58rem, .65vw, .74rem); opacity: .75; }
.header-copy strong { font-family: var(--display); font-size: clamp(1.1rem, 1.6vw, 1.8rem); }
.header-button { justify-self: end; display: flex; align-items: center; gap: .7rem; min-height: 3.2rem; padding: .6rem .8rem .6rem 1rem; border: 1px solid rgba(255,255,255,.5); background: transparent; text-transform: uppercase; letter-spacing: .09em; font-size: clamp(.65rem,.72vw,.78rem); font-weight: 800; cursor: pointer; transition: background .2s ease, transform .2s var(--ease); }
.header-button:hover { background: rgba(255,255,255,.12); }
.header-button:active { transform: translateY(1px); }
.header-button svg { width: 1.35rem; }
.header-button b { display: grid; place-items: center; min-width: 1.8rem; height: 1.8rem; padding: 0 .35rem; background: var(--yellow); color: var(--ink); }

.workspace { display: grid; grid-template-columns: clamp(6.2rem, 8vw, 8.4rem) minmax(0,1fr); min-height: 0; overflow: hidden; }
.toolbar { display: flex; flex-direction: column; gap: clamp(.45rem,1vh,.8rem); padding: clamp(.7rem,1.5vh,1.2rem) .7rem; overflow-y: auto; border-right: 1px solid var(--line); background: white; scrollbar-width: thin; }
.tool-group { display: grid; grid-template-columns: 1fr 1fr; gap: .42rem; }
.tool-group--actions { grid-template-columns: 1fr; }
.tool-button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .32rem; min-height: clamp(3.7rem,8vh,5.2rem); padding: .45rem .2rem; border: 1px solid transparent; background: transparent; color: var(--soft); font-size: clamp(.58rem,.64vw,.7rem); cursor: pointer; transition: color .2s ease, background .2s ease, transform .2s var(--ease); }
.tool-button svg { width: clamp(1.3rem,1.6vw,1.7rem); height: auto; }
.tool-button:hover { background: var(--paper); color: var(--ink); }
.tool-button:active { transform: scale(.97); }
.tool-button.is-active { background: var(--ink); color: white; }
.tool-button--camera { background: var(--orange); color: white; }
.tool-button--camera:hover { background: #de4d00; color: white; }
.tool-button:disabled { opacity: .35; cursor: not-allowed; }
.tool-separator { height: 1px; flex: 0 0 auto; background: var(--line); }
.color-tools { margin: 0; padding: 0; border: 0; }
.color-tools legend, .size-tool > span { margin-bottom: .5rem; color: var(--soft); font-size: .58rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: .42rem; }
.swatch { position: relative; aspect-ratio: 1; min-height: 1.7rem; border: 1px solid #babcb6; background: var(--swatch); cursor: pointer; }
.swatch.is-active::after { content: ""; position: absolute; inset: 24%; border: 2px solid currentColor; transform: rotate(45deg); }
.swatch--white { --swatch: #fff; color: var(--ink); }
.swatch--ink { --swatch: #24242a; color: white; }
.swatch--orange { --swatch: #ff5900; color: white; }
.swatch--purple { --swatch: #6831ff; color: white; }
.swatch--turquoise { --swatch: #00a9a3; color: white; }
.swatch--yellow { --swatch: #f6bb00; color: var(--ink); }
.size-tool { display: block; margin-top: auto; }
.size-tool > span { display: flex; justify-content: space-between; }
.size-tool input { width: 100%; accent-color: var(--orange); }

.board-column { display: grid; grid-template-rows: auto minmax(0,1fr) auto; min-width: 0; min-height: 0; padding: clamp(.8rem,1.7vh,1.4rem) clamp(1rem,2.2vw,2.5rem); }
.board-topline, .board-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: clamp(2.7rem,5vh,3.8rem); }
.board-topline > div { display: flex; align-items: center; gap: .6rem; }
.board-topline p, .board-actions p { margin: 0; }
.board-topline p { text-transform: uppercase; letter-spacing: .1em; font-size: clamp(.64rem,.72vw,.78rem); font-weight: 800; }
.mode-dot { width: .55rem; aspect-ratio: 1; background: var(--turquoise); border-radius: 50%; animation: breathe 2.2s ease-in-out infinite; }
.instruction { color: var(--soft); font-size: clamp(.7rem,.85vw,.9rem) !important; text-transform: none !important; letter-spacing: 0 !important; font-weight: 400 !important; }

.canvas-stage { position: relative; min-height: 0; overflow: hidden; border: 1px solid #cfd1cb; background: white; box-shadow: 12px 12px 0 rgba(36,36,42,.09); touch-action: none; }
.canvas-stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
#drawingCanvas { z-index: 2; cursor: crosshair; touch-action: none; }
.empty-state { position: absolute; z-index: 3; inset: 0; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: clamp(2rem,6vw,7rem); background: linear-gradient(110deg,rgba(255,255,255,.98) 0 54%,rgba(255,255,255,.84) 76%,rgba(255,255,255,.45) 100%); transition: opacity .45s var(--ease), visibility .45s; }
.empty-state::after { content: ""; position: absolute; right: -7%; top: -18%; width: min(38vw,34rem); aspect-ratio: 1; border: clamp(4rem,8vw,9rem) solid var(--turquoise); border-radius: 50%; opacity: .16; }
.empty-state.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.empty-kicker { margin: 0 0 .9rem; color: var(--orange); text-transform: uppercase; letter-spacing: .14em; font-size: clamp(.67rem,.8vw,.86rem); font-weight: 800; }
.empty-state h1 { max-width: 12ch; margin: 0; font-family: var(--display); font-size: clamp(2.7rem,5vw,6rem); line-height: .88; text-transform: uppercase; }
.empty-state > p:not(.empty-kicker) { max-width: 45ch; margin: 1.2rem 0 1.7rem; color: var(--soft); font-size: clamp(.9rem,1vw,1.1rem); line-height: 1.45; }
.empty-actions { display: flex; flex-wrap: wrap; gap: .7rem; }
.empty-actions button { display: inline-flex; align-items: center; gap: .55rem; min-height: 3.1rem; padding: .7rem 1.2rem; border: 2px solid var(--ink); background: transparent; text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 800; cursor: pointer; }
.empty-actions button:first-child { background: var(--ink); color: white; }
.empty-actions svg { width: 1.25rem; }
.board-corner { position: absolute; z-index: 4; pointer-events: none; width: clamp(2.2rem,4vw,4.5rem); aspect-ratio: 1; }
.board-corner--one { top: 0; right: 0; background: var(--yellow); clip-path: polygon(100% 0,100% 100%,0 0); }
.board-corner--two { bottom: 0; left: 0; background: var(--orange); clip-path: polygon(0 0,100% 100%,0 100%); }
.board-actions { padding-top: .5rem; }
.board-actions p { color: var(--soft); font-size: clamp(.68rem,.75vw,.82rem); }
.board-actions p span { color: var(--ink); font-weight: 800; }
.save-button { display: inline-flex; align-items: center; gap: .65rem; min-height: 3.2rem; padding: .7rem 1.3rem; border: 0; background: var(--orange); color: white; text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; font-weight: 800; cursor: pointer; transition: transform .2s var(--ease), background .2s ease; }
.save-button:hover { background: #df4e00; }
.save-button:active { transform: translateY(1px); }
.save-button:disabled { background: #b8bab5; cursor: not-allowed; }
.save-button svg { width: 1.25rem; }

dialog { padding: 0; border: 0; color: var(--ink); font-family: var(--body); }
dialog::backdrop { background: rgba(36,36,42,.72); backdrop-filter: blur(5px); }
.camera-dialog { width: min(68rem,calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); background: var(--paper); }
.dialog-head, .gallery-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; padding: clamp(1.2rem,2.5vw,2.2rem); }
.dialog-head span, .gallery-head span { color: var(--orange); text-transform: uppercase; letter-spacing: .13em; font-size: .67rem; font-weight: 800; }
.dialog-head h2, .gallery-head h2 { margin: .3rem 0 0; font-family: var(--display); font-size: clamp(1.8rem,3vw,3.5rem); line-height: .9; text-transform: uppercase; }
.close-button { display: grid; place-items: center; flex: 0 0 auto; width: 3rem; aspect-ratio: 1; border: 1px solid #c7c9c3; background: transparent; cursor: pointer; }
.close-button svg { width: 1.4rem; }
.camera-view { position: relative; height: min(57dvh,38rem); overflow: hidden; background: var(--ink); }
.camera-view video { display: block; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.camera-view.is-environment video { transform: none; }
.camera-loading, .camera-error { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 2rem; background: var(--ink); color: white; text-align: center; }
.camera-loading span { width: 3rem; aspect-ratio: 1; border: 3px solid rgba(255,255,255,.22); border-top-color: var(--yellow); border-radius: 50%; animation: spin .8s linear infinite; }
.camera-loading p { margin: .8rem 0 0; }
.camera-error p { max-width: 40ch; color: rgba(255,255,255,.7); }
.camera-frame { position: absolute; inset: 7%; border: 1px solid rgba(255,255,255,.52); pointer-events: none; }
.camera-frame::before, .camera-frame::after { content: ""; position: absolute; width: 4rem; height: 4rem; border-color: var(--yellow); }
.camera-frame::before { top: -.2rem; left: -.2rem; border-top: 5px solid var(--yellow); border-left: 5px solid var(--yellow); }
.camera-frame::after { right: -.2rem; bottom: -.2rem; border-right: 5px solid var(--yellow); border-bottom: 5px solid var(--yellow); }
.camera-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; padding: 1rem 2rem; }
.secondary-button, .file-button { justify-self: start; padding: .8rem 1rem; border: 1px solid #bfc1bb; background: white; text-transform: uppercase; letter-spacing: .08em; font-size: .68rem; font-weight: 800; cursor: pointer; }
.file-button { justify-self: end; }
.capture-button { display: grid; place-items: center; width: 4.5rem; aspect-ratio: 1; border: 3px solid var(--orange); border-radius: 50%; background: transparent; cursor: pointer; }
.capture-button span { width: 3.3rem; aspect-ratio: 1; border-radius: 50%; background: var(--orange); transition: transform .2s var(--ease); }
.capture-button:active span { transform: scale(.88); }
.capture-button:disabled { opacity: .4; cursor: not-allowed; }

.gallery-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; background: var(--paper); }
.gallery-head { min-height: 10rem; border-bottom: 1px solid var(--line); }
.gallery-head p { margin: .7rem 0 0; color: var(--soft); }
.gallery-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1rem; max-height: calc(100dvh - 10rem); padding: 1.2rem; overflow-y: auto; }
.gallery-item { position: relative; min-height: 14rem; overflow: hidden; border: 0; background: var(--ink); cursor: pointer; animation: itemIn .5s var(--ease) both; animation-delay: calc(var(--i) * 70ms); }
.gallery-item img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.gallery-item:hover img { transform: scale(1.025); }
.gallery-item span { position: absolute; left: 0; bottom: 0; padding: .55rem .75rem; background: var(--yellow); color: var(--ink); font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.gallery-empty { display: flex; flex-direction: column; justify-content: center; min-height: calc(100dvh - 11rem); padding: 3rem 9vw; }
.gallery-empty[hidden] { display: none; }
.gallery-empty span { font-family: var(--display); font-size: clamp(5rem,12vw,11rem); line-height: .65; color: var(--orange); }
.gallery-empty h3 { max-width: 13ch; margin: 2rem 0 1rem; font-family: var(--display); font-size: clamp(2rem,4vw,4.8rem); line-height: .9; text-transform: uppercase; }
.gallery-empty p { max-width: 44ch; margin: 0; color: var(--soft); }

.preview-dialog { position: relative; width: min(92vw,78rem); height: min(88dvh,54rem); overflow: hidden; background: var(--ink); }
.preview-dialog img { width: 100%; height: 100%; object-fit: contain; }
.preview-close { position: absolute; z-index: 2; top: 1rem; right: 1rem; background: white; }
.download-button { position: absolute; right: 1rem; bottom: 1rem; padding: .85rem 1.2rem; background: var(--orange); color: white; text-decoration: none; text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; font-weight: 800; }

.toast { position: fixed; z-index: 20; right: 1.5rem; bottom: 1.5rem; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .9rem; width: min(24rem,calc(100vw - 3rem)); padding: 1rem; background: var(--ink); color: white; transform: translateY(calc(100% + 3rem)); opacity: 0; transition: transform .5s var(--ease), opacity .35s ease; }
.toast.is-visible { transform: none; opacity: 1; }
.toast-mark { width: .8rem; aspect-ratio: 1; background: var(--turquoise); transform: rotate(45deg); }
.toast strong { font-family: var(--display); text-transform: uppercase; }
.toast p { margin: .16rem 0 0; color: rgba(255,255,255,.68); font-size: .8rem; }

@keyframes breathe { 50% { opacity: .35; transform: scale(.72); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes itemIn { from { opacity: 0; transform: translateY(1.2rem); } to { opacity: 1; transform: none; } }

@media (max-width: 820px), (orientation: portrait) {
  body { overflow: hidden; }
  .app-shell { height: 100dvh; min-height: 100dvh; overflow: hidden; }
  .app-header { position: relative; z-index: 6; grid-template-columns: 1fr auto; min-height: 5.5rem; }
  .brand-frame { width: min(15rem,50vw); }
  .header-copy { display: none; }
  .header-button span { display: none; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); min-height: 0; overflow: hidden; }
  .toolbar { position: relative; z-index: 5; flex-direction: row; align-items: center; gap: .4rem; padding: .55rem; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--line); }
  .tool-group { display: flex; flex: 0 0 auto; }
  .tool-button { flex: 0 0 4.1rem; min-height: 3.5rem; }
  .tool-separator { width: 1px; height: 3rem; }
  .color-tools { flex: 0 0 auto; }
  .color-tools legend, .size-tool { display: none; }
  .swatches { display: flex; }
  .swatch { width: 2.4rem; min-height: 2.4rem; }
  .board-column { height: auto; min-height: 0; padding: .7rem; }
  .instruction { display: none; }
  .empty-state { padding: 2rem; }
  .empty-state h1 { font-size: clamp(2.4rem,10vw,4.6rem); }
  .gallery-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .gallery-head { min-height: 9rem; }
}

@media (max-width: 520px) {
  .gallery-grid { grid-template-columns: 1fr; }
  .camera-actions { grid-template-columns: 1fr auto 1fr; padding: .8rem; }
  .secondary-button, .file-button { padding: .65rem; font-size: .58rem; }
  .board-actions p { display: none; }
  .board-actions { justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
