/* ============================================================
   문장 암기장 — Apple(HIG 웹 레퍼런스) 리디자인
   fog canvas(#f5f5f7) + 화이트 서피스, Apple 블루 액션(#0071e3),
   필(pill) 버튼, 플랫한 깊이감. 콘텐츠가 주인공.
   폰트: SF Pro(애플 기기) / Pretendard(그 외, 한글)
   ============================================================ */

:root {
  /* 뉴트럴 — Apple 웹 팔레트 (fog canvas / white surface) */
  --bg: #f5f5f7;
  --bg-2: #ececee;
  --surface: #ffffff;
  --ink: #1d1d1f;
  --ink-soft: #515154;
  --ink-mute: #86868b;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;

  /* 액센트 — Apple 블루 (채움 #0071e3 / 텍스트·아웃라인 #0066cc) */
  --accent: #0071e3;
  --accent-deep: #0066cc;
  --accent-2: #0071e3;
  --accent-ink: #0066cc;
  --accent-soft: #eaf2fb;
  --accent-mark: #d8e9fa;          /* 형광펜 톤 */
  --accent-grad: #0071e3;          /* 플랫 — 그라데이션 없음 */

  --dark-grad: #1d1d1f;            /* 플랫 블랙 */

  --ok: #008a5c;
  --ok-soft: #e6f6ef;
  --bad: #e30000;
  --bad-soft: #fdecec;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-pill: 980px;
  --tabbar-h: 88px;              /* 플로팅 탭바 + 하단 여백 */

  /* Apple 모션 커브 */
  --ease: cubic-bezier(0.28, 0.11, 0.32, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-pop: 0 4px 12px rgba(0, 0, 0, 0.08), 0 20px 44px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  /* 모든 기기에서 Pretendard로 통일 (SF/Apple SD Gothic Neo 대체 폰트) */
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Helvetica Neue", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.011em;
}

/* Apple 스타일 — 배경 장식 레이어 없음, 콘텐츠가 주인공 */

/* ---------- 헤더 — apple.com 글래스 내비게이션 ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(245, 245, 247, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.app-header h1 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.022em;
}
#chapterSelect {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 26px 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-pill);
  appearance: none;
  -webkit-appearance: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2386868b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 10px center / 12px 12px,
    rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--ink);
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
#chapterSelect:focus { outline: none; border-color: var(--accent); }

/* ---------- 탭 패널 ---------- */
main { padding: 10px 18px 18px; }
.tab-panel { display: none; }
.tab-panel.is-active {
  display: block;
  animation: panelIn 0.38s var(--ease);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 카드 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.label + .label { margin-top: 22px; }
.hint { font-weight: 500; text-transform: none; color: var(--ink-mute); letter-spacing: 0; }

.ko-sentence {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: -0.028em;
  margin-bottom: 12px;
  word-break: keep-all;
}

/* 진행 카운터 — 한글 문장 끝에 인라인으로 */
.ko-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-mute);
  margin-left: 6px;
  white-space: nowrap;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.en-sentence {
  font-size: 17px;
  line-height: 1.65;
  font-weight: 500;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(0, 113, 227, 0.06);
  white-space: pre-wrap;
}
.en-sentence:active { background: var(--accent-soft); }

/* 핵심표현 — 하이라이터 */
.key-expr {
  color: var(--accent-ink);
  font-weight: 700;
  background: linear-gradient(180deg, transparent 56%, var(--accent-mark) 56%);
}
.blank {
  display: inline-block;
  min-width: 90px;
  border-bottom: 2px solid var(--accent);
  color: transparent;
  user-select: none;
}
.blank.is-revealed { color: var(--accent-ink); font-weight: 700; }

/* ---------- 빈칸 입력 ---------- */
.blank-inputs { margin-top: 12px; display: grid; gap: 8px; }
.blank-inputs input {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  width: 100%;
  background: var(--surface);
}
.blank-inputs input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.blank-inputs input.is-correct { border-color: var(--ok); background: var(--ok-soft); }
.blank-inputs input.is-wrong { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- 버튼 ---------- */
.btn-row { display: flex; gap: 8px; margin-top: 18px; }
.btn {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  letter-spacing: -0.015em;
  transition: transform 0.3s var(--spring), opacity 0.18s var(--ease),
    filter 0.18s var(--ease), background 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
}
.btn-primary:active { filter: brightness(0.92); }
/* iOS 틴티드 버튼 (systemBlue 12%) */
.btn-ghost {
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent);
  border: none;
}
.btn-ghost:active { background: rgba(0, 113, 227, 0.18); }
/* SF 셰브런 */
.chev {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.btn-next {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  padding: 13px 16px;
  border-radius: var(--radius-pill);
  font-weight: 500;
}
.btn-dark {
  background: var(--accent);
  color: #fff;
}

/* 이전 / 정답 보기 / 다음 — 동일 폭 3버튼 */
.nav-row { margin-top: 10px; }
.nav-row .btn {
  flex: 1;
  padding: 12px 6px;
  font-size: 14px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

/* ---------- 피드백 / 답안 ---------- */
.feedback { margin-top: 8px; font-size: 14px; font-weight: 600; min-height: 1.2em; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--bad); }

/* 표현 노트 — 책 해설 요지 */
.note-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: keep-all;
  animation: panelIn 0.3s var(--ease);
}
.note-box::before {
  content: "💡 표현 노트";
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 5px;
}

.answer-box {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.is-hidden { display: none; }

textarea {
  font: inherit;
  font-size: 16px;
  width: 100%;
  padding: 15px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  resize: vertical;
  line-height: 1.65;
  background: var(--surface);
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.diary-output {
  font-size: 17px;
  line-height: 1.85;
  white-space: pre-wrap;
  font-weight: 500;
}
/* 생성된 일기 속 빨모쌤 표현 — 하이라이터 */
.diary-key {
  color: var(--accent-ink);
  font-weight: 700;
  background: linear-gradient(180deg, transparent 56%, var(--accent-mark) 56%);
  padding: 0 1px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 6px 12px;
  border-radius: 999px;
}

/* 사용된 표현 + 해설 카드 */
.used-list { display: flex; flex-direction: column; gap: 10px; }
.used-item {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 14px 15px;
}
.used-item .u-chapter {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin-bottom: 5px;
}
.used-item .u-expr {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-ink);
  letter-spacing: -0.01em;
  margin-bottom: 5px;
}
.used-item .u-note {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
}

/* 텍스트 버튼 (삭제) */
.btn-text-danger {
  display: block;
  margin: 18px auto 2px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-mute);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.15s ease;
}
.btn-text-danger:hover { color: var(--bad); }

/* ---------- 일기 날짜 바 + 커스텀 캘린더 ---------- */
.diary-datebar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.date-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  letter-spacing: 0;
}
.date-btn:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.date-caret { font-size: 10px; color: var(--ink-mute); }

.diary-saved {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 999px;
}
.diary-saved:empty { display: none; }

/* 캘린더 팝업 */
.cal-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 40;
  width: 296px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 14px;
}
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-title {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.cal-nav {
  width: 30px;
  height: 30px;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  cursor: pointer;
}
.cal-nav:active { background: var(--bg-2); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-w {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-mute);
  text-align: center;
  padding: 5px 0 6px;
  letter-spacing: 0.04em;
}
.cal-d {
  position: relative;
  z-index: 0;
  aspect-ratio: 1;
  border: none;
  background: none;
  border-radius: 9px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cal-d:hover { background: var(--bg); }
.cal-d.is-today { box-shadow: inset 0 0 0 1.5px var(--line); }
/* 기록 있는 날 — 형광펜 스와이프 */
.cal-d.has-entry::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 18%;
  height: 36%;
  background: var(--accent-mark);
  border-radius: 3px;
  transform: rotate(-2deg);
  z-index: -1;
}
.cal-d.is-selected {
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}
.cal-legend {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
}
.cal-legend-mark {
  width: 16px;
  height: 8px;
  background: var(--accent-mark);
  border-radius: 3px;
  transform: rotate(-2deg);
}

/* ---------- 하단 탭 바 ---------- */
/* Liquid Glass 플로팅 탭바 — 컨트롤 레이어만 유리, 콘텐츠는 불투명 */
.tab-bar {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 36px);
  max-width: 440px;
  height: 62px;
  padding: 5px;
  display: flex;
  gap: 2px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);   /* 스페큘러 하이라이트 */
}
.tab-btn {
  flex: 1;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  background: none;
  border: none;
  border-radius: var(--radius-pill);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  letter-spacing: -0.01em;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
  transition: color 0.15s ease;
}
.tab-btn.is-active {
  color: var(--accent);
  font-weight: 600;
  background: rgba(0, 113, 227, 0.1);      /* iOS 26 선택 로젠지 */
}
.tab-ico {
  width: 21px;
  height: 21px;
  display: block;
  stroke-width: 1.7;
  transition: transform 0.4s var(--spring);
}
.tab-btn.is-active .tab-ico { transform: scale(1.08) translateY(-1px); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   모드 토글 / 단어 카드 / 빈칸 슬롯
   ============================================================ */

/* iOS 세그먼티드 컨트롤 */
.mode-toggle {
  display: flex;
  gap: 2px;
  background: rgba(120, 120, 128, 0.12);
  border-radius: var(--radius-pill);
  padding: 2.5px;
  margin-bottom: 10px;
}
.mode-btn {
  flex: 1;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  letter-spacing: -0.015em;
  transition: background 0.25s var(--ease), color 0.25s var(--ease),
    box-shadow 0.25s var(--ease), transform 0.25s var(--spring);
}
.mode-btn:active { transform: scale(0.97); }
.mode-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04);
}

/* 빈칸 슬롯 */
.blank-zone { white-space: normal; }
.slot {
  display: inline-block;
  min-width: 34px;
  text-align: center;
  margin: 0 1px;
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}
.slot.is-empty {
  color: transparent;
  background: var(--accent-soft);
  border-radius: 6px 6px 0 0;
}
.slot.is-filled { color: var(--ink); cursor: pointer; }
.slot.is-answer { color: var(--accent-ink); }

/* 단어 카드 뱅크 */
.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}
.word-chip {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  padding: 9px 13px;
  background: var(--surface);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  letter-spacing: -0.015em;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: transform 0.3s var(--spring), opacity 0.16s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.word-chip:active { transform: scale(0.94); }
.word-chip.is-used {
  opacity: 0.26;
  box-shadow: none;
}

/* 정답보기 텍스트 버튼 / 진행 표시 */
.btn-text {
  display: block;
  margin: 14px auto 0;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.progress-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
