:root {
  --bg: #0f172a;
  --fg: #f8fafc;
  --accent: #38bdf8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px;
}

h1 { text-align: center; font-size: 1.4rem; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 8px 0 16px; }

.hidden { display: none !important; }

#home-stats { text-align: center; opacity: 0.7; margin: 0 0 28px; }

.home-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-btn {
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  border: none;
  padding: 16px;
  cursor: pointer;
  background: var(--accent);
  color: #0f172a;
}

.nav-btn-secondary {
  background: #1e293b;
  color: var(--fg);
  border: 1px solid #334155;
}

.back-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  padding: 4px 0;
  margin-bottom: 4px;
  cursor: pointer;
}

#add-status {
  text-align: center;
  color: var(--accent);
  min-height: 1.2em;
}

#add-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

#add-form textarea,
#add-form select,
#add-form button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: var(--fg);
  padding: 10px;
}

#add-form button {
  background: var(--accent);
  color: #0f172a;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

#produce-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sentence-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #1e293b;
  border-radius: 8px;
  padding: 10px 12px;
}

.sentence-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sentence-text { flex: 1; text-align: left; min-width: 0; }
.sentence-tag {
  font-size: 0.75rem;
  opacity: 0.7;
  white-space: nowrap;
}

.play-btn,
.delete-btn {
  background: none;
  border: 1px solid #475569;
  color: var(--fg);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.play-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.translation-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.translation-row textarea { flex: 1; }

.secondary-btn {
  font: inherit;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: var(--fg);
  padding: 10px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.secondary-btn:disabled { opacity: 0.6; cursor: default; }

.produce-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #1e293b;
  border-radius: 8px;
  padding: 14px;
}

.produce-prompt {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}

.produce-hint {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.85;
}

.hint-tag {
  background: #fde047;
  color: #422006;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 2px 6px;
  margin-right: 4px;
}

.produce-answer {
  font-size: 1rem;
  color: var(--accent);
  border-top: 1px solid #334155;
  padding-top: 10px;
}

.produce-item .secondary-btn,
.produce-item .play-btn {
  align-self: flex-start;
}

.streak-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1e293b;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.streak-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.streak-stat-value { font-size: 1.3rem; font-weight: 700; }
.streak-stat-label { font-size: 0.7rem; opacity: 0.7; }

.streak-fire {
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.calendar-nav .secondary-btn { padding: 4px 12px; }
#cal-month-label { font-weight: 600; min-width: 6em; text-align: center; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.6;
  margin-bottom: 4px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 24px;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.85rem;
  background: #1e293b;
}

.cal-cell-empty { background: none; }
.cal-cell-today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-cell-hit { background: #164e63; font-size: 1.1rem; }

.sentence-count-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.count-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #1e293b;
  border-radius: 10px;
  padding: 12px 8px;
}

.count-value { font-size: 1.2rem; font-weight: 700; color: var(--accent); }
.count-label { font-size: 0.7rem; opacity: 0.7; text-align: center; }

.review-row {
  display: flex;
  gap: 8px;
  border-top: 1px solid #334155;
  padding-top: 8px;
}

.review-btn {
  flex: 1;
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  padding: 10px;
  cursor: pointer;
}

.review-again { background: #7f1d1d; color: #fecaca; }
.review-good { background: #14532d; color: #bbf7d0; }

.shadow-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #0f172a;
  border-radius: 8px;
  padding: 10px;
}

.waveform-canvas {
  width: 100%;
  height: 60px;
  background: #1e293b;
  border-radius: 6px;
}

.shadow-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shadow-status {
  font-size: 0.75rem;
  opacity: 0.7;
}

.pronounce-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.pronounce-position {
  font-size: 0.8rem;
  opacity: 0.6;
}

.pronounce-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #1e293b;
  border-radius: 14px;
  padding: 20px;
}

.pronounce-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pronounce-text {
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.4;
  margin: 0;
}

.pronounce-translation {
  text-align: center;
  opacity: 0.7;
  margin: -8px 0 0;
}

.pronounce-nav {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.pronounce-nav .secondary-btn { flex: 1; }

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.badge-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.7rem;
}

.badge-earned {
  background: #422006;
  color: #fde68a;
  border: 1px solid #92400e;
}

.badge-locked {
  background: #1e293b;
  color: #64748b;
  border: 1px solid #334155;
}

.badge-icon { font-size: 0.9rem; }

.badge-toast {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: #422006;
  color: #fde68a;
  border: 1px solid #92400e;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 600;
  transition: top 0.3s ease;
  z-index: 100;
  white-space: nowrap;
}

.badge-toast-show { top: 16px; }

/* Phase 5.5 — 배경/마스코트 커스터마이징 */
#bg-photo-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center bottom; /* 캐릭터를 하단 배치로 디자인할 예정 — cover로 잘려도 하단 기준 고정 */
  background-attachment: fixed;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.home-header h1 { margin: 0; flex: 1; }

.icon-btn {
  font: inherit;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: var(--fg);
  padding: 6px 10px;
  cursor: pointer;
}

.settings-block {
  background: #1e293b;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.settings-block h3 { margin: 0 0 6px; font-size: 1rem; }
.settings-hint { font-size: 0.8rem; opacity: 0.7; margin: 0 0 12px; }
.settings-status { font-size: 0.8rem; color: var(--accent); min-height: 1.2em; margin: 8px 0 0; }

.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.file-label { display: inline-flex; align-items: center; }

.bg-preview {
  width: 100%;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  font-size: 0.8rem;
  opacity: 0.6;
}
.bg-preview img { width: 100%; height: 100%; object-fit: cover; }

.mascot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.mascot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border-radius: 10px;
  padding: 10px;
}
.mascot-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}
.mascot-preview img { width: 100%; height: 100%; object-fit: cover; }
.mascot-card .settings-actions { flex-direction: column; width: 100%; }
.mascot-card .secondary-btn { width: 100%; text-align: center; padding: 6px 8px; font-size: 0.75rem; }

.cal-mascot-img { width: 70%; height: 70%; object-fit: cover; border-radius: 50%; }

.bulk-add-block { margin-top: 4px; margin-bottom: 24px; }
.bulk-add-block > .secondary-btn { width: 100%; margin-bottom: 8px; }
#bulk-add-panel { display: flex; flex-direction: column; gap: 8px; }
#bulk-text {
  font: inherit;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: var(--fg);
  padding: 10px;
  resize: vertical;
}

/* 배경사진이 설정된 동안엔 카드들을 반투명 유리질감으로 바꿔 캐릭터/사진이 레이아웃에 가리지 않게 함. */
body.has-bg-photo .streak-header,
body.has-bg-photo .count-card,
body.has-bg-photo .cal-cell:not(.cal-cell-empty),
body.has-bg-photo .sentence-item,
body.has-bg-photo .produce-item,
body.has-bg-photo .pronounce-card,
body.has-bg-photo .settings-block,
body.has-bg-photo .mascot-card,
body.has-bg-photo .shadow-panel,
body.has-bg-photo .bg-preview,
body.has-bg-photo .nav-btn-secondary,
body.has-bg-photo #add-form textarea,
body.has-bg-photo #add-form select,
body.has-bg-photo #bulk-text {
  background: rgba(30, 41, 59, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.has-bg-photo .cal-cell-hit { background: rgba(22, 78, 99, 0.6); }
body.has-bg-photo .waveform-canvas { background: rgba(30, 41, 59, 0.55); }
