/* =========================================================
   FlexiSpine — 기본 스타일
   방향: 아침 산책처럼 편안하고 깔끔하게.
   평평한 흰 면 + 잎새 초록 1가지 + 준비 신호용 햇살 노랑.
   그라데이션·네온·유리 효과 없이, 큰 글씨와 넉넉한 터치 영역.
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- 색·글꼴·간격 토큰 (라이트) ---------- */
:root {
  --bg: #F3F6F4;
  --surface: #FFFFFF;
  --surface-2: #EEF3F0;
  --line: #DFE7E2;
  --ink: #1D2B25;
  --muted: #5C6B64;

  --leaf: #2B8564;          /* 주요 색: 버튼, 선택, 진행 */
  --leaf-ink: #1F6B4F;      /* 연한 배경 위 초록 글씨 */
  --leaf-soft: #E2F1EA;
  --on-leaf: #FFFFFF;

  --sun: #EFA23A;           /* 준비 카운트다운, 식단 강조 */
  --sun-ink: #9A5A06;
  --sun-soft: #FCEFD9;

  --rose: #C9445B;
  --rose-soft: #FBE7EA;

  --radius-lg: 22px;        /* 큰 면(카드) */
  --radius-md: 14px;        /* 버튼 */
  --radius-sm: 10px;        /* 칩 */

  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;

  --nav-h: 64px;
  --page-pad: 20px;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  /* 예전 이름 호환 (남아 있는 인라인 스타일용) */
  --text-main: var(--ink);
  --text-muted: var(--muted);
  --primary-color: var(--leaf);
  --panel-border: var(--line);
}

/* ---------- 다크 모드 ---------- */
:root[data-theme="dark"] {
  --bg: #121816;
  --surface: #1B2320;
  --surface-2: #222C28;
  --line: #2C3833;
  --ink: #E6EEEA;
  --muted: #9AABA3;

  --leaf: #5CC79B;
  --leaf-ink: #7DD9B1;
  --leaf-soft: rgba(92, 199, 155, 0.14);
  --on-leaf: #0E1D16;

  --sun: #F2B85C;
  --sun-ink: #F5C67A;
  --sun-soft: rgba(242, 184, 92, 0.15);

  --rose: #F08497;
  --rose-soft: rgba(240, 132, 151, 0.12);
}

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

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: break-word;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--leaf);
  outline-offset: 2px;
  border-radius: 6px;
}

.icon {
  width: 24px;
  height: 24px;
  display: block;
  fill: currentColor;
  flex-shrink: 0;
}

/* ---------- 앱 틀 ---------- */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 var(--page-pad) calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px);
}

.tab-content {
  animation: view-in 0.25s var(--ease);
}

@keyframes view-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- 화면 제목 ---------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 28px 0 18px;
}

.brand {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--leaf-ink);
  margin-bottom: 6px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.page-sub {
  margin-top: 4px;
  font-size: 0.92rem;
  color: var(--muted);
}

/* ---------- 버튼 ---------- */
.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 52px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  transition: background-color 0.15s, color 0.15s, transform 0.1s;
}

.control-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.primary-btn {
  background: var(--leaf);
  color: var(--on-leaf);
}

.primary-btn:hover {
  filter: brightness(1.05);
}

.secondary-btn {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary-btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.secondary-btn:disabled {
  color: var(--muted);
  opacity: 0.45;
  cursor: default;
}

.secondary-btn .icon {
  width: 20px;
  height: 20px;
}

.btn-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--surface-2);
}

.btn-icon .icon,
.icon-theme {
  width: 22px;
  height: 22px;
}

/* 재생/일시정지 아이콘 */
.play-icon {
  display: inline-block;
  flex-shrink: 0;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid currentColor;
  margin-right: 2px;
}

.pause-icon {
  display: inline-block;
  flex-shrink: 0;
  width: 12px;
  height: 14px;
  background: linear-gradient(to right, currentColor 0 4px, transparent 4px 8px, currentColor 8px 12px);
  margin-right: 2px;
}

/* 글자 버튼 (처음으로, 효과음) */
.settings-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--muted);
}

.settings-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.settings-btn.active {
  color: var(--leaf-ink);
}

.settings-btn .icon {
  width: 18px;
  height: 18px;
}

/* ---------- 하단 탭 ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.nav-items {
  display: flex;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
}

.nav-icon {
  width: 26px;
  height: 26px;
  padding: 2px 0;
  fill: currentColor;
  box-sizing: content-box;
  border-radius: 999px;
  transition: background-color 0.2s, width 0.2s;
}

.nav-item span {
  font-size: 0.78rem;
  font-weight: 600;
}

.nav-item.active {
  color: var(--leaf-ink);
}

.nav-item.active .nav-icon {
  width: 26px;
  padding: 2px 16px;
  background: var(--leaf-soft);
}

/* ---------- 모달 (휴대폰에서는 아래에서 올라오는 시트) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 24, 20, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(16, 24, 20, 0.18);
  transform: translateY(16px);
  transition: transform 0.25s var(--ease);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-header .btn-icon {
  border: none;
  background: var(--surface-2);
  width: 40px;
  height: 40px;
}

@media (max-width: 520px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content {
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
