:root {
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  color: #181818;
  background: #fff;
  --page: #fff;
  --surface: #fff;
  --ink: #181818;
  --muted: #64666a;
  --line: #dbdcde;
  --button: #f3f3f3;
  --selected: #202020;
  --selected-ink: #fff;
  --red: #e51d2d;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--page); color: var(--ink); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }
.logo-color-filter { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-shell { width: min(1220px, 100%); min-height: 100vh; margin: auto; padding: 20px 24px 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 52px; padding: 5px 0 19px; }
.header-brand { display: block; flex: 0 0 auto; width: 168px; max-width: 45vw; height: auto; }
.header-side { display: flex; align-items: center; gap: 12px; }
.theme-toggle { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--surface); font-size: 1.4rem; }
.workspace { flex: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(330px, .85fr); gap: 34px; align-items: start; }
.site-footer { margin-top: 56px; padding: 24px 0 28px; border-top: 1px solid var(--line); text-align: center; }
.demo-disclaimer { margin: 0 auto 18px; max-width: 60ch; color: var(--muted); font-size: .82rem; line-height: 1.6; }
.footer-brand { display: block; width: 142px; max-width: 55vw; height: auto; margin: 0 auto; }
.preview-panel { position: sticky; top: 18px; min-width: 0; }
.preview-footline { display: flex; justify-content: space-between; gap: 12px; align-items: center; color: var(--muted); font-size: .8rem; }
.preview-footline { padding-top: 10px; }
.fabric { --belt-color: #171717; --preview-bg: #f4f2ef; position: relative; height: clamp(300px, 38vw, 485px); overflow: hidden; border-radius: 12px; background: var(--preview-bg); box-shadow: inset 0 0 0 1px rgba(0,0,0,.1), inset 0 0 30px rgba(0,0,0,.04); }
.fabric[data-orientation="vertical"] { height: clamp(400px, 52vw, 600px); }
.product-art { position: absolute; inset: 50% auto auto 50%; height: auto; overflow: visible; transform: translate(-50%, -50%); filter: drop-shadow(0 15px 14px rgba(0,0,0,.18)); transition: width .2s ease, transform .25s ease; }
.belt-art { width: 92%; }
.fabric[data-orientation="vertical"] .belt-art { transform: translate(-50%, -50%) rotate(90deg); }
.towel-art { display: none; width: 80%; }
.belt-shadow { fill: rgba(0,0,0,.24); }
.belt-body, .towel-body { fill: var(--belt-color); transition: fill .2s ease; }
.belt-light { fill: url(#beltLight); }
.belt-weave { fill: url(#beltWeave); }
.belt-seam { fill: none; stroke: rgba(255,255,255,.28); stroke-width: 3; stroke-dasharray: 2 4; }
.towel-shadow { fill: rgba(0,0,0,.18); }
.towel-light { fill: url(#towelLight); }
.towel-pile { fill: url(#towelPile); }
.towel-seam { fill: none; stroke: rgba(255,255,255,.34); stroke-width: 5; stroke-dasharray: 3 6; }
.handkerchief-art { display: none; width: 62%; }
.handkerchief-shadow { fill: rgba(0,0,0,.2); }
.handkerchief-body { fill: var(--belt-color); transition: fill .2s ease; }
.handkerchief-light { fill: url(#handkerchiefLight); }
.handkerchief-weave { fill: url(#handkerchiefWeave); }
.handkerchief-seam { fill: none; stroke: rgba(255,255,255,.38); stroke-width: 4; stroke-dasharray: 3 5; }
.product-photo-layer { position: absolute; z-index: 1; inset: 50% auto auto 50%; width: 70%; height: auto; aspect-ratio: 3 / 1; transform: translate(-50%, -50%); filter: drop-shadow(0 15px 14px rgba(0,0,0,.18)); transition: width .2s ease, height .2s ease, transform .25s ease; }
.product-photo-layer img, .product-photo-layer span { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.product-photo-layer img { filter: grayscale(.72) contrast(.96) brightness(1.06); }
.product-photo-layer span { background: var(--belt-color); opacity: .74; mix-blend-mode: color; -webkit-mask: var(--product-mask) center / contain no-repeat; mask: var(--product-mask) center / contain no-repeat; }
.fabric[data-orientation="vertical"][data-product="belt"] .product-photo-layer { transform: translate(-50%, -50%) rotate(90deg); }
#previewCanvas { position: relative; z-index: 2; width: 100%; height: 100%; display: block; }
.controls { min-width: 0; padding-top: 2px; }
.field { display: grid; gap: 9px; }
.field > label, legend, .size-group > label { color: var(--ink); font-size: 1rem; font-weight: 800; }
.text-input-wrap { position: relative; display: block; }
#previewText { width: 100%; min-height: 82px; padding: 13px 16px; resize: vertical; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: inset 0 1px 3px rgba(0,0,0,.04); font-size: 1rem; font-weight: 600; line-height: 1.55; }
.text-input-wrap #previewText { padding-right: 49px; }
#clearText { position: absolute; right: 11px; top: 13px; width: 27px; height: 27px; border: 0; border-radius: 50%; color: #fff; background: var(--muted); font-size: 1.15rem; line-height: 1; }
.field-note { color: var(--muted); font-size: .72rem; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 12px; padding: 0; }
.control-group { margin-top: 29px; }
.font-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.font-option { min-height: 57px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--button); text-align: center; transition: border-color .15s ease, background-color .15s ease; }
.font-option:hover { border-color: var(--red); }
.font-option.active { border: 2px solid var(--red); padding: 9px 11px; color: var(--selected-ink); background: var(--selected); }
.font-option strong { display: block; font-size: .94rem; line-height: 1.25; }
.font-option small { display: none; }
.product-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.product-option { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--button); font-weight: 800; }
.product-option.active { border: 2px solid var(--red); color: var(--selected-ink); background: var(--selected); }
.size-group > label { display: block; margin-bottom: 11px; }
.size-control { display: grid; grid-template-columns: 41px minmax(0, 1fr) 41px 65px; align-items: center; gap: 12px; }
.size-control button { height: 41px; border: 1px solid var(--line); border-radius: 8px; background: var(--button); color: var(--ink); font-size: 1.45rem; line-height: 1; }
.size-control button:hover { border-color: var(--red); }
.size-control input { width: 100%; accent-color: var(--red); }
.size-control output { text-align: right; white-space: nowrap; font-size: .9rem; font-weight: 800; }
.line-spacing-control { grid-template-columns: minmax(0, 1fr) 65px; }
.swatches { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; padding: 4px 3px; }
.swatch { width: 43px; height: 43px; padding: 0; border: 1px solid rgba(0,0,0,.14); border-radius: 50%; background: var(--color); }
.swatch.active { outline: 2px solid var(--red); outline-offset: 3px; }
.fabric-swatches .swatch { border-radius: 8px; background-image: repeating-linear-gradient(87deg, rgba(0,0,0,.045) 0 1px, transparent 1px 3px); }
.orientation-switch, .product-style-switch { display: grid; gap: 10px; }
.orientation-switch { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.product-style-switch { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.orientation-switch button, .product-style-switch button { min-height: 46px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--button); font-size: .92rem; font-weight: 700; }
.orientation-switch button.active, .product-style-switch button.active { border: 2px solid var(--red); color: var(--selected-ink); background: var(--selected); }
.position-switch { position: relative; width: 176px; max-width: 100%; aspect-ratio: 1.45; margin: 4px auto 8px; display: grid; grid-template-columns: repeat(3, 22px); grid-template-rows: repeat(3, 22px); justify-content: space-between; align-content: space-between; }
.position-switch::before { content: ""; position: absolute; inset: 10px; z-index: 0; background: linear-gradient(to right, transparent 0 1%, currentColor 1% 2%, transparent 2% 49%, currentColor 49% 51%, transparent 51% 98%, currentColor 98% 99%, transparent 99%), linear-gradient(to bottom, transparent 0 1%, currentColor 1% 2%, transparent 2% 49%, currentColor 49% 51%, transparent 51% 98%, currentColor 98% 99%, transparent 99%); color: var(--ink); opacity: .65; }
.position-switch button { position: relative; z-index: 1; width: 22px; height: 22px; padding: 0; border: 1.5px solid var(--muted); border-radius: 50%; background: var(--surface); }
.position-switch button.active { border: 5px solid var(--red); background: var(--selected); }
.position-note { display: block; text-align: center; }
#productColorGroup.color-locked { opacity: .58; }
#productColorGroup.color-locked .swatch { cursor: not-allowed; }
#productColorNote { display: block; margin-top: 12px; }
.status-text { margin: 27px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.6; }
.export-actions { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.export-actions button { width: 100%; min-height: 50px; border: 0; border-radius: 9px; background: var(--red); color: #fff; font-weight: 800; font-size: 1rem; }
.export-actions button:hover { filter: brightness(.94); }
.export-actions button:disabled { opacity: .5; cursor: wait; }
:root[data-theme="dark"] { color-scheme: dark; --page: #141414; --surface: #212121; --ink: #f7f7f7; --muted: #b7b7b7; --line: #414141; --button: #292929; --selected: #202020; --selected-ink: #fff; }
:root[data-theme="dark"] .header-brand, :root[data-theme="dark"] .footer-brand { filter: url(#logo-dark-ink); }
@media (max-width: 850px) {
  .app-shell { --mobile-gutter: 18px; --sticky-header-height: 92px; width: min(620px, 100%); padding: 20px var(--mobile-gutter) 0; }
  .topbar { position: sticky; top: 0; z-index: 30; height: var(--sticky-header-height); min-height: 0; margin: -20px calc(-1 * var(--mobile-gutter)) 0; padding: 20px var(--mobile-gutter) 12px; background: var(--page); }
  .workspace { display: flex; flex-direction: column; gap: 23px; }
  .preview-panel { position: sticky; top: var(--sticky-header-height); z-index: 29; align-self: stretch; width: calc(100% + 2 * var(--mobile-gutter)); margin: 0 calc(-1 * var(--mobile-gutter)); padding: 8px var(--mobile-gutter) 12px; background: var(--page); box-shadow: 0 8px 12px -12px rgba(0,0,0,.35); }
  .preview-footline { min-width: 0; font-size: clamp(.68rem, 2.8vw, .8rem); white-space: nowrap; }
  .controls { width: 100%; }
  .fabric { height: clamp(220px, 44vw, 300px); }
  .fabric[data-orientation="vertical"] { height: clamp(240px, 42dvh, 340px); }
}
@media (min-width: 851px) {
  html, body { height: 100%; overflow: hidden; }
  .app-shell { height: 100vh; min-height: 0; overflow: hidden; }
  .topbar { flex: 0 0 auto; }
  .workspace { min-height: 0; flex: 1; overflow: hidden; }
  .preview-panel { position: sticky; top: 0; }
  .controls { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding-right: 10px; padding-bottom: 48px; scrollbar-gutter: stable; }
  .site-footer { display: none; }
}
@media (max-width: 480px) {
  .app-shell { --mobile-gutter: 17px; --sticky-header-height: 83px; padding-top: 18px; }
  .topbar { margin-top: -18px; padding-top: 18px; }
  .header-brand { width: 148px; }
  .site-footer { margin-top: 42px; padding: 20px 0 24px; }
  .footer-brand { width: 132px; }
  .fabric { height: 210px; }
  .fabric[data-orientation="vertical"] { height: clamp(240px, 42dvh, 340px); }
  .swatches { justify-content: space-between; gap: 9px; }
  .swatch { width: 40px; height: 40px; }
  .position-switch { width: 164px; }
}
