:root {
  --bg: #fafafa;
  --card-bg: #ffffff;
  --border: #e2e2e2;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --accent: #d6249f;
  --accent-grad-start: #833ab4;
  --accent-grad-mid: #fd1d1d;
  --accent-grad-end: #fcb045;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 60px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard", "Apple SD Gothic Neo", Roboto, sans-serif;
  line-height: 1.55;
}

.lang-switch {
  max-width: 760px;
  margin: 20px auto 0;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.lang-btn {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.lang-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #fdf2f9;
  font-weight: 600;
}

.page-header {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 0 20px;
  text-align: center;
}

.page-header h1 {
  font-size: 1.6rem;
  margin: 0 0 8px;
  background: linear-gradient(90deg, var(--accent-grad-start), var(--accent-grad-mid), var(--accent-grad-end));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

main {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.card h2 {
  font-size: 1.05rem;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-grad-start), var(--accent-grad-mid));
  color: white;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

input[type="number"] {
  width: 90px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
}

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.stepper input[type="number"] {
  width: 56px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-radius: 0;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  padding: 8px 4px;
  /* hide native spinner arrows; we render our own +/- buttons */
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper input[type="number"]::-webkit-outer-spin-button,
.stepper input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.step-btn {
  border: none;
  background: var(--card-bg);
  color: var(--accent);
  width: 38px;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.step-btn:hover {
  background: #fdf2f9;
}

.step-btn:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  background: var(--card-bg);
}

.unit {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 8px 0 0;
}

#multipleWarning:empty { display: none; }
#multipleWarning {
  color: #b45309;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.85rem;
}

#rowBreakdownHint:empty { display: none; }

.preset-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.preset-option {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}

.preset-option:has(input:checked) {
  border-color: var(--accent);
  background: #fdf2f9;
}

.preset-option small {
  color: var(--text-muted);
}

.specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.spec-item {
  background: #f6f6f7;
  border-radius: 10px;
  padding: 10px 14px;
}

.spec-item .label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.spec-item .value {
  font-size: 1.05rem;
  font-weight: 600;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: #fdf2f9;
}

.dropzone img.preview-thumb {
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.preview-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 2px;
}

.toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn.active {
  background: linear-gradient(90deg, var(--accent-grad-start), var(--accent-grad-mid));
  color: #fff;
}

.unified-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 420px;
  margin: 10px 0 16px;
  transition: gap 0.4s ease, background 0.4s ease;
  border-radius: 10px;
  overflow: hidden;
}

.unified-preview.mode-grid {
  gap: 2px;
  background: #000;
}

.cell {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  aspect-ratio: var(--upload-ratio, 4 / 5);
  background: #f0f0f0;
  transition: border-radius 0.4s ease, aspect-ratio 0.4s ease;
}

.unified-preview.mode-grid .cell {
  border-radius: 0;
  aspect-ratio: 3 / 4;
}

.cell img.tile-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cell .badge-num {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  pointer-events: none;
}

.cell .dl-single-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.cell .dl-single-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

.filler-cell,
.empty-cell {
  aspect-ratio: var(--upload-ratio, 4 / 5);
  border-radius: 10px;
  transition: border-radius 0.4s ease, aspect-ratio 0.4s ease;
}

.unified-preview.mode-grid .filler-cell,
.unified-preview.mode-grid .empty-cell {
  border-radius: 0;
  aspect-ratio: 3 / 4;
}

.empty-cell {
  background: #f0f0f0;
}

.filler-cell {
  background: repeating-linear-gradient(45deg, #fff7ed, #fff7ed 6px, #ffedd5 6px, #ffedd5 12px);
  border: 1px dashed #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #b45309;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px;
  line-height: 1.2;
  white-space: pre-line;
}

.filler-note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.85rem;
  color: #92400e;
  margin-bottom: 16px;
  white-space: pre-line;
}

.download-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-grad-start), var(--accent-grad-mid), var(--accent-grad-end));
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-footer {
  max-width: 760px;
  margin: 30px auto 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}

.legal-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-footer .legal {
  margin: 0;
}

.meta-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-footer .contact {
  margin: 0;
  font-size: 0.78rem;
}

.page-footer .contact a {
  color: var(--accent);
  text-decoration: none;
}

.page-footer .contact a:hover {
  text-decoration: underline;
}

.page-footer .copyright {
  margin: 0;
  font-size: 0.75rem;
  color: #a0a0a0;
}
