:root{
  --bg: #eceef1;
  --panel: rgba(255,255,255,0.72);
  --panel-border: rgba(255,255,255,0.9);
  --ink: #1c1e21;
  --sub: #6b7078;
  --accent: #ff3b5c;
  --accent-soft: #ffe1e6;
  --track: #d8dbe0;
  --shadow-lg: 0 24px 60px -20px rgba(28,30,33,0.35);
  --radius-panel: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Hiragino Sans", "Helvetica Neue", Arial, sans-serif;
}

*{ box-sizing: border-box; }

body{
  margin:0;
  min-height:100vh;
  background:
    radial-gradient(1200px 600px at 15% -10%, #ffffff 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, #dfe3ea 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 40px 20px;
}

.app{
  width:100%;
  max-width: 980px;
  display:grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap:24px;
}
@media (max-width: 820px){
  .app{ grid-template-columns: 1fr; }
}

.card{
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-panel);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: var(--shadow-lg);
  padding: 28px;
}

header.title{
  width: 100%;
  margin-bottom: 22px;
}
header.title .eyebrow{
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 6px;
}
header.title h1{
  font-size: 22px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
header.title p{
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--sub);
  line-height: 1.5;
}

/* preview stage */
.stage{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap: 20px;
}

.checker{
  width: 300px;
  height: 300px;
  border-radius: 26px;
  background-image:
    linear-gradient(45deg, #dfe2e7 25%, transparent 25%),
    linear-gradient(-45deg, #dfe2e7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dfe2e7 75%),
    linear-gradient(-45deg, transparent 75%, #dfe2e7 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
  background-color: #f4f5f7;
  display:flex;
  align-items:center;
  justify-content:center;
  position: relative;
  overflow: hidden;
}

#previewCanvas{
  width: 240px;
  height: 240px;
}

.drop{
  width:100%;
  border: 1.5px dashed rgba(28,30,33,0.22);
  border-radius: 16px;
  padding: 16px;
  text-align:center;
  font-size: 13px;
  color: var(--sub);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.drop:hover, .drop.dragover{
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.drop input{ display:none; }
.drop b{ color: var(--ink); }

/* preview stage: no image selected yet */
.stage.empty .checker{ display:none; }
.stage.empty .drop{
  min-height: 320px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 40px;
  font-size: 15px;
}
.stage:not(.empty) .drop{ display:none; }
.imageResetBtn{ display:none; }
.stage:not(.empty) .imageResetBtn{ display:block; }

/* controls */
.field{
  margin-bottom: 20px;
}
.field:last-of-type{ margin-bottom: 0; }
.field-label{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}
.field-label span.val{
  font-variant-numeric: tabular-nums;
  color: var(--sub);
  font-weight: 500;
  font-size: 12.5px;
}

.color-swatch{
  width: 28px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

input[type="range"]{
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--track);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(28,30,33,0.12);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25), 0 0 0 4px var(--accent-soft);
  cursor:pointer;
  margin-top: -7px;
}
input[type="range"]::-moz-range-thumb{
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(28,30,33,0.12);
  box-shadow: 0 1px 3px rgba(0,0,0,0.25), 0 0 0 4px var(--accent-soft);
  cursor:pointer;
}
input[type="range"]::-moz-range-track{
  height:4px; border-radius:999px; background:var(--track);
}

.row2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.divider{
  height:1px;
  background: rgba(28,30,33,0.08);
  margin: 22px 0;
}

.btn{
  width:100%;
  padding: 13px 18px;
  border-radius: 12px;
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, opacity .15s ease, box-shadow .15s ease;
}
.btn:active{ transform: scale(0.98); }
.btn-primary{
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 24px -8px rgba(255,59,92,0.55);
}
.btn-primary:disabled{
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow:none;
}
.btn-primary:not(:disabled):hover{
  box-shadow: 0 14px 28px -8px rgba(255,59,92,0.65);
}
.btn-secondary{
  background: rgba(28,30,33,0.06);
  color: var(--ink);
}
.btn-secondary:hover{
  background: rgba(28,30,33,0.1);
}

.hint{
  font-size: 12px;
  color: var(--sub);
  margin-top: 10px;
  text-align:center;
}

.filename{
  font-size:12px;
  color: var(--sub);
  margin-top:2px;
  max-width: 300px;
  overflow:hidden;
  text-overflow: ellipsis;
  white-space:nowrap;
}
