:root {
  color-scheme: light;
  --paper-bg: #ffffff;
  --ink: #263238;
  --muted: #607d8b;
  --accent: #f59e0b;
  --accent-soft: #fff7ed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Pretendard', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: linear-gradient(135deg, #fef3c7 0%, #eefcf7 100%);
  color: var(--ink);
  padding: 20px;
}

.page-toolbar {
  max-width: 220mm;
  margin: 0 auto 18px;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.page-toolbar h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.page-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.unit-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}

.unit-picker select {
  border: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  outline: none;
}

.print-btn,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.print-btn {
  background: var(--accent);
  color: #111;
}

.secondary-link {
  background: #fff;
  color: var(--ink);
  border: 1px solid #e5e7eb;
}

#card-print-root {
  width: 100%;
  max-width: 220mm;
  margin: 0 auto;
}

.print-page {
  width: 210mm;
  height: 297mm;
  margin: 0 auto 10mm;
  padding: 7mm;
  background: var(--paper-bg);
  display: grid;
  grid-template-columns: repeat(2, 96.25mm);
  grid-template-rows: repeat(3, 92mm);
  gap: 3.5mm;
  page-break-after: always;
  position: relative;
}

.print-page::before {
  content: '';
  position: absolute;
  inset: 4mm;
  border: 1px dashed #94a3b8;
  pointer-events: none;
}

.card {
  overflow: hidden;
  background: white;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px dashed #cbd5e1;
  box-shadow: none;
  position: relative;
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid rgba(148, 163, 184, 0.35);
  pointer-events: none;
}

.card-front {
  background: #ffffff;
}

.card-back {
  background: #ffffff;
  padding: 4mm;
  justify-content: center;
}

.card-image-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #fff;
  min-height: 0;
}

.card-image-shell-with-label {
  flex-direction: column;
  gap: 2mm;
  padding: 2mm;
}

.card-image-shell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.card-image-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 10px;
}

.card-front-word {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
  line-height: 1.2;
  padding-bottom: 1mm;
}

.card-content {
  flex: 1;
  padding: 3mm;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.2mm;
}

.card-word {
  font-size: 15px;
  font-weight: 800;
  margin: 0;
  color: var(--ink);
  line-height: 1.2;
  text-align: center;
}

.card-meaning-en {
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--muted);
  margin: 0;
  text-align: center;
}

.card-example {
  margin: 0;
  font-size: 9.5px;
  line-height: 1.35;
  color: #374151;
  padding: 1.8mm 2.2mm;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
}

.card-example .label {
  display: block;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 1mm;
}

.empty-card {
  background: transparent;
}

@media print {
  body {
    background: white;
    padding: 0;
  }

  .page-toolbar {
    display: none !important;
  }

  .print-page {
    margin: 0;
    box-shadow: none;
    border: none;
    page-break-after: always;
  }
}
