/* ── 애플스타일 기반 ── */
:root {
  --bg: #f5f5f7;
  --surface: #fff;
  --elev: #fbfbfd;
  --hover: #f0f0f3;
  --separator: rgba(60,60,67,0.12);
  --separator-strong: rgba(60,60,67,0.24);
  --text: #1d1d1f;
  --text-sec: #6e6e73;
  --text-ter: #86868b;
  --accent: #007aff;
  --accent-hov: #0969da;
  --accent-soft: rgba(0,122,255,0.10);
  /* 견출지 배색 (사진 참고) */
  --label-orange: #c94f00;
  --label-red: #b03a3a;
  --label-text: #3a2a22;
  --label-border: #c94f00;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Pretendard', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  letter-spacing: -0.01em;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.app-header {
  background: rgba(255,255,255,0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--separator);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; }
.logo { font-size: 1.4rem; }

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

/* 업로드 */
.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 16px;
  border: 1.5px dashed var(--separator-strong);
  border-radius: var(--radius);
  background: var(--elev);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-align: center;
}
.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-icon { font-size: 2rem; margin-bottom: 8px; opacity: 0.8; }
.upload-zone p { font-size: 0.92rem; }
.upload-zone p.sub { color: var(--text-sec); font-size: 0.82rem; margin-top: 4px; }

.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.option-row label { color: var(--text-sec); font-weight: 500; font-size: 0.88rem; }
select {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  font: inherit;
}
.hint {
  font-size: 0.78rem;
  color: var(--text-ter);
  margin-top: 6px;
}
.hint code {
  background: var(--hover);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.85em;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
  flex-wrap: wrap;
}
.preview-header h2 { margin: 0; display: flex; align-items: center; gap: 10px; }
.count-badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
}
.actions { display: flex; gap: 6px; }

.primary-btn {
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s var(--ease);
}
.primary-btn:hover { background: var(--accent-hov); }
.ghost-btn {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
}
.ghost-btn:hover { background: var(--hover); }

/* ══ 견출지 그리드 ══ */
.labels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74mm, 1fr));
  justify-items: center;
  gap: 4mm;
}

/* ══ 견출지 (사진 참고, 실제 규격 70mm × 40mm) ══ */
.label {
  position: relative;
  width: 70mm;
  height: 40mm;
  max-width: 100%;
  background: #fff;
  border: 1.5px solid #000;
  border-radius: 2px;
  padding: 2mm 3mm 7mm;   /* 하단 푸터 공간 여유 있게 */
  display: flex;
  flex-direction: column;
  gap: 0;
  color: var(--label-text);
  font-family: 'Nanum Gothic', 'Malgun Gothic', sans-serif;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.label-date {
  color: #000;
  font-weight: 800;
  font-size: 3.8mm;
  letter-spacing: 0.05em;
  line-height: 1.1;
  padding-bottom: 1mm;
  margin-bottom: 1mm;
}
.label-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 2px;
}
/* 썸네일이 이제 사이즈/마감 행 옆(오른쪽 4번째 컬럼)에 있어서 상단 공간 확보 불필요 */
.label-name {
  font-weight: 700;
  font-size: 4.2mm;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  font-family: inherit;
}
.nim { color: var(--label-text); font-weight: 500; font-size: 3mm; }

.label-grid {
  display: grid;
  grid-template-columns: 12mm 1fr 8mm 14mm;
  grid-template-rows: 1fr 1fr;
  flex: 1;
  min-height: 0;
}
.label-cell {
  display: flex;
  align-items: center;
  gap: 2mm;
  font-size: 3mm;
  padding: 0.5mm 2mm;
}
.label-type       { grid-column: 1; grid-row: 1; }
.label-size       { grid-column: 2; grid-row: 1; }
.label-total      { grid-column: 3; grid-row: 1; justify-content: flex-start; padding: 0.5mm 1mm; }
.label-finish-label { grid-column: 1; grid-row: 2; }
.label-count      { grid-column: 2; grid-row: 2; }
.label-thumb      {
  grid-column: 4;
  grid-row: 1 / 3;                     /* 두 행 걸침 */
  width: 13mm;
  height: 13mm;
  object-fit: cover;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 2px;
  position: static;
  align-self: center;                  /* 세로 가운데 */
  justify-self: center;                /* 가로 가운데 */
}
.label-cell input {
  background: transparent;
  border: none;
  outline: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  width: 100%;
  min-width: 0;
}
.label-cell.label-type,
.label-cell.label-finish-label {
  justify-content: flex-start;
  font-weight: 500;
}
.label-cell.label-size {
  font-weight: 600;
  gap: 4px;
}
.folder-total {
  font-size: 3.6mm;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
}
.label-cell.label-count {
  font-weight: 600;
}

.label-footer {
  position: absolute;
  bottom: 1.5mm; left: 2mm; right: 2mm;
  text-align: center;
  font-size: 2.2mm;
  color: #000;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  padding-top: 1mm;
  border-top: 1px solid #000;   /* 영어 위에 한 줄만 */
}
/* 썸네일은 이제 그리드 내부에 배치 — 기존 absolute 룰 제거 */

/* 인쇄 — 불필요 UI 숨기고 라벨만 */
@media print {
  @page { margin: 10mm; }
  body { background: #fff; }
  .app-header, .card:not(#previewCard), .preview-header .actions, .upload-zone, .option-row, .hint, button { display: none !important; }
  .main { padding: 0 !important; max-width: none !important; }
  #previewCard { border: none; box-shadow: none; padding: 0; }
  .labels-grid { grid-template-columns: repeat(3, 1fr); gap: 3mm; }
  .label { break-inside: avoid; }
  .preview-header h2 { display: none; }
}

/* 모바일 */
@media (max-width: 540px) {
  .labels-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}
