:root {
  --bg: oklch(97% 0.012 90);
  --surface: oklch(99.5% 0.004 90);
  --ink: oklch(24% 0.02 60);
  --muted: oklch(55% 0.02 60);
  --line: oklch(90% 0.012 80);
  --accent: oklch(64% 0.15 42);        /* 따뜻한 주황 (강아지 톤) */
  --accent-ink: oklch(99% 0.01 60);
  --accent-soft: oklch(94% 0.05 55);
  --ok: oklch(62% 0.13 155);
  --danger: oklch(58% 0.19 25);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px oklch(30% 0.02 60 / 0.06), 0 8px 28px oklch(30% 0.03 60 / 0.08);
  --dur: 200ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo",
          "Noto Sans KR", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* display:flex/grid 클래스가 hidden 속성을 덮는 것 방지 */
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 100% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.shell { max-width: 1080px; margin: 0 auto; padding: clamp(1.25rem, 2vw, 2.5rem); }

/* Masthead */
.masthead {
  display: flex; gap: 1rem; align-items: flex-start;
  padding-bottom: 1.5rem; margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.mark {
  font-size: 2.2rem; line-height: 1;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 0.5rem 0.6rem; box-shadow: var(--shadow);
}
h1 { margin: 0.1rem 0 0.35rem; font-size: clamp(1.5rem, 1rem + 2vw, 2.1rem); letter-spacing: -0.02em; }
.sub { margin: 0; color: var(--muted); font-size: 0.95rem; max-width: 60ch; }
.sub b { color: var(--ink); font-weight: 600; }

/* Board */
.board { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 820px) { .board { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem; display: flex; flex-direction: column; gap: 0.9rem;
}
.panel-title {
  margin: 0; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--muted); font-weight: 700;
}

/* Drop zone */
.drop {
  position: relative; border: 1.5px dashed var(--line); border-radius: var(--radius-sm);
  background: oklch(98% 0.01 90); min-height: 260px;
  display: grid; place-items: center; cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  overflow: hidden;
}
.drop:hover, .drop:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop.drag { border-color: var(--accent); background: var(--accent-soft); }
.drop.has-img { cursor: crosshair; border-style: solid; }
.drop-inner { text-align: center; padding: 2rem 1rem; pointer-events: none; }
.drop-icon { font-size: 1.8rem; }
.drop-text { margin: 0.6rem 0 0.2rem; font-weight: 500; }
.drop-hint { margin: 0; font-size: 0.8rem; color: var(--muted); }
.link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

.src-wrap { position: relative; width: 100%; display: grid; place-items: center; }
.src-wrap img { max-width: 100%; max-height: 440px; display: block; border-radius: 6px; }
.focus-dot {
  position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--accent-ink); background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 2px 8px oklch(30% 0.05 60 / 0.4);
  transform: translate(-50%, -50%); pointer-events: none;
}

/* Controls */
.controls { display: flex; flex-direction: column; gap: 1rem; }
.ctrl-block { display: flex; flex-direction: column; gap: 0.5rem; }
.ctrl-label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.ctrl-label b { color: var(--accent); font-variant-numeric: tabular-nums; }
.ctrl-hint { margin: 0; font-size: 0.8rem; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 0.4rem 0.75rem; font-size: 0.85rem; cursor: pointer;
  font-family: inherit; transition: all var(--dur) var(--ease);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.chip small { opacity: 0.7; font-weight: 400; }

.custom-size { display: flex; align-items: center; gap: 0.5rem; }
.custom-size input {
  width: 84px; padding: 0.4rem 0.55rem; border: 1px solid var(--line);
  border-radius: 8px; font-family: inherit; font-size: 0.9rem; text-align: center;
  font-variant-numeric: tabular-nums; background: var(--surface); color: var(--ink);
}
.custom-size input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.ratio { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.slider { width: 100%; accent-color: var(--accent); }

/* 전체 담기 토글 */
.fit-toggle {
  display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer;
  padding: 0.7rem 0.85rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: oklch(98% 0.01 90); font-size: 0.85rem; transition: all var(--dur) var(--ease);
}
.fit-toggle:hover { border-color: var(--accent); }
.fit-toggle input { margin-top: 0.15rem; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.fit-toggle span { color: var(--muted); line-height: 1.35; }
.fit-toggle b { color: var(--ink); }
.fit-toggle:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
#cropOpts.disabled { opacity: 0.4; pointer-events: none; }

/* Buttons */
.go {
  appearance: none; border: none; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--accent); color: var(--accent-ink); font-family: inherit;
  font-weight: 600; font-size: 0.95rem; padding: 0.7rem 1rem; border-radius: var(--radius-sm);
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.go:hover { filter: brightness(1.05); }
.go:active { transform: translateY(1px); }
.go[disabled] { opacity: 0.55; cursor: progress; }
.ghost {
  appearance: none; background: transparent; border: 1px solid var(--line); color: var(--muted);
  font-family: inherit; font-size: 0.88rem; padding: 0.55rem 1rem; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--dur) var(--ease);
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Output */
.out-state, .out-wrap { flex: 1; display: flex; flex-direction: column; gap: 0.8rem; }
.out-state { align-items: center; justify-content: center; text-align: center; min-height: 260px; }
.muted { color: var(--muted); }
.out-wrap img {
  max-width: 100%; max-height: 460px; border-radius: 8px; align-self: center;
  box-shadow: var(--shadow); background:
    repeating-conic-gradient(oklch(92% 0.01 90) 0% 25%, transparent 0% 50%) 50% / 20px 20px;
}
.out-actions { display: flex; align-items: center; gap: 0.8rem; justify-content: center; }
.out-meta { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } .go:active { transform: none; } }

/* Errors + footer */
.err {
  margin: 1rem 0 0; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm);
  background: oklch(95% 0.04 25); color: var(--danger);
  border: 1px solid oklch(85% 0.08 25); font-size: 0.9rem;
}
.foot { margin-top: 1.25rem; text-align: right; }
.api-badge { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.api-badge.bad { color: var(--danger); }
.api-badge.ok::before { content: "● "; color: var(--ok); }
