@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@500;600;700&display=swap");
@import "./theme.css";

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

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--ew-font-ui);
  color: var(--ew-text);
  background: linear-gradient(165deg, #E8E4DF 0%, #D4CFC8 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }

.ew-device {
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
  padding: 12px;
  min-height: 100vh;
}

.ew-screen {
  position: relative;
  background: var(--ew-bg);
  border-radius: 40px;
  overflow: hidden;
  height: min(calc(100vh - 24px), 844px);
  min-height: 640px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.5) inset, var(--ew-shadow-lg), 0 0 0 8px #1a1a1a;
  display: flex;
  flex-direction: column;
}

.ew-capsule {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 32px;
  background: #000;
  border-radius: 18px;
  z-index: 100;
  pointer-events: none;
}

.ew-home-bar {
  position: absolute;
  bottom: calc(var(--ew-safe-bottom) + 4px);
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 4px;
  background: rgba(0,0,0,0.18);
  border-radius: var(--ew-radius-full);
  z-index: 100;
  pointer-events: none;
}

.ew-tabbar:not([hidden]) ~ .ew-home-bar {
  bottom: calc(var(--ew-safe-bottom) + 6px);
}

.ew-app {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: 44px;
  min-height: 0;
}

.ew-page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
  animation: ew-fade-in var(--ew-duration) var(--ew-ease);
}

.ew-page--no-tab { padding-bottom: calc(var(--ew-safe-bottom) + 8px); }

.ew-page--immersive {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

.ew-page--plan {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 0;
}

@keyframes ew-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.ew-navbar {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 var(--ew-space-md);
  position: relative;
  flex-shrink: 0;
}

.ew-navbar__back {
  position: absolute;
  left: var(--ew-space-md);
  width: 32px;
  height: 32px;
  border-radius: var(--ew-radius-full);
  background: var(--ew-bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--ew-text);
}

.ew-navbar__back:active { transform: scale(0.92); }
.ew-navbar__title { font-size: 17px; font-weight: 600; }

.ew-tabbar {
  flex-shrink: 0;
  height: calc(var(--ew-tabbar-h) + var(--ew-safe-bottom) + 8px);
  padding-bottom: calc(var(--ew-safe-bottom) + 8px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--ew-border);
  display: flex;
  z-index: 90;
}

.ew-tabbar[hidden] {
  display: none !important;
}

.ew-tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ew-text-tertiary);
  font-size: 10px;
  font-weight: 500;
  padding-top: 6px;
}

.ew-tabbar__item--active { color: var(--ew-accent); }
.ew-tabbar__icon { font-size: 20px; line-height: 1; }

.ew-heading { font-size: 28px; font-weight: 700; margin: 0 0 var(--ew-space-sm); padding: 0 var(--ew-space-md); }
.ew-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ew-text-tertiary);
  letter-spacing: 0.08em;
  margin: var(--ew-space-lg) 0 var(--ew-space-md);
  padding: 0 var(--ew-space-md);
}

.ew-hero {
  margin: var(--ew-space-md);
  padding: var(--ew-space-lg);
  border-radius: var(--ew-radius-lg);
  background: var(--ew-bg-elevated);
  box-shadow: var(--ew-shadow-md);
  position: relative;
  overflow: hidden;
}

.ew-hero::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  opacity: 0.15;
  transform: translate(30%, -30%);
}

.ew-hero--anger::before { background: var(--ew-anger); }
.ew-hero--joy::before { background: var(--ew-joy); }
.ew-hero--sorrow::before { background: var(--ew-sorrow); }
.ew-hero--peace::before { background: var(--ew-peace); }
.ew-hero--awareness::before { background: var(--ew-awareness); }

.ew-hero__label { font-size: 12px; color: var(--ew-text-tertiary); margin-bottom: var(--ew-space-xs); }
.ew-hero__pack { font-size: 20px; font-weight: 700; margin-bottom: var(--ew-space-md); }
.ew-hero__stats { display: flex; gap: var(--ew-space-md); flex-wrap: wrap; margin-bottom: var(--ew-space-md); }
.ew-hero__stat { font-size: 13px; color: var(--ew-text-secondary); }
.ew-hero__stat strong { color: var(--ew-text); font-weight: 600; }

.ew-hero__mode {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background: var(--ew-bg-muted);
  border-radius: var(--ew-radius-full);
  font-size: 12px;
  color: var(--ew-text-secondary);
  margin-bottom: var(--ew-space-md);
}

.ew-hero__mode-edit { color: var(--ew-anger-deep); font-weight: 600; margin-left: 8px; }

.ew-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  border-radius: var(--ew-radius-md);
  font-size: 16px;
  font-weight: 600;
  transition: transform 0.15s;
}

.ew-btn:active { transform: scale(0.98); }
.ew-pack-card--active {
  border-color: var(--ew-primary);
  box-shadow: 0 0 0 1px var(--ew-primary-soft), var(--ew-shadow-sm);
}

.ew-btn--primary {
  background: linear-gradient(135deg, var(--ew-primary) 0%, var(--ew-primary-deep) 100%);
}

.ew-study__bar-fill { background: var(--ew-primary); }

.ew-quiz-option--selected { border-color: var(--ew-primary); background: var(--ew-primary-soft); }
.ew-btn--secondary { background: var(--ew-bg-muted); color: var(--ew-text); }
.ew-btn--ghost { background: transparent; color: var(--ew-text-secondary); height: 44px; font-size: 14px; }
.ew-btn--done { background: var(--ew-peace); color: #fff; }

.ew-pack-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--ew-space-md);
  padding: 0 var(--ew-space-md);
}

.ew-pack-card {
  position: relative;
  padding: var(--ew-space-md);
  border-radius: var(--ew-radius-md);
  background: var(--ew-bg-elevated);
  box-shadow: var(--ew-shadow-sm);
  border: 1px solid var(--ew-border);
  text-align: left;
  transition: transform 0.2s var(--ew-ease);
  overflow: hidden;
}

.ew-pack-card:active { transform: scale(0.97); }
.ew-pack-card--wide { grid-column: 1 / -1; }
.ew-pack-card--locked { opacity: 0.72; }
.ew-pack-card__accent { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.ew-pack-card__char { font-family: var(--ew-font-word); font-size: 32px; font-weight: 700; margin-bottom: var(--ew-space-sm); }
.ew-pack-card__name { font-size: 15px; font-weight: 600; }
.ew-pack-card__count { font-size: 12px; color: var(--ew-text-tertiary); margin: 4px 0 var(--ew-space-sm); }
.ew-pack-card__progress { height: 4px; background: var(--ew-bg-muted); border-radius: var(--ew-radius-full); overflow: hidden; }
.ew-pack-card__progress-fill { height: 100%; border-radius: var(--ew-radius-full); transition: width 0.6s var(--ew-ease); }
.ew-pack-card__badge {
  position: absolute;
  top: var(--ew-space-sm);
  right: var(--ew-space-sm);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--ew-radius-full);
  background: var(--ew-bg-muted);
  color: var(--ew-text-tertiary);
}

.ew-detail-header { padding: var(--ew-space-md) var(--ew-space-lg); text-align: center; }
.ew-detail-header__char { font-family: var(--ew-font-word); font-size: 56px; font-weight: 700; margin-bottom: var(--ew-space-sm); }

.ew-detail-stats {
  display: flex;
  justify-content: center;
  gap: var(--ew-space-lg);
  padding: var(--ew-space-md);
  margin: 0 var(--ew-space-md);
  background: var(--ew-bg-elevated);
  border-radius: var(--ew-radius-md);
  box-shadow: var(--ew-shadow-sm);
}

.ew-detail-stat { text-align: center; }
.ew-detail-stat__num { font-size: 22px; font-weight: 700; }
.ew-detail-stat__label { font-size: 11px; color: var(--ew-text-tertiary); }

.ew-word-preview { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 var(--ew-space-md); margin-top: var(--ew-space-md); }
.ew-word-chip { padding: 6px 12px; border-radius: var(--ew-radius-full); font-size: 13px; background: var(--ew-bg-muted); color: var(--ew-text-secondary); }
.ew-word-chip--mastered { background: var(--ew-peace-soft); color: var(--ew-peace-deep); }
.ew-word-chip--learning { background: var(--ew-joy-soft); color: var(--ew-joy-deep); }

.ew-detail-actions { padding: var(--ew-space-lg) var(--ew-space-md); display: flex; flex-direction: column; gap: var(--ew-space-sm); }

.ew-overlay {
  position: absolute;
  inset: 0;
  background: rgba(44, 40, 37, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.ew-overlay[hidden] { display: none !important; }

.ew-sheet {
  width: 100%;
  max-width: 390px;
  background: var(--ew-bg-elevated);
  border-radius: var(--ew-radius-lg) var(--ew-radius-lg) 0 0;
  padding: var(--ew-space-lg) var(--ew-space-md) calc(var(--ew-space-lg) + var(--ew-safe-bottom));
  animation: ew-sheet-up 0.35s var(--ew-ease);
  max-height: 85vh;
  overflow-y: auto;
}

@keyframes ew-sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.ew-sheet__handle { width: 36px; height: 4px; background: var(--ew-border-strong); border-radius: var(--ew-radius-full); margin: 0 auto var(--ew-space-lg); }
.ew-sheet__title { font-size: 20px; font-weight: 700; margin-bottom: var(--ew-space-xs); }
.ew-sheet__desc { font-size: 14px; color: var(--ew-text-secondary); margin-bottom: var(--ew-space-lg); }

.ew-option-group { margin-bottom: var(--ew-space-lg); }
.ew-option-group__label { font-size: 13px; font-weight: 600; color: var(--ew-text-secondary); margin-bottom: var(--ew-space-sm); }
.ew-option-row { display: flex; gap: var(--ew-space-sm); }

.ew-option {
  flex: 1;
  padding: var(--ew-space-md);
  border-radius: var(--ew-radius-md);
  border: 2px solid var(--ew-border);
  background: var(--ew-bg);
  text-align: center;
}

.ew-option--selected { border-color: var(--ew-accent); background: var(--ew-bg-elevated); }
.ew-option__value { font-size: 22px; font-weight: 700; }
.ew-option__unit { font-size: 11px; color: var(--ew-text-tertiary); }

.ew-mode-card {
  display: block;
  width: 100%;
  padding: var(--ew-space-md);
  border-radius: var(--ew-radius-md);
  border: 2px solid var(--ew-border);
  background: var(--ew-bg);
  text-align: left;
  margin-bottom: var(--ew-space-sm);
}

.ew-mode-card--selected { border-color: var(--ew-accent); }
.ew-mode-card__title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.ew-mode-card__desc { font-size: 12px; color: var(--ew-text-secondary); line-height: 1.4; }

.ew-study { padding: var(--ew-space-md); flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ew-study__progress { display: flex; align-items: center; gap: var(--ew-space-sm); margin-bottom: var(--ew-space-lg); }
.ew-study__bar { flex: 1; height: 6px; background: var(--ew-bg-muted); border-radius: var(--ew-radius-full); overflow: hidden; }
.ew-study__bar-fill { height: 100%; background: var(--ew-accent); border-radius: var(--ew-radius-full); transition: width 0.4s var(--ew-ease); }
.ew-study__count { font-size: 13px; color: var(--ew-text-tertiary); font-weight: 600; }

.ew-word-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--ew-space-lg);
  background: var(--ew-bg-elevated);
  border-radius: var(--ew-radius-lg);
  box-shadow: var(--ew-shadow-md);
  margin-bottom: var(--ew-space-lg);
  animation: ew-card-pop 0.5s var(--ew-ease);
}

@keyframes ew-card-pop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.ew-word-card__lemma { font-family: var(--ew-font-word); font-size: 64px; font-weight: 700; margin-bottom: var(--ew-space-md); }
.ew-polarity { display: inline-flex; padding: 4px 12px; border-radius: var(--ew-radius-full); font-size: 12px; font-weight: 600; margin-bottom: var(--ew-space-md); }
.ew-polarity--positive { background: var(--ew-peace-soft); color: var(--ew-peace-deep); }
.ew-polarity--negative { background: var(--ew-anger-soft); color: var(--ew-anger-deep); }
.ew-polarity--neutral { background: var(--ew-bg-muted); color: var(--ew-text-secondary); }
.ew-word-card__def { font-size: 17px; text-align: center; line-height: 1.6; margin-bottom: var(--ew-space-md); max-width: 280px; }
.ew-word-card__example { font-size: 14px; color: var(--ew-text-secondary); text-align: center; line-height: 1.5; padding: var(--ew-space-md); background: var(--ew-bg-muted); border-radius: var(--ew-radius-md); max-width: 300px; }
.ew-word-card__example em { font-style: normal; color: var(--ew-text); font-weight: 500; }

.ew-quiz-scene { width: 100%; height: 140px; border-radius: var(--ew-radius-md); margin-bottom: var(--ew-space-md); display: flex; align-items: flex-end; padding: var(--ew-space-md); }
.ew-quiz-scene--warm-frustrated { background: linear-gradient(145deg, #FFE8D6, #FFB899 50%, #E8766A); }
.ew-quiz-scene--cool-fire { background: linear-gradient(145deg, #EEF4F8, #B8D4E8 50%, #E8766A); }
.ew-quiz-scene--warm-joy { background: linear-gradient(145deg, #FFF9E6, #F5C842 60%); }
.ew-quiz-scene--soft-purple { background: linear-gradient(145deg, #F3EFFA, #C8B8E8 50%, #A891D4); }
.ew-quiz-scene--calm-green { background: linear-gradient(145deg, #E8F5F0, #A8D8C8 50%, #6BBFA3); }
.ew-quiz-scene__title { font-size: 14px; font-weight: 600; color: rgba(255,255,255,0.95); }

.ew-quiz__prompt { font-size: 16px; font-weight: 600; line-height: 1.5; margin-bottom: var(--ew-space-md); }
.ew-quiz__scene-text { font-size: 15px; color: var(--ew-text-secondary); line-height: 1.6; margin-bottom: var(--ew-space-lg); padding: var(--ew-space-md); background: var(--ew-bg-muted); border-radius: var(--ew-radius-md); }

.ew-quiz-options { display: flex; flex-direction: column; gap: var(--ew-space-sm); margin-bottom: var(--ew-space-lg); }
.ew-quiz-option { padding: var(--ew-space-md); border-radius: var(--ew-radius-md); border: 2px solid var(--ew-border); background: var(--ew-bg-elevated); font-size: 15px; text-align: left; }
.ew-quiz-option--selected { border-color: var(--ew-accent); }
.ew-quiz-option--correct { border-color: var(--ew-success); background: var(--ew-peace-soft); }
.ew-quiz-option--wrong { border-color: var(--ew-error); background: var(--ew-anger-soft); }

.ew-feedback { padding: var(--ew-space-md); border-radius: var(--ew-radius-md); font-size: 14px; line-height: 1.5; margin-bottom: var(--ew-space-md); }
.ew-feedback--correct { background: var(--ew-peace-soft); color: var(--ew-peace-deep); }
.ew-feedback--wrong { background: var(--ew-anger-soft); color: var(--ew-anger-deep); }

.ew-result { text-align: center; padding: var(--ew-space-xl) var(--ew-space-md); }
.ew-result__emoji { font-size: 56px; margin-bottom: var(--ew-space-md); }
.ew-result__title { font-size: 24px; font-weight: 700; margin-bottom: var(--ew-space-sm); }
.ew-result__score { font-size: 48px; font-weight: 700; font-family: var(--ew-font-word); margin: var(--ew-space-lg) 0; }
.ew-result__words { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: var(--ew-space-lg) 0; }
.ew-result-actions { padding: var(--ew-space-md); display: flex; flex-direction: column; gap: var(--ew-space-sm); }

.ew-naming-section { padding: 0 var(--ew-space-md); margin-bottom: var(--ew-space-lg); }
.ew-naming-section__title { font-size: 15px; font-weight: 600; margin-bottom: var(--ew-space-md); }
.ew-cue-grid { display: flex; flex-wrap: wrap; gap: var(--ew-space-sm); }
.ew-cue { padding: 10px 16px; border-radius: var(--ew-radius-full); border: 2px solid var(--ew-border); background: var(--ew-bg-elevated); font-size: 14px; }
.ew-cue--selected { border-color: var(--ew-accent); background: var(--ew-accent); color: #fff; }

.ew-candidate { display: block; width: 100%; padding: var(--ew-space-md); border-radius: var(--ew-radius-md); border: 2px solid var(--ew-border); background: var(--ew-bg-elevated); text-align: left; margin-bottom: var(--ew-space-sm); }
.ew-candidate--selected { border-color: var(--ew-peace-deep); background: var(--ew-peace-soft); }
.ew-candidate__lemma { font-family: var(--ew-font-word); font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.ew-candidate__def { font-size: 13px; color: var(--ew-text-secondary); }

.ew-toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(44, 40, 37, 0.88);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--ew-radius-md);
  font-size: 14px;
  z-index: 300;
  pointer-events: none;
}

.ew-profile-header { padding: var(--ew-space-lg) var(--ew-space-md); text-align: center; }
.ew-radar-wrap { margin: var(--ew-space-md); padding: var(--ew-space-lg); background: var(--ew-bg-elevated); border-radius: var(--ew-radius-lg); box-shadow: var(--ew-shadow-sm); }
.ew-radar { width: 100%; max-width: 260px; margin: 0 auto; display: block; }

.ew-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ew-space-md); padding: 0 var(--ew-space-md); margin-bottom: var(--ew-space-lg); }
.ew-stat-card { padding: var(--ew-space-md); background: var(--ew-bg-elevated); border-radius: var(--ew-radius-md); box-shadow: var(--ew-shadow-sm); }
.ew-stat-card__value { font-size: 28px; font-weight: 700; font-family: var(--ew-font-word); }
.ew-stat-card__label { font-size: 12px; color: var(--ew-text-tertiary); }

.ew-polarity-bar { margin: 0 var(--ew-space-md) var(--ew-space-lg); padding: var(--ew-space-md); background: var(--ew-bg-elevated); border-radius: var(--ew-radius-md); }
.ew-polarity-bar__track { display: flex; height: 8px; border-radius: var(--ew-radius-full); overflow: hidden; margin: var(--ew-space-sm) 0; }
.ew-polarity-bar__seg--pos { background: var(--ew-peace); }
.ew-polarity-bar__seg--neg { background: var(--ew-anger); }
.ew-polarity-bar__seg--neu { background: var(--ew-sorrow); }

.ew-list-link { display: flex; align-items: center; justify-content: space-between; padding: var(--ew-space-md); margin: 0 var(--ew-space-md) var(--ew-space-sm); background: var(--ew-bg-elevated); border-radius: var(--ew-radius-md); box-shadow: var(--ew-shadow-sm); font-size: 15px; font-weight: 500; }
.ew-list-link__arrow { color: var(--ew-text-tertiary); }

.ew-wordbook-item { display: flex; align-items: center; gap: var(--ew-space-md); padding: var(--ew-space-md); margin: 0 var(--ew-space-md) var(--ew-space-sm); background: var(--ew-bg-elevated); border-radius: var(--ew-radius-md); box-shadow: var(--ew-shadow-sm); }
.ew-wordbook-item__lemma { font-family: var(--ew-font-word); font-size: 24px; font-weight: 700; min-width: 64px; }
.ew-wordbook-item__def { font-size: 13px; color: var(--ew-text-secondary); }
.ew-empty { text-align: center; padding: var(--ew-space-xl); color: var(--ew-text-tertiary); font-size: 14px; }

.ew-nvc-card { margin: var(--ew-space-md); padding: var(--ew-space-md); background: var(--ew-extension-soft); border-radius: var(--ew-radius-md); border: 1px dashed var(--ew-extension); }
.ew-nvc-card__label { font-size: 11px; font-weight: 600; color: var(--ew-extension); margin-bottom: var(--ew-space-sm); }
.ew-nvc-compare { display: grid; gap: var(--ew-space-sm); margin-top: var(--ew-space-md); }
.ew-nvc-compare__item { padding: var(--ew-space-sm) var(--ew-space-md); border-radius: var(--ew-radius-sm); font-size: 13px; line-height: 1.5; }
.ew-nvc-compare__item--jackal { background: var(--ew-anger-soft); }
.ew-nvc-compare__item--giraffe { background: var(--ew-peace-soft); }
