/* ---------- Design tokens ---------- */
:root {
  color-scheme: light;
  /* Neutral grays, navy for brand and structure, teal for actions. */
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f1f4f7;
  --surface-3: #e5eaf0;
  --ink: #1a2332;
  --muted: #5b6b7f;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #0f2a44;
  --primary: #0e7c7a;
  --primary-hover: #0b6765;
  --on-primary: #ffffff;
  --accent: #0e7c7a;
  --accent-soft: #e3f2f1;
  --success: #15803d;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  /* Crop workspace. Light theme: white card on a neutral gray canvas, so a white photo background stays visible. */
  --stage: #e4e9ef;
  --stage-surface: #ffffff;
  --stage-line: #e2e8f0;
  --stage-line-strong: #b8c3d0;
  --stage-ink: #1a2332;
  --stage-muted: #5b6b7f;
  --stage-accent: #0e7c7a;
  --on-stage-accent: #ffffff;
  --stage-fill: #f1f4f7;
  --stage-fill-strong: #e5eaf0;
  --stage-track: #cbd5e1;
  --stage-dot: rgb(15 42 68 / .1);
  --stage-glow: #f3f6f9;
  --stage-mask: rgba(228, 233, 239, .82);
  --guide: #2563eb;
  --guide-dim: #1d4ed8;
  --focus: #0e7c7a;
  --radius-lg: 1.25rem;
  --radius: .875rem;
  --radius-sm: .625rem;
  --shadow: 0 1px 2px rgb(15 42 68 / .05), 0 6px 24px rgb(15 42 68 / .07);
  --shadow-pop: 0 12px 32px rgb(15 42 68 / .18);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%235b6b7f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

/* Dark theme follows the system unless the viewer picked light; data-theme="dark" forces it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1f262f;
    --surface-3: #29313b;
    --ink: #e6edf3;
    --muted: #9ba7b4;
    --line: #262e38;
    --line-strong: #3a4552;
    --brand: #1e4568;
    --primary: #14b8a6;
    --primary-hover: #2dd4bf;
    --on-primary: #04201e;
    --accent: #5eead4;
    --accent-soft: #11302e;
    --success: #4ade80;
    --warn: #fbbf24;
    --warn-bg: #2a2110;
    --danger: #f87171;
    --danger-bg: #2c1517;
    --stage: #080b10;
    --stage-surface: #121820;
    --stage-line: #2a3440;
    --stage-line-strong: #3d4957;
    --stage-ink: #eef2f6;
    --stage-muted: #a3b0be;
    --stage-accent: #2dd4bf;
    --on-stage-accent: #042f2e;
    --stage-fill: rgb(255 255 255 / .05);
    --stage-fill-strong: rgb(255 255 255 / .1);
    --stage-track: rgb(255 255 255 / .16);
    --stage-dot: rgb(255 255 255 / .06);
    --stage-glow: #1a2330;
    --stage-mask: rgba(8, 11, 16, .74);
    --guide-dim: #60a5fa;
    --focus: #5eead4;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 28px rgb(0 0 0 / .25);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%239ba7b4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1f262f;
    --surface-3: #29313b;
    --ink: #e6edf3;
    --muted: #9ba7b4;
    --line: #262e38;
    --line-strong: #3a4552;
    --brand: #1e4568;
    --primary: #14b8a6;
    --primary-hover: #2dd4bf;
    --on-primary: #04201e;
    --accent: #5eead4;
    --accent-soft: #11302e;
    --success: #4ade80;
    --warn: #fbbf24;
    --warn-bg: #2a2110;
    --danger: #f87171;
    --danger-bg: #2c1517;
    --stage: #080b10;
    --stage-surface: #121820;
    --stage-line: #2a3440;
    --stage-line-strong: #3d4957;
    --stage-ink: #eef2f6;
    --stage-muted: #a3b0be;
    --stage-accent: #2dd4bf;
    --on-stage-accent: #042f2e;
    --stage-fill: rgb(255 255 255 / .05);
    --stage-fill-strong: rgb(255 255 255 / .1);
    --stage-track: rgb(255 255 255 / .16);
    --stage-dot: rgb(255 255 255 / .06);
    --stage-glow: #1a2330;
    --stage-mask: rgba(8, 11, 16, .74);
    --guide-dim: #60a5fa;
    --focus: #5eead4;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 28px rgb(0 0 0 / .25);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%239ba7b4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
h1, h2, p, figure { margin: 0; }
button, select, input { font: inherit; color: inherit; }
button, select, summary, label:has(input) { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button, select, input, a, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: .5rem; }
a { color: var(--accent); text-underline-offset: .2em; }
.wrap { width: min(100% - 2.5rem, 76rem); margin-inline: auto; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.ui-icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ui-icon.tiny { width: .9rem; height: .9rem; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; }
.hint, .metric, label, summary { font-size: .875rem; }
.hint { color: var(--muted); }
.metric { font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.top-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 3.75rem; }
.brand { display: flex; align-items: center; gap: .75rem; min-width: 0; font-size: 1.125rem; font-weight: 800; letter-spacing: -.02em; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mark { display: block; width: 2.4rem; height: 2.4rem; flex: none; border-radius: .75rem; box-shadow: 0 2px 8px rgb(15 42 68 / .2); }

.top-actions { display: flex; align-items: center; gap: .25rem; flex: none; }
.icon-circle {
  display: grid;
  place-items: center;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 999px;
  transition: background .15s var(--ease);
}
.icon-circle:hover { background: var(--surface-3); }
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-icon-moon { display: none; }
}
.language-menu { position: relative; flex: none; }
.language-menu summary {
  display: grid;
  place-items: center;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  list-style: none;
  color: var(--ink);
  border-radius: 999px;
  transition: background .15s var(--ease);
}
.language-menu summary::-webkit-details-marker { display: none; }
.language-menu[open] summary, .language-menu summary:hover { background: var(--surface-3); }
.language-options {
  position: absolute;
  inset-block-start: calc(100% + .4rem);
  inset-inline-end: 0;
  display: grid;
  gap: 2px;
  inline-size: min(15rem, calc(100vw - 1.5rem));
  max-block-size: 70vh;
  overflow-y: auto;
  padding: .4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  animation: pop .16s var(--ease);
}
.language-options button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-block-size: 2.75rem;
  padding: .4rem .75rem;
  text-align: start;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
}
.language-options button:hover { background: var(--surface-2); }
.language-options button:focus-visible { outline-offset: -3px; }
.language-options [aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.language-options [aria-pressed="true"]::after {
  content: "";
  inline-size: .65rem;
  block-size: .38rem;
  border: solid currentColor;
  border-width: 0 0 2px 2px;
  transform: translateY(-2px) rotate(-45deg);
}

/* ---------- Hero & steps ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 18rem);
  align-items: center;
  gap: 2rem;
  padding-block: 1.25rem 1.25rem;
}
.hero-art { align-self: center; }
.hero-copy { display: grid; gap: .7rem; justify-items: start; }
.hero-art svg { display: block; width: 100%; height: auto; overflow: visible; }
.art-stage { fill: var(--stage); }
.art-dots circle { fill: var(--stage-muted); opacity: .4; }
.art-photo { fill: #ffffff; }
.art-person { fill: #cfd8e4; }
.art-guide { stroke: var(--guide); stroke-width: 1.6; stroke-dasharray: 6 4; fill: none; }
.art-band { fill: var(--guide); fill-opacity: .18; }
.art-center { stroke: #94a3b8; stroke-width: 1; stroke-dasharray: 2 4; fill: none; }
.art-corners { stroke: var(--stage-accent); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.art-dim { stroke: var(--stage-muted); stroke-width: 1.3; fill: none; }
.art-label { fill: var(--stage-ink); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.art-chip rect:first-child { fill: var(--primary); filter: drop-shadow(0 6px 12px rgb(0 0 0 / .25)); }
.art-chip text { fill: var(--on-primary); font-size: 15px; font-weight: 800; }
.art-chip.alt rect:first-child { fill: var(--surface); stroke: var(--line); }
.art-chip.alt text { fill: var(--ink); }
.art-mini { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.art-mini-cut { stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 2 2; }
.hero h1 { font-size: clamp(1.75rem, 3.6vw, 2.75rem); font-weight: 800; line-height: 1.15; letter-spacing: -.03em; }
.hero-copy > p { max-width: 42rem; color: var(--muted); }
.privacy {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .75rem .3rem .55rem;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, transparent);
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 650;
}
.privacy .ui-icon { width: 1.05rem; height: 1.05rem; }

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  width: 100%;
  max-width: 40rem;
  margin: .5rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}
.steps li { position: relative; }
.steps a {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-block-size: 2.75rem;
  padding: .35rem .5rem .35rem .35rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 999px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.steps a:hover { background: var(--surface-2); }
.step-dot {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 1.85rem;
  block-size: 1.85rem;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 750;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.step-label { min-width: 0; overflow-wrap: anywhere; }
.steps .is-current a { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.steps .is-current .step-dot { background: var(--brand); color: #fff; }
.steps .is-done .step-dot { background: var(--primary); color: var(--on-primary); }
.steps .is-done a { color: var(--ink); }

/* ---------- Cards ---------- */
.card {
  min-width: 0;
  padding: clamp(1rem, 2vw, 1.4rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: .65rem; min-block-size: 2.75rem; margin-bottom: .9rem; }
.card-head h2 { flex: 1; min-width: 0; font-size: 1.0625rem; font-weight: 750; line-height: 1.3; letter-spacing: -.01em; }
.card-head h2:focus { outline: none; }
.step-badge {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  border-radius: .55rem;
  background: var(--brand);
  color: #fff;
  font-size: .8125rem;
  font-weight: 800;
}
.step-badge.is-done { background: var(--primary); color: var(--on-primary); }
.step-badge.is-todo { background: var(--surface-3); color: var(--muted); }
.pill {
  flex: none;
  padding: .25rem .65rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8125rem;
  font-weight: 650;
  white-space: nowrap;
}

/* ---------- Buttons ---------- */
.button {
  min-block-size: 2.75rem;
  padding: .55rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink);
  font-size: .9375rem;
  font-weight: 650;
  line-height: 1.2;
  transition: background .15s var(--ease), transform .1s var(--ease), box-shadow .15s var(--ease);
}
.button:hover:not(:disabled) { background: var(--surface-3); }
.button:active:not(:disabled) { transform: scale(.97); }
.button.primary { background: var(--primary); color: var(--on-primary); box-shadow: 0 4px 14px rgb(14 124 122 / .28); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover); }
.button.ghost { background: transparent; border-color: var(--line-strong); }
.button.primary:disabled { background: var(--surface-3); color: var(--muted); box-shadow: none; opacity: 1; }
.download-hint { margin-top: .5rem; text-align: center; }
.button.wide { width: 100%; }
.button.large { min-block-size: 3.4rem; font-size: 1.0625rem; border-radius: 1rem; }

/* ---------- Setup / document chips ---------- */
.setup { margin-bottom: 1rem; }
.chips {
  display: flex;
  gap: .55rem;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  margin-inline: -.25rem;
  padding: .25rem;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  position: relative;
  display: grid;
  align-content: center;
  gap: .1rem;
  flex: 0 0 auto;
  min-inline-size: 8.5rem;
  max-inline-size: 13rem;
  min-block-size: 3.75rem;
  padding: .55rem .9rem;
  text-align: start;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  scroll-snap-align: start;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.chip:hover { background: var(--surface-3); }
.chip:active { transform: scale(.97); }
.chip-name { font-size: .9rem; font-weight: 650; line-height: 1.25; }
.chip-size { color: var(--muted); font-size: .78rem; }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.chip[aria-pressed="true"] .chip-name { color: var(--accent); }
.chip[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset-block-start: .5rem;
  inset-inline-end: .55rem;
  inline-size: .5rem;
  block-size: .28rem;
  border: solid var(--accent);
  border-width: 0 0 2px 2px;
  transform: rotate(-45deg);
}
.spec-note {
  display: flex;
  gap: .6rem;
  margin-top: .9rem;
  padding: .75rem .9rem;
  background: var(--surface-2);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .875rem;
  overflow-wrap: anywhere;
}
.spec-note > .ui-icon { margin-top: .1rem; color: var(--accent); }
.spec-note a { display: inline-flex; align-items: center; gap: .2rem; font-weight: 650; white-space: nowrap; }

/* ---------- Workspace ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
/* The editor card matches the row height; any extra height goes to the canvas, so the
   empty drop zone never leaves a blank strip under it. The preview keeps its own height. */
#crop-station { align-self: stretch; display: flex; flex-direction: column; }
#crop-station .stage { flex: 1 0 auto; }
/* Before a photo is loaded, keep the drop zone near the top so its buttons stay above the fold. */
/* Before a photo is loaded, the whole canvas is one large drop target. */
.stage:not(.editing) { place-items: stretch; padding: .75rem; }

/* Crop station: dark editing surface like a photo app */
#crop-station {
  --focus: var(--stage-accent);
  color: var(--stage-ink);
  background: var(--stage-surface);
  border-color: var(--stage-line);
}
#crop-station .hint { color: var(--stage-muted); }
#crop-station .button.ghost { color: var(--stage-ink); border-color: var(--stage-line); }
#crop-station .button.ghost:hover:not(:disabled) { background: var(--stage-fill-strong); }
.head-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: .55rem; min-block-size: 2.75rem; padding-inline: .25rem; font-weight: 600; user-select: none; }
.switch input {
  appearance: none;
  position: relative;
  flex: none;
  inline-size: 2.6rem;
  block-size: 1.5rem;
  margin: 0;
  border-radius: 999px;
  background: var(--stage-track);
  transition: background .2s var(--ease);
}
.switch input::after {
  content: "";
  position: absolute;
  inset-block-start: .1875rem;
  inset-inline-start: .1875rem;
  inline-size: 1.125rem;
  block-size: 1.125rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / .3);
  transition: transform .2s var(--ease);
}
.switch input:checked { background: var(--stage-accent); }
.switch input:checked::after { transform: translateX(1.1rem); }
.switch input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Stage */
.stage {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  height: clamp(21rem, 42vw, 32rem);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 40%, var(--stage-glow) 0, transparent 70%),
    radial-gradient(circle, var(--stage-dot) 1px, transparent 1.4px) 0 0 / 18px 18px,
    var(--stage);
  transition: box-shadow .2s var(--ease);
}
.stage.editing { touch-action: none; cursor: grab; }
.stage.editing:active { cursor: grabbing; }
.stage:focus-visible { outline: 3px solid var(--stage-accent); outline-offset: 2px; }
.stage.drag-over { box-shadow: inset 0 0 0 3px var(--stage-accent), inset 0 0 60px color-mix(in srgb, var(--stage-accent) 20%, transparent); }
#editor, #guides { position: absolute; pointer-events: none; }
#editor { inset: 0; width: 100%; height: 100%; }
#guides {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--crop-w);
  height: var(--crop-h);
  outline: 1px solid #ffffff55;
  overflow: visible;
}
.frame-corners, .guide-halo, .guide-center, .guide-crown, .guide-line { fill: none; vector-effect: non-scaling-stroke; }
.frame-corners { stroke: var(--stage-accent); stroke-width: 3; stroke-linecap: round; }
/* Each guide sits on a white halo so it stays visible over light backgrounds and dark hair. */
.guide-halo { stroke: #ffffff; stroke-width: 5; stroke-opacity: .85; stroke-linecap: round; }
.guide-halo.thin { stroke-width: 3; stroke-opacity: .55; }
.guide-center { stroke: #0f2a44; stroke-width: 1.25; stroke-dasharray: 3 4; opacity: .8; }
.guide-crown, .guide-line { stroke: var(--guide); stroke-width: 2.25; stroke-dasharray: 9 5; stroke-linecap: round; }
.guide-band rect { fill: var(--guide); fill-opacity: .16; }
.guide-band.eyes .guide-line { stroke: #d97706; stroke-dasharray: 4 4; }
.guide-band.eyes rect { fill: #f59e0b; fill-opacity: .18; }
.guide-dim path { fill: none; stroke: var(--stage-muted); stroke-width: 1.3; stroke-linecap: round; }
.guide-dim.head path { stroke: var(--guide-dim); stroke-width: 1.6; }
.guide-dim.eyes path { stroke: #d97706; stroke-width: 1.6; }
/* The label's halo matches the canvas, so it cuts a gap in the bracket like a technical drawing. */
.guide-label {
  fill: var(--stage-ink);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--stage);
  stroke-width: 7px;
  stroke-linejoin: round;
}
.guide-dim.head .guide-label { fill: var(--guide-dim); }
.guide-dim.eyes .guide-label { fill: #d97706; }

.empty {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: .25rem;
  padding: clamp(1.25rem, 4vh, 2.5rem) 1.25rem 2rem;
  text-align: center;
  border: 1.5px dashed var(--stage-line-strong);
  border-radius: var(--radius);
  background: var(--stage-fill);
  cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.empty:hover, .stage.drag-over .empty {
  border-color: var(--stage-accent);
  background: color-mix(in srgb, var(--stage-accent) 6%, var(--stage-fill));
}
.drop-icon {
  display: grid;
  place-items: center;
  inline-size: 3.75rem;
  block-size: 3.75rem;
  margin-bottom: .5rem;
  border-radius: 1.1rem;
  color: var(--stage-accent);
  background: color-mix(in srgb, var(--stage-accent) 12%, transparent);
}
.drop-icon .ui-icon { width: 2.1rem; height: 2.1rem; stroke-width: 1.5; }
.empty strong { font-size: 1.0625rem; }
.empty .hint { margin-bottom: .75rem; }
.empty-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; width: min(24rem, 100%); }
.empty-actions .button { min-block-size: 3.25rem; }
/* Decorative preview of the crop that follows; fills the large drop zone without extra text. */
.empty-art { width: min(10rem, 45%); margin-top: clamp(1.5rem, 6vh, 3.5rem); opacity: .55; pointer-events: none; }
.empty-art-photo { fill: var(--stage-surface); stroke: var(--stage-line-strong); }
.empty-art-person { fill: var(--stage-line-strong); }
.empty-art-guide { fill: none; stroke: var(--guide); stroke-width: 1.5; stroke-dasharray: 5 4; }
.empty-art-corners { fill: none; stroke: var(--stage-accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.empty-art-dim { fill: none; stroke: var(--stage-muted); stroke-width: 1.2; }

.status-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1rem; min-block-size: 1.6rem; margin-top: .55rem; }
#status, #download-status { overflow-wrap: anywhere; }
#download-status:empty { display: none; }
#crop-station .source-stats .metric { color: var(--stage-accent); }

/* Adjust panel */
.adjust { display: grid; gap: .85rem; margin-top: .6rem; }
.toolbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.tool {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: .3rem;
  min-block-size: 4rem;
  padding: .55rem .4rem;
  color: var(--stage-ink);
  background: var(--stage-fill);
  border: 1px solid var(--stage-line);
  border-radius: var(--radius);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  transition: background .15s var(--ease), transform .1s var(--ease);
}
.tool .ui-icon { width: 1.4rem; height: 1.4rem; color: var(--stage-accent); }
.tool:hover { background: var(--stage-fill-strong); }
.tool:active { transform: scale(.96); }
.tool[aria-pressed="true"] { background: color-mix(in srgb, var(--stage-accent) 15%, transparent); border-color: var(--stage-accent); }

.slider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.slider { display: block; padding: .6rem .85rem .7rem; background: var(--stage-fill); border-radius: var(--radius); }
.slider-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; min-block-size: 1.75rem; font-weight: 600; }
.slider output {
  padding: .05rem .5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--stage-accent) 14%, transparent);
  color: var(--stage-accent);
  font-size: .8125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  --fill: var(--stage-accent);
  appearance: none;
  display: block;
  width: 100%;
  block-size: 2rem;
  margin: .2rem 0 0;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track { block-size: .3rem; border-radius: 999px; background: var(--stage-track); }
input[type="range"]::-moz-range-track { block-size: .3rem; border-radius: 999px; background: var(--stage-track); }
input[type="range"]::-moz-range-progress { block-size: .3rem; border-radius: 999px; background: var(--fill); }
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin-top: -.6rem;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--fill);
  box-shadow: 0 2px 6px rgb(0 0 0 / .35);
}
input[type="range"]::-moz-range-thumb {
  inline-size: 1.1rem;
  block-size: 1.1rem;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--fill);
  box-shadow: 0 2px 6px rgb(0 0 0 / .35);
}
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--stage-accent) 40%, transparent); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--stage-accent) 40%, transparent); }

.editor-help { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.tip { padding: .6rem .8rem; border-inline-start: 3px solid var(--stage-accent); background: var(--stage-fill); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tip[hidden] + .tip { grid-column: 1 / -1; }

/* Disclosures */
.disclosure { border-top: 1px solid var(--line); }
.disclosure summary {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-block-size: 3.25rem;
  list-style: none;
  font-size: .9375rem;
  font-weight: 650;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary > .ui-icon { color: var(--accent); }
.disclosure summary::after {
  content: "";
  flex: none;
  margin-inline-start: auto;
  inline-size: .5rem;
  block-size: .5rem;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .2s var(--ease);
}
.disclosure[open] summary::after { transform: translateY(2px) rotate(-135deg); }
.details-body { display: grid; gap: .6rem; padding-bottom: 1rem; animation: fade .2s var(--ease); }
#crop-station .disclosure { border-color: var(--stage-line); }
#crop-station .disclosure summary::after { border-color: var(--stage-muted); }
.warn-text { padding: .6rem .8rem; border-radius: var(--radius-sm); color: var(--warn) !important; background: var(--warn-bg); }
.advanced-row { display: grid; grid-template-columns: minmax(7rem, auto) 1fr; gap: .6rem; }

/* ---------- Result ---------- */
#result, #crop-station { scroll-margin-block-start: 4.75rem; }
.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .25rem;
  padding: .25rem;
  margin-bottom: .9rem;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.segmented button {
  min-block-size: 2.75rem;
  padding: .35rem .5rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: .65rem;
  font-size: .875rem;
  font-weight: 650;
  line-height: 1.15;
  overflow-wrap: anywhere;
  transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}
.segmented [aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgb(15 42 68 / .14); }
.segmented button:focus-visible { outline-offset: -2px; }

.preview {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  height: 17rem;
  padding: 1rem;
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25% 75%, var(--surface-2) 75%) 0 0 / 16px 16px,
    linear-gradient(45deg, var(--surface-2) 25%, transparent 25% 75%, var(--surface-2) 75%) 8px 8px / 16px 16px,
    var(--surface-3);
}
#preview { display: block; width: auto; height: auto; max-width: 100%; max-height: 15rem; border-radius: 2px; box-shadow: 0 6px 20px rgb(15 42 68 / .25); }
.preview-caption { margin-top: .5rem; color: var(--muted); text-align: center; }

.output-notices { display: grid; gap: .5rem; margin-top: .75rem; }
.output-notices:not(:has(p:not([hidden]))) { display: none; }
.notice {
  display: flex;
  gap: .55rem;
  padding: .65rem .8rem;
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: var(--danger-bg);
  font-size: .875rem;
  font-weight: 550;
  animation: fade .2s var(--ease);
}
.notice .ui-icon { margin-top: .05rem; }

.settings { display: grid; gap: .85rem; margin-block: 1rem; }
.setting-row { display: grid; gap: .4rem; min-width: 0; }
.setting-row > span:first-child { color: var(--muted); font-size: .8125rem; font-weight: 650; }
/* One-tap choices replace the native dropdowns; the hidden selects stay the source of truth. */
.choice {
  display: flex;
  gap: .25rem;
  padding: .25rem;
  background: var(--surface-2);
  border-radius: var(--radius);
}
/* Buttons size to their labels, so long labels such as 十字準星與細框 stay on one line. */
.choice button {
  flex: 1 1 auto;
  min-block-size: 2.75rem;
  padding: .35rem .6rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: .65rem;
  font-size: .8125rem;
  font-weight: 650;
  line-height: 1.2;
  word-break: keep-all;
  text-wrap: balance;
  transition: background .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}
.choice button:hover:not([aria-pressed="true"]) { color: var(--ink); background: var(--surface-3); }
.choice [aria-pressed="true"] { color: var(--accent); background: var(--surface); box-shadow: 0 1px 3px rgb(15 42 68 / .14); }
.choice button:focus-visible { outline-offset: -2px; }

.download { margin-top: .25rem; }
#download-status { margin-top: .55rem; text-align: center; }
#result .disclosure:first-of-type { margin-top: 1rem; }
.count {
  padding: .1rem .55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}
.count.complete { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.check-list label {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  min-block-size: 2.75rem;
  padding: .65rem .75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: .9rem;
  line-height: 1.45;
  transition: background .15s var(--ease);
}
.check-list label:has(input:checked) { background: color-mix(in srgb, var(--success) 12%, var(--surface)); }
.check-list label:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.check-list input {
  appearance: none;
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 1.35rem;
  block-size: 1.35rem;
  margin: 0;
  border: 2px solid var(--line-strong);
  border-radius: .4rem;
  background: var(--surface);
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.check-list input:checked { background: var(--success); border-color: var(--success); }
.check-list input:checked::after {
  content: "";
  inline-size: .55rem;
  block-size: .3rem;
  border: solid #fff;
  border-width: 0 0 2px 2px;
  transform: translateY(-1px) rotate(-45deg);
  animation: pop .2s var(--ease);
}
.link-list { display: grid; gap: .4rem; }
.link-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-block-size: 2.9rem;
  padding: .5rem .85rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
}
.link-list a:hover { background: var(--surface-3); }
.link-list .ui-icon { color: var(--muted); }
.footer { display: grid; gap: .75rem; justify-items: center; padding-block: 1.75rem 2rem; text-align: center; font-size: .8125rem; text-wrap: balance; }
.footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem 1.25rem; }
.footer-nav a { display: inline-flex; align-items: center; min-block-size: 2.75rem; color: var(--muted); font-size: .875rem; font-weight: 600; text-decoration: none; }
.footer-nav a:hover, .footer-nav a[aria-current="page"] { color: var(--accent); }
.footer-legal a { color: var(--muted); }
.footer-legal a:hover { color: var(--accent); }

/* ---------- Mobile dock (tab bar) ---------- */
.mobile-dock { display: none; }

@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* The preview follows the crop editor only when the whole panel fits on screen (see app.js). */
@media (min-width: 56.01rem) {
  #result.pinned { position: sticky; top: 4.75rem; }
}

@media (max-width: 56rem) {
  html { scroll-padding-bottom: calc(5rem + env(safe-area-inset-bottom)); }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(10rem, 13rem); gap: 1.25rem; }
  #review { display: none; }
  .mobile-dock {
    position: fixed;
    z-index: 10;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
    padding: .4rem max(.75rem, calc((100% - 28rem) / 2)) calc(.4rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    backdrop-filter: saturate(1.6) blur(16px);
    border-top: 1px solid var(--line);
  }
  .mobile-dock[hidden] { display: none; }
  .dock-tab {
    display: grid;
    justify-items: center;
    gap: .15rem;
    min-block-size: 3.4rem;
    padding: .35rem;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    font-size: .75rem;
    font-weight: 650;
    line-height: 1.15;
    transition: color .2s var(--ease), background .2s var(--ease);
  }
  .dock-tab .ui-icon { width: 1.45rem; height: 1.45rem; }
  .dock-tab[aria-current="true"] { color: var(--accent); background: var(--accent-soft); }
  body:has(.mobile-dock:not([hidden])) { padding-bottom: calc(4.6rem + env(safe-area-inset-bottom)); }
}

@media (max-width: 37rem) {
  .wrap { width: calc(100% - 2rem); }
  .top-bar { min-height: 3.4rem; }
  .mark { width: 2.1rem; height: 2.1rem; }
  .brand { font-size: 1rem; }
  .hero { grid-template-columns: minmax(0, 1fr); padding-block: 1.1rem .9rem; }
  .hero-art { display: none; }
  .hero-copy > p { font-size: .9375rem; }
  .steps { gap: .25rem; }
  .steps a { flex-direction: column; gap: .3rem; padding: .45rem .25rem; border-radius: var(--radius); text-align: center; font-size: .75rem; }
  .card { border-radius: 1.1rem; }
  #crop-station { margin-inline: -.5rem; padding-inline: .75rem; }
  .stage { height: min(64vh, 27rem); }
  .head-actions .button span { display: none; }
  .head-actions .button { padding-inline: .7rem; }
  .slider-grid, .editor-help { grid-template-columns: minmax(0, 1fr); }
  .tip[hidden] + .tip { grid-column: auto; }
  .advanced-row { grid-template-columns: minmax(0, 1fr); }
  .empty-actions { grid-template-columns: minmax(0, 1fr); }
  .empty-art { display: none; }
  .preview { height: 15rem; }
  #preview { max-height: 13rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
