:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #5b6470;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --border: #d5d9df;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15181c;
    --surface: #1f2328;
    --text: #e8eaed;
    --muted: #a3abb5;
    --accent: #6ea2f0;
    --accent-text: #0d1117;
    --danger: #f28b82;
    --border: #3a4049;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}

.page {
  max-width: 40rem;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

h1 { font-size: 1.5rem; margin: 0 0 4px; }

.lead, .hint { color: var(--muted); margin: 0; }

.picker {
  margin: 24px 0 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* The native input stays in the page (and keyboard reachable) but is drawn as the label button. */
.picker-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.picker-button {
  display: inline-block;
  min-height: 44px;
  padding: 10px 20px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.picker-button:hover { text-decoration: underline; }

.picker:focus-within .picker-button { outline: 3px solid var(--accent); outline-offset: 2px; }

.status { min-height: 1.5em; margin: 0 0 12px; }
.status[data-state="rejected"] { color: var(--danger); }

.spec { margin: 8px 0 0; font-weight: 600; }

.preview-area { display: flex; justify-content: center; }

/* The frame wraps the canvas exactly, so the crop region can be placed in % of the photo. */
.photo-frame {
  position: relative;
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden; /* clips the dimming shadow of the crop region */
  line-height: 0;
}

.photo-frame[hidden] { display: none; }

.preview {
  display: block;
  max-width: 100%;
  height: auto;
}

.preview[hidden] { display: none; }

/* Border box = the crop rectangle. The shadow dims the photo outside it. */
.crop-region {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #ffffff;
  outline: 1px solid rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  cursor: grab;
  touch-action: none; /* a touch on the region drags it instead of scrolling the page */
  -webkit-user-select: none;
  user-select: none;
}

.crop-region.dragging { cursor: grabbing; }

.crop-region[hidden] { display: none; }

.save {
  margin: 16px 0 0;
  text-align: center;
}

.save-button {
  min-height: 44px;
  padding: 10px 20px;
  margin-bottom: 8px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.save-button:hover:not(:disabled) { text-decoration: underline; }
.save-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.save-button:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
