/* ===================================================
   WordRoots — Main Stylesheet
   =================================================== */

/* ── Variables ── */
:root {
  --bg:          #0d0e14;
  --bg2:         #13151f;
  --bg3:         #1a1d2b;
  --card:        #1e2130;
  --card-hover:  #252840;
  --border:      rgba(255,255,255,0.07);
  --border2:     rgba(255,255,255,0.12);

  --accent:      #7c6ff7;
  --accent2:     #a78bfa;
  --accent3:     #c4b5fd;
  --accent-glow: rgba(124,111,247,0.35);

  --gold:        #f59e0b;
  --gold2:       #fcd34d;
  --teal:        #2dd4bf;
  --rose:        #fb7185;
  --green:       #4ade80;

  --text-1:      #f1f2f8;
  --text-2:      #9da3be;
  --text-3:      #6b7280;

  --radius:      16px;
  --radius-sm:   10px;
  --shadow:      0 8px 32px rgba(0,0,0,0.45);
  --shadow-sm:   0 4px 16px rgba(0,0,0,0.3);

  --font:        'Inter', sans-serif;
  --font-serif:  'Playfair Display', serif;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,14,20,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.3rem; color: var(--text-1);
  text-decoration: none;
}
.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}
.logo-text { font-weight: 400; }
.logo-text strong { font-weight: 800; color: var(--accent2); }

.header-nav { display: flex; gap: 8px; }

.nav-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 40px;
  color: var(--text-2);
  font-size: 0.875rem; font-family: var(--font); font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}
.nav-btn:hover { background: var(--card); color: var(--text-1); }
.nav-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}

.badge {
  background: var(--rose);
  color: #fff;
  font-size: 0.7rem; font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 20px; text-align: center;
}
.nav-btn.active .badge { background: rgba(255,255,255,0.3); }

/* ── Main Layout ── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.main.hidden { display: none; }

/* ── Hero ── */
.hero {
  text-align: center;
  padding: 60px 0 48px;
}
.hero-subtitle {
  font-size: 0.875rem; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 16px;
}
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-1);
  margin-bottom: 40px;
}
.hero-title em {
  font-style: italic;
  color: var(--accent2);
}

/* ── Search Box ── */
.search-wrap { max-width: 720px; margin: 0 auto; }

.search-box {
  display: flex; align-items: center;
  background: var(--card);
  border: 1.5px solid var(--border2);
  border-radius: 60px;
  padding: 6px 6px 6px 24px;
  gap: 12px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow);
}

.search-icon { color: var(--text-3); font-size: 1rem; flex-shrink: 0; }

.search-input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--text-1);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 400;
}
.search-input::placeholder { color: var(--text-3); }

.search-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 40px;
  color: #fff;
  font-family: var(--font); font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.search-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px var(--accent-glow);
}
.search-btn:active { transform: translateY(0); }

.quick-words {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 16px;
  justify-content: center;
}
.quick-label { font-size: 0.8rem; color: var(--text-3); font-weight: 500; }
.quick-tag {
  padding: 5px 14px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 20px;
  color: var(--text-2);
  font-size: 0.8rem; font-family: var(--font); font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.quick-tag:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transform: translateY(-1px);
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}
.card-title {
  font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--accent2);
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.card-title i { font-size: 0.9rem; }

/* ── Result Section ── */
.result-section { margin-top: 20px; }
.result-container { display: flex; flex-direction: column; gap: 20px; }

/* ── Word Header Card ── */
.word-header-card {
  background: linear-gradient(135deg, #1e2130 0%, #1a1d35 100%);
  border-color: rgba(124,111,247,0.25);
  display: flex; gap: 32px; align-items: flex-start;
  flex-wrap: wrap;
}
.word-header-left { flex: 1; min-width: 200px; }
.word-header-right { flex: 1; min-width: 200px; }

.word-main {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 600;
  color: var(--text-1);
  line-height: 1.1;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff 0%, var(--accent3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.word-phonetic {
  font-size: 1rem; color: var(--text-3);
  font-weight: 400;
  font-style: italic;
}
.word-pos-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

/* ── 사전 정의 카드 (API posMap) ── */
.pos-details-card {
  background: linear-gradient(135deg, #151820 0%, #1a1d2b 100%);
  border-color: rgba(74, 222, 128, 0.2);
}

.dict-source-badge {
  background: rgba(74, 222, 128, 0.12);
  border: 1px solid rgba(74, 222, 128, 0.3);
  color: var(--green);
  font-size: 0.68rem; font-weight: 700;
  padding: 2px 10px; border-radius: 20px;
  margin-left: 8px;
  text-transform: none; letter-spacing: 0;
}

.pos-details-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pos-detail-group { }

/* 한국어 번호 정의 리스트 */
.def-list-ko {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
  counter-reset: def-counter;
}
.def-ko-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  counter-increment: def-counter;
}
.def-ko-item::before {
  content: counter(def-counter);
  min-width: 22px; height: 22px;
  background: rgba(139,92,246,0.18);
  border: 1px solid rgba(139,92,246,0.35);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  color: var(--accent2);
  flex-shrink: 0;
  margin-top: 1px;
}
.def-ko-text {
  font-size: 0.97rem;
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.7;
}
.def-ko-text.translating {
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.88rem;
}

/* 번역 로딩 스피너 */
.translate-spinner {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid rgba(139,92,246,0.25);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* 품사 그룹 헤더 */
.pos-group-header {
  margin-bottom: 10px;
}

/* 이전 호환용 (혹시 남아있는 경우) */
.def-list {
  list-style: none;
  padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 7px;
}
.def-list li {
  font-size: 0.92rem;
  color: var(--text-2);
  line-height: 1.65;
  padding-left: 18px;
  position: relative;
}
.def-list li::before {
  content: '›';
  position: absolute; left: 0;
  color: var(--green);
  font-weight: 700; font-size: 1rem;
}

/* 의미 한국어/영어 분리 표시 */
.meaning-ko {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.55;
  margin-bottom: 6px;
}
/* 로컬 한국어 없을 때 영어를 메인 위치에 표시 */
.meaning-ko.meaning-en-only {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-1);
}
.meaning-en-sub {
  display: block;
  font-size: 0.83rem;
  color: var(--text-3);
  line-height: 1.5;
  font-style: italic;
  padding-left: 2px;
  border-left: 2px solid rgba(139,92,246,0.35);
  padding-left: 8px;
  margin-top: 2px;
}



/* ── 발음 버튼 행 ── */
.phonetic-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

/* TTS 버튼 묶음 */
.tts-btns {
  display: flex;
  gap: 7px;
  align-items: center;
}

/* 개별 TTS 버튼 */
.tts-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px 5px 10px;
  border-radius: 30px;
  border: 1.5px solid var(--border2);
  background: var(--bg3);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.02em;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.tts-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s;
  border-radius: 30px;
}

/* 미국식 — 파란 계열 */
.tts-us { border-color: rgba(96, 165, 250, 0.35); }
.tts-us::before { background: rgba(96, 165, 250, 0.12); }
.tts-us:hover {
  border-color: #60a5fa;
  color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(96, 165, 250, 0.25);
}
.tts-us:hover::before { opacity: 1; }

/* 영국식 — 빨간 계열 */
.tts-uk { border-color: rgba(251, 113, 133, 0.35); }
.tts-uk::before { background: rgba(251, 113, 133, 0.12); }
.tts-uk:hover {
  border-color: #fb7185;
  color: #fda4af;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(251, 113, 133, 0.25);
}
.tts-uk:hover::before { opacity: 1; }

/* 재생 중 상태 */
.tts-btn.tts-playing {
  animation: tts-pulse 0.9s ease-in-out infinite;
}
.tts-us.tts-playing {
  border-color: #60a5fa;
  color: #93c5fd;
  background: rgba(96, 165, 250, 0.15);
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.35);
}
.tts-uk.tts-playing {
  border-color: #fb7185;
  color: #fda4af;
  background: rgba(251, 113, 133, 0.15);
  box-shadow: 0 0 16px rgba(251, 113, 133, 0.35);
}

@keyframes tts-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.04); opacity: 0.85; }
}

/* 아이콘 재생 중 진동 */
.tts-btn.tts-playing .tts-icon {
  animation: tts-wave 0.6s ease-in-out infinite alternate;
}
@keyframes tts-wave {
  from { transform: scaleX(1);   }
  to   { transform: scaleX(1.3); }
}

.tts-flag  { font-size: 1rem; line-height: 1; }
.tts-label { font-size: 0.75rem; font-weight: 700; }
.tts-icon  { font-size: 0.78rem; transition: transform 0.15s; }

/* 미지원 브라우저 알림 */
.tts-unsupported {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-3);
  padding: 5px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 20px;
}
.tts-unsupported i { color: var(--gold); }
.pos-tag {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.pos-noun    { background: rgba(45,212,191,0.15); color: var(--teal); border: 1px solid rgba(45,212,191,0.3); }
.pos-verb    { background: rgba(251,113,133,0.15); color: var(--rose); border: 1px solid rgba(251,113,133,0.3); }
.pos-adj     { background: rgba(124,111,247,0.15); color: var(--accent2); border: 1px solid rgba(124,111,247,0.3); }
.pos-adv     { background: rgba(245,158,11,0.15);  color: var(--gold);  border: 1px solid rgba(245,158,11,0.3); }

.word-meaning-label {
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3); margin-bottom: 8px;
}
.word-meaning {
  font-size: 1.15rem; font-weight: 500;
  color: var(--text-1); line-height: 1.5;
  margin-bottom: 20px;
}

.save-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 22px;
  background: transparent;
  border: 1.5px solid var(--border2);
  border-radius: 40px;
  color: var(--text-2);
  font-family: var(--font); font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.save-btn:hover { background: var(--card-hover); color: var(--text-1); }
.save-btn.saved {
  background: rgba(245,158,11,0.15);
  border-color: var(--gold);
  color: var(--gold2);
}

/* ── Etymology Card ── */
.etymology-tree {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}
.etym-part {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
}
.etym-root {
  background: linear-gradient(135deg, rgba(124,111,247,0.2), rgba(167,139,250,0.2));
  border: 1.5px solid rgba(124,111,247,0.4);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 1.05rem; font-weight: 700;
  color: var(--accent2);
  white-space: nowrap;
}
.etym-label {
  font-size: 0.72rem; color: var(--text-3); font-weight: 500;
  text-align: center; max-width: 100px;
}
.etym-arrow {
  font-size: 1.2rem; color: var(--text-3);
  padding: 0 4px;
  display: flex; align-items: center;
}
.etym-meaning {
  font-size: 0.75rem; color: var(--gold2); font-weight: 600;
  margin-top: 2px;
}

.etymology-origin {
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.7;
  border-left: 3px solid var(--accent);
}

/* ── Story Card ── */
.story-card {
  background: linear-gradient(135deg, #1a1d2b 0%, #1e1530 100%);
  border-color: rgba(167,139,250,0.2);
  position: relative;
  overflow: hidden;
}
.story-card::before {
  content: '"';
  position: absolute; top: -10px; left: 20px;
  font-family: var(--font-serif);
  font-size: 8rem; color: rgba(124,111,247,0.08);
  line-height: 1; pointer-events: none;
}
.story-badge {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-size: 0.68rem; font-weight: 700;
  padding: 2px 10px; border-radius: 20px;
  margin-left: auto; text-transform: none; letter-spacing: 0;
}

.story-scene {
  font-size: 1.05rem; line-height: 2;
  color: var(--text-1);
  margin-bottom: 20px;
  position: relative; z-index: 1;
}
.story-scene .highlight-word {
  background: linear-gradient(135deg, rgba(124,111,247,0.3), rgba(167,139,250,0.3));
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--accent3);
  font-weight: 700;
}

.story-highlight {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 0.875rem;
  color: var(--gold2);
  font-weight: 500;
  display: flex; align-items: flex-start; gap: 10px;
}
.story-highlight::before {
  content: '💡';
  font-size: 1rem; flex-shrink: 0;
}

/* ── Two Column ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 680px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ── Example Card ── */
.example-item {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.example-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.example-en {
  font-size: 0.95rem; color: var(--text-1);
  font-style: italic; line-height: 1.6;
  margin-bottom: 4px;
}
.example-en .highlight-word {
  color: var(--accent2); font-style: normal; font-weight: 700;
}
.example-ko {
  font-size: 0.82rem; color: var(--text-3);
  font-style: normal;
}

/* ── Related Words Card ── */
.related-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
}
.related-item:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  transform: translateX(3px);
}
.related-word {
  font-weight: 700; color: var(--text-1);
  font-size: 0.95rem;
}
.related-pos {
  font-size: 0.72rem; color: var(--text-3);
  background: var(--bg);
  padding: 1px 8px; border-radius: 10px;
  margin-left: auto;
}
.related-meaning { font-size: 0.8rem; color: var(--text-2); }

/* ── Tip Card ── */
.tip-card {
  background: linear-gradient(135deg, #14161f 0%, #1a1d2b 100%);
}
.tips-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.tip-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}
.tip-item-icon { font-size: 1.5rem; margin-bottom: 8px; }
.tip-item-title {
  font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); margin-bottom: 6px;
}
.tip-item-text { font-size: 0.88rem; color: var(--text-2); line-height: 1.6; }

/* ── Loading ── */
.loading-wrap {
  display: flex; justify-content: center;
  padding: 80px 0;
}
.loading-card {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px 60px;
  box-shadow: var(--shadow);
}
.loading-orb {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 50%;
  margin: 0 auto 24px;
  animation: pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 32px var(--accent-glow);
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.8; }
}
.loading-text {
  font-size: 1rem; color: var(--text-2);
  font-weight: 500; margin-bottom: 16px;
}
.loading-steps { display: flex; flex-direction: column; gap: 6px; }
.loading-step {
  font-size: 0.82rem; color: var(--text-3);
  display: flex; align-items: center; gap: 8px;
  justify-content: center;
}
.loading-step.done { color: var(--green); }
.loading-step.active { color: var(--accent2); }

/* ── Error ── */
.error-wrap {
  display: flex; justify-content: center; padding: 60px 0;
}
.error-card {
  text-align: center; background: var(--card);
  border: 1px solid rgba(251,113,133,0.3);
  border-radius: 20px; padding: 40px;
}
.error-card i { font-size: 2.5rem; color: var(--rose); margin-bottom: 16px; display: block; }
.error-card p { color: var(--text-2); margin-bottom: 20px; }
.error-card button {
  padding: 10px 24px; background: var(--accent);
  border: none; border-radius: 40px;
  color: #fff; font-family: var(--font); font-weight: 600;
  cursor: pointer; transition: all 0.2s;
}
.error-card button:hover { background: var(--accent2); }

/* ── Saved Section ── */
.saved-section { padding-top: 40px; }
.saved-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  margin-bottom: 32px;
}
.saved-header h2 {
  font-size: 1.5rem; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  color: var(--text-1);
}
.saved-header h2 i { color: var(--accent2); }
.saved-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.saved-controls input {
  padding: 9px 18px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 40px;
  color: var(--text-1);
  font-family: var(--font); font-size: 0.875rem;
  outline: none; transition: border-color 0.2s;
  width: 220px;
}
.saved-controls input:focus { border-color: var(--accent); }

.danger-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  background: transparent;
  border: 1px solid rgba(251,113,133,0.3);
  border-radius: 40px;
  color: var(--rose);
  font-family: var(--font); font-size: 0.875rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
}
.danger-btn:hover { background: rgba(251,113,133,0.1); }

.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.saved-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.saved-card::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(124,111,247,0.06));
  pointer-events: none;
}
.saved-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(124,111,247,0.2);
}
.saved-card-word {
  font-family: var(--font-serif);
  font-size: 1.5rem; font-weight: 600;
  color: var(--text-1); margin-bottom: 4px;
}
.saved-card-phonetic { font-size: 0.8rem; color: var(--text-3); margin-bottom: 10px; }
.saved-card-meaning { font-size: 0.875rem; color: var(--text-2); line-height: 1.5; margin-bottom: 12px; }
.saved-card-footer {
  display: flex; align-items: center; justify-content: space-between;
}
.saved-card-date { font-size: 0.72rem; color: var(--text-3); }
.saved-card-delete {
  width: 28px; height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-3);
  font-size: 0.75rem;
  cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.saved-card-delete:hover {
  background: rgba(251,113,133,0.15);
  border-color: var(--rose);
  color: var(--rose);
}

.empty-state {
  text-align: center; padding: 80px 20px;
  color: var(--text-3);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; display: block; }
.empty-state p { font-size: 1rem; line-height: 1.8; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 24px;
  padding: 36px;
  max-width: 640px; width: 100%;
  max-height: 85vh; overflow-y: auto;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  transition: transform 0.25s;
  position: relative;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 50%; color: var(--text-2);
  font-size: 0.9rem; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--card-hover); color: var(--text-1); }

.modal-word {
  font-family: var(--font-serif);
  font-size: 2.2rem; font-weight: 600;
  color: var(--accent2); margin-bottom: 4px;
}
.modal-phonetic { font-size: 0.9rem; color: var(--text-3); margin-bottom: 12px; }
.modal-meaning {
  font-size: 1.05rem; color: var(--text-1);
  font-weight: 500; margin-bottom: 20px; line-height: 1.5;
}
.modal-section { margin-bottom: 20px; }
.modal-section-title {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--accent2); margin-bottom: 10px;
}
.modal-story {
  font-size: 0.9rem; color: var(--text-2);
  line-height: 1.9;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  padding: 16px;
  border-left: 3px solid var(--accent);
}

/* ── Image Card ── */
.image-card {
  background: linear-gradient(135deg, #131520 0%, #1a1d2b 100%);
  border-color: rgba(45, 212, 191, 0.18);
}

.image-source-badge {
  background: rgba(45, 212, 191, 0.15);
  border: 1px solid rgba(45, 212, 191, 0.3);
  color: var(--teal);
  font-size: 0.68rem; font-weight: 700;
  padding: 2px 10px; border-radius: 20px;
  margin-left: 8px;
  text-transform: none; letter-spacing: 0;
}

.img-refresh-btn {
  margin-left: auto;
  width: 30px; height: 30px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 50%;
  color: var(--text-2);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.img-refresh-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* 4열 그리드 */
.image-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
@media (max-width: 900px) {
  .image-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .image-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}

.img-item {
  border-radius: var(--radius-sm);
  overflow: hidden;
  animation: fadeInUp 0.4s ease both;
  aspect-ratio: 3 / 2;
  position: relative;
}

.img-wrapper {
  width: 100%; height: 100%;
  position: relative;
  overflow: hidden;
  background: var(--bg3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* 스켈레톤 로더 */
.img-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(
    90deg,
    var(--bg3) 25%,
    rgba(255,255,255,0.04) 50%,
    var(--bg3) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--radius-sm);
  z-index: 1;
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.img-wrapper img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.4s ease;
  position: relative;
  z-index: 2;
}
.img-wrapper:hover img { transform: scale(1.05); }

/* 오버레이 */
.img-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 55%);
  display: flex; flex-direction: column;
  justify-content: flex-end;
  padding: 10px 12px;
  opacity: 0;
  transition: opacity 0.25s;
  z-index: 3;
  border-radius: var(--radius-sm);
}
.img-wrapper:hover .img-overlay { opacity: 1; }

.img-title {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.9);
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.img-source-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.68rem; color: var(--teal);
  text-decoration: none; font-weight: 600;
  transition: color 0.2s;
}
.img-source-link:hover { color: #fff; }

/* 이미지 로딩 */
.image-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 12px;
  padding: 36px;
  color: var(--text-3); font-size: 0.875rem;
}
.img-spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border2);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 이미지 에러 */
.image-error {
  display: flex; align-items: center; justify-content: center;
  gap: 10px;
  padding: 36px;
  color: var(--text-3); font-size: 0.875rem;
}
.image-error i { font-size: 1.4rem; color: var(--text-3); }

/* 에러 placeholder */
.img-error-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg3);
  color: var(--text-3);
  font-size: 1.8rem;
}

/* ── Animations ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.result-container > * {
  animation: fadeInUp 0.4s ease both;
}
.result-container > *:nth-child(1) { animation-delay: 0.05s; }
.result-container > *:nth-child(2) { animation-delay: 0.12s; }
.result-container > *:nth-child(3) { animation-delay: 0.19s; }
.result-container > *:nth-child(4) { animation-delay: 0.26s; }
.result-container > *:nth-child(5) { animation-delay: 0.33s; }
.result-container > *:nth-child(6) { animation-delay: 0.40s; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .main { padding: 24px 16px 60px; }
  .hero { padding: 40px 0 32px; }
  .word-header-card { flex-direction: column; gap: 20px; }
  .search-btn .btn-text { display: none; }
  .saved-header { flex-direction: column; align-items: flex-start; }
  .header-nav .nav-btn span.btn-text { display: none; }
  .modal { padding: 24px; }
}
